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 LogUI.java
Date Thu, 01 May 2003 08:23:14 GMT
psmith      2003/05/01 01:23:14

  Modified:    src/java/org/apache/log4j/chainsaw LogUI.java
  Log:
  Slowly expanding the list of Hotkeys, by moving towards a more Action
  oriented framework.
  
  Toggle Details pane, which is the one I REALLY want to work, still isn't
  working for yet.  Hold tight.
  
  Revision  Changes    Path
  1.13      +57 -32    jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/LogUI.java
  
  Index: LogUI.java
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/LogUI.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- LogUI.java	1 May 2003 04:50:25 -0000	1.12
  +++ LogUI.java	1 May 2003 08:23:14 -0000	1.13
  @@ -57,6 +57,7 @@
   import java.awt.Point;
   import java.awt.event.ActionEvent;
   import java.awt.event.ActionListener;
  +import java.awt.event.InputEvent;
   import java.awt.event.KeyEvent;
   import java.awt.event.KeyListener;
   import java.awt.event.MouseAdapter;
  @@ -78,6 +79,8 @@
   import java.util.Set;
   import java.util.Vector;
   
  +import javax.swing.AbstractAction;
  +import javax.swing.Action;
   import javax.swing.BorderFactory;
   import javax.swing.ButtonGroup;
   import javax.swing.JButton;
  @@ -100,6 +103,7 @@
   import javax.swing.JTabbedPane;
   import javax.swing.JTable;
   import javax.swing.JTextField;
  +import javax.swing.KeyStroke;
   import javax.swing.ListSelectionModel;
   import javax.swing.SwingUtilities;
   import javax.swing.border.TitledBorder;
  @@ -708,14 +712,13 @@
         final DetailThread detailThread = new DetailThread(detail, tableModel);
         detailThread.start();
   
  -      JCheckBox cb = new JCheckBox("Pause");
  -      cb.addActionListener(
  -        new ActionListener() {
  +      final JCheckBox cb = new JCheckBox();
  +      Action pauseAction = new AbstractAction("Pause") {
             boolean paused = false;
   
             public void actionPerformed(ActionEvent evt) {
               paused = !paused;
  -
  +            cb.getModel().setSelected(paused);
               if (paused) {
                 if (!pausedList.contains(ident)) {
                   pausedList.add(ident);
  @@ -726,7 +729,14 @@
                 }
               }
             }
  -        });
  +        };
  +      pauseAction.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_P));
  +      pauseAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("F12"));
  +      pauseAction.putValue(Action.SHORT_DESCRIPTION, "Halts the display, while still allowing
events to stream in the background");
  +
  +      cb.setAction(pauseAction);
  +      cb.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("F12"),pauseAction.getValue(Action.NAME)
);
  +      cb.getActionMap().put(pauseAction.getValue(Action.NAME), pauseAction);
   
         GridBagLayout gridbag = new GridBagLayout();
         GridBagConstraints gbc = new GridBagConstraints();
  @@ -835,6 +845,8 @@
         upperPanel.add(findLabel);
   
         final JTextField findText = new JTextField();
  +      
  +      
         gbc.gridx = 6;
         gbc.gridy = 0;
         gbc.weightx = 1;
  @@ -872,16 +884,23 @@
             }
           });
   
  -      JButton findButton = new JButton("Find next");
  -      findButton.addActionListener(
  -        new ActionListener() {
  -          public void actionPerformed(ActionEvent evt) {
  -            final int row =
  -              tableModel.find(table.getSelectedRow() + 1, findText.getText());
  -            table.scrollToRow(
  -              row, table.columnAtPoint(table.getVisibleRect().getLocation()));
  -          }
  -        });
  +      String findNextActionLabel = "Find next";
  +      Action findNextAction = new AbstractAction(findNextActionLabel) {
  +        public void actionPerformed(ActionEvent evt) {
  +          final int row =
  +            tableModel.find(table.getSelectedRow() + 1, findText.getText());
  +          table.scrollToRow(
  +            row,
  +            table.columnAtPoint(table.getVisibleRect().getLocation()));
  +        }
  +      };
  +      
  +      findNextAction.putValue(Action.SHORT_DESCRIPTION, "Finds the next match");
  +      
  +      JButton findButton = new JButton(findNextAction);
  +      findButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("F3"),
findNextActionLabel);
  +      findButton.getActionMap().put(findNextAction.getValue(Action.NAME), findNextAction);
  +          
         gbc.gridx = 7;
         gbc.gridy = 0;
         gbc.weightx = 0;
  @@ -1040,25 +1059,31 @@
             }
           });
   
  -      final JCheckBoxMenuItem menuItemToggleDetails =
  -        new JCheckBoxMenuItem(
  -          "Show Detail Pane",
  -          lowerPanel.getDividerLocation() != (lowerPanel.getHeight()
  -          - lowerPanel.getDividerSize()));
  -      menuItemToggleDetails.addActionListener(
  -        new ActionListener() {
  -          public void actionPerformed(ActionEvent evt) {
  -            if (menuItemToggleDetails.isSelected()) {
  -              lowerPanel.setDividerLocation(
  -                lowerPanel.getLastDividerLocation());
  -            } else {
  -              int lastPosition = lowerPanel.getDividerLocation();
  -              lowerPanel.setDividerLocation(1.0d);
  -              lowerPanel.setLastDividerLocation(lastPosition);
  -            }
  +
  +//      final Boolean initialToggling = (lowerPanel.getDividerLocation() != (lowerPanel.getHeight()-
lowerPanel.getDividerSize())          
  +      Action toggleDetailPaneAction = new AbstractAction("Show Detail Pane") {
  +        boolean enabled = true;
  +        public void actionPerformed(ActionEvent evt) {
  +          if (enabled) {
  +            lowerPanel.setDividerLocation(lowerPanel.getLastDividerLocation());
  +          } else {
  +            int lastPosition = lowerPanel.getDividerLocation();
  +            lowerPanel.setDividerLocation(1.0d);
  +            lowerPanel.setLastDividerLocation(lastPosition);
             }
  -        });
  +        }
  +      };
  +      toggleDetailPaneAction.putValue("enabled",Boolean.TRUE) ;
  +      toggleDetailPaneAction.putValue(Action.ACCELERATOR_KEY,KeyStroke.getKeyStroke(KeyEvent.VK_D,
InputEvent.ALT_MASK)) ;
  +      toggleDetailPaneAction.putValue(Action.SHORT_DESCRIPTION, "Hides/Shows the Detail
Pane") ;
  +        
  +      JCheckBoxMenuItem menuItemToggleDetails = new JCheckBoxMenuItem(toggleDetailPaneAction);
  +//      TODO this hot key doesn't seem to work just yet
  +//      menuItemToggleDetails.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_D,
InputEvent.ALT_MASK), toggleDetailPaneAction.getValue(Action.NAME));
  +//      menuItemToggleDetails.getActionMap().put(toggleDetailPaneAction.getValue(Action.NAME),
toggleDetailPaneAction);
   
  +      menuItemToggleDetails.setSelected(true);
  +            
         final JCheckBoxMenuItem menuItemToggleToolTips =
           new JCheckBoxMenuItem(
             "Show ToolTips", displayFilter.isToolTipsEnabled());
  
  
  

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