You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by ps...@apache.org on 2003/05/20 05:58:41 UTC
cvs commit: jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw ChainsawStatusBar.java LogUI.java ChainsawTabbledPane.java ChainsawToolBarAndMenus.java
psmith 2003/05/19 20:58:41
Modified: src/java/org/apache/log4j/chainsaw LogUI.java
ChainsawTabbledPane.java
ChainsawToolBarAndMenus.java
Added: src/java/org/apache/log4j/chainsaw ChainsawStatusBar.java
Log:
added a Status bar, plus a menu to hide/show it, but it's not in Settings
just yet (sorry, ran out of time).
Also fixed bug where the new Small buttons were adding actions
to themselves twice, causing a File Open to prompt you again for a file
when you've already selected one.
Hopefully no merging stuff ups by me again.
Revision Changes Path
1.64 +83 -47 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.63
retrieving revision 1.64
diff -u -r1.63 -r1.64
--- LogUI.java 20 May 2003 03:46:41 -0000 1.63
+++ LogUI.java 20 May 2003 03:58:40 -0000 1.64
@@ -155,6 +155,7 @@
private static final String LOOK_AND_FEEL = "LookAndFeel";
ChainsawTabbledPane tabbedPane;
JToolBar toolbar;
+ private final ChainsawStatusBar statusBar = new ChainsawStatusBar();
private final Map tableModelMap = new HashMap();
private final Map tableMap = new HashMap();
private final List columnNames = new ArrayList();
@@ -310,7 +311,7 @@
filterableColumns.add(ChainsawConstants.NONE_COL_NAME);
JPanel panePanel = new JPanel();
- panePanel.setLayout(new BorderLayout());
+ panePanel.setLayout(new BorderLayout(2,2));
getContentPane().setLayout(new BorderLayout());
@@ -396,6 +397,7 @@
getContentPane().add(toolbar, BorderLayout.NORTH);
getContentPane().add(panePanel, BorderLayout.CENTER);
+ getContentPane().add(statusBar, BorderLayout.SOUTH);
addWindowListener(
new WindowAdapter() {
@@ -438,6 +440,10 @@
tabbedPane.removeTabAt(tabbedPane.indexOfTab("Welcome"));
}
+ ChainsawStatusBar getStatusBar() {
+ return statusBar;
+ }
+
/**
* Shutsdown by ensuring the Appender gets a chance to close.
*/
@@ -461,6 +467,31 @@
return null;
}
+ void removeStatusBar() {
+ System.out.println("Removing statusbar");
+ SwingUtilities.invokeLater(
+ new Runnable() {
+ public void run() {
+ getContentPane().remove(statusBar);
+ getContentPane().validate();
+ getContentPane().repaint();
+ }
+ });
+ }
+
+ void addStatusBar() {
+ removeStatusBar();
+ System.out.println("Adding status bar");
+ SwingUtilities.invokeLater(
+ new Runnable() {
+ public void run() {
+ getContentPane().add(statusBar, BorderLayout.SOUTH);
+ getContentPane().validate();
+ getContentPane().repaint();
+ }
+ });
+ }
+
public String getActiveTabName() {
int index = tabbedPane.getSelectedIndex();
@@ -948,6 +979,7 @@
upperPanel = new JPanel(new BorderLayout());
upperPanel.setBorder(BorderFactory.createEmptyBorder(2, 5, 2, 0));
+
final JLabel filterLabel = new JLabel("QuickFilter: ");
filterLabel.setFont(filterLabel.getFont().deriveFont(Font.BOLD));
@@ -1408,7 +1440,6 @@
" Events " + currentCount + " of " + totalCount);
}
});
-
tableModel.addEventCountListener(new TabIconHandler(ident));
}
@@ -1733,52 +1764,57 @@
}
class TabIconHandler implements EventCountListener {
- private final String ident;
- private int lastCount;
- private int currentCount;
- private boolean hasNewEvents = false;
- ImageIcon NEW_EVENTS=new ImageIcon(ChainsawIcons.ABOUT);
- ImageIcon HAS_EVENTS = new ImageIcon(ChainsawIcons.UNDOCKED_ICON);
-
- public TabIconHandler(final String ident) {
- this.ident = ident;
-
- new Thread(new Runnable() {
- public void run() {
- while (true) {
- //if this tab is active, remove the icon
- if (tabbedPane.getSelectedIndex() == tabbedPane.indexOfTab(ident)) {
- tabbedPane.setIconAt(tabbedPane.indexOfTab(ident), null);
- hasNewEvents = false;
- } else {
- //don't process undocked tabs
- if (tabbedPane.indexOfTab(ident) > -1) {
- //if the tab is not active and the counts don't match, set the new events icon
- if (lastCount != currentCount) {
- tabbedPane.setIconAt(tabbedPane.indexOfTab(ident), NEW_EVENTS);
- lastCount = currentCount;
- hasNewEvents = true;
- } else {
- if (hasNewEvents) {
- tabbedPane.setIconAt(tabbedPane.indexOfTab(ident), HAS_EVENTS);
- }
- }
- }
- }
-
- try {
- Thread.sleep(1000);
- } catch (InterruptedException ie){}
- }
- }
- }).start();
- }
-
- public void eventCountChanged(int currentCount, int totalCount) {
- this.currentCount=currentCount;
- }
+ private final String ident;
+ private int lastCount;
+ private int currentCount;
+ private boolean hasNewEvents = false;
+ ImageIcon NEW_EVENTS = new ImageIcon(ChainsawIcons.ABOUT);
+ ImageIcon HAS_EVENTS = new ImageIcon(ChainsawIcons.UNDOCKED_ICON);
+
+ public TabIconHandler(final String ident) {
+ this.ident = ident;
+
+ new Thread(
+ new Runnable() {
+ public void run() {
+ while (true) {
+ //if this tab is active, remove the icon
+ if (
+ tabbedPane.getSelectedIndex() == tabbedPane.indexOfTab(ident)) {
+ tabbedPane.setIconAt(tabbedPane.indexOfTab(ident), null);
+ hasNewEvents = false;
+ } else {
+ //don't process undocked tabs
+ if (tabbedPane.indexOfTab(ident) > -1) {
+ //if the tab is not active and the counts don't match, set the new events icon
+ if (lastCount != currentCount) {
+ tabbedPane.setIconAt(
+ tabbedPane.indexOfTab(ident), NEW_EVENTS);
+ lastCount = currentCount;
+ hasNewEvents = true;
+ } else {
+ if (hasNewEvents) {
+ tabbedPane.setIconAt(
+ tabbedPane.indexOfTab(ident), HAS_EVENTS);
+ }
+ }
+ }
+ }
+
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException ie) {
+ }
+ }
+ }
+ }).start();
+ }
+
+ public void eventCountChanged(int currentCount, int totalCount) {
+ this.currentCount = currentCount;
+ }
}
-
+
class ScrollToBottom extends Thread {
boolean scrollToBottom;
boolean bypassed;
1.7 +1 -0 jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/ChainsawTabbledPane.java
Index: ChainsawTabbledPane.java
===================================================================
RCS file: /home/cvs/jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/ChainsawTabbledPane.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ChainsawTabbledPane.java 17 May 2003 23:03:55 -0000 1.6
+++ ChainsawTabbledPane.java 20 May 2003 03:58:40 -0000 1.7
@@ -41,6 +41,7 @@
*/
public ChainsawTabbledPane(int tabPlacement) {
super(tabPlacement);
+ setBorder(null);
}
/**
1.23 +19 -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.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- ChainsawToolBarAndMenus.java 20 May 2003 01:53:11 -0000 1.22
+++ ChainsawToolBarAndMenus.java 20 May 2003 03:58:40 -0000 1.23
@@ -84,7 +84,6 @@
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.ButtonGroup;
-import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBoxMenuItem;
@@ -224,8 +223,10 @@
if (logui.pausedList.contains(logPanel.getIdentifier())) {
pauseButton.getModel().setSelected(true);
+ logui.getStatusBar().setPaused(true);
} else {
pauseButton.getModel().setSelected(false);
+ logui.getStatusBar().setPaused(false);
}
detailPaneButton.getModel().setSelected(logPanel.isDetailPaneVisible());
@@ -385,6 +386,8 @@
} else {
logui.pausedList.remove(ident);
}
+
+ scanState();
}
};
@@ -630,11 +633,24 @@
new JCheckBoxMenuItem(toggleDetailPaneAction);
toggleDetailMenuItem.setSelected(true);
+ final JCheckBoxMenuItem toggleStatusBarCheck = new JCheckBoxMenuItem();
+ toggleStatusBarCheck.setAction(
+ new AbstractAction("Show Status bar") {
+ public void actionPerformed(ActionEvent arg0) {
+ if (toggleStatusBarCheck.isSelected()) {
+ logui.addStatusBar();
+ } else {
+ logui.removeStatusBar();
+ }
+ }
+ });
+ toggleStatusBarCheck.setSelected(true);
viewMenu.add(toggleDetailMenuItem);
viewMenu.addSeparator();
viewMenu.add(new JMenuItem(clearAction));
viewMenu.addSeparator();
viewMenu.add(showToolbarCheck);
+ viewMenu.add(toggleStatusBarCheck);
viewMenu.add(menuItemClose);
ButtonGroup tabPlacementGroup = new ButtonGroup();
@@ -888,7 +904,8 @@
this();
setAction(act);
setRequestFocusEnabled(false);
- addActionListener(act);
+
+ // addActionListener(act);
addMouseListener(this);
}
1.1 jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/ChainsawStatusBar.java
Index: ChainsawStatusBar.java
===================================================================
/*
* ============================================================================
* The Apache Software License, Version 1.1
* ============================================================================
*
* Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modifica-
* tion, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The end-user documentation included with the redistribution, if any, must
* include the following acknowledgment: "This product includes software
* developed by the Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself, if
* and wherever such third-party acknowledgments normally appear.
*
* 4. The names "log4j" and "Apache Software Foundation" must not be used to
* endorse or promote products derived from this software without prior
* written permission. For written permission, please contact
* apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache", nor may
* "Apache" appear in their name, without prior written permission of the
* Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
* DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* on behalf of the Apache Software Foundation. For more information on the
* Apache Software Foundation, please see <http://www.apache.org/>.
*
*/
package org.apache.log4j.chainsaw;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.border.Border;
import javax.swing.border.SoftBevelBorder;
/**
* A general purpose status bar for all Frame windows
*
* @author Paul Smith <ps...@apache.org>
*
*/
class ChainsawStatusBar extends JPanel {
private final JLabel statusMsg = new JLabel("Welcome to Chainsaw v2!");
private final JLabel pausedLabel = new JLabel("", JLabel.CENTER);
// private final Border statusBarComponentBorder =
// BorderFactory.createEmptyBorder();
private final Border statusBarComponentBorder = BorderFactory.createLineBorder(statusMsg.getBackground().darker());
// private final Border statusBarComponentBorder =
// new SoftBevelBorder(SoftBevelBorder.LOWERED);
ChainsawStatusBar() {
setLayout(new GridBagLayout());
JPanel statusMsgPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 2, 2));
statusMsgPanel.add(statusMsg);
statusMsgPanel.setBorder(statusBarComponentBorder);
pausedLabel.setBorder(statusBarComponentBorder);
pausedLabel.setPreferredSize(
new Dimension(50, (int) pausedLabel.getPreferredSize().getHeight()));
GridBagConstraints c = new GridBagConstraints();
c.insets = new Insets(2, 2, 2, 2);
c.weightx = 1.0;
c.weighty = 1.0;
c.ipadx = 2;
c.ipady = 2;
c.gridx = 0;
c.gridy = 0;
c.fill = GridBagConstraints.BOTH;
c.anchor = GridBagConstraints.WEST;
add(statusMsgPanel, c);
c.weightx = 0.0;
c.weighty = 0.0;
c.gridx = 1;
add(pausedLabel, c);
}
/**
* Calling this method indicates an event has been received in
* the current LogPanel, this method will trigger update
* the Icon/Text of the Statusbar to indicate the received event
* and after a period of time, this message will be removed or
* the icon will be hidden.
*
*/
void receivedEvent() {
// TODO implement this method
}
/**
* Indicates a new connection has been established between
* Chainsaw and some remote host
* @param source
*/
void remoteConnectionReceived(String source) {
// TODO implement this method
}
/**
* Called when the paused state of the LogPanel has been updated
* @param isPaused
*/
void setPaused(final boolean isPaused) {
Runnable runnable =
new Runnable() {
public void run() {
pausedLabel.setText(isPaused ? "Paused" : "");
}
};
SwingUtilities.invokeLater(runnable);
}
void setMessage(final String msg) {
SwingUtilities.invokeLater(
new Runnable() {
public void run() {
statusMsg.setText(msg);
}
});
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-dev-help@jakarta.apache.org