Browse Source

Move serverlist dialog to server list plugin.

Fixes-Issue: CLIENT-238
Change-Id: I4333c2a982b0c6757b4a450441903316500e4065
Reviewed-on: http://gerrit.dmdirc.com/2245
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Shane Mc Cormack <shane@dmdirc.com>
tags/0.7rc1
Greg Holmes 12 years ago
parent
commit
30b3ef4e1b

src/com/dmdirc/addons/ui_swing/dialogs/serverlist/AddEntryInputDialog.java → src/com/dmdirc/addons/serverlistdialog/AddEntryInputDialog.java View File

20
  * SOFTWARE.
20
  * SOFTWARE.
21
  */
21
  */
22
 
22
 
23
-package com.dmdirc.addons.ui_swing.dialogs.serverlist;
23
+package com.dmdirc.addons.serverlistdialog;
24
 
24
 
25
 import com.dmdirc.addons.ui_swing.components.text.TextLabel;
25
 import com.dmdirc.addons.ui_swing.components.text.TextLabel;
26
 import com.dmdirc.addons.ui_swing.components.validating.ValidatingJTextField;
26
 import com.dmdirc.addons.ui_swing.components.validating.ValidatingJTextField;
30
 import com.dmdirc.util.validators.URIValidator;
30
 import com.dmdirc.util.validators.URIValidator;
31
 import com.dmdirc.util.validators.Validator;
31
 import com.dmdirc.util.validators.Validator;
32
 import com.dmdirc.addons.serverlists.ServerGroup;
32
 import com.dmdirc.addons.serverlists.ServerGroup;
33
+import com.dmdirc.addons.ui_swing.SwingController;
33
 
34
 
34
-import com.dmdirc.ui.IconManager;
35
 import java.awt.Window;
35
 import java.awt.Window;
36
-import java.awt.Dialog.ModalityType;
37
 import java.awt.event.ActionEvent;
36
 import java.awt.event.ActionEvent;
38
 import java.awt.event.ActionListener;
37
 import java.awt.event.ActionListener;
39
 import java.awt.event.WindowAdapter;
38
 import java.awt.event.WindowAdapter;
54
  */
53
  */
55
 public class AddEntryInputDialog extends StandardDialog {
54
 public class AddEntryInputDialog extends StandardDialog {
56
 
55
 
57
-    /**
58
-     * A version number for this class. It should be changed whenever the class
59
-     * structure is changed (or anything else that would prevent serialized
60
-     * objects being unserialized with the new class).
61
-     */
56
+    /** Serial version UID. */
62
     private static final long serialVersionUID = 1;
57
     private static final long serialVersionUID = 1;
63
     /** Entry name Validator. */
58
     /** Entry name Validator. */
64
     private final Validator<String> entryValidator;
59
     private final Validator<String> entryValidator;
76
     private final JTree items;
71
     private final JTree items;
77
     /** Parent model. */
72
     /** Parent model. */
78
     private final ServerListModel model;
73
     private final ServerListModel model;
79
-    /** Icon manager. */
80
-    private final IconManager iconManager;
74
+    /** Swing controller. */
75
+    private final SwingController controller;
81
 
76
 
82
     /**
77
     /**
83
      * Instantiates a new standard input dialog.
78
      * Instantiates a new standard input dialog.
84
      *
79
      *
85
-     * @param iconManager Icon manager
80
+     * @param controller Swing controller
86
      * @param items Parent tree
81
      * @param items Parent tree
87
      * @param owner Dialog owner
82
      * @param owner Dialog owner
88
      * @param model Server list model
83
      * @param model Server list model
89
      */
84
      */
90
-    public AddEntryInputDialog(final IconManager iconManager,
85
+    public AddEntryInputDialog(final SwingController controller,
91
             final Window owner, final JTree items,
86
             final Window owner, final JTree items,
92
             final ServerListModel model) {
87
             final ServerListModel model) {
93
         super(owner, ModalityType.MODELESS);
88
         super(owner, ModalityType.MODELESS);
94
 
89
 
95
-        this.iconManager = iconManager;
90
+        this.controller = controller;
96
         this.items = items;
91
         this.items = items;
97
         this.model = model;
92
         this.model = model;
98
         this.entryValidator = new NotEmptyValidator();
93
         this.entryValidator = new NotEmptyValidator();
128
      */
123
      */
129
     private void initComponents() {
124
     private void initComponents() {
130
         orderButtons(new JButton(), new JButton());
125
         orderButtons(new JButton(), new JButton());
131
-        entryName = new ValidatingJTextField(iconManager, entryValidator);
132
-        uri = new ValidatingJTextField(iconManager, new URIJTextField(), uriValidator);
126
+        entryName = new ValidatingJTextField(controller.getIconManager(), entryValidator);
127
+        uri = new ValidatingJTextField(controller.getIconManager(), new URIJTextField(), uriValidator);
133
         blurb = new TextLabel(message);
128
         blurb = new TextLabel(message);
134
         validateText();
129
         validateText();
135
     }
130
     }

src/com/dmdirc/addons/ui_swing/dialogs/serverlist/AddGroupInputDialog.java → src/com/dmdirc/addons/serverlistdialog/AddGroupInputDialog.java View File

20
  * SOFTWARE.
20
  * SOFTWARE.
21
  */
21
  */
22
 
22
 
23
-package com.dmdirc.addons.ui_swing.dialogs.serverlist;
23
+package com.dmdirc.addons.serverlistdialog;
24
 
24
 
25
+import com.dmdirc.addons.serverlists.ServerGroup;
26
+import com.dmdirc.addons.ui_swing.SwingController;
25
 import com.dmdirc.addons.ui_swing.components.text.TextLabel;
27
 import com.dmdirc.addons.ui_swing.components.text.TextLabel;
26
 import com.dmdirc.addons.ui_swing.components.validating.ValidatingJTextField;
28
 import com.dmdirc.addons.ui_swing.components.validating.ValidatingJTextField;
27
 import com.dmdirc.addons.ui_swing.dialogs.StandardDialog;
29
 import com.dmdirc.addons.ui_swing.dialogs.StandardDialog;
28
 import com.dmdirc.addons.ui_swing.dialogs.StandardInputDialog;
30
 import com.dmdirc.addons.ui_swing.dialogs.StandardInputDialog;
29
 import com.dmdirc.util.validators.NotEmptyValidator;
31
 import com.dmdirc.util.validators.NotEmptyValidator;
30
 import com.dmdirc.util.validators.Validator;
32
 import com.dmdirc.util.validators.Validator;
31
-import com.dmdirc.addons.serverlists.ServerGroup;
32
-import com.dmdirc.ui.IconManager;
33
 
33
 
34
 import java.awt.Window;
34
 import java.awt.Window;
35
-import java.awt.Dialog.ModalityType;
36
 import java.awt.event.ActionEvent;
35
 import java.awt.event.ActionEvent;
37
 import java.awt.event.ActionListener;
36
 import java.awt.event.ActionListener;
38
 import java.awt.event.WindowAdapter;
37
 import java.awt.event.WindowAdapter;
53
  */
52
  */
54
 public class AddGroupInputDialog extends StandardDialog {
53
 public class AddGroupInputDialog extends StandardDialog {
55
 
54
 
56
-    /**
57
-     * A version number for this class. It should be changed whenever the class
58
-     * structure is changed (or anything else that would prevent serialized
59
-     * objects being unserialized with the new class).
60
-     */
55
+    /** Serial version UID. */
61
     private static final long serialVersionUID = 1;
56
     private static final long serialVersionUID = 1;
62
     /** Validator. */
57
     /** Validator. */
63
     private final Validator<String> validator;
58
     private final Validator<String> validator;
73
     private final JTree tree;
68
     private final JTree tree;
74
     /** Parent model. */
69
     /** Parent model. */
75
     private final ServerListModel serverListModel;
70
     private final ServerListModel serverListModel;
76
-    /** Icon manager. */
77
-    private final IconManager iconManager;
71
+    /** Swing controller. */
72
+    private final SwingController controller;
78
 
73
 
79
     /**
74
     /**
80
      * Instantiates a new standard input dialog.
75
      * Instantiates a new standard input dialog.
81
      *
76
      *
82
-     * @param iconManager Icon manager
77
+     * @param controller Swing controller
83
      * @param items Parent tree
78
      * @param items Parent tree
84
      * @param owner Dialog owner
79
      * @param owner Dialog owner
85
      * @param model Server list model
80
      * @param model Server list model
86
      */
81
      */
87
-    public AddGroupInputDialog(final IconManager iconManager,
82
+    public AddGroupInputDialog(final SwingController controller,
88
             final Window owner, final JTree items,
83
             final Window owner, final JTree items,
89
             final ServerListModel model) {
84
             final ServerListModel model) {
90
         super(owner, ModalityType.MODELESS);
85
         super(owner, ModalityType.MODELESS);
91
 
86
 
92
-        this.iconManager = iconManager;
87
+        this.controller = controller;
93
         this.tree = items;
88
         this.tree = items;
94
         this.serverListModel = model;
89
         this.serverListModel = model;
95
         this.validator = new NotEmptyValidator();
90
         this.validator = new NotEmptyValidator();
137
      */
132
      */
138
     private void initComponents() {
133
     private void initComponents() {
139
         orderButtons(new JButton(), new JButton());
134
         orderButtons(new JButton(), new JButton());
140
-        groupName = new ValidatingJTextField(iconManager, validator);
135
+        groupName = new ValidatingJTextField(controller.getIconManager(), validator);
141
         networkName = new JTextField();
136
         networkName = new JTextField();
142
         blurb = new TextLabel(message);
137
         blurb = new TextLabel(message);
143
         validateText();
138
         validateText();

src/com/dmdirc/addons/ui_swing/dialogs/serverlist/Help.java → src/com/dmdirc/addons/serverlistdialog/Help.java View File

20
  * SOFTWARE.
20
  * SOFTWARE.
21
  */
21
  */
22
 
22
 
23
-package com.dmdirc.addons.ui_swing.dialogs.serverlist;
23
+package com.dmdirc.addons.serverlistdialog;
24
 
24
 
25
 import com.dmdirc.addons.ui_swing.components.text.TextLabel;
25
 import com.dmdirc.addons.ui_swing.components.text.TextLabel;
26
 
26
 

src/com/dmdirc/addons/ui_swing/dialogs/serverlist/Info.java → src/com/dmdirc/addons/serverlistdialog/Info.java View File

20
  * SOFTWARE.
20
  * SOFTWARE.
21
  */
21
  */
22
 
22
 
23
-package com.dmdirc.addons.ui_swing.dialogs.serverlist;
23
+package com.dmdirc.addons.serverlistdialog;
24
 
24
 
25
 import com.dmdirc.addons.ui_swing.UIUtilities;
25
 import com.dmdirc.addons.ui_swing.UIUtilities;
26
 import com.dmdirc.addons.serverlists.ServerGroupItem;
26
 import com.dmdirc.addons.serverlists.ServerGroupItem;

src/com/dmdirc/addons/ui_swing/dialogs/serverlist/Perform.java → src/com/dmdirc/addons/serverlistdialog/Perform.java View File

20
  * SOFTWARE.
20
  * SOFTWARE.
21
  */
21
  */
22
 
22
 
23
-package com.dmdirc.addons.ui_swing.dialogs.serverlist;
23
+package com.dmdirc.addons.serverlistdialog;
24
 
24
 
25
 import com.dmdirc.addons.ui_swing.components.performpanel.PerformPanel;
25
 import com.dmdirc.addons.ui_swing.components.performpanel.PerformPanel;
26
 import com.dmdirc.addons.serverlists.ServerGroupItem;
26
 import com.dmdirc.addons.serverlists.ServerGroupItem;

src/com/dmdirc/addons/ui_swing/dialogs/serverlist/Profiles.java → src/com/dmdirc/addons/serverlistdialog/Profiles.java View File

20
  * SOFTWARE.
20
  * SOFTWARE.
21
  */
21
  */
22
 
22
 
23
-package com.dmdirc.addons.ui_swing.dialogs.serverlist;
23
+package com.dmdirc.addons.serverlistdialog;
24
 
24
 
25
+import com.dmdirc.addons.ui_swing.SwingController;
25
 import com.dmdirc.addons.ui_swing.components.vetoable.VetoableComboBoxModel;
26
 import com.dmdirc.addons.ui_swing.components.vetoable.VetoableComboBoxModel;
26
 import com.dmdirc.config.Identity;
27
 import com.dmdirc.config.Identity;
27
-import com.dmdirc.config.IdentityManager;
28
 import com.dmdirc.addons.serverlists.ServerGroupItem;
28
 import com.dmdirc.addons.serverlists.ServerGroupItem;
29
 
29
 
30
 import java.util.HashMap;
30
 import java.util.HashMap;
46
  */
46
  */
47
 public class Profiles extends JPanel implements ServerListListener {
47
 public class Profiles extends JPanel implements ServerListListener {
48
 
48
 
49
-    /**
50
-     * A version number for this class. It should be changed whenever the class
51
-     * structure is changed (or anything else that would prevent serialized
52
-     * objects being unserialized with the new class).
53
-     */
49
+    /** Serial version UID. */
54
     private static final long serialVersionUID = 2;
50
     private static final long serialVersionUID = 2;
55
     /** Server list model. */
51
     /** Server list model. */
56
     private final ServerListModel model;
52
     private final ServerListModel model;
59
             new HashMap<ServerGroupItem, JComboBox>();
55
             new HashMap<ServerGroupItem, JComboBox>();
60
     /** Info label. */
56
     /** Info label. */
61
     private final JLabel label;
57
     private final JLabel label;
58
+    /** Swing controller. */
59
+    private final SwingController controller;
62
 
60
 
63
     /**
61
     /**
64
      * Creates a new profile panel backed by the specified model.
62
      * Creates a new profile panel backed by the specified model.
65
      *
63
      *
66
      * @param model Backing server list model
64
      * @param model Backing server list model
65
+     * @param controller Swing controller
67
      */
66
      */
68
-    public Profiles(final ServerListModel model) {
67
+    public Profiles(final ServerListModel model, final SwingController controller) {
69
         super();
68
         super();
70
 
69
 
71
         this.model = model;
70
         this.model = model;
71
+        this.controller = controller;
72
 
72
 
73
         label = new JLabel("Use this profile on this network: ");
73
         label = new JLabel("Use this profile on this network: ");
74
         setBorder(BorderFactory.createTitledBorder(UIManager.getBorder(
74
         setBorder(BorderFactory.createTitledBorder(UIManager.getBorder(
109
         if (!combos.containsKey(item)) {
109
         if (!combos.containsKey(item)) {
110
             final DefaultComboBoxModel comboModel = new VetoableComboBoxModel();
110
             final DefaultComboBoxModel comboModel = new VetoableComboBoxModel();
111
 
111
 
112
-            final List<Identity> profiles = IdentityManager.getCustomIdentities(
113
-                    "profile");
112
+            final List<Identity> profiles = controller.getIdentityManager()
113
+                    .getIdentitiesByType("profile");
114
             Identity selectedItem = null;
114
             Identity selectedItem = null;
115
             comboModel.addElement(null);
115
             comboModel.addElement(null);
116
             for (Identity profile : profiles) {
116
             for (Identity profile : profiles) {

src/com/dmdirc/addons/ui_swing/dialogs/serverlist/ServerListDialog.java → src/com/dmdirc/addons/serverlistdialog/ServerListDialog.java View File

20
  * SOFTWARE.
20
  * SOFTWARE.
21
  */
21
  */
22
 
22
 
23
-package com.dmdirc.addons.ui_swing.dialogs.serverlist;
23
+package com.dmdirc.addons.serverlistdialog;
24
 
24
 
25
-import com.dmdirc.addons.ui_swing.components.LockedLayer;
26
-import com.dmdirc.addons.ui_swing.dialogs.StandardDialog;
27
 import com.dmdirc.addons.serverlists.ServerGroupItem;
25
 import com.dmdirc.addons.serverlists.ServerGroupItem;
28
 import com.dmdirc.addons.ui_swing.SwingController;
26
 import com.dmdirc.addons.ui_swing.SwingController;
27
+import com.dmdirc.addons.ui_swing.components.LockedLayer;
28
+import com.dmdirc.addons.ui_swing.dialogs.StandardDialog;
29
 import com.dmdirc.ui.core.util.URLHandler;
29
 import com.dmdirc.ui.core.util.URLHandler;
30
 
30
 
31
-import java.awt.Window;
32
 import java.awt.color.ColorSpace;
31
 import java.awt.color.ColorSpace;
33
 import java.awt.event.ActionEvent;
32
 import java.awt.event.ActionEvent;
34
 import java.awt.event.ActionListener;
33
 import java.awt.event.ActionListener;
47
 public final class ServerListDialog extends StandardDialog implements
46
 public final class ServerListDialog extends StandardDialog implements
48
         ActionListener, ServerListListener {
47
         ActionListener, ServerListListener {
49
 
48
 
50
-    /**
51
-     * A version number for this class. It should be changed whenever the class
52
-     * structure is changed (or anything else that would prevent serialized
53
-     * objects being unserialized with the new class).
54
-     */
49
+    /** Serial version UID. */
55
     private static final long serialVersionUID = 2;
50
     private static final long serialVersionUID = 2;
56
     /** Server list model. */
51
     /** Server list model. */
57
     private final ServerListModel model;
52
     private final ServerListModel model;
58
     /** Connect button. */
53
     /** Connect button. */
59
     private final JButton connectButton;
54
     private final JButton connectButton;
60
-    /** Previously created instance of dialog. */
61
-    private static ServerListDialog me = null;
62
     /** Info lock. */
55
     /** Info lock. */
63
     private final LockedLayer<Info> infoLock;
56
     private final LockedLayer<Info> infoLock;
64
     /** Perform lock. */
57
     /** Perform lock. */
78
     /** Help panel. */
71
     /** Help panel. */
79
     private final Help help;
72
     private final Help help;
80
 
73
 
81
-    /**
82
-     * Creates the dialog if one doesn't exist, and displays it.
83
-     *
84
-     * @param controller Swing Controller
85
-     * @param parentWindow Parent window
86
-     * @param urlHandler The URL Handler to use to handle clicked links
87
-     */
88
-    public static void showServerListDialog(final SwingController controller,
89
-            final Window parentWindow, final URLHandler urlHandler) {
90
-        me = getServerListDialog(controller, parentWindow, urlHandler);
91
-
92
-        me.display();
93
-        me.requestFocusInWindow();
94
-    }
95
-
96
-    /**
97
-     * Returns the current instance of the ServerListDialog.
98
-     *
99
-     * @param controller Swing Controller
100
-     * @param parentWindow Parent window
101
-     * @param urlHandler The URL Handler to use to handle clicked links
102
-     *
103
-     * @return The current ServerListDialog instance
104
-     */
105
-    public static ServerListDialog getServerListDialog(
106
-            final SwingController controller, final Window parentWindow,
107
-            final URLHandler urlHandler) {
108
-        synchronized (ServerListDialog.class) {
109
-            if (me == null) {
110
-                me = new ServerListDialog(controller, parentWindow,
111
-                ModalityType.MODELESS, urlHandler);
112
-            }
113
-        }
114
-
115
-        return me;
116
-    }
117
-
118
     /**
74
     /**
119
      * Creates a new server list dialog.
75
      * Creates a new server list dialog.
120
      *
76
      *
121
-     * @param window Parent window
77
+     * @param controller Swing controller
122
      * @param modalityType Desired modality
78
      * @param modalityType Desired modality
123
      * @param urlHandler The URL Handler to use to handle clicked links
79
      * @param urlHandler The URL Handler to use to handle clicked links
124
      */
80
      */
125
-    private ServerListDialog(final SwingController controller,
126
-            final Window window, final ModalityType modalityType,
81
+    public ServerListDialog(final SwingController controller,
127
             final URLHandler urlHandler) {
82
             final URLHandler urlHandler) {
128
-        super(window, modalityType);
83
+        super(controller.getMainFrame(), ModalityType.MODELESS);
129
 
84
 
130
         setTitle("Server List");
85
         setTitle("Server List");
131
         model = new ServerListModel();
86
         model = new ServerListModel();
145
         infoLock = new LockedLayer<Info>(new BufferedImageOpEffect(
100
         infoLock = new LockedLayer<Info>(new BufferedImageOpEffect(
146
                 new ColorConvertOp(ColorSpace.getInstance(ColorSpace.CS_GRAY),
101
                 new ColorConvertOp(ColorSpace.getInstance(ColorSpace.CS_GRAY),
147
                 null)));
102
                 null)));
148
-        profileLayer = new JXLayer<Profiles>(new Profiles(model), profileLock);
103
+        profileLayer = new JXLayer<Profiles>(new Profiles(model, controller),
104
+                profileLock);
149
         performLayer = new JXLayer<Perform>(new Perform(model), performLock);
105
         performLayer = new JXLayer<Perform>(new Perform(model), performLock);
150
         settingsLayer = new JXLayer<Settings>(new Settings(controller, model),
106
         settingsLayer = new JXLayer<Settings>(new Settings(controller, model),
151
                 settingsLock);
107
                 settingsLock);
155
 
111
 
156
         setLayout(new MigLayout("fill, wrap 2, wmin 600, wmax 600"));
112
         setLayout(new MigLayout("fill, wrap 2, wmin 600, wmax 600"));
157
 
113
 
158
-        add(new Tree(controller.getIconManager(), model, this),
114
+        add(new Tree(controller, model, this),
159
                 "grow, spany 4, wmax 150, wmin 150");
115
                 "grow, spany 4, wmax 150, wmin 150");
160
         add(help, "pos 160 0.5al");
116
         add(help, "pos 160 0.5al");
161
         add(infoLayer, "growx, pushx");
117
         add(infoLayer, "growx, pushx");
198
         }
154
         }
199
     }
155
     }
200
 
156
 
201
-    /** {@inheritDoc} */
202
-    @Override
203
-    public void dispose() {
204
-        synchronized (ServerListDialog.class) {
205
-            if (me == null) {
206
-                return;
207
-            }
208
-            super.dispose();
209
-            me = null;
210
-        }
211
-    }
212
-
213
     /**
157
     /**
214
      * Lock or unlock layers.
158
      * Lock or unlock layers.
215
      */
159
      */

+ 64
- 0
src/com/dmdirc/addons/serverlistdialog/ServerListDialogPlugin.java View File

1
+/*
2
+ * Copyright (c) 2006-2011 DMDirc Developers
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.addons.serverlistdialog;
24
+
25
+import com.dmdirc.addons.ui_swing.SwingController;
26
+import com.dmdirc.addons.ui_swing.components.menubar.MenuBar;
27
+import com.dmdirc.plugins.PluginManager;
28
+
29
+import java.awt.event.ActionEvent;
30
+import java.awt.event.ActionListener;
31
+
32
+import javax.swing.JMenuItem;
33
+
34
+/**
35
+ * Server list dialog plugin.
36
+ */
37
+public class ServerListDialogPlugin implements ActionListener {
38
+
39
+    /** Swing controller. */
40
+    private final SwingController controller;
41
+
42
+    /**
43
+     * Creates a new server list dialog plugin.
44
+     */
45
+    public ServerListDialogPlugin(final PluginManager pluginManager) {
46
+        controller = (SwingController) pluginManager.getPluginInfoByName(
47
+                "ui_swing").getPlugin();
48
+        final JMenuItem item = new JMenuItem("Server lists");
49
+        item.setMnemonic('l');
50
+        item.addActionListener(this);
51
+        ((MenuBar) controller.getMainFrame().getJMenuBar()).addMenuItem(
52
+                "Server", item);
53
+    }
54
+
55
+    /**
56
+     * {@inheritDoc}
57
+     *
58
+     * @param e Action event
59
+     */
60
+    @Override
61
+    public void actionPerformed(final ActionEvent e) {
62
+        new ServerListDialog(controller, controller.getURLHandler()).display();
63
+    }
64
+}

src/com/dmdirc/addons/ui_swing/dialogs/serverlist/ServerListListener.java → src/com/dmdirc/addons/serverlistdialog/ServerListListener.java View File

20
  * SOFTWARE.
20
  * SOFTWARE.
21
  */
21
  */
22
 
22
 
23
-package com.dmdirc.addons.ui_swing.dialogs.serverlist;
23
+package com.dmdirc.addons.serverlistdialog;
24
 
24
 
25
 import com.dmdirc.addons.serverlists.ServerGroupItem;
25
 import com.dmdirc.addons.serverlists.ServerGroupItem;
26
 
26
 

src/com/dmdirc/addons/ui_swing/dialogs/serverlist/ServerListModel.java → src/com/dmdirc/addons/serverlistdialog/ServerListModel.java View File

20
  * SOFTWARE.
20
  * SOFTWARE.
21
  */
21
  */
22
 
22
 
23
-package com.dmdirc.addons.ui_swing.dialogs.serverlist;
23
+package com.dmdirc.addons.serverlistdialog;
24
 
24
 
25
 import com.dmdirc.actions.wrappers.PerformWrapper.PerformDescription;
25
 import com.dmdirc.actions.wrappers.PerformWrapper.PerformDescription;
26
 import com.dmdirc.actions.wrappers.PerformType;
26
 import com.dmdirc.actions.wrappers.PerformType;

src/com/dmdirc/addons/ui_swing/dialogs/serverlist/Settings.java → src/com/dmdirc/addons/serverlistdialog/Settings.java View File

20
  * SOFTWARE.
20
  * SOFTWARE.
21
  */
21
  */
22
 
22
 
23
-package com.dmdirc.addons.ui_swing.dialogs.serverlist;
23
+package com.dmdirc.addons.serverlistdialog;
24
 
24
 
25
 import com.dmdirc.addons.ui_swing.components.expandingsettings.SettingsPanel;
25
 import com.dmdirc.addons.ui_swing.components.expandingsettings.SettingsPanel;
26
-import com.dmdirc.config.IdentityManager;
27
 import com.dmdirc.addons.serverlists.ServerGroup;
26
 import com.dmdirc.addons.serverlists.ServerGroup;
28
 import com.dmdirc.addons.serverlists.ServerGroupItem;
27
 import com.dmdirc.addons.serverlists.ServerGroupItem;
29
 import com.dmdirc.addons.ui_swing.SwingController;
28
 import com.dmdirc.addons.ui_swing.SwingController;
47
  */
46
  */
48
 public class Settings extends JPanel implements ServerListListener {
47
 public class Settings extends JPanel implements ServerListListener {
49
 
48
 
50
-    /**
51
-     * A version number for this class. It should be changed whenever the class
52
-     * structure is changed (or anything else that would prevent serialized
53
-     * objects being unserialized with the new class).
54
-     */
49
+    /** Serial version UID. */
55
     private static final long serialVersionUID = 2;
50
     private static final long serialVersionUID = 2;
56
     /** Server list model. */
51
     /** Server list model. */
57
     private final ServerListModel model;
52
     private final ServerListModel model;
119
                 panels.put(item, new SettingsPanel(controller, "", false));
114
                 panels.put(item, new SettingsPanel(controller, "", false));
120
                 addSettings(panels.get(item), new ConfigManager("irc", "",
115
                 addSettings(panels.get(item), new ConfigManager("irc", "",
121
                     item.getGroup().getNetwork(), item.getName()),
116
                     item.getGroup().getNetwork(), item.getName()),
122
-                    IdentityManager.getServerConfig(item.getName()));
117
+                    controller.getIdentityManager().createServerConfig(item.getName()));
123
             } else if (item == null) {
118
             } else if (item == null) {
124
                 panels.put(null, new SettingsPanel(controller, "", false));
119
                 panels.put(null, new SettingsPanel(controller, "", false));
125
             } else {
120
             } else {

src/com/dmdirc/addons/ui_swing/dialogs/serverlist/Tree.java → src/com/dmdirc/addons/serverlistdialog/Tree.java View File

20
  * SOFTWARE.
20
  * SOFTWARE.
21
  */
21
  */
22
 
22
 
23
-package com.dmdirc.addons.ui_swing.dialogs.serverlist;
23
+package com.dmdirc.addons.serverlistdialog;
24
 
24
 
25
+import com.dmdirc.addons.serverlists.ServerGroupItem;
26
+import com.dmdirc.addons.ui_swing.SwingController;
25
 import com.dmdirc.addons.ui_swing.components.TreeScroller;
27
 import com.dmdirc.addons.ui_swing.components.TreeScroller;
26
 import com.dmdirc.addons.ui_swing.components.renderers.ServerGroupTreeRenderer;
28
 import com.dmdirc.addons.ui_swing.components.renderers.ServerGroupTreeRenderer;
27
-import com.dmdirc.addons.serverlists.ServerGroupItem;
28
-import com.dmdirc.ui.IconManager;
29
 
29
 
30
 import java.awt.Rectangle;
30
 import java.awt.Rectangle;
31
 import java.awt.Window;
31
 import java.awt.Window;
52
 public class Tree extends JPanel implements TreeSelectionListener,
52
 public class Tree extends JPanel implements TreeSelectionListener,
53
         ServerListListener, ActionListener {
53
         ServerListListener, ActionListener {
54
 
54
 
55
-    /**
56
-     * A version number for this class. It should be changed whenever the class
57
-     * structure is changed (or anything else that would prevent serialized
58
-     * objects being unserialized with the new class).
59
-     */
55
+    /** Serial version UID. */
60
     private static final long serialVersionUID = 2;
56
     private static final long serialVersionUID = 2;
61
     /** Tree. */
57
     /** Tree. */
62
     private final JTree items;
58
     private final JTree items;
70
     private final JButton addItemButton;
66
     private final JButton addItemButton;
71
     /** Parent window. */
67
     /** Parent window. */
72
     private final Window parentWindow;
68
     private final Window parentWindow;
73
-    /** Icon manager. */
74
-    private final IconManager iconManager;
69
+    /** Swing controller. */
70
+    private final SwingController controller;
75
 
71
 
76
     /**
72
     /**
77
      * Instantiates a new tree of server groups.
73
      * Instantiates a new tree of server groups.
78
      *
74
      *
79
-     * @param iconManager Icon Manager
75
+     * @param controller Swing controller
80
      * @param model Model backing this tree
76
      * @param model Model backing this tree
81
      * @param parentWindow Dialog's parent window
77
      * @param parentWindow Dialog's parent window
82
      */
78
      */
83
-    public Tree(final IconManager iconManager, final ServerListModel model,
79
+    public Tree(final SwingController controller, final ServerListModel model,
84
             final Window parentWindow) {
80
             final Window parentWindow) {
85
         super();
81
         super();
86
 
82
 
87
-        this.iconManager = iconManager;
83
+        this.controller = controller;
88
         this.model = model;
84
         this.model = model;
89
         this.parentWindow = parentWindow;
85
         this.parentWindow = parentWindow;
90
         addGroupButton = new JButton("Add group");
86
         addGroupButton = new JButton("Add group");
93
         treeModel = model.getTreeModel();
89
         treeModel = model.getTreeModel();
94
         items = new JTree(treeModel) {
90
         items = new JTree(treeModel) {
95
 
91
 
96
-            /**
97
-             * A version number for this class. It should be changed whenever
98
-             * the class structure is changed (or anything else that would
99
-             * prevent serialized objects being unserialized with the new
100
-             * class).
101
-             */
92
+            /** Serial version UID. */
102
             private static final long serialVersionUID = 2;
93
             private static final long serialVersionUID = 2;
103
 
94
 
104
             /** {@inheritDoc} */
95
             /** {@inheritDoc} */
145
         addItemButton.addActionListener(this);
136
         addItemButton.addActionListener(this);
146
     }
137
     }
147
 
138
 
148
-    /** {@inheritDoc} */
139
+    /**
140
+     * {@inheritDoc}
141
+     *
142
+     * @param e Tree selection event
143
+     */
149
     @Override
144
     @Override
150
     public final void valueChanged(final TreeSelectionEvent e) {
145
     public final void valueChanged(final TreeSelectionEvent e) {
151
         if (items.getSelectionPath() == null) {
146
         if (items.getSelectionPath() == null) {
199
     @Override
194
     @Override
200
     public void actionPerformed(final ActionEvent e) {
195
     public void actionPerformed(final ActionEvent e) {
201
         if (e.getSource() == addGroupButton) {
196
         if (e.getSource() == addGroupButton) {
202
-            new AddGroupInputDialog(iconManager, parentWindow, items, model).display();
197
+            new AddGroupInputDialog(controller, parentWindow, items, model).display();
203
         } else {
198
         } else {
204
-            new AddEntryInputDialog(iconManager, parentWindow, items, model).display();
199
+            new AddEntryInputDialog(controller, parentWindow, items, model).display();
205
         }
200
         }
206
     }
201
     }
207
 
202
 
216
     private DefaultMutableTreeNode getNodeForGroup(final ServerGroupItem item) {
211
     private DefaultMutableTreeNode getNodeForGroup(final ServerGroupItem item) {
217
         DefaultMutableTreeNode node = (DefaultMutableTreeNode) items.getModel()
212
         DefaultMutableTreeNode node = (DefaultMutableTreeNode) items.getModel()
218
                 .getRoot();
213
                 .getRoot();
219
-        final Enumeration enumeration = ((DefaultMutableTreeNode) items
214
+        final Enumeration<?> enumeration = ((DefaultMutableTreeNode) items
220
                 .getModel().getRoot()).breadthFirstEnumeration();
215
                 .getModel().getRoot()).breadthFirstEnumeration();
221
         while (enumeration.hasMoreElements()) {
216
         while (enumeration.hasMoreElements()) {
222
             final DefaultMutableTreeNode current =
217
             final DefaultMutableTreeNode current =

src/com/dmdirc/addons/ui_swing/dialogs/serverlist/URIJTextField.java → src/com/dmdirc/addons/serverlistdialog/URIJTextField.java View File

19
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
  * SOFTWARE.
20
  * SOFTWARE.
21
  */
21
  */
22
-package com.dmdirc.addons.ui_swing.dialogs.serverlist;
22
+package com.dmdirc.addons.serverlistdialog;
23
 
23
 
24
 import javax.swing.JTextField;
24
 import javax.swing.JTextField;
25
 
25
 

+ 29
- 0
src/com/dmdirc/addons/serverlistdialog/plugin.config View File

1
+# This is a DMDirc configuration file.
2
+
3
+# This section indicates which sections below take key/value
4
+# pairs, rather than a simple list. It should be placed above
5
+# any sections that take key/values.
6
+keysections:
7
+  metadata
8
+  updates
9
+  version
10
+  requires
11
+
12
+metadata:
13
+  author=Greg <greg@dmdirc.com>
14
+  mainclass=com.dmdirc.addons.serverlistdialog.ServerListDialogPlugin
15
+  description=Support for server lists
16
+  name=serverlistdialog
17
+  nicename=Server List Dialog
18
+
19
+updates:
20
+  id=59
21
+
22
+version:
23
+  friendly=0.1
24
+
25
+requires:
26
+  parent=ui_swing
27
+
28
+persistent:
29
+  *

+ 1
- 0
src/com/dmdirc/addons/serverlists/plugin.config View File

7
   metadata
7
   metadata
8
   updates
8
   updates
9
   version
9
   version
10
+  requires
10
 
11
 
11
 metadata:
12
 metadata:
12
   author=Chris <chris@dmdirc.com>
13
   author=Chris <chris@dmdirc.com>

+ 4
- 37
src/com/dmdirc/addons/ui_swing/components/menubar/ServerMenu.java View File

29
 import com.dmdirc.addons.ui_swing.SwingController;
29
 import com.dmdirc.addons.ui_swing.SwingController;
30
 import com.dmdirc.addons.ui_swing.components.frames.TextFrame;
30
 import com.dmdirc.addons.ui_swing.components.frames.TextFrame;
31
 import com.dmdirc.addons.ui_swing.dialogs.NewServerDialog;
31
 import com.dmdirc.addons.ui_swing.dialogs.NewServerDialog;
32
-import com.dmdirc.addons.ui_swing.dialogs.serverlist.ServerListDialog;
33
-import com.dmdirc.plugins.PluginInfo;
34
-import com.dmdirc.plugins.PluginManager;
35
 
32
 
36
 import java.awt.event.ActionEvent;
33
 import java.awt.event.ActionEvent;
37
 import java.awt.event.ActionListener;
34
 import java.awt.event.ActionListener;
41
 import javax.swing.event.MenuEvent;
38
 import javax.swing.event.MenuEvent;
42
 import javax.swing.event.MenuListener;
39
 import javax.swing.event.MenuListener;
43
 
40
 
41
+import lombok.AutoGenMethodStub;
42
+
44
 /**
43
 /**
45
  * A menu providing server related commands to the menu bar.
44
  * A menu providing server related commands to the menu bar.
46
  */
45
  */
46
+@AutoGenMethodStub
47
 public class ServerMenu extends JMenu implements ActionListener,
47
 public class ServerMenu extends JMenu implements ActionListener,
48
         MenuListener {
48
         MenuListener {
49
 
49
 
58
     /** Main frame. */
58
     /** Main frame. */
59
     private final MainFrame mainFrame;
59
     private final MainFrame mainFrame;
60
     /** Menu items which can be enabled/disabled. */
60
     /** Menu items which can be enabled/disabled. */
61
-    private JMenuItem ssd, disconnect, serverlist;
61
+    private JMenuItem ssd, disconnect;
62
 
62
 
63
     /**
63
     /**
64
      * Creates a new Server menu.
64
      * Creates a new Server menu.
81
      * Initialises the server menu.
81
      * Initialises the server menu.
82
      */
82
      */
83
     private void initServerMenu() {
83
     private void initServerMenu() {
84
-        serverlist = new JMenuItem();
85
-        serverlist.setText("Server lists");
86
-        serverlist.setMnemonic('l');
87
-        serverlist.setActionCommand("ServerList");
88
-        serverlist.addActionListener(this);
89
-
90
         JMenuItem menuItem = new JMenuItem();
84
         JMenuItem menuItem = new JMenuItem();
91
         menuItem.setText("New Server...");
85
         menuItem.setText("New Server...");
92
         menuItem.setMnemonic('n');
86
         menuItem.setMnemonic('n');
123
     public void actionPerformed(final ActionEvent e) {
117
     public void actionPerformed(final ActionEvent e) {
124
         if ("NewServer".equals(e.getActionCommand())) {
118
         if ("NewServer".equals(e.getActionCommand())) {
125
             NewServerDialog.showNewServerDialog(controller);
119
             NewServerDialog.showNewServerDialog(controller);
126
-        } else if (e.getActionCommand().equals("ServerList")) {
127
-            ServerListDialog.showServerListDialog(controller, mainFrame,
128
-                    controller.getURLHandler());
129
         } else if (e.getActionCommand().equals("Exit")) {
120
         } else if (e.getActionCommand().equals("Exit")) {
130
             mainFrame.quit();
121
             mainFrame.quit();
131
         } else if (e.getActionCommand().equals("ServerSettings")) {
122
         } else if (e.getActionCommand().equals("ServerSettings")) {
150
         disconnect.setEnabled(activeWindow != null && activeWindow
141
         disconnect.setEnabled(activeWindow != null && activeWindow
151
                 .getServer() != null && activeWindow.getServer().getState()
142
                 .getServer() != null && activeWindow.getServer().getState()
152
                 == ServerState.CONNECTED);
143
                 == ServerState.CONNECTED);
153
-
154
-        final PluginInfo plugin = PluginManager.getPluginManager()
155
-                .getPluginInfoByName("serverlists");
156
-        if (plugin != null) {
157
-            if (!plugin.isLoaded()) {
158
-                plugin.loadPlugin();
159
-            }
160
-
161
-            if (getMenuComponent(0) != serverlist) {
162
-                add(serverlist, 0);
163
-            }
164
-        }
165
-    }
166
-
167
-    /** {@inheritDoc} */
168
-    @Override
169
-    public final void menuDeselected(final MenuEvent e) {
170
-        //Ignore
171
-    }
172
-
173
-    /** {@inheritDoc} */
174
-    @Override
175
-    public final void menuCanceled(final MenuEvent e) {
176
-        //Ignore
177
     }
144
     }
178
 }
145
 }

Loading…
Cancel
Save