You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

StepSettings.java 5.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /*
  2. * Copyright (c) 2006-2011 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. package com.dmdirc.installer.ui;
  23. import com.dmdirc.installer.DefaultSettings;
  24. import com.dmdirc.installer.Main;
  25. import com.dmdirc.installer.Settings;
  26. import com.dmdirc.installer.Installer.ShortcutType;
  27. import java.awt.GridBagConstraints;
  28. import java.awt.GridBagLayout;
  29. import java.awt.Image;
  30. import java.awt.Insets;
  31. import javax.swing.Box;
  32. import javax.swing.JCheckBox;
  33. import javax.swing.JTextField;
  34. /**
  35. * Queries the user for where to install dmdirc, and if they want to setup shortcuts
  36. */
  37. public final class StepSettings extends SwingStep implements Settings {
  38. /**
  39. * A version number for this class. It should be changed whenever the class
  40. * structure is changed (or anything else that would prevent serialized
  41. * objects being unserialized with the new class).
  42. */
  43. private static final long serialVersionUID = 3;
  44. /** Menu Shorcuts checkbox. */
  45. private final JCheckBox shortcutMenu = new JCheckBox("Create " + Main.
  46. getInstaller().getMenuName() + " shortcut");
  47. /** Desktop Shorcuts checkbox. */
  48. private final JCheckBox shortcutDesktop = new JCheckBox(
  49. "Create desktop shortcut");
  50. /** Quick-Launch Shorcuts checkbox. */
  51. private final JCheckBox shortcutQuick = new JCheckBox(
  52. "Create Quick Launch shortcut");
  53. /** Register IRC:// protocol. */
  54. private final JCheckBox shortcutProtocol = new JCheckBox(
  55. "Make DMDirc handle irc:// links");
  56. /** Install Location input. */
  57. private final JTextField location = new JTextField(Main.getInstaller().
  58. defaultInstallLocation(), 20);
  59. /**
  60. * Creates a new instance of StepSettings.
  61. */
  62. public StepSettings() {
  63. super();
  64. final DefaultSettings defaultSettings = new DefaultSettings();
  65. shortcutMenu.setSelected(defaultSettings.getShortcutMenuState());
  66. shortcutDesktop.setSelected(defaultSettings.getShortcutDesktopState());
  67. shortcutQuick.setSelected(defaultSettings.getShortcutQuickState());
  68. shortcutProtocol.setSelected(defaultSettings.getShortcutProtocolState());
  69. final GridBagConstraints constraints = new GridBagConstraints();
  70. setLayout(new GridBagLayout());
  71. constraints.weightx = 1.0;
  72. constraints.fill = GridBagConstraints.BOTH;
  73. constraints.gridx = 0;
  74. constraints.gridy = 0;
  75. constraints.gridwidth = 2;
  76. add(new TextLabel("Here you can choose options for the install."
  77. + "\n\nInstall Location:"), constraints);
  78. constraints.fill = GridBagConstraints.HORIZONTAL;
  79. constraints.gridx = 1;
  80. constraints.gridy = 1;
  81. add(location, constraints);
  82. constraints.gridwidth = 2;
  83. constraints.gridx = 0;
  84. constraints.insets = new Insets(InstallerDialog.SMALL_GAP, 0, 0, 0);
  85. if (Main.getInstaller().supportsShortcut(ShortcutType.MENU)) {
  86. constraints.gridy = (constraints.gridy + 1);
  87. add(shortcutMenu, constraints);
  88. }
  89. if (Main.getInstaller().supportsShortcut(ShortcutType.DESKTOP)) {
  90. constraints.gridy = (constraints.gridy + 1);
  91. add(shortcutDesktop, constraints);
  92. }
  93. if (Main.getInstaller().supportsShortcut(ShortcutType.QUICKLAUNCH)) {
  94. constraints.gridy = (constraints.gridy + 1);
  95. add(shortcutQuick, constraints);
  96. }
  97. if (Main.getInstaller().supportsShortcut(ShortcutType.PROTOCOL)) {
  98. constraints.gridy = (constraints.gridy + 1);
  99. add(shortcutProtocol, constraints);
  100. }
  101. constraints.gridy = (constraints.gridy + 1);
  102. constraints.weighty = 1.0;
  103. constraints.fill = GridBagConstraints.BOTH;
  104. add(Box.createVerticalGlue(), constraints);
  105. }
  106. /** {@inheritDoc} */
  107. @Override
  108. public String getStepName() {
  109. return "Settings";
  110. }
  111. /** {@inheritDoc} */
  112. @Override
  113. public Image getIcon() {
  114. return null;
  115. }
  116. /** {@inheritDoc} */
  117. @Override
  118. public String getStepDescription() {
  119. return "";
  120. }
  121. /** {@inheritDoc} */
  122. @Override
  123. public boolean getShortcutMenuState() {
  124. return shortcutMenu.isSelected();
  125. }
  126. /** {@inheritDoc} */
  127. @Override
  128. public boolean getShortcutDesktopState() {
  129. return shortcutDesktop.isSelected();
  130. }
  131. /** {@inheritDoc} */
  132. @Override
  133. public boolean getShortcutQuickState() {
  134. return shortcutQuick.isSelected();
  135. }
  136. /** {@inheritDoc} */
  137. @Override
  138. public boolean getShortcutProtocolState() {
  139. return shortcutProtocol.isSelected();
  140. }
  141. /** {@inheritDoc} */
  142. @Override
  143. public String getInstallLocation() {
  144. return location.getText().trim();
  145. }
  146. }