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 04:00:22 GMT
psmith      2003/05/05 21:00:22

  Modified:    src/java/org/apache/log4j/chainsaw LogUI.java
  Log:
  moved the Find action, and UI elements out into ChainsawToolbarsAndMenus.
  
  A side effect of this change is that An undocked pane 
  unfortunately won't have a Find function, but that isn't far away.
  
  Revision  Changes    Path
  1.28      +96 -77    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.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- LogUI.java	6 May 2003 02:29:06 -0000	1.27
  +++ LogUI.java	6 May 2003 04:00:21 -0000	1.28
  @@ -230,6 +230,27 @@
   
   		tabbedPane = new ChainsawTabbledPane();
           tabbedPane.addChangeListener(tbms);
  +
  +    /**
  +     * We listen for double clicks, and auto-undock currently
  +     * selected Tab if the mouse event location matches the currently selected
  +     * tab 
  +     */
  +    tabbedPane.addMouseListener(new MouseAdapter() {
  +      public void mouseClicked(MouseEvent e) {
  +        super.mouseClicked(e);
  +        if(e.getClickCount()>1 && e.getButton() == MouseEvent.BUTTON1) {
  +          int tabIndex = tabbedPane.indexAtLocation(e.getX(), e.getY());
  +          if(tabIndex !=-1 && tabIndex == tabbedPane.getSelectedIndex()) {
  +            LogPanel logPanel = getCurrentLogPanel();
  +            if (logPanel!=null) {
  +              logPanel.undock();
  +            }
  +          }
  +        }
  +      }
  +
  +    });
           
   		tabbedPane.add("Welcome", new WelcomePanel());
   		panePanel.add(tabbedPane);
  @@ -544,7 +565,7 @@
   	class LogPanel extends DockablePanel {
   		final ColorFilter colorFilter = new ColorFilter();
   		final DisplayFilter displayFilter;
  -		final TableModel tableModel;
  +		final DefaultSortTableModel tableModel;
   		final JEditorPane detail;
   		final JSplitPane lowerPanel;
   		final DetailThread detailThread;
  @@ -552,6 +573,7 @@
       final JFrame f;
       final DockablePanel externalPanel;
       final Action dockingAction;
  +    final JSortTable table;
   		private boolean isDetailPaneVisible = true;
   		boolean isDocked = true;
   		String identifier;
  @@ -580,6 +602,7 @@
   
   			identifier = ident;
         this.tableModel = tableModel;
  +      this.table = table;
         
   			map.put(ChainsawConstants.LEVEL_COL_NAME, levelSet);
   			levelSet.addAll(levelList);
  @@ -879,85 +902,56 @@
   
   			upperPanel.add(filterText);
   
  -			JLabel findLabel = new JLabel("Find: ");
  -			gbc.gridx = 5;
  -			gbc.gridy = 0;
  -			gbc.weightx = 0;
  -			gridbag.setConstraints(findLabel, gbc);
  -			upperPanel.add(findLabel);
  -
  -			final JTextField findText = new JTextField();
  -
  -			gbc.gridx = 6;
  -			gbc.gridy = 0;
  -			gbc.weightx = 1;
  -			gbc.fill = GridBagConstraints.HORIZONTAL;
  -			gridbag.setConstraints(findText, gbc);
  -			findText.setToolTipText(
  -				"Performs a case-insensitive search across all columns");
  -			upperPanel.add(findText);
  -
  -			findText.getDocument().addDocumentListener(new DocumentListener() {
  -				public void insertUpdate(DocumentEvent e) {
  -					find();
  -				}
  -
  -				public void removeUpdate(DocumentEvent e) {
  -					find();
  -				}
  -
  -				public void changedUpdate(DocumentEvent e) {
  -					find();
  -				}
  -
  -				public void find() {
  -					final int row = tableModel.find(0, findText.getText());
  -
  -					if (findText.getDocument().getLength() == 0) {
  -						scrollToBottom.bypass(false);
  -					} else {
  -						scrollToBottom.bypass(true);
  -					}
  -
  -					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);
  +//			JLabel findLabel = new JLabel("Find: ");
  +//			gbc.gridx = 5;
  +//			gbc.gridy = 0;
  +//			gbc.weightx = 0;
  +//			gridbag.setConstraints(findLabel, gbc);
  +//			upperPanel.add(findLabel);
  +//
  +//			final JTextField findText = new JTextField();
  +//
  +//			gbc.gridx = 6;
  +//			gbc.gridy = 0;
  +//			gbc.weightx = 1;
  +//			gbc.fill = GridBagConstraints.HORIZONTAL;
  +//			gridbag.setConstraints(findText, gbc);
  +//			findText.setToolTipText(
  +//				"Performs a case-insensitive search across all columns");
  +//			upperPanel.add(findText);
  +//
  +//			findText.getDocument().addDocumentListener(new DocumentListener() {
  +//				public void insertUpdate(DocumentEvent e) {
  +//					find();
  +//				}
  +//
  +//				public void removeUpdate(DocumentEvent e) {
  +//					find();
  +//				}
  +//
  +//				public void changedUpdate(DocumentEvent e) {
  +//					find();
  +//				}
  +//
  +//				public void find() {
  +//					final int row = tableModel.find(0, findText.getText());
  +//
  +//					if (findText.getDocument().getLength() == 0) {
  +//						scrollToBottom.bypass(false);
  +//					} else {
  +//						scrollToBottom.bypass(true);
  +//					}
  +//
  +//					table.scrollToRow(
  +//						row,
  +//						table.columnAtPoint(
  +//							table.getVisibleRect().getLocation()));
  +//				}
  +//			});
   
   			gbc.gridx = 7;
   			gbc.gridy = 0;
   			gbc.weightx = 0;
  -			gridbag.setConstraints(findButton, gbc);
  -
  -			upperPanel.add(findButton);
   
   			final JScrollPane eventsPane = new JScrollPane(table);
   			eventsPane.setPreferredSize(new Dimension(900, 300));
  @@ -1288,7 +1282,6 @@
   		String getIdentifier() {
   			return identifier;
   		}
  -    
       void clearModel() {
         TableModel model = tableModel;
   
  @@ -1303,10 +1296,26 @@
         }
       }
       
  +    /**
  +     * Finds the row with the specified text, and ensures it is made visible
  +     * @param text
  +     */
  +    void find(String text) {
  +      final int row = tableModel.find(table.getSelectedRow() + 1, text);
  +      table.scrollToRow(
  +        row,
  +        table.columnAtPoint(table.getVisibleRect().getLocation()));
  +    }
  +    
       boolean isDetailPaneVisible() {
       	return isDetailPaneVisible;
       }
       
  +    /**
  +     * Docks this DockablePanel by hiding the JFrame and placing the
  +     * Panel back inside the LogUI window.
  +     *
  +     */
       void dock() {
         f.setVisible(false);
         removeAll();
  @@ -1320,6 +1329,11 @@
   
       }
       
  +    /**
  +     * Undocks this DockablePanel by removing the panel from the LogUI
  +     * window and placing it inside it's own JFrame.
  +     *
  +     */
       void undock() {
         externalPanel.removeAll();
         externalPanel.add(upperPanel, BorderLayout.NORTH);
  @@ -1332,6 +1346,11 @@
         dockingAction.putValue(Action.NAME, "Dock");
       }
       
  +    /**
  +     * Shows or hides the Detail Pane depending on the Last
  +     * known position
  +     *
  +     */
       void toggleDetailPanel() {
         int currentPosition = lowerPanel.getDividerLocation();
         int lastPosition = lowerPanel.getLastDividerLocation();
  
  
  

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