View Javadoc

    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements.  See the NOTICE file distributed with
    4    * this work for additional information regarding copyright ownership.
    5    * The ASF licenses this file to You under the Apache License, Version 2.0
    6    * (the "License"); you may not use this file except in compliance with
    7    * the License.  You may obtain a copy of the License at
    8    *
    9    *      http://www.apache.org/licenses/LICENSE-2.0
    10   *
    11   * Unless required by applicable law or agreed to in writing, software
    12   * distributed under the License is distributed on an "AS IS" BASIS,
    13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14   * See the License for the specific language governing permissions and
    15   * limitations under the License.
    16   */
    17
    18  package org.apache.log4j.chainsaw;
    19
    20  import java.awt.Dimension;
    21  import java.awt.FlowLayout;
    22  import java.awt.event.ActionEvent;
    23  import java.awt.event.ActionListener;
    24  import java.beans.PropertyChangeEvent;
    25  import java.beans.PropertyChangeListener;
    26  import java.io.File;
    27  import java.net.MalformedURLException;
    28  import java.net.URL;
    29  import java.util.Dictionary;
    30  import java.util.Enumeration;
    31  import java.util.Hashtable;
    32
    33  import java.util.Locale;
    34  import javax.swing.BorderFactory;
    35  import javax.swing.Box;
    36  import javax.swing.BoxLayout;
    37  import javax.swing.ButtonGroup;
    38  import javax.swing.DefaultComboBoxModel;
    39  import javax.swing.InputVerifier;
    40  import javax.swing.JButton;
    41  import javax.swing.JCheckBox;
    42  import javax.swing.JComboBox;
    43  import javax.swing.JComponent;
    44  import javax.swing.JFrame;
    45  import javax.swing.JLabel;
    46  import javax.swing.JOptionPane;
    47  import javax.swing.JPanel;
    48  import javax.swing.JRadioButton;
    49  import javax.swing.JSlider;
    50  import javax.swing.JTextField;
    51  import javax.swing.SwingConstants;
    52  import javax.swing.UIManager;
    53  import javax.swing.event.ChangeEvent;
    54  import javax.swing.event.ChangeListener;
    55  import javax.swing.tree.DefaultMutableTreeNode;
    56  import javax.swing.tree.DefaultTreeModel;
    57  import javax.swing.tree.TreeModel;
    58
    59  import org.apache.log4j.LogManager;
    60  import org.apache.log4j.Logger;
    61  import org.apache.log4j.chainsaw.helper.SwingHelper;
    62  import org.apache.log4j.chainsaw.osx.OSXIntegration;
    63
    64
    65  /**
    66   * A panel used by the user to modify any application-wide preferences.
    67   *
    68   * @author Paul Smith &lt;psmith@apache.org&gt;
    69   *
    70   */
    71  public class ApplicationPreferenceModelPanel extends AbstractPreferencePanel {
    72    private ApplicationPreferenceModel committedPreferenceModel;
    73    private ApplicationPreferenceModel uncommittedPreferenceModel =
    74      new ApplicationPreferenceModel();
    75    private JTextField identifierExpression;
    76    private JTextField toolTipDisplayMillis;
    77    private JTextField cyclicBufferSize;
    78    private JComboBox configurationURL;
    79    private final Logger logger;
    80    private GeneralAllPrefPanel generalAllPrefPanel;
    81
    82      ApplicationPreferenceModelPanel(ApplicationPreferenceModel model) {
    83      this.committedPreferenceModel = model;
    84      logger = LogManager.getLogger(ApplicationPreferenceModelPanel.class);
    85      initComponents();
    86      getOkButton().addActionListener(
    87        new ActionListener() {
    88          public void actionPerformed(ActionEvent e) {
    89            uncommittedPreferenceModel.setConfigurationURL((String)configurationURL.getSelectedItem());
    90            uncommittedPreferenceModel.setIdentifierExpression(
    91              identifierExpression.getText());
    92              try {
    93                  int millis = Integer.parseInt(toolTipDisplayMillis.getText());
    94                  if (millis >= 0) {
    95                      uncommittedPreferenceModel.setToolTipDisplayMillis(millis);
    96                  }
    97              } catch (NumberFormatException nfe) {}
    98              try {
    99                  int bufferSize = Integer.parseInt(cyclicBufferSize.getText());
    100                 if (bufferSize >= 0) {
    101                     uncommittedPreferenceModel.setCyclicBufferSize(bufferSize);
    102                 }
    103             } catch (NumberFormatException nfe) {}
    104           committedPreferenceModel.apply(uncommittedPreferenceModel);
    105           hidePanel();
    106         }
    107       });
    108
    109     getCancelButton().addActionListener(
    110       new ActionListener() {
    111         public void actionPerformed(ActionEvent e) {
    112           uncommittedPreferenceModel.apply(committedPreferenceModel);
    113           hidePanel();
    114         }
    115       });
    116   }
    117
    118
    119 public static void main(String[] args) {
    120     JFrame f = new JFrame("App Preferences Panel Test Bed");
    121     ApplicationPreferenceModel model = new ApplicationPreferenceModel();
    122     ApplicationPreferenceModelPanel panel =
    123       new ApplicationPreferenceModelPanel(model);
    124     f.getContentPane().add(panel);
    125
    126     model.addPropertyChangeListener(
    127       new PropertyChangeListener() {
    128         public void propertyChange(PropertyChangeEvent evt) {
    129           System.out.println(evt);
    130         }
    131       });
    132     panel.setOkCancelActionListener(
    133       new ActionListener() {
    134         public void actionPerformed(ActionEvent e) {
    135           System.exit(1);
    136         }
    137       });
    138
    139     f.setSize(640, 480);
    140     f.setVisible(true);
    141   }
    142
    143   /**
    144    * Ensures this panels DISPLAYED model is in sync with
    145    * the model initially passed to the constructor.
    146    *
    147    */
    148   public void updateModel() {
    149     this.uncommittedPreferenceModel.apply(committedPreferenceModel);
    150   }
    151
    152   /* (non-Javadoc)
    153    * @see org.apache.log4j.chainsaw.AbstractPreferencePanel#createTreeModel()
    154    */
    155   protected TreeModel createTreeModel() {
    156     final DefaultMutableTreeNode rootNode =
    157       new DefaultMutableTreeNode("Preferences");
    158     DefaultTreeModel model = new DefaultTreeModel(rootNode);
    159
    160       generalAllPrefPanel = new GeneralAllPrefPanel();
    161       DefaultMutableTreeNode general =
    162       new DefaultMutableTreeNode(generalAllPrefPanel);
    163
    164     DefaultMutableTreeNode visuals =
    165       new DefaultMutableTreeNode(new VisualsPrefPanel());
    166
    167     rootNode.add(general);
    168     rootNode.add(visuals);
    169
    170     return model;
    171   }
    172
    173     public class VisualsPrefPanel extends BasicPrefPanel {
    174     private final JRadioButton topPlacement = new JRadioButton(" Top         ");
    175     private final JRadioButton bottomPlacement = new JRadioButton(" Bottom         ");
    176     private final JCheckBox statusBar = new JCheckBox(" Show Status bar ");
    177     private final JCheckBox toolBar = new JCheckBox(" Show Toolbar ");
    178     private final JCheckBox receivers = new JCheckBox(" Show Receivers ");
    179     private UIManager.LookAndFeelInfo[] lookAndFeels = UIManager.getInstalledLookAndFeels();
    180     private final ButtonGroup lookAndFeelGroup = new ButtonGroup();
    181
    182     private VisualsPrefPanel() {
    183       super("Visuals");
    184
    185       //Nimbus has major issues with colors in tables..just remove it from the list..
    186       //only use this if nimbus was found..
    187       UIManager.LookAndFeelInfo[] newLookAndFeels = new UIManager.LookAndFeelInfo[lookAndFeels.length];
    188       boolean useNewLookAndFeels = false;
    189       int j = 0;
    190       for (int i=0;i<lookAndFeels.length;i++) {
    191         if (lookAndFeels[i].getClassName().toLowerCase(Locale.ENGLISH).contains("nimbus")) {
    192             useNewLookAndFeels = true;
    193         } else {
    194             newLookAndFeels[j++] = lookAndFeels[i];
    195         }
    196       }
    197       if (useNewLookAndFeels) {
    198           UIManager.LookAndFeelInfo[] replacedLookAndFeels = new UIManager.LookAndFeelInfo[lookAndFeels.length - 1];
    199           System.arraycopy(newLookAndFeels, 0, replacedLookAndFeels, 0, newLookAndFeels.length - 1);
    200           lookAndFeels = replacedLookAndFeels;
    201       }
    202
    203       setupComponents();
    204       setupListeners();
    205       setupInitialValues();
    206     }
    207
    208     /**
    209      *
    210      */
    211     private void setupListeners() {
    212       topPlacement.addActionListener(
    213         new ActionListener() {
    214           public void actionPerformed(ActionEvent e) {
    215             uncommittedPreferenceModel.setTabPlacement(SwingConstants.TOP);
    216           }
    217         });
    218       bottomPlacement.addActionListener(
    219         new ActionListener() {
    220           public void actionPerformed(ActionEvent e) {
    221             uncommittedPreferenceModel.setTabPlacement(SwingConstants.BOTTOM);
    222           }
    223         });
    224
    225       statusBar.addActionListener(
    226         new ActionListener() {
    227           public void actionPerformed(ActionEvent e) {
    228             uncommittedPreferenceModel.setStatusBar(statusBar.isSelected());
    229           }
    230         });
    231
    232       toolBar.addActionListener(
    233         new ActionListener() {
    234           public void actionPerformed(ActionEvent e) {
    235             uncommittedPreferenceModel.setToolbar(toolBar.isSelected());
    236           }
    237         });
    238
    239       receivers.addActionListener(
    240         new ActionListener() {
    241           public void actionPerformed(ActionEvent e) {
    242             uncommittedPreferenceModel.setReceivers(receivers.isSelected());
    243           }
    244         });
    245
    246       uncommittedPreferenceModel.addPropertyChangeListener(
    247         "tabPlacement",
    248         new PropertyChangeListener() {
    249           public void propertyChange(PropertyChangeEvent evt) {
    250             int value = ((Integer) evt.getNewValue()).intValue();
    251
    252             configureTabPlacement(value);
    253           }
    254         });
    255
    256       uncommittedPreferenceModel.addPropertyChangeListener(
    257         "statusBar",
    258         new PropertyChangeListener() {
    259           public void propertyChange(PropertyChangeEvent evt) {
    260             statusBar.setSelected(
    261               ((Boolean) evt.getNewValue()).booleanValue());
    262           }
    263         });
    264
    265       uncommittedPreferenceModel.addPropertyChangeListener(
    266         "toolbar",
    267         new PropertyChangeListener() {
    268           public void propertyChange(PropertyChangeEvent evt) {
    269             toolBar.setSelected(((Boolean) evt.getNewValue()).booleanValue());
    270           }
    271         });
    272
    273       uncommittedPreferenceModel.addPropertyChangeListener(
    274         "receivers",
    275         new PropertyChangeListener() {
    276           public void propertyChange(PropertyChangeEvent evt) {
    277             receivers.setSelected(
    278               ((Boolean) evt.getNewValue()).booleanValue());
    279           }
    280         });
    281
    282       uncommittedPreferenceModel.addPropertyChangeListener(
    283         "lookAndFeelClassName",
    284         new PropertyChangeListener() {
    285           public void propertyChange(PropertyChangeEvent evt) {
    286             String lf = evt.getNewValue().toString();
    287
    288             Enumeration enumeration = lookAndFeelGroup.getElements();
    289
    290             while (enumeration.hasMoreElements()) {
    291               JRadioButton button = (JRadioButton) enumeration.nextElement();
    292
    293               if (button.getName()!=null && button.getName().equals(lf)) {
    294                 button.setSelected(true);
    295
    296                 break;
    297               }
    298             }
    299           }
    300         });
    301     }
    302
    303     /**
    304      *
    305      */
    306     private void setupComponents() {
    307       setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    308
    309       JPanel tabPlacementBox = new JPanel();
    310       tabPlacementBox.setLayout(new BoxLayout(tabPlacementBox, BoxLayout.Y_AXIS));
    311
    312       tabPlacementBox.setBorder(BorderFactory.createTitledBorder(" Tab Placement "));
    313
    314       ButtonGroup tabPlacementGroup = new ButtonGroup();
    315
    316       tabPlacementGroup.add(topPlacement);
    317       tabPlacementGroup.add(bottomPlacement);
    318
    319       tabPlacementBox.add(topPlacement);
    320       tabPlacementBox.add(bottomPlacement);
    321
    322       /**
    323        * If we're OSX, we're 'not allowed' to change the tab placement...
    324        */
    325       if(OSXIntegration.IS_OSX) {
    326           tabPlacementBox.setEnabled(false);
    327           topPlacement.setEnabled(false);
    328           bottomPlacement.setEnabled(false);
    329       }
    330
    331       add(tabPlacementBox);
    332       add(statusBar);
    333       add(receivers);
    334       add(toolBar);
    335
    336       JPanel lfPanel = new JPanel();
    337       lfPanel.setLayout(new BoxLayout(lfPanel, BoxLayout.Y_AXIS));
    338       lfPanel.setBorder(BorderFactory.createTitledBorder(" Look & Feel "));
    339
    340       for (int i = 0; i < lookAndFeels.length; i++) {
    341         final UIManager.LookAndFeelInfo lfInfo = lookAndFeels[i];
    342         final JRadioButton lfItem = new JRadioButton(" " + lfInfo.getName() + " ");
    343         lfItem.setName(lfInfo.getClassName());
    344         lfItem.addActionListener(
    345           new ActionListener() {
    346             public void actionPerformed(ActionEvent e) {
    347               uncommittedPreferenceModel.setLookAndFeelClassName(
    348                 lfInfo.getClassName());
    349             }
    350           });
    351         lookAndFeelGroup.add(lfItem);
    352         lfPanel.add(lfItem);
    353       }
    354
    355       try {
    356         final Class gtkLF =
    357           Class.forName("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
    358         final JRadioButton lfIGTK = new JRadioButton(" GTK+ 2.0 ");
    359         lfIGTK.addActionListener(
    360           new ActionListener() {
    361             public void actionPerformed(ActionEvent e) {
    362               uncommittedPreferenceModel.setLookAndFeelClassName(
    363                 gtkLF.getName());
    364             }
    365           });
    366         lookAndFeelGroup.add(lfIGTK);
    367         lfPanel.add(lfIGTK);
    368       } catch (Exception e) {
    369         logger.debug("Can't find new GTK L&F, might be Windows, or <JDK1.4.2");
    370       }
    371
    372       add(lfPanel);
    373
    374       add(
    375         new JLabel(
    376           "<html>Look and Feel change will apply the next time you start Chainsaw.<br>" +
    377           "If this value is not set, the default L&F of your system is used.</html>"));
    378     }
    379     private void configureTabPlacement(int value) {
    380         switch (value) {
    381         case SwingConstants.TOP:
    382           topPlacement.setSelected(true);
    383
    384           break;
    385
    386         case SwingConstants.BOTTOM:
    387           bottomPlacement.setSelected(true);
    388
    389           break;
    390
    391         default:
    392           break;
    393         }
    394     }
    395     private void setupInitialValues() {
    396         statusBar.setSelected(uncommittedPreferenceModel.isStatusBar());
    397         receivers.setSelected(uncommittedPreferenceModel.isReceivers());
    398         toolBar.setSelected(uncommittedPreferenceModel.isToolbar());
    399         configureTabPlacement(uncommittedPreferenceModel.getTabPlacement());
    400         Enumeration e = lookAndFeelGroup.getElements();
    401         while(e.hasMoreElements()) {
    402             JRadioButton radioButton = (JRadioButton)e.nextElement();
    403             if(radioButton.getText().equals(uncommittedPreferenceModel.getLookAndFeelClassName())) {
    404                 radioButton.setSelected(true);
    405                 break;
    406             }
    407         }
    408     }
    409   }
    410
    411   /**
    412    * @author psmith
    413    *
    414    */
    415   public class GeneralAllPrefPanel extends BasicPrefPanel {
    416     private final JCheckBox showNoReceiverWarning =
    417       new JCheckBox(" Prompt me on startup if there are no Receivers defined ");
    418     private final JCheckBox showSplash = new JCheckBox(" Show Splash screen at startup ");
    419     private final JSlider responsiveSlider =
    420       new JSlider(SwingConstants.HORIZONTAL, 1, 4, 2);
    421     private final JCheckBox confirmExit = new JCheckBox(" Confirm Exit ");
    422     Dictionary sliderLabelMap = new Hashtable();
    423
    424     private final JCheckBox okToRemoveSecurityManager = new JCheckBox(" Ok to remove SecurityManager ");
    425
    426     public GeneralAllPrefPanel() {
    427       super("General");
    428
    429       GeneralAllPrefPanel.this.initComponents();
    430     }
    431
    432     private void initComponents() {
    433       setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    434
    435       configurationURL = new JComboBox(new DefaultComboBoxModel(committedPreferenceModel.getConfigurationURLs()));
    436       configurationURL.setEditable(true);
    437       configurationURL.setPrototypeDisplayValue("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
    438       configurationURL.setPreferredSize(new Dimension(375, 13));
    439
    440       identifierExpression = new JTextField(30);
    441       toolTipDisplayMillis = new JTextField(8);
    442       cyclicBufferSize = new JTextField(8);
    443       Box p = new Box(BoxLayout.X_AXIS);
    444
    445       p.add(showNoReceiverWarning);
    446       p.add(Box.createHorizontalGlue());
    447
    448       confirmExit.setToolTipText("If set, you prompt to confirm Chainsaw exit");
    449       okToRemoveSecurityManager.setToolTipText("You will need to tick this to be able to load Receivers/Plugins that require external dependancies.");
    450       setupInitialValues();
    451       setupListeners();
    452
    453       initSliderComponent();
    454       add(responsiveSlider);
    455
    456       JPanel p1 = new JPanel(new FlowLayout(FlowLayout.LEFT));
    457
    458       p1.add(new JLabel(" Tab name/event routing expression "));
    459       p1.add(Box.createHorizontalStrut(5));
    460       p1.add(identifierExpression);
    461       add(p1);
    462       add(p);
    463
    464       Box p2 = new Box(BoxLayout.X_AXIS);
    465       p2.add(confirmExit);
    466       p2.add(Box.createHorizontalGlue());
    467
    468       Box p3 = new Box(BoxLayout.X_AXIS);
    469       p3.add(showSplash);
    470       p3.add(Box.createHorizontalGlue());
    471
    472       Box ok4 = new Box(BoxLayout.X_AXIS);
    473       ok4.add(okToRemoveSecurityManager);
    474       ok4.add(Box.createHorizontalGlue());
    475
    476       add(p2);
    477       add(p3);
    478       add(ok4);
    479
    480       JPanel p4 = new JPanel(new FlowLayout(FlowLayout.LEFT));
    481
    482       p4.add(new JLabel(" ToolTip Display (millis) "));
    483       p4.add(Box.createHorizontalStrut(5));
    484       p4.add(toolTipDisplayMillis);
    485       add(p4);
    486
    487       JPanel p5 = new JPanel(new FlowLayout(FlowLayout.LEFT));
    488
    489       p5.add(new JLabel(" Cyclic buffer size "));
    490       p5.add(Box.createHorizontalStrut(5));
    491       p5.add(cyclicBufferSize);
    492       p5.add(Box.createHorizontalStrut(5));
    493       p5.add(new JLabel(" (effective on restart) "));
    494       add(p5);
    495
    496       Box p6 = new Box(BoxLayout.Y_AXIS);
    497
    498       Box configURLPanel = new Box(BoxLayout.X_AXIS);
    499       JLabel configLabel = new JLabel(" Auto Config URL ");
    500       configURLPanel.add(configLabel);
    501       configURLPanel.add(Box.createHorizontalStrut(5));
    502
    503       configURLPanel.add(configurationURL);
    504       configURLPanel.add(Box.createHorizontalGlue());
    505
    506       p6.add(configURLPanel);
    507
    508       JButton browseButton = new JButton(" Open File... ");
    509       browseButton.addActionListener(new ActionListener()
    510       {
    511           public void actionPerformed(ActionEvent e)
    512           {
    513               browseForConfiguration();
    514           }
    515       });
    516       Box browsePanel = new Box(BoxLayout.X_AXIS);
    517       browsePanel.add(Box.createHorizontalGlue());
    518       browsePanel.add(browseButton);
    519       p6.add(Box.createVerticalStrut(5));
    520       p6.add(browsePanel);
    521       p6.add(Box.createVerticalGlue());
    522       add(p6);
    523
    524       configurationURL.setToolTipText("A complete and valid URL identifying the location of a valid log4 xml configuration file to auto-configure Receivers and other Plugins");
    525       configurationURL.setInputVerifier(new InputVerifier() {
    526
    527         public boolean verify(JComponent input)
    528         {
    529             try {
    530                 String selectedItem = (String)configurationURL.getSelectedItem();
    531                 if (selectedItem != null && !(selectedItem.trim().equals(""))) {
    532                     new URL(selectedItem);
    533                 }
    534             } catch (Exception e) {
    535                 return false;
    536             }
    537             return true;
    538         }});
    539         String configToDisplay = committedPreferenceModel.getBypassConfigurationURL() != null?committedPreferenceModel.getBypassConfigurationURL():committedPreferenceModel.getConfigurationURL();
    540         configurationURL.setSelectedItem(configToDisplay);
    541     }
    542
    543     public void browseForConfiguration() {
    544           String defaultPath = ".";
    545           if (configurationURL.getItemCount() > 0) {
    546               Object selectedItem = configurationURL.getSelectedItem();
    547               if (selectedItem != null) {
    548                   File currentConfigurationPath = new File(selectedItem.toString()).getParentFile();
    549                   if (currentConfigurationPath != null) {
    550                       defaultPath = currentConfigurationPath.getPath();
    551                       //FileDialog will not navigate to this location unless we remove the prefixing protocol and slash
    552                       //at least on winxp
    553                       if (defaultPath.toLowerCase(Locale.ENGLISH).startsWith("file:\\")) {
    554                           defaultPath = defaultPath.substring("file:\\".length());
    555                       }
    556                   }
    557               }
    558           }
    559       File selectedFile = SwingHelper.promptForFile(this, defaultPath, "Select a Chainsaw configuration file", true);
    560       if (selectedFile != null) {
    561               try
    562               {
    563                   String newConfigurationFile = selectedFile.toURI().toURL().toExternalForm();
    564                   if (!committedPreferenceModel.getConfigurationURLs().contains(newConfigurationFile)) {
    565                     configurationURL.addItem(newConfigurationFile);
    566                   }
    567                   configurationURL.setSelectedItem(newConfigurationFile);
    568               }
    569               catch (MalformedURLException e1)
    570               {
    571                   e1.printStackTrace();
    572               }
    573           }
    574       }
    575
    576       private void initSliderComponent() {
    577       responsiveSlider.setToolTipText(
    578         "Adjust to set the responsiveness of the app.  How often the view is updated.");
    579       responsiveSlider.setSnapToTicks(true);
    580       responsiveSlider.setLabelTable(sliderLabelMap);
    581       responsiveSlider.setPaintLabels(true);
    582       responsiveSlider.setPaintTrack(true);
    583
    584       responsiveSlider.setBorder(BorderFactory.createTitledBorder(" Responsiveness "));
    585
    586       //            responsiveSlider.setAlignmentY(0);
    587       //            responsiveSlider.setAlignmentX(0);
    588     }
    589
    590     private void setupListeners() {
    591       uncommittedPreferenceModel.addPropertyChangeListener(
    592         "showNoReceiverWarning",
    593         new PropertyChangeListener() {
    594           public void propertyChange(PropertyChangeEvent evt) {
    595             showNoReceiverWarning.setSelected(
    596               ((Boolean) evt.getNewValue()).booleanValue());
    597           }
    598         });
    599
    600       uncommittedPreferenceModel.addPropertyChangeListener("showSplash", new PropertyChangeListener() {
    601
    602         public void propertyChange(PropertyChangeEvent evt) {
    603           boolean value = ((Boolean)evt.getNewValue()).booleanValue();
    604           showSplash.setSelected(value);
    605         }});
    606
    607       uncommittedPreferenceModel.addPropertyChangeListener("okToRemoveSecurityManager", new PropertyChangeListener() {
    608
    609 		public void propertyChange(PropertyChangeEvent evt) {
    610             boolean newValue = ((Boolean) evt.getNewValue()).booleanValue();
    611             if(newValue) {
    612             okToRemoveSecurityManager.setSelected(newValue);
    613             }else {
    614                 okToRemoveSecurityManager.setSelected(false);
    615             }
    616
    617 		}});
    618
    619
    620       uncommittedPreferenceModel.addPropertyChangeListener(
    621         "identifierExpression",
    622         new PropertyChangeListener() {
    623           public void propertyChange(PropertyChangeEvent evt) {
    624             identifierExpression.setText(evt.getNewValue().toString());
    625           }
    626         });
    627
    628       uncommittedPreferenceModel.addPropertyChangeListener(
    629         "responsiveness",
    630         new PropertyChangeListener() {
    631           public void propertyChange(PropertyChangeEvent evt) {
    632             int value = ((Integer) evt.getNewValue()).intValue();
    633
    634             if (value >= 1000) {
    635               int newValue = (value - 750) / 1000;
    636               logger.debug(
    637                 "Adjusting old Responsiveness value from " + value + " to "
    638                 + newValue);
    639               value = newValue;
    640             }
    641
    642             responsiveSlider.setValue(value);
    643           }
    644         });
    645
    646         uncommittedPreferenceModel.addPropertyChangeListener(
    647           "toolTipDisplayMillis",
    648           new PropertyChangeListener() {
    649             public void propertyChange(PropertyChangeEvent evt) {
    650               toolTipDisplayMillis.setText(evt.getNewValue().toString());
    651             }
    652           });
    653
    654         uncommittedPreferenceModel.addPropertyChangeListener(
    655           "cyclicBufferSize",
    656           new PropertyChangeListener() {
    657             public void propertyChange(PropertyChangeEvent evt) {
    658               cyclicBufferSize.setText(evt.getNewValue().toString());
    659             }
    660           });
    661
    662       showNoReceiverWarning.addActionListener(
    663         new ActionListener() {
    664           public void actionPerformed(ActionEvent e) {
    665             uncommittedPreferenceModel.setShowNoReceiverWarning(
    666               showNoReceiverWarning.isSelected());
    667           }
    668         });
    669
    670       showSplash.addActionListener(new ActionListener() {
    671
    672         public void actionPerformed(ActionEvent e) {
    673           uncommittedPreferenceModel.setShowSplash(showSplash.isSelected());
    674         }});
    675
    676       okToRemoveSecurityManager.addActionListener(new ActionListener() {
    677
    678         public void actionPerformed(ActionEvent e) {
    679
    680           if(okToRemoveSecurityManager.isSelected() && JOptionPane.showConfirmDialog(okToRemoveSecurityManager, "By ticking this option, you are authorizing Chainsaw to remove Java's Security Manager.\n\n" +
    681                     "This is required under Java Web Start so that it can access Jars/classes locally.  Without this, Receivers like JMSReceiver + DBReceiver that require" +
    682                     " specific driver jars will NOT be able to be run.  \n\n" +
    683                     "By ticking this, you are saying that this is ok.", "Please Confirm", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
    684           	uncommittedPreferenceModel.setOkToRemoveSecurityManager(true);
    685           }else {
    686             uncommittedPreferenceModel.setOkToRemoveSecurityManager(false);
    687           }
    688
    689         }});
    690
    691
    692       responsiveSlider.getModel().addChangeListener(
    693         new ChangeListener() {
    694           public void stateChanged(ChangeEvent e) {
    695             if (responsiveSlider.getValueIsAdjusting()) {
    696               /**
    697                * We'll wait until it stops.
    698                */
    699             } else {
    700               int value = responsiveSlider.getValue();
    701
    702               if (value == 0) {
    703                 value = 1;
    704               }
    705
    706               logger.debug("Adjust responsiveness to " + value);
    707               uncommittedPreferenceModel.setResponsiveness(value);
    708             }
    709           }
    710         });
    711
    712       uncommittedPreferenceModel.addPropertyChangeListener(
    713         "confirmExit",
    714         new PropertyChangeListener() {
    715           public void propertyChange(PropertyChangeEvent evt) {
    716             boolean value = ((Boolean) evt.getNewValue()).booleanValue();
    717             confirmExit.setSelected(value);
    718           }
    719         });
    720
    721       uncommittedPreferenceModel.addPropertyChangeListener("configurationURL", new PropertyChangeListener() {
    722
    723           public void propertyChange(PropertyChangeEvent evt) {
    724             String value = evt.getNewValue().toString();
    725             configurationURL.setSelectedItem(value);
    726           }});
    727       confirmExit.addActionListener(
    728         new ActionListener() {
    729           public void actionPerformed(ActionEvent e) {
    730             uncommittedPreferenceModel.setConfirmExit(
    731               confirmExit.isSelected());
    732           }
    733         });
    734     }
    735
    736     private void setupInitialValues() {
    737       sliderLabelMap.put(new Integer(1), new JLabel(" Fastest "));
    738       sliderLabelMap.put(new Integer(2), new JLabel(" Fast "));
    739       sliderLabelMap.put(new Integer(3), new JLabel(" Medium "));
    740       sliderLabelMap.put(new Integer(4), new JLabel(" Slow "));
    741
    742       //
    743       showNoReceiverWarning.setSelected(
    744         uncommittedPreferenceModel.isShowNoReceiverWarning());
    745       identifierExpression.setText(
    746         uncommittedPreferenceModel.getIdentifierExpression());
    747
    748       confirmExit.setSelected(uncommittedPreferenceModel.isConfirmExit());
    749       okToRemoveSecurityManager.setSelected(uncommittedPreferenceModel.isOkToRemoveSecurityManager());
    750       showNoReceiverWarning.setSelected(uncommittedPreferenceModel.isShowNoReceiverWarning());
    751       showSplash.setSelected(uncommittedPreferenceModel.isShowSplash());
    752       identifierExpression.setText(uncommittedPreferenceModel.getIdentifierExpression());
    753       toolTipDisplayMillis.setText(uncommittedPreferenceModel.getToolTipDisplayMillis()+"");
    754       cyclicBufferSize.setText(uncommittedPreferenceModel.getCyclicBufferSize() + "");
    755       configurationURL.setSelectedItem(uncommittedPreferenceModel.getConfigurationURL());
    756     }
    757   }
    758 }