psmith 2003/06/15 20:14:45
Modified: src/java/org/apache/log4j/chainsaw ChainsawStatusBar.java
Log:
added a new icon label in the status bar that shows when a new
remote connection is made.
Revision Changes Path
1.5 +59 -6
jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/ChainsawStatusBar.java
Index: ChainsawStatusBar.java
===================================================================
RCS file:
/home/cvs/jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/ChainsawStatusBar.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ChainsawStatusBar.java 20 May 2003 07:37:49 -0000 1.4
+++ ChainsawStatusBar.java 16 Jun 2003 03:14:45 -0000 1.5
@@ -79,10 +79,15 @@
private final JLabel pausedLabel = new JLabel("", JLabel.CENTER);
private final JLabel lineSelectionLabel = new JLabel("", JLabel.CENTER);
private final JLabel receivedEventLabel = new JLabel("", JLabel.CENTER);
+ private final JLabel receivedConnectionlabel = new JLabel("", JLabel.CENTER);
private volatile long lastReceivedEvent = System.currentTimeMillis();
+ private volatile long lastReceivedConnection = System.currentTimeMillis();
private final Thread receiveThread;
+ private final Thread connectionThread;
private final Icon radioTowerIcon =
new ImageIcon(ChainsawIcons.ANIM_RADIO_TOWER);
+ private final Icon netConnectIcon = new ImageIcon(ChainsawIcons.ANIM_NET_CONNECT);
+
// private final Border statusBarComponentBorder =
// BorderFactory.createEmptyBorder();
@@ -116,6 +121,15 @@
radioTowerIcon.getIconWidth() + 4,
(int) receivedEventLabel.getPreferredSize().getHeight()));
+ receivedConnectionlabel.setBorder(statusBarComponentBorder);
+ receivedConnectionlabel.setToolTipText(
+ "Indicates whether Chainsaw has received a remote connection");
+ receivedConnectionlabel.setPreferredSize(
+ new Dimension(
+ netConnectIcon.getIconWidth() + 4,
+ (int) receivedConnectionlabel.getPreferredSize().getHeight()));
+
+
lineSelectionLabel.setBorder(statusBarComponentBorder);
lineSelectionLabel.setPreferredSize(
new Dimension(
@@ -144,16 +158,21 @@
c.weightx = 0.0;
c.weighty = 0.0;
c.gridx = 1;
- add(receivedEventLabel, c);
+ add(receivedConnectionlabel, c);
c.weightx = 0.0;
c.weighty = 0.0;
c.gridx = 2;
- add(lineSelectionLabel, c);
+ add(receivedEventLabel, c);
c.weightx = 0.0;
c.weighty = 0.0;
c.gridx = 3;
+ add(lineSelectionLabel, c);
+
+ c.weightx = 0.0;
+ c.weighty = 0.0;
+ c.gridx = 4;
add(pausedLabel, c);
@@ -167,23 +186,53 @@
} catch (InterruptedException e) {
}
- Icon icon = null;
+ Icon icon = null;
+
if (
(System.currentTimeMillis() - lastReceivedEvent) < DELAY_PERIOD) {
icon = radioTowerIcon;
- }
+ }
final Icon theIcon = icon;
SwingUtilities.invokeLater(
new Runnable() {
public void run() {
- receivedEventLabel.setIcon(theIcon);
+ receivedEventLabel.setIcon(theIcon);
}
});
}
}
});
receiveThread.start();
+
+ connectionThread =
+ new Thread(
+ new Runnable() {
+ public void run() {
+ while (true) {
+ try {
+ Thread.sleep(DELAY_PERIOD);
+ } catch (InterruptedException e) {
+ }
+
+ Icon icon = null;
+
+ if (
+ (System.currentTimeMillis() - lastReceivedConnection) <
DELAY_PERIOD) {
+ icon = netConnectIcon;
+ }
+
+ final Icon theIcon = icon;
+ SwingUtilities.invokeLater(
+ new Runnable() {
+ public void run() {
+ receivedConnectionlabel.setIcon(theIcon);
+ }
+ });
+ }
+ }
+ });
+ connectionThread.start();
}
/**
@@ -205,7 +254,11 @@
* @param source
*/
void remoteConnectionReceived(String source) {
- // TODO implement this method
+ lastReceivedConnection = System.currentTimeMillis();
+ setMessage("Connection received from " + source);
+ connectionThread.interrupt();
+
+ // TODO and maybe play a sound?
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]