Remove code that handled dutch items, old page formats, high bidder email, all bidder names (not available anymore), saving deleted listing ids in the XML file, large swaths of dead and/or obsolete code, and all the DB Time Queue code. Abstracted the XMLElement code out to an interface, which XMLSerialize now uses, avoiding a circular dependency/tangle. Made all my email addresses point to the same address, NOT at SourceForge anymore. by mrs, 06 Aug, 2009 09:21 AM
Diff this changeset:
JConfigFrame.java
mrs      1   package com.jbidwatcher.ui.config;
cyberfox 2   /*
cyberfox 3    * Copyright (c) 2000-2007, CyberFOX Software, Inc. All Rights Reserved.
cyberfox 4    *
cyberfox 5    * Developed by mrs (Morgan Schweers)
cyberfox 6    */
cyberfox 7   
cyberfox 8   import com.jbidwatcher.platform.Platform;
mrs      9   import com.jbidwatcher.util.config.*;
mrs      10  import com.jbidwatcher.util.Constants;
mrs      11  import com.jbidwatcher.ui.util.JBidFrame;
mrs      12  import com.jbidwatcher.ui.util.OptionUI;
cyberfox 13  
cyberfox 14  import java.awt.*;
cyberfox 15  import java.awt.event.ActionEvent;
cyberfox 16  import java.awt.event.ActionListener;
cyberfox 17  import java.awt.event.WindowAdapter;
cyberfox 18  import java.awt.event.WindowEvent;
cyberfox 19  import java.util.List;
cyberfox 20  import java.util.ArrayList;
cyberfox 21  
cyberfox 22  import javax.swing.JButton;
cyberfox 23  import javax.swing.JFrame;
cyberfox 24  import javax.swing.JPanel;
cyberfox 25  import javax.swing.JTabbedPane;
cyberfox 26  import javax.swing.JLabel;
cyberfox 27  
cyberfox 28  /**
cyberfox 29   * Implements the "Configure" frames. This holds all the configuration options.
cyberfox 30   *
cyberfox 31   * @version $Revision: 1.38 $
cyberfox 32   */
cyberfox 33  public class JConfigFrame implements ActionListener {
cyberfox 34    private JFrame mainFrame;
cyberfox 35    private boolean buttonPressed = false;
cyberfox 36    private List<JConfigTab> allTabs;
cyberfox 37    private static int cfgCount = 1;
cyberfox 38  
cyberfox 39    public void spinWait() {
cyberfox 40      while(!buttonPressed) {
cyberfox 41        try { //noinspection MultiplyOrDivideByPowerOfTwo,BusyWait
mrs      42          Thread.sleep(Constants.ONE_SECOND/2);
cyberfox 43        } catch(InterruptedException ignored) {
cyberfox 44          //  We don't care that we caught an exception, just that we woke up.
cyberfox 45        }
cyberfox 46      }
cyberfox 47    }
cyberfox 48  
mrs      49    public JConfigFrame() {
mrs      50      mainFrame = createConfigFrame();
mrs      51      Rectangle rec = OptionUI.findCenterBounds(mainFrame.getPreferredSize());
cyberfox 52      mainFrame.setLocation(rec.x, rec.y);
cyberfox 53      show();
cyberfox 54    }
cyberfox 55  
cyberfox 56    public final void show() {
cyberfox 57      for (JConfigTab jct : allTabs) {
cyberfox 58        jct.updateValues();
cyberfox 59      }
cyberfox 60      mainFrame.setState(Frame.NORMAL);
cyberfox 61      mainFrame.setVisible(true);
cyberfox 62    }
cyberfox 63  
cyberfox 64    private void applyAll() {
cyberfox 65      for (JConfigTab jct : allTabs) {
cyberfox 66        jct.apply();
cyberfox 67      }
cyberfox 68    }
cyberfox 69  
cyberfox 70    private void cancelAll() {
cyberfox 71      for (JConfigTab jct : allTabs) {
cyberfox 72        jct.cancel();
cyberfox 73      }
cyberfox 74    }
cyberfox 75  
cyberfox 76    public void actionPerformed(ActionEvent ae) {
cyberfox 77      String actionString = ae.getActionCommand();
cyberfox 78  
cyberfox 79      if(actionString.equals("Save")) {
cyberfox 80        applyAll();
cyberfox 81        JConfig.updateComplete();
cyberfox 82        JConfig.saveConfiguration();
cyberfox 83      } else if(actionString.equals("Cancel")) {
cyberfox 84        cancelAll();
cyberfox 85      }
cyberfox 86  
cyberfox 87      mainFrame.setVisible(false);
cyberfox 88      buttonPressed = true;
cyberfox 89    }
cyberfox 90  
cyberfox 91    public static JPanel buildButtonPane(ActionListener al) {
cyberfox 92      JPanel tp = new JPanel();
cyberfox 93  
cyberfox 94      JButton cancelButton = new JButton("Cancel");
cyberfox 95      cancelButton.setToolTipText("Cancel any changes made.");
cyberfox 96      JButton saveButton = new JButton("Save");
cyberfox 97      saveButton.setToolTipText("Apply changes and save settings.");
cyberfox 98  
cyberfox 99      tp.add(cancelButton, BorderLayout.WEST);
cyberfox 100     tp.add(  saveButton, BorderLayout.CENTER);
cyberfox 101 
cyberfox 102     cancelButton.addActionListener(al);
cyberfox 103     saveButton.addActionListener(al);
cyberfox 104 
cyberfox 105     return(tp);
cyberfox 106   }
cyberfox 107 
cyberfox 108   private static void anotherConfig() {
cyberfox 109     cfgCount++;
cyberfox 110   }
cyberfox 111 
mrs      112   private JFrame createConfigFrame() {
cyberfox 113     JTabbedPane jtpAllTabs = new JTabbedPane();
cyberfox 114     final JFrame w;
cyberfox 115 
cyberfox 116     if(cfgCount == 2) {
mrs      117       w = new JBidFrame("Configuration Manager (2)");
cyberfox 118     } else {
cyberfox 119       anotherConfig();
mrs      120       w = new JBidFrame("Configuration Manager");
cyberfox 121     }
cyberfox 122 
cyberfox 123     Container contentPane = w.getContentPane();
cyberfox 124     contentPane.setLayout(new BorderLayout());
cyberfox 125     contentPane.add(jtpAllTabs, BorderLayout.CENTER);
cyberfox 126 
cyberfox 127     allTabs = new ArrayList<JConfigTab>();
cyberfox 128 
cyberfox 129     //  Add all non-server-specific tabs here.
cyberfox 130     allTabs.add(new JConfigGeneralTab());
mrs      131     allTabs.add(new JConfigEbayTab());
cyberfox 132 
cyberfox 133     //  Stub the browser tab under MacOSX, so they don't try to use it.
cyberfox 134     if(Platform.isMac()) {
cyberfox 135       allTabs.add(new JConfigMacBrowserTab());
cyberfox 136     } else {
cyberfox 137       allTabs.add(new JConfigBrowserTab());
cyberfox 138     }
mrs      139     allTabs.add(new JConfigFirewallTab());
cyberfox 140     allTabs.add(new JConfigSnipeTab());
mrs      141 //    if(JConfig.queryConfiguration("allow.my_jbidwatcher", "false").equals("true"))
mrs      142       allTabs.add(new JConfigMyJBidwatcherTab());
mrs      143     allTabs.add(new JConfigFilePathTab());
cyberfox 144     allTabs.add(new JConfigWebserverTab());
mrs      145     allTabs.add(new JConfigDatabaseTab());
cyberfox 146 
cyberfox 147     allTabs.add(new JConfigSecurityTab());
mrs      148     allTabs.add(new JConfigAdvancedTab());
cyberfox 149 
cyberfox 150     //  HACKHACK -- Presently all tabs created need to have 3 rows of
cyberfox 151     //  GridLayout.  In general, all tabs have to have the same number
cyberfox 152     //  of rows.  This is likely to suck, in the long run.  For now,
cyberfox 153     //  it's the requirement.  If you have more or less, the display
cyberfox 154     //  either for that tab (if it has less), or for all the others
cyberfox 155     //  (if it has more) will look somewhat wonky.
cyberfox 156 
cyberfox 157     //  Loop over all tabs, and add them to the display.
cyberfox 158     for (JConfigTab allTab : allTabs) {
cyberfox 159       allTab.setOpaque(true);
cyberfox 160       jtpAllTabs.addTab(allTab.getTabName(), allTab);
cyberfox 161     }
cyberfox 162 
cyberfox 163     jtpAllTabs.setSelectedIndex(0);
cyberfox 164     contentPane.add(buildButtonPane(this), BorderLayout.SOUTH);
cyberfox 165 
cyberfox 166     w.addWindowListener(new IconifyingWindowAdapter(w));
cyberfox 167     w.pack();
cyberfox 168     w.setResizable(false);
cyberfox 169     return w;
cyberfox 170   }
cyberfox 171 
cyberfox 172   private class JConfigSecurityTab extends JConfigStubTab {
cyberfox 173     public String getTabName() { return("Security"); }
cyberfox 174   }
cyberfox 175 
cyberfox 176   private final class JConfigMacBrowserTab extends JConfigStubTab {
cyberfox 177     public String getTabName() { return("Browser"); }
cyberfox 178 
cyberfox 179     JConfigMacBrowserTab() {
cyberfox 180       JLabel newLabel = new JLabel("Under MacOSX, the browser does not need to be configured.");
cyberfox 181       setLayout(new BorderLayout());
cyberfox 182       add(newLabel, BorderLayout.CENTER);
cyberfox 183     }
cyberfox 184   }
cyberfox 185 
cyberfox 186   public static class IconifyingWindowAdapter extends WindowAdapter {
cyberfox 187     private final JFrame _window;
cyberfox 188 
cyberfox 189     public IconifyingWindowAdapter(JFrame window) {
cyberfox 190       _window = window;
cyberfox 191     }
cyberfox 192 
cyberfox 193     public void windowIconified(WindowEvent we) {
cyberfox 194       super.windowIconified(we);
mrs      195       if(Platform.supportsTray() && Platform.isTrayEnabled()) {
cyberfox 196         if(JConfig.queryConfiguration("windows.tray", "true").equals("true") &&
cyberfox 197            JConfig.queryConfiguration("windows.minimize", "true").equals("true")) {
cyberfox 198           _window.setVisible(false);
cyberfox 199         }
cyberfox 200       }
cyberfox 201     }
cyberfox 202 
cyberfox 203     public void windowDeiconified(WindowEvent we) {
cyberfox 204       super.windowDeiconified(we);
mrs      205       if(Platform.supportsTray() && Platform.isTrayEnabled()) {
cyberfox 206         if(JConfig.queryConfiguration("windows.tray", "true").equals("true") &&
cyberfox 207            JConfig.queryConfiguration("windows.minimize", "true").equals("true")) {
cyberfox 208           _window.setState(Frame.NORMAL);
cyberfox 209           _window.setVisible(true);
cyberfox 210         }
cyberfox 211       }
cyberfox 212     }
cyberfox 213   }
cyberfox 214 }

Check out the code: svn co jbidwatcher/trunk/src/com/jbidwatcher/ui/config/JConfigFrame.java