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 sd...@apache.org on 2004/01/02 22:51:59 UTC
cvs commit: logging-log4j/src/java/org/apache/log4j/chainsaw/icons LineIconFactory.java
sdeboy 2004/01/02 13:51:59
Modified: src/java/org/apache/log4j/chainsaw LogUI.java
src/java/org/apache/log4j/chainsaw/icons
LineIconFactory.java
Log:
made tab selection icon change immediate
added a spacer blank icon for selected tabs so the alignment stays the same as events show up
made a blank icon for facilitating spacer
Revision Changes Path
1.70 +32 -40 logging-log4j/src/java/org/apache/log4j/chainsaw/LogUI.java
Index: LogUI.java
===================================================================
RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/chainsaw/LogUI.java,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -r1.69 -r1.70
--- LogUI.java 31 Dec 2003 19:31:16 -0000 1.69
+++ LogUI.java 2 Jan 2004 21:51:58 -0000 1.70
@@ -83,6 +83,7 @@
import javax.swing.Action;
import javax.swing.BorderFactory;
import javax.swing.Box;
+import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComponent;
@@ -114,6 +115,7 @@
import org.apache.log4j.chainsaw.help.Tutorial;
import org.apache.log4j.chainsaw.helper.SwingHelper;
import org.apache.log4j.chainsaw.icons.ChainsawIcons;
+import org.apache.log4j.chainsaw.icons.LineIconFactory;
import org.apache.log4j.chainsaw.messages.MessageCenter;
import org.apache.log4j.chainsaw.plugins.ChainsawCentral;
import org.apache.log4j.chainsaw.prefs.LoadSettingsEvent;
@@ -566,20 +568,6 @@
getContentPane().setLayout(new BorderLayout());
getTabbedPane().addChangeListener(getToolBarAndMenus());
- getTabbedPane().addChangeListener(
- new ChangeListener() {
- //received a statechange event - selection changed - remove icon from
- // selected index
- public void stateChanged(ChangeEvent e) {
- if (
- getTabbedPane().getSelectedComponent() instanceof ChainsawTabbedPane) {
- if (getTabbedPane().getSelectedIndex() > -1) {
- getTabbedPane().setIconAt(
- getTabbedPane().getSelectedIndex(), null);
- }
- }
- }
- });
KeyStroke ksRight =
KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, Event.CTRL_MASK);
@@ -1629,7 +1617,9 @@
final LogPanel thisPanel =
new LogPanel(getStatusBar(), ident);
- thisPanel.addEventCountListener(new TabIconHandler(ident));
+ TabIconHandler iconHandler = new TabIconHandler(ident);
+ thisPanel.addEventCountListener(iconHandler);
+ tabbedPane.addChangeListener(iconHandler);
PropertyChangeListener toolbarMenuUpdateListener =
new PropertyChangeListener() {
@@ -1706,49 +1696,45 @@
}
}
- class TabIconHandler implements EventCountListener {
+ class TabIconHandler implements EventCountListener, ChangeListener {
//the tabIconHandler is associated with a new tab, and a new tab always
//shows the 'new events' icon
- private boolean receivedNotification = true;
+ private boolean newEvents = true;
+ private boolean seenEvents = false;
+ private final String ident;
ImageIcon NEW_EVENTS = new ImageIcon(ChainsawIcons.ANIM_RADIO_TOWER);
ImageIcon HAS_EVENTS = new ImageIcon(ChainsawIcons.INFO);
+ Icon SELECTED = LineIconFactory.createBlankIcon();
- public TabIconHandler(final String ident) {
+ public TabIconHandler(String identifier) {
+ ident = identifier;
new Thread(
new Runnable() {
public void run() {
while (true) {
//if this tab is active, remove the icon
- if (
- (getTabbedPane().getSelectedIndex() > -1)
- && (getTabbedPane().getSelectedIndex() == getTabbedPane()
- .indexOfTab(
- ident))) {
- getTabbedPane().setIconAt(
- getTabbedPane().indexOfTab(ident), null);
-
- } else {
- //don't process undocked tabs
- if (getTabbedPane().indexOfTab(ident) > -1) {
- //if the tab is not active and we received notification, set the
- // new events icon
- if (receivedNotification) {
+ //don't process undocked tabs
+ if (getTabbedPane().getSelectedIndex() == getTabbedPane().indexOfTab(ident)) {
+ getTabbedPane().setIconAt(getTabbedPane().indexOfTab(ident), SELECTED);
+ newEvents = false;
+ seenEvents = true;
+ } else if (getTabbedPane().indexOfTab(ident) > -1) {
+ if (newEvents) {
+ getTabbedPane().setIconAt(
+ getTabbedPane().indexOfTab(ident), NEW_EVENTS);
+ newEvents = false;
+ seenEvents = false;
+ } else if (!seenEvents) {
getTabbedPane().setIconAt(
- getTabbedPane().indexOfTab(ident), NEW_EVENTS);
- receivedNotification = false;
- } else {
- getTabbedPane().setIconAt(
getTabbedPane().indexOfTab(ident), HAS_EVENTS);
- }
}
}
try {
Thread.sleep(handler.getQueueInterval() + 1000);
- } catch (InterruptedException ie) {
- }
+ } catch (InterruptedException ie) {}
}
}
}).start();
@@ -1763,7 +1749,13 @@
* DOCUMENT ME!
*/
public void eventCountChanged(int currentCount, int totalCount) {
- receivedNotification = true;
+ newEvents = true;
+ }
+
+ public void stateChanged(ChangeEvent event) {
+ if (getTabbedPane().indexOfTab(ident) == getTabbedPane().getSelectedIndex()) {
+ getTabbedPane().setIconAt(getTabbedPane().indexOfTab(ident), SELECTED);
+ }
}
}
/**
1.2 +33 -0 logging-log4j/src/java/org/apache/log4j/chainsaw/icons/LineIconFactory.java
Index: LineIconFactory.java
===================================================================
RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/chainsaw/icons/LineIconFactory.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- LineIconFactory.java 3 Sep 2003 23:22:09 -0000 1.1
+++ LineIconFactory.java 2 Jan 2004 21:51:58 -0000 1.2
@@ -143,6 +143,39 @@
return new CloseIcon(8, 0, 0);
}
+ public static final Icon createBlankIcon() {
+ return new BlankIcon(16, 0, 0);
+ }
+
+ /**
+ * A nice and simple 'X' style icon that is used to indicate a 'close' operation.
+ *
+ * @author Scott Deboy <sd...@apache.org>
+ *
+ */
+ private static class BlankIcon implements Icon {
+ int size;
+ int xOffSet;
+ int yOffSet;
+
+ public BlankIcon(int size, int xOffSet, int yOffSet) {
+ this.size = size;
+ this.xOffSet = xOffSet;
+ this.yOffSet = yOffSet;
+ }
+
+ public int getIconHeight() {
+ return size;
+ }
+
+ public int getIconWidth() {
+ return size;
+ }
+
+ public void paintIcon(Component c, Graphics g, int x, int y) {
+ }
+ }
+
/**
* A nice and simple 'X' style icon that is used to indicate a 'close' operation.
*
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org