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/src/java/org/apache/log4j/chainsaw LogUI.java
Date Fri, 19 Dec 2003 10:15:59 GMT
psmith      2003/12/19 02:15:59

  Modified:    src/java/org/apache/log4j/chainsaw LogUI.java
  Log:
  Once and for all (touch wood) solved the problem of some components
  not getting the chance to get the correct l&f.
  
  This is done by loading the App pref model BEFORE any GUI elements
  get initialised, and therefore we know what the correct L&F should be.
  
  Revision  Changes    Path
  1.59      +19 -29    jakarta-log4j/src/java/org/apache/log4j/chainsaw/LogUI.java
  
  Index: LogUI.java
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/chainsaw/LogUI.java,v
  retrieving revision 1.58
  retrieving revision 1.59
  diff -u -r1.58 -r1.59
  --- LogUI.java	19 Dec 2003 06:51:58 -0000	1.58
  +++ LogUI.java	19 Dec 2003 10:15:59 -0000	1.59
  @@ -159,7 +159,6 @@
     private static final String MAIN_WINDOW_X = "main.window.x";
     static final String TABLE_COLUMN_ORDER = "table.columns.order";
     static final String TABLE_COLUMN_WIDTHS = "table.columns.widths";
  -  private static final String LOOK_AND_FEEL = "LookAndFeel";
     private static final String STATUS_BAR = "StatusBar";
     static final String COLUMNS_EXTENSION = ".columns";
     static final String COLORS_EXTENSION = ".colors";
  @@ -182,7 +181,6 @@
     private ChainsawToolBarAndMenus tbms;
     private ChainsawAbout aboutBox;
     private final SettingsManager sm = SettingsManager.getInstance();
  -  private String lookAndFeelClassName;
     private final JFrame tutorialFrame = new JFrame("Chainsaw Tutorial");
   
     /**
  @@ -212,6 +210,7 @@
      */
     private EventListenerList shutdownListenerList = new EventListenerList();
     private WelcomePanel welcomePanel;
  +  private String lookAndFeelClassName;
   
     /**
      * Constructor which builds up all the visual elements of the frame including
  @@ -270,7 +269,14 @@
      * @param args
      */
     public static void main(String[] args) {
  -    createChainsawGUI(true, null);
  +    
  +    ApplicationPreferenceModel model = new ApplicationPreferenceModel();
  +    
  +    SettingsManager.getInstance().configure(model);
  +    
  +    applyLookAndFeel(model.getLookAndFeelClassName());
  +    
  +    createChainsawGUI(model, true, null);
     }
   
     /**
  @@ -282,7 +288,7 @@
      * @param shutdownAction
      *                    DOCUMENT ME!
      */
  -  public static void createChainsawGUI(
  +  public static void createChainsawGUI(ApplicationPreferenceModel model,
       boolean showSplash, Action shutdownAction) {
       LogUI logUI = new LogUI();
   
  @@ -295,6 +301,8 @@
       LogManager.getRootLogger().addAppender(logUI.handler);
       logUI.activateViewer();
   
  +    logUI.getApplicationPreferenceModel().apply(model);
  +    
       if (shutdownAction != null) {
         logUI.setShutdownAction(shutdownAction);
       }
  @@ -380,10 +388,6 @@
       event.saveSetting(LogUI.MAIN_WINDOW_WIDTH, getWidth());
       event.saveSetting(LogUI.MAIN_WINDOW_HEIGHT, getHeight());
   
  -    if (lookAndFeelClassName != null) {
  -      event.saveSetting(LogUI.LOOK_AND_FEEL, lookAndFeelClassName);
  -    }
  -
       if (configURLToUse != null) {
         event.saveSetting(LogUI.CONFIG_FILE_TO_USE, configURLToUse.toString());
       }
  @@ -698,21 +702,7 @@
       Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize();
       preferencesFrame.setLocation(new Point((screenDimension.width/2)-(preferencesFrame.getSize().width/2),
 (screenDimension.height/2)-(preferencesFrame.getSize().height/2)  ));
       
  -    getSettingsManager().configure(
  -      new SettingsListener() {
  -        public void loadSettings(LoadSettingsEvent event) {
  -          lookAndFeelClassName = event.getSetting(LogUI.LOOK_AND_FEEL);
  -
  -          if (lookAndFeelClassName != null) {
  -            applyLookAndFeel(lookAndFeelClassName);
  -          }
  -        }
  -
  -        public void saveSettings(SaveSettingsEvent event) {
  -          //required because of SettingsListener interface..not used during load
  -        }
  -      });
  -    
  + 
       pack();
       
       final JPopupMenu tabPopup = new JPopupMenu();
  @@ -1326,7 +1316,7 @@
      * @param lookAndFeelClassName
      *                    The FQN of the LookANdFeel
      */
  -  private void applyLookAndFeel(String lookAndFeelClassName) {
  +  private static void applyLookAndFeel(String lookAndFeelClassName) {
       if (
         UIManager.getLookAndFeel().getClass().getName().equals(
             lookAndFeelClassName)) {
  @@ -1335,14 +1325,14 @@
         return;
       }
   
  -    LogLog.debug("Setting L&F -> " + lookAndFeelClassName);
   
  +    if(lookAndFeelClassName == null || lookAndFeelClassName.trim().equals("")) {
  +      LogLog.info("Using System native L&F");
  +      lookAndFeelClassName = UIManager.getSystemLookAndFeelClassName();
  +    }
  +    LogLog.debug("Setting L&F -> " + lookAndFeelClassName);
       try {
         UIManager.setLookAndFeel(lookAndFeelClassName);
  -      SwingUtilities.updateComponentTreeUI(this);
  -      SwingUtilities.updateComponentTreeUI(preferencesFrame);
  -	  SwingUtilities.updateComponentTreeUI(receiversPanel);
  -      applicationPreferenceModelPanel.notifyOfLookAndFeelChange();
        } catch (Exception e) {
         LogLog.error("Failed to change L&F", e);
       }
  
  
  

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