Viewing Issue Advanced Details

ID 0001279 Category [DMDirc] User Interface - Preferences Dialog Severity minor
Reproducibility N/A Date Submitted 2008-05-27 14:59 Last Update 2010-03-06 20:29
Reporter Greboid Assigned To Demented-Idiot View Status public
Priority normal Status resolved Resolution fixed
Platform Fixed in Version Target Version 0.6.4
Product Version Product Build
Summary 0001279: Preferences dialog needs a file browse component
Description
would be good to have a file browsing component for the prefs dialog.
Needs unit test no
Upstream Bug URL

Relationships

blocks 0003754resolvedDemented-Idiot file path settings in prefs dialog should use new FileBrowser component 

Notes

authorChris Smith <chris@dmdirc.com>2008-05-31 14:08:16 (GMT)
commitd4b0319535ff40c29b318f5d3e38e9c556c23817 (patch) (side-by-side diff)
Updates now store UpdateComponents.
Fixes "Unknown" being displayed on restart-requiring components Fixes issue 1279 git-svn-id: http://svn.dmdirc.com/trunk@4134 00569f92-eb28-0410-84fd-f71c24880f43
-rw-r--r--src/com/dmdirc/ui/swing/dialogs/updater/UpdateTableModel.java8
-rw-r--r--src/com/dmdirc/updater/Update.java19
2 files changed, 6 insertions, 21 deletions
Click to Expand/Collapse
diff src/com/dmdirc/ui/swing/dialogs/updater/UpdateTableModel.java
@@ -152,13 +152,7 @@ public class UpdateTableModel extends AbstractTableModel implements UpdateListen
case 0:
return enabled.get(updates.get(rowIndex));
case 1:
- if (UpdateChecker.findComponent(updates.get(rowIndex).
- getComponent()) == null) {
- return "Unknown";
- } else {
- return UpdateChecker.findComponent(updates.get(rowIndex).
- getComponent());
- }
+ return updates.get(rowIndex).getComponent();
case 2:
return updates.get(rowIndex).getRemoteVersion();
case 3:
Click to Expand/Collapse
diff src/com/dmdirc/updater/Update.java
@@ -40,11 +40,7 @@ import java.util.List;
public final class Update implements DownloadListener {
/** Update component. */
- private final String component;
- /** Channel name. */
- private final String channel;
- /** Remote version number. */
- private final String versionID;
+ private final UpdateComponent component;
/** Remote version name. */
private final String versionName;
/** Update url. */
@@ -69,15 +65,11 @@ public final class Update implements DownloadListener {
final String[] parts = updateInfo.split(" ");
if (parts.length == 6) {
- component = parts[1];
- channel = parts[2];
- versionID = parts[3];
+ component = UpdateChecker.findComponent(parts[1]);
versionName = parts[4];
url = parts[5];
} else {
component = null;
- channel = null;
- versionID = null;
versionName = null;
url = null;
@@ -92,7 +84,7 @@ public final class Update implements DownloadListener {
*
* @return The component of this update
*/
- public String getComponent() {
+ public UpdateComponent getComponent() {
return component;
}
@@ -183,12 +175,11 @@ public final class Update implements DownloadListener {
setStatus(UpdateStatus.INSTALLING);
try {
- final boolean restart = UpdateChecker.findComponent(getComponent())
- .doInstall(path);
+ final boolean restart = getComponent().doInstall(path);
if (restart) {
setStatus(UpdateStatus.RESTART_NEEDED);
- UpdateChecker.removeComponent(getComponent());
+ UpdateChecker.removeComponent(getComponent().getName());
} else {
setStatus(UpdateStatus.INSTALLED);
}

This commit was included in build DMDIRC-REPORTS-94. The build succeeded after 9 minutes (finished on 31-May-2008 at 16:13:02).

This commit was included in build DMDIRC-TRUNK-178. The build failed after 2 minutes (finished on 31-May-2008 at 15:11:17).

(0002631)
MD87 (administrator)
2008-05-31 15:10

Yay for typoing issue numbers

A patchset (1) related to this change has been added to gerrit by Simon Mott

Add FileBrowser to PreferencesType enum Related to issue 1279

A patchset (1) related to this change has been added to gerrit by Simon Mott

Add FileBrowser component to PrefsComponentFactory Fixes issue 1279

A patchset (2) related to this change has been added to gerrit by Simon Mott

Add FileBrowser to PreferencesType enum Related to issue 1279

Change-Id: I5feb28c328a5cd07f9e95647976cb5777ba047f4

A patchset (2) related to this change has been added to gerrit by Simon Mott

Add FileBrowser component to PrefsComponentFactory Fixes issue 1279

Change-Id: I5a0241e72db64a39b571fb76d2eee96b8a017ed1

A patchset (3) related to this change has been added to gerrit by Simon Mott

Add FileBrowser to PreferencesType enum Related to issue 1279

Change-Id: I5feb28c328a5cd07f9e95647976cb5777ba047f4

A patchset (3) related to this change has been added to gerrit by Simon Mott

Add FileBrowser component to PrefsComponentFactory Fixes issue 1279

Change-Id: I5a0241e72db64a39b571fb76d2eee96b8a017ed1
authorSimon Mott <simon@dmdirc.com>2010-02-08 21:08:43 (GMT)
committer Gregory Holmes <greg@dmdirc.com>2010-03-06 20:14:15 (GMT)
commitb667c29739a1544597f48faa5e967c5b22d38b72 (patch) (side-by-side diff)
Add FileBrowser to PreferencesType enum
Related to issue 1279 Change-Id: I5feb28c328a5cd07f9e95647976cb5777ba047f4 Reviewed-on: http://gerrit.dmdirc.com/868 Automatic-Compile: DMDirc Local Commits <dmdirc@googlemail.com> Reviewed-by: Gregory Holmes <greg@dmdirc.com>
-rw-r--r--src/com/dmdirc/config/prefs/PreferencesType.java13
1 files changed, 9 insertions, 4 deletions
Click to Expand/Collapse
diff src/com/dmdirc/config/prefs/PreferencesType.java
@@ -23,11 +23,11 @@ package com.dmdirc.config.prefs;
/**
* Enumerates the possible types of preferences.
- *
+ *
* @author chris
*/
public enum PreferencesType {
-
+
/** A free-form text preference. */
TEXT,
/** A free-form integer preference. */
@@ -45,6 +45,11 @@ public enum PreferencesType {
/** A duration specified in milliseconds. */
DURATION,
/** Font type. */
- FONT;
-
+ FONT,
+ /** File-Only browse component */
+ FILE,
+ /** Directory-Only browse component */
+ DIRECTORY,
+ /** File or Directory browse component */
+ FILES_AND_DIRECTORIES;
}
authorSimon Mott <simon@dmdirc.com>2010-02-08 21:13:11 (GMT)
committer Chris Smith <chris@dmdirc.com>2010-03-06 20:28:22 (GMT)
commit86a9b06e6f1a53007e9d6d6cf417d267e75e8075 (patch) (side-by-side diff)
Add FileBrowser component to PrefsComponentFactory
Fixes issue 1279 Change-Id: I5a0241e72db64a39b571fb76d2eee96b8a017ed1 Reviewed-on: http://gerrit.dmdirc.com/869 Reviewed-by: Gregory Holmes <greg@dmdirc.com> Automatic-Compile: DMDirc Local Commits <dmdirc@googlemail.com>
-rw-r--r--src/com/dmdirc/addons/ui_swing/PrefsComponentFactory.java62
-rw-r--r--src/com/dmdirc/addons/ui_swing/components/FileBrowser.java137
2 files changed, 189 insertions, 10 deletions
Click to Expand/Collapse
diff src/com/dmdirc/addons/ui_swing/PrefsComponentFactory.java
@@ -22,6 +22,7 @@
package com.dmdirc.addons.ui_swing;
+import com.dmdirc.addons.ui_swing.components.FileBrowser;
import com.dmdirc.config.prefs.PreferencesSetting;
import com.dmdirc.config.prefs.validator.NumericalValidator;
import com.dmdirc.addons.ui_swing.components.colours.ColourChooser;
@@ -46,6 +47,7 @@ import java.util.Map;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JComponent;
+import javax.swing.JFileChooser;
import javax.swing.JSpinner;
import javax.swing.JTextField;
import javax.swing.SpinnerNumberModel;
@@ -105,6 +107,15 @@ public final class PrefsComponentFactory {
case FONT:
option = getFontOption(setting);
break;
+ case FILE:
+ option = getFileBrowseOption(setting, JFileChooser.FILES_ONLY);
+ break;
+ case DIRECTORY:
+ option = getFileBrowseOption(setting, JFileChooser.DIRECTORIES_ONLY);
+ break;
+ case FILES_AND_DIRECTORIES:
+ option = getFileBrowseOption(setting, JFileChooser.FILES_AND_DIRECTORIES);
+ break;
default:
throw new IllegalArgumentException(setting.getType()
+ " is not a valid option type");
@@ -146,7 +157,7 @@ public final class PrefsComponentFactory {
final JCheckBox option = new JCheckBox();
option.setSelected(Boolean.parseBoolean(setting.getValue()));
option.addChangeListener(new ChangeListener() {
-
+
/** {@inheritDoc} */
@Override
public void stateChanged(final ChangeEvent e) {
@@ -176,7 +187,7 @@ public final class PrefsComponentFactory {
}
option.addActionListener(new ActionListener() {
-
+
/** {@inheritDoc} */
@Override
public void actionPerformed(final ActionEvent e) {
@@ -238,7 +249,7 @@ public final class PrefsComponentFactory {
&& !setting.getValue().startsWith("false:");
final String integer = setting.getValue() == null ? "0" : setting.getValue().
substring(1 + setting.getValue().indexOf(':'));
-
+
OptionalJSpinner option;
Validator optionalValidator = setting.getValidator();
Validator numericalValidator = null;
@@ -296,7 +307,7 @@ public final class PrefsComponentFactory {
}
option.addDurationListener(new DurationListener() {
-
+
/** {@inheritDoc} */
@Override
public void durationUpdated(final int newDuration) {
@@ -317,7 +328,7 @@ public final class PrefsComponentFactory {
final ColourChooser option = new ColourChooser(setting.getValue(), true, true);
option.addActionListener(new ActionListener() {
-
+
/** {@inheritDoc} */
@Override
public void actionPerformed(final ActionEvent e) {
@@ -343,7 +354,7 @@ public final class PrefsComponentFactory {
final OptionalColourChooser option = new OptionalColourChooser(colour, state, true, true);
option.addActionListener(new ActionListener() {
-
+
/** {@inheritDoc} */
@Override
public void actionPerformed(final ActionEvent e) {
@@ -355,7 +366,7 @@ public final class PrefsComponentFactory {
return option;
}
-
+
/**
* Initialises and returns an Font Chooser for the specified setting.
*
@@ -366,7 +377,7 @@ public final class PrefsComponentFactory {
final String value = setting.getValue();
final FontPicker option = new FontPicker(value);
-
+
option.addActionListener(new ActionListener() {
/** {@inheritDoc} */
@@ -379,8 +390,39 @@ public final class PrefsComponentFactory {
setting.setValue(null);
}
}
- });
-
+ });
+
+ return option;
+ }
+
+ /**
+ * Initialises and returns a FileBrowser for the specified setting.
+ *
+ * @param setting The setting to create the component for
+ * @param type The type of filechooser we want (Files/Directories/Both)
+ *
+ * @return A JComponent descendent for the specified setting
+ */
+ private static JComponent getFileBrowseOption(final PreferencesSetting setting,
+ final int type) {
+ final FileBrowser option = new FileBrowser(setting, type);
+
+ option.addActionListener(new ActionListener() {
+ /** {@inheritDoc} */
+ @Override
+ public void actionPerformed(final ActionEvent e) {
+ setting.setValue(option.getPath());
+ }
+ });
+
+ option.addKeyListener(new KeyAdapter() {
+ /** {@inheritDoc} */
+ @Override
+ public void keyReleased(final KeyEvent e) {
+ setting.setValue(((JTextField) e.getSource()).getText());
+ }
+ });
+
return option;
}
Click to Expand/Collapse
diff src/com/dmdirc/addons/ui_swing/components/FileBrowser.java
new file mode 100644
@@ -0,0 +1,137 @@
+/*
+ * Copyright (c) 2006-2010 Chris Smith, Shane Mc Cormack, Gregory Holmes,
+ * Simon Mott
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package com.dmdirc.addons.ui_swing.components;
+
+import com.dmdirc.addons.ui_swing.components.validating.ValidatingJTextField;
+import com.dmdirc.config.prefs.PreferencesSetting;
+import com.dmdirc.util.ListenerList;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import java.awt.event.KeyListener;
+import javax.swing.JButton;
+import javax.swing.JFileChooser;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+
+import net.miginfocom.swing.MigLayout;
+
+/**
+ * File browser component.
+ *
+ * @author Simon Mott
+ * @since 0.6.3
+ */
+public class FileBrowser extends JPanel implements ActionListener {
+
+ /**
+ * A version number for this class. It should be changed whenever the class
+ * structure is changed (or anything else that would prevent serialized
+ * objects being unserialized with the new class).
+ */
+ private static final long serialVersionUID = 1;
+
+ /** Browse button. */
+ private JButton browseButton;
+ /** Text field to show path of chosen file. */
+ private ValidatingJTextField pathField;
+ /** File browsing window. */
+ private JFileChooser fileChooser = new JFileChooser();
+ /** Our listeners. */
+ private final ListenerList listeners = new ListenerList();
+
+ /**
+ * Creates a new File Browser.
+ *
+ * @param setting The setting to create the component for
+ * @param type The type of filechooser we want (Files/Directories/Both)
+ */
+ public FileBrowser(final PreferencesSetting setting, final int type) {
+ fileChooser.setFileSelectionMode(type);
+
+ browseButton = new JButton("Browse");
+ browseButton.addActionListener(this);
+
+ pathField = new ValidatingJTextField(new JTextField(setting.getValue()),
+ setting.getValidator());
+
+ setLayout(new MigLayout("ins 0, fill"));
+ add(pathField, "growx, pushx, sgy all");
+ add(browseButton, "sgy all");
+ }
+
+ /**
+ * {@inheritDoc}.
+ *
+ * @param e Action event
+ */
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ fileChooser.showOpenDialog(this);
+
+ if (fileChooser.getSelectedFile() != null) {
+ pathField.setText(fileChooser.getSelectedFile().getAbsolutePath());
+ }
+ fireActionEvent();
+ }
+
+ /**
+ * Adds an action listener to this file browser. Action
+ * listeners are notified whenever the path changes.
+ *
+ * @param l The listener to be added
+ */
+ public void addActionListener(final ActionListener l) {
+ listeners.add(ActionListener.class, l);
+ }
+
+ /**
+ * {@inheritDoc}.
+ *
+ * @param l The listener to be added
+ */
+ @Override
+ public void addKeyListener(final KeyListener l) {
+ pathField.addKeyListener(l);
+ }
+
+ /**
+ * Returns the current path selected by this file browser.
+ *
+ * @return Path selected by this filebrowser
+ */
+ public String getPath() {
+ return pathField.getText();
+ }
+
+ /**
+ * Informs all action listeners that an action has occured.
+ */
+ protected void fireActionEvent() {
+ for (ActionListener listener : listeners.get(ActionListener.class)) {
+ listener.actionPerformed(new ActionEvent(this, 1, getPath()));
+ }
+ }
+}

Issue History

Date Modified Username Field Change
2008-05-27 14:59 Greboid New Issue
2008-05-27 14:59 Greboid Status new => assigned
2008-05-27 14:59 Greboid Assigned To => Greboid
2008-05-28 03:50 MD87 Assigned To Greboid => Dataforce
2008-05-31 15:08 MD87 Checkin
2008-05-31 15:08 MD87 Note Added: 0002630
2008-05-31 15:08 MD87 Status assigned => resolved
2008-05-31 15:08 MD87 Resolution open => fixed
2008-05-31 15:10 MD87 Status resolved => assigned
2008-05-31 15:10 MD87 Resolution fixed => reopened
2008-05-31 15:10 MD87 Note Added: 0002631
2008-07-23 22:00 MD87 Target Version 0.6.3 => 0.7
2010-01-31 02:41 Greboid Needs unit test => no
2010-01-31 02:41 Greboid Assigned To Dataforce => Demented-Idiot
2010-01-31 02:41 Greboid Target Version 0.7 => 0.6.4
2010-02-08 21:12 Version Control Checkin
2010-02-08 21:12 Version Control Note Added: 0009792
2010-02-08 21:13 Version Control Checkin
2010-02-08 21:13 Version Control Note Added: 0009793
2010-02-08 21:13 Version Control Status assigned => fix pending
2010-02-08 21:45 Version Control Checkin
2010-02-08 21:45 Version Control Note Added: 0009796
2010-02-08 21:46 Version Control Checkin
2010-02-08 21:46 Version Control Note Added: 0009797
2010-02-08 22:38 Version Control Checkin
2010-02-08 22:38 Version Control Note Added: 0009798
2010-02-08 22:39 Version Control Checkin
2010-02-08 22:39 Version Control Note Added: 0009799
2010-02-09 00:30 Demented-Idiot Relationship added blocks 0003754
2010-03-06 20:15 Version Control Checkin
2010-03-06 20:15 Version Control Note Added: 0010092
2010-03-06 20:29 Version Control Checkin
2010-03-06 20:29 Version Control Note Added: 0010097
2010-03-06 20:29 Version Control Status fix pending => resolved
2010-03-06 20:29 Version Control Resolution reopened => fixed