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 08:42:29 UTC

cvs commit: jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw ChainsawStatusBar.java

psmith      2003/05/19 23:42:29

  Modified:    src/java/org/apache/log4j/chainsaw ChainsawStatusBar.java
  Log:
  modified l&F and added selectedLine as a statusbar item.
  
  Revision  Changes    Path
  1.2       +53 -5     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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ChainsawStatusBar.java	20 May 2003 03:58:40 -0000	1.1
  +++ ChainsawStatusBar.java	20 May 2003 06:42:29 -0000	1.2
  @@ -70,15 +70,18 @@
    *
    */
   class ChainsawStatusBar extends JPanel {
  -  private final JLabel statusMsg = new JLabel("Welcome to Chainsaw v2!");
  +  private final String DEFAULT_MSG = "Welcome to Chainsaw v2!";
  +  private final JLabel statusMsg = new JLabel(DEFAULT_MSG);
     private final JLabel pausedLabel = new JLabel("", JLabel.CENTER);
  +  private final JLabel lineSelectionLabel = 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);
  +  private final Border statusBarComponentBorder =
  +    BorderFactory.createLineBorder(statusMsg.getBackground().darker());
   
  +  //  private final Border statusBarComponentBorder =
  +  //    new SoftBevelBorder(SoftBevelBorder.LOWERED);
     ChainsawStatusBar() {
       setLayout(new GridBagLayout());
   
  @@ -89,7 +92,24 @@
   
       pausedLabel.setBorder(statusBarComponentBorder);
       pausedLabel.setPreferredSize(
  -      new Dimension(50, (int) pausedLabel.getPreferredSize().getHeight()));
  +      new Dimension(
  +        pausedLabel.getFontMetrics(pausedLabel.getFont()).stringWidth(
  +          "Paused"), (int) pausedLabel.getPreferredSize().getHeight()));
  +
  +    pausedLabel.setToolTipText(
  +      "Shows whether the current Log panel is paused or not");
  +
  +    lineSelectionLabel.setBorder(statusBarComponentBorder);
  +    lineSelectionLabel.setPreferredSize(
  +      new Dimension(
  +        lineSelectionLabel.getFontMetrics(lineSelectionLabel.getFont())
  +                          .stringWidth("999999:999999"),
  +        (int) lineSelectionLabel.getPreferredSize().getHeight()));
  +    lineSelectionLabel.setToolTipText(
  +      "Shows the currently selected line # & Total # of Lines");
  +
  +    statusMsg.setMinimumSize(pausedLabel.getPreferredSize());
  +    statusMsg.setToolTipText("Shows messages from Chainsaw");
   
       GridBagConstraints c = new GridBagConstraints();
       c.insets = new Insets(2, 2, 2, 2);
  @@ -107,6 +127,11 @@
       c.weightx = 0.0;
       c.weighty = 0.0;
       c.gridx = 1;
  +    add(lineSelectionLabel, c);
  +
  +    c.weightx = 0.0;
  +    c.weighty = 0.0;
  +    c.gridx = 2;
   
       add(pausedLabel, c);
     }
  @@ -145,6 +170,29 @@
         };
   
       SwingUtilities.invokeLater(runnable);
  +  }
  +
  +  void setSelectedLine(final int selectedLine, final int lineCount) {
  +    SwingUtilities.invokeLater(
  +      new Runnable() {
  +        public void run() {
  +          lineSelectionLabel.setText(selectedLine + ":" + lineCount);
  +        }
  +      });
  +  }
  +
  +  void setNothingSelected() {
  +    SwingUtilities.invokeLater(
  +      new Runnable() {
  +        public void run() {
  +          lineSelectionLabel.setText("");
  +        }
  +      });
  +  }
  +
  +  void clear() {
  +    setMessage(DEFAULT_MSG);
  +    setNothingSelected();
     }
   
     void setMessage(final String msg) {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-dev-help@jakarta.apache.org