logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From psm...@apache.org
Subject cvs commit: jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw ChainsawToolBarAndMenus.java
Date Mon, 05 May 2003 03:13:12 GMT
psmith      2003/05/04 20:13:12

  Modified:    src/java/org/apache/log4j/chainsaw
                        ChainsawToolBarAndMenus.java
  Log:
  implemented State change tracking, so when components change state
  the menu's and toolbar buttons remain consistent with what can or 
  cannot be done at this point in time.
  
  Revision  Changes    Path
  1.2       +39 -6     jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/ChainsawToolBarAndMenus.java
  
  Index: ChainsawToolBarAndMenus.java
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/ChainsawToolBarAndMenus.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ChainsawToolBarAndMenus.java	3 May 2003 06:53:13 -0000	1.1
  +++ ChainsawToolBarAndMenus.java	5 May 2003 03:13:12 -0000	1.2
  @@ -18,7 +18,6 @@
   import javax.swing.ImageIcon;
   import javax.swing.JButton;
   import javax.swing.JCheckBoxMenuItem;
  -import javax.swing.JComponent;
   import javax.swing.JMenu;
   import javax.swing.JMenuBar;
   import javax.swing.JMenuItem;
  @@ -26,6 +25,8 @@
   import javax.swing.JToolBar;
   import javax.swing.KeyStroke;
   import javax.swing.SwingUtilities;
  +import javax.swing.event.ChangeEvent;
  +import javax.swing.event.ChangeListener;
   
   import org.apache.log4j.chainsaw.icons.ChainsawIcons;
   
  @@ -34,7 +35,8 @@
    * @author Paul Smith <psmith@apache.org>
    *
    */
  -class ChainsawToolBarAndMenus {
  +class ChainsawToolBarAndMenus 
  +  implements ChangeListener{
   
   	ChainsawToolBarAndMenus(final LogUI logui) {
   		this.logui = logui;
  @@ -57,7 +59,36 @@
   	JMenuBar getMenubar() {
   		return menuBar;
   	}
  -	
  +  
  +  public void stateChanged(ChangeEvent e) {
  +    scanState();
  +  }
  +    
  +   private void scanState() {
  +     /**
  +      * We get the currently selected LogPanel, and if null, deactivate some
  +      * actions
  +      */
  +     LogUI.LogPanel logPanel = logui.getCurrentLogPanel();
  +
  +      
  +     if (logPanel == null) {
  +       pauseAction.setEnabled(false);
  +       fileMenu.getFileSaveAction().setEnabled(false);
  +     } else {
  +//       System.out.println("LogPanel is now " + logPanel.getIdentifier());
  +       fileMenu.getFileSaveAction().setEnabled(true);
  +       pauseAction.setEnabled(true);
  +       if (logui.pausedList.contains(logPanel.getIdentifier())) {
  +        pauseButton.getModel().setSelected(true);
  +      } else {
  +        pauseButton.getModel().setSelected(false);
  +      }
  +       
  +     }
  +
  +   }
  +
   	private Action createToggleToolbarAction() {
   		/**
   		 * -== Begin of Show/Hide toolbar action
  @@ -160,7 +191,7 @@
   		toolbar.add(fileSaveButton);
   		toolbar.addSeparator();
   		
  -		final JToggleButton pauseButton = new JToggleButton(pauseAction);
  +		pauseButton.setAction(pauseAction);
   		pauseButton.setText("");
         
   //		pauseButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("F12"),pauseAction.getValue(Action.NAME)
);
  @@ -168,6 +199,8 @@
   		Dimension d=new Dimension(24,24);
   		pauseButton.setPreferredSize(d);
   		pauseButton.setMaximumSize(d);
  +    
  +        
   
   		toolbar.add(pauseButton);
   		
  @@ -214,7 +247,7 @@
   	private final Action pauseAction;
   	
   	private final FileMenu fileMenu;
  -	
  -
  +  
  +    private final JToggleButton pauseButton = new JToggleButton();
   	
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-dev-help@jakarta.apache.org


Mime
View raw message