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 Tue, 06 May 2003 02:29:06 GMT
psmith      2003/05/05 19:29:06

  Modified:    src/java/org/apache/log4j/chainsaw LogUI.java
  Log:
  created dock() and undock() actions, moved around the action for it
  and made the JFrame that is used for undocking automatically Dock 
  back when it is closed.  (Still need an actual Close action for both
  docked and undocked LogPanels to really truely get rid of them).
  
  Revision  Changes    Path
  1.27      +48 -26    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.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- LogUI.java	5 May 2003 18:30:05 -0000	1.26
  +++ LogUI.java	6 May 2003 02:29:06 -0000	1.27
  @@ -548,6 +548,10 @@
   		final JEditorPane detail;
   		final JSplitPane lowerPanel;
   		final DetailThread detailThread;
  +    final JPanel upperPanel;
  +    final JFrame f;
  +    final DockablePanel externalPanel;
  +    final Action dockingAction;
   		private boolean isDetailPaneVisible = true;
   		boolean isDocked = true;
   		String identifier;
  @@ -775,7 +779,7 @@
   			GridBagLayout gridbag = new GridBagLayout();
   			GridBagConstraints gbc = new GridBagConstraints();
   
  -			final JPanel upperPanel = new JPanel(gridbag);
  +			upperPanel = new JPanel(gridbag);
   			upperPanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
   
   			gbc.gridx = 0;
  @@ -1066,9 +1070,10 @@
   
   			final JMenuItem menuItemToggleDock = new JMenuItem("Undock/dock");
   
  -			final JFrame f = new JFrame(ident);
  +			f = new JFrame(ident);
  +      f.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
         
  -			final DockablePanel externalPanel = new DockablePanel();
  +			externalPanel = new DockablePanel();
   			externalPanel.setLayout(new BorderLayout());
   			f.setSize(new Dimension(500, 500));
   			f.getContentPane().add(externalPanel);
  @@ -1084,29 +1089,21 @@
   				}
   			});
   
  -			menuItemToggleDock.addActionListener(new ActionListener() {
  -				public void actionPerformed(ActionEvent evt) {
  -					if (isDocked()) {
  -						externalPanel.removeAll();
  -						externalPanel.add(upperPanel, BorderLayout.NORTH);
  -						externalPanel.add(lowerPanel, BorderLayout.CENTER);
  -						tabbedPane.remove(LogPanel.this);
  -						externalPanel.setDocked(false);
  -						setDocked(false);
  -						panelMap.put(ident, externalPanel);
  -						f.setVisible(true);
  -					} else {
  -						f.setVisible(false);
  -						removeAll();
  -						add(upperPanel, BorderLayout.NORTH);
  -						add(lowerPanel, BorderLayout.CENTER);
  -						panelMap.put(ident, LogPanel.this);
  -						tabbedPane.addANewTab(ident,  LogPanel.this);
  -						externalPanel.setDocked(true);
  -						setDocked(true);
  -					}
  -				}
  -			});
  +      dockingAction = new AbstractAction("Undock") {
  +        public void actionPerformed(ActionEvent evt) {
  +          if (isDocked()) {
  +            undock();
  +          } else {
  +            dock();
  +          }
  +        }
  +      };
  +			menuItemToggleDock.setAction(dockingAction);
  +      f.addWindowListener(new WindowAdapter() {
  +        public void windowClosing(WindowEvent e) {
  +          dock();
  +        }
  +      });
   
   			JMenuItem menuItemDisplayFilter =
   				new JMenuItem("Define display and color filters...");
  @@ -1308,6 +1305,31 @@
       
       boolean isDetailPaneVisible() {
       	return isDetailPaneVisible;
  +    }
  +    
  +    void dock() {
  +      f.setVisible(false);
  +      removeAll();
  +      add(upperPanel, BorderLayout.NORTH);
  +      add(lowerPanel, BorderLayout.CENTER);
  +      panelMap.put(getIdentifier(), LogPanel.this);
  +      tabbedPane.addANewTab(getIdentifier(),  LogPanel.this);
  +      externalPanel.setDocked(true);
  +      setDocked(true);
  +      dockingAction.putValue(Action.NAME, "Undock");
  +
  +    }
  +    
  +    void undock() {
  +      externalPanel.removeAll();
  +      externalPanel.add(upperPanel, BorderLayout.NORTH);
  +      externalPanel.add(lowerPanel, BorderLayout.CENTER);
  +      tabbedPane.remove(LogPanel.this);
  +      externalPanel.setDocked(false);
  +      setDocked(false);
  +      panelMap.put(getIdentifier(), externalPanel);
  +      f.setVisible(true);
  +      dockingAction.putValue(Action.NAME, "Dock");
       }
       
       void toggleDetailPanel() {
  
  
  

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