File Source: StepSettings.java

         /* 
    P/P   *  Method: com.dmdirc.installer.ui.StepSettings__static_init
          */
     1  /*
     2   * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
     3   *
     4   * Permission is hereby granted, free of charge, to any person obtaining a copy
     5   * of this software and associated documentation files (the "Software"), to deal
     6   * in the Software without restriction, including without limitation the rights
     7   * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
     8   * copies of the Software, and to permit persons to whom the Software is
     9   * furnished to do so, subject to the following conditions:
    10   *
    11   * The above copyright notice and this permission notice shall be included in
    12   * all copies or substantial portions of the Software.
    13   *
    14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    20   * SOFTWARE.
    21   */
    22  
    23  package com.dmdirc.installer.ui;
    24  
    25  import com.dmdirc.installer.Main;
    26  import com.dmdirc.installer.Settings;
    27  import com.dmdirc.installer.DefaultSettings;
    28  import com.dmdirc.installer.Installer.ShortcutType;
    29  
    30  import java.awt.GridBagConstraints;
    31  import java.awt.GridBagLayout;
    32  import java.awt.Image;
    33  import java.awt.Insets;
    34  import javax.swing.Box;
    35  import javax.swing.JCheckBox;
    36  import javax.swing.JTextField;
    37  
    38  /**
    39   * Queries the user for where to install dmdirc, and if they want to setup shortcuts
    40   */
    41  public final class StepSettings extends SwingStep implements Settings {
    42  
    43      /**
    44       * A version number for this class. It should be changed whenever the class
    45       * structure is changed (or anything else that would prevent serialized
    46       * objects being unserialized with the new class).
    47       */
    48      private static final long serialVersionUID = 3;
    49      /** Menu Shorcuts checkbox. */
    50      private final JCheckBox shortcutMenu = new JCheckBox("Create " + Main.
    51              getInstaller().getMenuName() + " shortcut");
    52      /** Desktop Shorcuts checkbox. */
    53      private final JCheckBox shortcutDesktop = new JCheckBox(
    54              "Create desktop shortcut");
    55      /** Quick-Launch Shorcuts checkbox. */
    56      private final JCheckBox shortcutQuick = new JCheckBox(
    57              "Create Quick Launch shortcut");
    58      /** Register IRC:// protocol. */
    59      private final JCheckBox shortcutProtocol = new JCheckBox(
    60              "Make DMDirc handle irc:// links");
    61      /** Install Location input. */
    62      private final JTextField location = new JTextField(Main.getInstaller().
    63              defaultInstallLocation(), 20);
    64  
    65      /**
    66       * Creates a new instance of StepSettings.
    67       */
    68      public StepSettings() {
                 /* 
    P/P           *  Method: void com.dmdirc.installer.ui.StepSettings()
                  * 
                  *  Preconditions:
                  *    init'ed(com/dmdirc/installer/Main.myInstaller)
                  * 
                  *  Presumptions:
                  *    init'ed(com.dmdirc.installer.Installer$ShortcutType.DESKTOP)
                  *    init'ed(com.dmdirc.installer.Installer$ShortcutType.MENU)
                  *    init'ed(com.dmdirc.installer.Installer$ShortcutType.PROTOCOL)
                  *    init'ed(com.dmdirc.installer.Installer$ShortcutType.QUICKLAUNCH)
                  * 
                  *  Postconditions:
                  *    com/dmdirc/installer/Main.myInstaller == One-of{old com/dmdirc/installer/Main.myInstaller, &new WindowsInstaller(getInstaller#1), &new LinuxInstaller(getInstaller#2)}
                  *    com/dmdirc/installer/Main.myInstaller != null
                  *    this.location == &new JTextField(StepSettings#6)
                  *    this.shortcutDesktop == &new JCheckBox(StepSettings#3)
                  *    this.shortcutMenu == &new JCheckBox(StepSettings#1)
                  *    this.shortcutProtocol == &new JCheckBox(StepSettings#5)
                  *    this.shortcutQuick == &new JCheckBox(StepSettings#4)
                  *    new JCheckBox(StepSettings#1) num objects == 1
                  *    new JCheckBox(StepSettings#3) num objects == 1
                  *    new JCheckBox(StepSettings#4) num objects == 1
                  *    ...
                  * 
                  *  Test Vectors:
                  *    com.dmdirc.installer.Installer:supportsShortcut(...)@101: {0}, {1}
                  *    com.dmdirc.installer.Installer:supportsShortcut(...)@105: {0}, {1}
                  *    com.dmdirc.installer.Installer:supportsShortcut(...)@109: {0}, {1}
                  *    com.dmdirc.installer.Installer:supportsShortcut(...)@97: {0}, {1}
                  */
    69          super();
    70  
    71          DefaultSettings defaultSettings = new DefaultSettings();
    72          shortcutMenu.setSelected(defaultSettings.getShortcutMenuState());
    73          shortcutDesktop.setSelected(defaultSettings.getShortcutDesktopState());
    74          shortcutQuick.setSelected(defaultSettings.getShortcutQuickState());
    75          shortcutProtocol.setSelected(defaultSettings.getShortcutProtocolState());
    76  
    77          final GridBagConstraints constraints = new GridBagConstraints();
    78  		setLayout(new GridBagLayout());
    79  
    80          constraints.weightx = 1.0;
    81  		constraints.fill = GridBagConstraints.BOTH;
    82  		constraints.gridx = 0;
    83  		constraints.gridy = 0;
    84  		constraints.gridwidth = 2;
    85          add(new TextLabel("Here you can choose options for the install." +
    86                            "\n\nInstall Location:"), constraints);
    87  
    88          constraints.fill = GridBagConstraints.HORIZONTAL;
    89  		constraints.gridx = 1;
    90          constraints.gridy = 1;
    91          add(location, constraints);
    92  
    93          constraints.gridwidth = 2;
    94  		constraints.gridx = 0;
    95  		constraints.insets = new Insets(InstallerDialog.SMALL_GAP, 0, 0, 0);
    96  
    97          if (Main.getInstaller().supportsShortcut(ShortcutType.MENU)) {
    98              constraints.gridy = (constraints.gridy + 1);
    99              add(shortcutMenu, constraints);
   100          }
   101          if (Main.getInstaller().supportsShortcut(ShortcutType.DESKTOP)) {
   102              constraints.gridy = (constraints.gridy + 1);
   103              add(shortcutDesktop, constraints);
   104          }
   105          if (Main.getInstaller().supportsShortcut(ShortcutType.QUICKLAUNCH)) {
   106              constraints.gridy = (constraints.gridy + 1);
   107              add(shortcutQuick, constraints);
   108          }
   109          if (Main.getInstaller().supportsShortcut(ShortcutType.PROTOCOL)) {
   110              constraints.gridy = (constraints.gridy + 1);
   111              add(shortcutProtocol, constraints);
   112          }
   113  
   114          constraints.gridy = (constraints.gridy + 1);
   115  		constraints.weighty = 1.0;
   116  		constraints.fill = GridBagConstraints.BOTH;
   117          add(Box.createVerticalGlue(), constraints);
   118      }
   119  
   120      /** {@inheritDoc} */
   121      @Override
   122      public String getStepName() {
                 /* 
    P/P           *  Method: String getStepName()
                  * 
                  *  Postconditions:
                  *    return_value == &"Settings"
                  */
   123          return "Settings";
   124      }
   125  
   126      /** {@inheritDoc} */
   127      @Override
   128      public Image getIcon() {
                 /* 
    P/P           *  Method: Image getIcon()
                  * 
                  *  Postconditions:
                  *    return_value == null
                  */
   129          return null;
   130      }
   131  
   132      /** {@inheritDoc} */
   133      @Override
   134      public String getStepDescription() {
                 /* 
    P/P           *  Method: String getStepDescription()
                  * 
                  *  Postconditions:
                  *    return_value == &""
                  */
   135          return "";
   136      }
   137  
   138      /** {@inheritDoc} */
   139      @Override
   140      public boolean getShortcutMenuState() {
                 /* 
    P/P           *  Method: bool getShortcutMenuState()
                  * 
                  *  Preconditions:
                  *    this.shortcutMenu != null
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
   141          return shortcutMenu.isSelected();
   142      }
   143  
   144      /** {@inheritDoc} */
   145      @Override
   146      public boolean getShortcutDesktopState() {
                 /* 
    P/P           *  Method: bool getShortcutDesktopState()
                  * 
                  *  Preconditions:
                  *    this.shortcutDesktop != null
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
   147          return shortcutDesktop.isSelected();
   148      }
   149  
   150      /** {@inheritDoc} */
   151      @Override
   152      public boolean getShortcutQuickState() {
                 /* 
    P/P           *  Method: bool getShortcutQuickState()
                  * 
                  *  Preconditions:
                  *    this.shortcutQuick != null
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
   153          return shortcutQuick.isSelected();
   154      }
   155  
   156      /** {@inheritDoc} */
   157      @Override
   158      public boolean getShortcutProtocolState() {
                 /* 
    P/P           *  Method: bool getShortcutProtocolState()
                  * 
                  *  Preconditions:
                  *    this.shortcutProtocol != null
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
   159          return shortcutProtocol.isSelected();
   160      }
   161  
   162      /** {@inheritDoc} */
   163      @Override
   164      public String getInstallLocation() {
                 /* 
    P/P           *  Method: String getInstallLocation()
                  * 
                  *  Preconditions:
                  *    this.location != null
                  * 
                  *  Presumptions:
                  *    javax.swing.JTextField:getText(...)@165 != null
                  * 
                  *  Postconditions:
                  *    return_value != null
                  */
   165          return location.getText().trim();
   166      }
   167  }








SofCheck Inspector Build Version : 2.17854
StepSettings.java 2009-Jun-25 01:54:24
StepSettings.class 2009-Sep-02 17:04:16