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 Tue, 06 May 2003 04:01:02 GMT
psmith      2003/05/05 21:01:02

  Modified:    src/java/org/apache/log4j/chainsaw
                        ChainsawToolBarAndMenus.java
  Log:
  Find and Find Next have been moved into this class.
  
  Revision  Changes    Path
  1.8       +84 -2     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.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ChainsawToolBarAndMenus.java	6 May 2003 02:25:22 -0000	1.7
  +++ ChainsawToolBarAndMenus.java	6 May 2003 04:01:02 -0000	1.8
  @@ -15,6 +15,7 @@
   
   import javax.swing.AbstractAction;
   import javax.swing.Action;
  +import javax.swing.Box;
   import javax.swing.ImageIcon;
   import javax.swing.JButton;
   import javax.swing.JCheckBoxMenuItem;
  @@ -23,13 +24,15 @@
   import javax.swing.JMenu;
   import javax.swing.JMenuBar;
   import javax.swing.JMenuItem;
  -import javax.swing.JPanel;
  +import javax.swing.JTextField;
   import javax.swing.JToggleButton;
   import javax.swing.JToolBar;
   import javax.swing.KeyStroke;
   import javax.swing.SwingUtilities;
   import javax.swing.event.ChangeEvent;
   import javax.swing.event.ChangeListener;
  +import javax.swing.event.DocumentEvent;
  +import javax.swing.event.DocumentListener;
   
   import org.apache.log4j.chainsaw.icons.ChainsawIcons;
   
  @@ -46,6 +49,7 @@
   		menuBar = new JMenuBar();
   		fileMenu = new FileMenu(logui);
       closeAction = createCloseHelpAction();
  +    findNextAction = setupFindFieldsAndActions();
   
   		lockToolbarAction = createLockableToolbarAction();
   		toggleToolbarAction = createToggleToolbarAction();
  @@ -78,6 +82,8 @@
   
   		if (logPanel == null) {
   			pauseAction.setEnabled(false);
  +      findNextAction.setEnabled(false);
  +      findTextField.setEnabled(false);
   			clearAction.setEnabled(false);
   			fileMenu.getFileSaveAction().setEnabled(false);
   			toggleDetailPaneAction.setEnabled(false);
  @@ -88,10 +94,11 @@
           closeAction.setEnabled(false);
         }
   		} else {
  -			//       System.out.println("LogPanel is now " + logPanel.getIdentifier());
   			fileMenu.getFileSaveAction().setEnabled(true);
   			pauseAction.setEnabled(true);
   			clearAction.setEnabled(true);
  +      findNextAction.setEnabled(true);
  +      findTextField.setEnabled(true);
   			toggleDetailPaneAction.setEnabled(true);
   			if (logui.pausedList.contains(logPanel.getIdentifier())) {
   				pauseButton.getModel().setSelected(true);
  @@ -109,6 +116,54 @@
   
   	}
   
  +
  +  private void find() {
  +    LogUI.LogPanel logPanel = logui.getCurrentLogPanel();
  +    if (logPanel!=null) {
  +      logPanel.find(findTextField.getText());
  +    }
  +
  +  }
  +  
  +  private Action setupFindFieldsAndActions() {
  +    
  +    findTextField.getDocument().addDocumentListener(new DocumentListener() {
  +      public void insertUpdate(DocumentEvent e) {
  +        find();
  +      }
  +
  +      public void removeUpdate(DocumentEvent e) {
  +        find();
  +      }
  +
  +      public void changedUpdate(DocumentEvent e) {
  +        find();
  +      }
  +    });
  +  
  +  
  +    final Action action = new AbstractAction("Find Next") {
  +
  +      public void actionPerformed(ActionEvent e) {
  +        find();
  +      }
  +      
  +    };
  +    action.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_F));
  +    action.putValue(
  +      Action.ACCELERATOR_KEY,
  +      KeyStroke.getKeyStroke("F3"));
  +    action.putValue(
  +      Action.SHORT_DESCRIPTION,
  +      "Finds the next occurrence of the Find string");
  +    action.putValue(
  +      Action.SMALL_ICON,
  +      new ImageIcon(ChainsawIcons.FIND));
  +    
  +    return action;
  +    
  +  }
  +  
   	private Action createToggleToolbarAction() {
   		/**
   		 * -== Begin of Show/Hide toolbar action
  @@ -313,6 +368,30 @@
   		toolbar.add(pauseButton);
   		toolbar.add(clearButton);
   		toolbar.add(detailPaneButton);
  +    
  +    toolbar.addSeparator();
  +    
  +    JButton findNextButton = new JButton(findNextAction);
  +    findNextButton.setText("");
  +    resizeToolbarButton(findNextButton);
  +    findNextButton.getActionMap().put(
  +      findNextAction.getValue(Action.NAME),
  +    findNextAction);
  +    findNextButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
  +      (KeyStroke)findNextAction.getValue(Action.ACCELERATOR_KEY),
  +    findNextAction.getValue(Action.NAME));
  +    
  +    toolbar.add(findNextButton);
  +    
  +    
  +    Dimension fixedSize = new Dimension(80,24);
  +    findTextField.setPreferredSize(fixedSize);
  +    findTextField.setMaximumSize(fixedSize);
  +    findTextField.setMinimumSize(fixedSize);
  +    Box findBox = Box.createHorizontalBox();
  +    findBox.add(findTextField);
  +    findBox.add(Box.createGlue());
  +    toolbar.add(findBox);
   
   		toolbar.setMargin(buttonMargins);
   		toolbar.setFloatable(false);
  @@ -437,11 +516,14 @@
   	private final Action clearAction;
     private final Action closeAction;
   	private final Action toggleDetailPaneAction;
  +  private final Action findNextAction;
     
   	private final FileMenu fileMenu;
   
   	private final JToggleButton pauseButton = new JToggleButton();
   	private final JToggleButton detailPaneButton = new JToggleButton();
   	private final JButton clearButton = new JButton();
  +  
  +  final JTextField findTextField = new JTextField();
   
   }
  
  
  

---------------------------------------------------------------------
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