psmith      2003/06/19 23:32:31

  Modified:    src/java/org/apache/log4j/chainsaw ReceiversPanel.java
  Log:
  right click popup menu is now consistent with the Receiver toolbar.
  
  Revision  Changes    Path
  1.11      +109 -86   
jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/ReceiversPanel.java
  
  Index: ReceiversPanel.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/ReceiversPanel.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- ReceiversPanel.java       20 Jun 2003 06:17:16 -0000      1.10
  +++ ReceiversPanel.java       20 Jun 2003 06:32:31 -0000      1.11
  @@ -65,6 +65,7 @@
   import java.awt.Graphics2D;
   import java.awt.RenderingHints;
   import java.awt.event.ActionEvent;
  +import java.awt.event.KeyEvent;
   
   import java.util.Collection;
   import java.util.Iterator;
  @@ -104,6 +105,12 @@
     private final Runnable updateReceiverTree;
     private final JPopupMenu popupMenu = new ReceiverPopupMenu();
     private final Action startAllAction;
  +  final Action playReceiverButtonAction;
  +  final Action shutdownReceiverButtonAction;
  +  final Action pauseReceiverButtonAction;
  +    
  +  final Action newReceiverButtonAction;
  +  final Action editReceiverButtonAction;
   
     ReceiversPanel(final LogUI logui) {
       super(new BorderLayout());
  @@ -117,6 +124,91 @@
       receiversTree.setModel(ReceiversTreeModel.create());
   
       receiversTree.setToolTipText("Allows you to manage Log4j Receivers");
  +    newReceiverButtonAction =
  +      new AbstractAction() {
  +          public void actionPerformed(ActionEvent e) {
  +            JOptionPane.showMessageDialog(logui, "Not Implemented yet, sorry");
  +          }
  +        };
  +    newReceiverButtonAction.putValue(Action.SMALL_ICON, new 
ImageIcon(ChainsawIcons.ICON_NEW_RECEIVER));
  +    newReceiverButtonAction.putValue(Action.SHORT_DESCRIPTION, "Creates and 
configures a new Receiver");
  +    newReceiverButtonAction.putValue(Action.NAME, "New Receiver");
  +    newReceiverButtonAction.putValue(
  +      Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_N));
  +
  +    newReceiverButtonAction.setEnabled(true);
  +      
  +    editReceiverButtonAction =
  +      new AbstractAction() {
  +          public void actionPerformed(ActionEvent e) {
  +            JOptionPane.showMessageDialog(logui, "Not Implemented yet, sorry");
  +          }
  +        };
  +    editReceiverButtonAction.putValue(Action.SMALL_ICON, new 
ImageIcon(ChainsawIcons.ICON_EDIT_RECEIVER));
  +    editReceiverButtonAction.putValue(Action.SHORT_DESCRIPTION, "Edits the 
configuration of the selected Receiver");
  +    editReceiverButtonAction.putValue(Action.NAME, "Edit Receiver");
  +    editReceiverButtonAction.setEnabled(false);
  +    editReceiverButtonAction.putValue(
  +      Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_E));
  +
  +    playReceiverButtonAction =
  +      new AbstractAction() {
  +          public void actionPerformed(ActionEvent e) {
  +            playCurrentlySelectedReceiver();
  +          }
  +        };
  +
  +    playReceiverButtonAction.putValue(
  +      Action.SHORT_DESCRIPTION, "Resumes the selected Node");
  +    playReceiverButtonAction.putValue(
  +      Action.NAME, "Resume");
  +    playReceiverButtonAction.putValue(
  +      Action.SMALL_ICON, new ImageIcon(ChainsawIcons.ICON_RESUME_RECEIVER));
  +    playReceiverButtonAction.setEnabled(false);
  +    playReceiverButtonAction.putValue(
  +      Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_R));
  +
  +
  +    pauseReceiverButtonAction =
  +      new AbstractAction() {
  +          public void actionPerformed(ActionEvent e) {
  +            pauseCurrentlySelectedReceiver();
  +          }
  +        };
  +
  +    pauseReceiverButtonAction.putValue(
  +      Action.SHORT_DESCRIPTION,
  +      "Pause the selected Receiver.  All events received will be discarded.");
  +    pauseReceiverButtonAction.putValue(
  +      Action.NAME, "Pause");
  +
  +    pauseReceiverButtonAction.putValue(
  +      Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_P));
  +      
  +
  +    pauseReceiverButtonAction.putValue(
  +      Action.SMALL_ICON, new ImageIcon(ChainsawIcons.PAUSE));
  +    pauseReceiverButtonAction.setEnabled(false);
  +
  +    shutdownReceiverButtonAction =
  +      new AbstractAction() {
  +          public void actionPerformed(ActionEvent e) {
  +            shutdownCurrentlySelectedReceiver();
  +          }
  +        };
  +
  +    shutdownReceiverButtonAction.putValue(
  +      Action.SHORT_DESCRIPTION,
  +      "Shuts down the selected Receiver, and removes it from the Plugin registry");
  +    shutdownReceiverButtonAction.putValue(
  +      Action.NAME, "Shutdown");
  +
  +    shutdownReceiverButtonAction.putValue(
  +      Action.SMALL_ICON, new ImageIcon(ChainsawIcons.ICON_STOP_RECEIVER));
  +    shutdownReceiverButtonAction.putValue(
  +      Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_S));
  +
  +    shutdownReceiverButtonAction.setEnabled(false);
   
       startAllAction =
         new AbstractAction(
  @@ -330,86 +422,23 @@
      */
     private class ReceiverToolbar extends JToolBar
       implements TreeSelectionListener {
  -    final Action playReceiverButtonAction;
  -    final Action shutdownReceiverButtonAction;
  -    final Action pauseReceiverButtonAction;
  -    
  -    final Action newReceiverButtonAction;
  -    final Action editReceiverButtonAction;
   
       private ReceiverToolbar() {
         setFloatable(false);
   
  -      newReceiverButtonAction =
  -        new AbstractAction() {
  -            public void actionPerformed(ActionEvent e) {
  -              JOptionPane.showMessageDialog(logui, "Not Implemented yet, sorry");
  -            }
  -          };
  -      newReceiverButtonAction.putValue(Action.SMALL_ICON, new 
ImageIcon(ChainsawIcons.ICON_NEW_RECEIVER));
  -      newReceiverButtonAction.putValue(Action.SHORT_DESCRIPTION, "Creates and 
configures a new Receiver");
  -      newReceiverButtonAction.setEnabled(true);
  -      
  -      editReceiverButtonAction =
  -        new AbstractAction() {
  -            public void actionPerformed(ActionEvent e) {
  -              JOptionPane.showMessageDialog(logui, "Not Implemented yet, sorry");
  -            }
  -          };
  -      editReceiverButtonAction.putValue(Action.SMALL_ICON, new 
ImageIcon(ChainsawIcons.ICON_EDIT_RECEIVER));
  -      editReceiverButtonAction.putValue(Action.SHORT_DESCRIPTION, "Edits the 
configuration of the selected Receiver");
  -      editReceiverButtonAction.setEnabled(false);
  -      
  -      playReceiverButtonAction =
  -        new AbstractAction() {
  -            public void actionPerformed(ActionEvent e) {
  -              playCurrentlySelectedReceiver();
  -            }
  -          };
  -
  -      playReceiverButtonAction.putValue(
  -        Action.SHORT_DESCRIPTION, "Resumes the selected Node");
  -      playReceiverButtonAction.putValue(
  -        Action.SMALL_ICON, new ImageIcon(ChainsawIcons.ICON_RESUME_RECEIVER));
  -      playReceiverButtonAction.setEnabled(false);
   
         SmallButton playReceiverButton =
           new SmallButton(playReceiverButtonAction);
  -
  -      pauseReceiverButtonAction =
  -        new AbstractAction() {
  -            public void actionPerformed(ActionEvent e) {
  -              pauseCurrentlySelectedReceiver();
  -            }
  -          };
  -
  -      pauseReceiverButtonAction.putValue(
  -        Action.SHORT_DESCRIPTION,
  -        "Pause the selected Receiver.  All events received will be discarded.");
  -      pauseReceiverButtonAction.putValue(
  -        Action.SMALL_ICON, new ImageIcon(ChainsawIcons.PAUSE));
  -      pauseReceiverButtonAction.setEnabled(false);
  +      playReceiverButton.setText(null);
   
         SmallButton pauseReceiverButton =
           new SmallButton(pauseReceiverButtonAction);
  -
  -      shutdownReceiverButtonAction =
  -        new AbstractAction() {
  -            public void actionPerformed(ActionEvent e) {
  -              shutdownCurrentlySelectedReceiver();
  -            }
  -          };
  -
  -      shutdownReceiverButtonAction.putValue(
  -        Action.SHORT_DESCRIPTION,
  -        "Shuts down the selected Receiver, and removes it from the Plugin 
registry");
  -      shutdownReceiverButtonAction.putValue(
  -        Action.SMALL_ICON, new ImageIcon(ChainsawIcons.ICON_STOP_RECEIVER));
  -      shutdownReceiverButtonAction.setEnabled(false);
  -
  +      pauseReceiverButton.setText(null);
  +      
         SmallButton shutdownReceiverButton =
           new SmallButton(shutdownReceiverButtonAction);
  -
  +      shutdownReceiverButton.setText(null);
  +      
         SmallButton restartAllButton = new SmallButton(startAllAction);
         restartAllButton.setText(null);
   
  @@ -464,7 +493,7 @@
             newReceiverButtonAction.setEnabled(false);
             
           } else {
  -          shutdownReceiverButtonAction.setEnabled(false);
  +          shutdownReceiverButtonAction.setEnabled(true);
             pauseReceiverButtonAction.setEnabled(false);
             playReceiverButtonAction.setEnabled(true);
             editReceiverButtonAction.setEnabled(true);
  @@ -488,14 +517,8 @@
      *
      */
     class ReceiverPopupMenu extends JPopupMenu {
  -    final JMenu startMenu = new JMenu("Start");
  -    final JMenu pauseMenu = new JMenu("Pause");
  -    final JMenu shutdownMenu = new JMenu("Shutdown");
   
       ReceiverPopupMenu() {
  -      add(startMenu);
  -      add(pauseMenu);
  -      add(shutdownMenu);
       }
   
       private JMenuItem createNotDoneYet() {
  @@ -517,11 +540,7 @@
         }
   
         Object userObject = node.getUserObject();
  -      startMenu.removeAll();
  -      pauseMenu.removeAll();
  -      shutdownMenu.removeAll();
  -
  -      System.out.println(userObject);
  +      removeAll();
   
         if (userObject == ReceiversTreeModel.RootNode.getUserObject()) {
           buildForReceiversRoot();
  @@ -558,9 +577,9 @@
             }
           };
   
  -      startMenu.add(createNotDoneYet());
  -      pauseMenu.add(createNotDoneYet());
  -      shutdownMenu.add(createNotDoneYet());
  +      add(playReceiverButtonAction);
  +      add(pauseReceiverButtonAction);
  +      add(shutdownReceiverButtonAction);
       }
   
       /**
  @@ -570,9 +589,13 @@
        */
       private void buildForReceiversRoot() {
         JMenuItem startAll = new JMenuItem(startAllAction);
  -      startMenu.add(startAll);
  -      pauseMenu.add(createNotDoneYet());
  -      shutdownMenu.add(createNotDoneYet());
  +      
  +      add(newReceiverButtonAction);
  +      add(editReceiverButtonAction);
  +      
  +      addSeparator();
  +      add(startAll);
  +      
       }
     }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to