Browse Source

Delete old profiles dialog.

pull/115/head
Greg Holmes 9 years ago
parent
commit
a118568327
20 changed files with 8 additions and 2673 deletions
  1. 5
    19
      ui_swing/src/com/dmdirc/addons/ui_swing/components/menubar/SettingsMenu.java
  2. 1
    2
      ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/newserver/NewServerDialog.java
  3. 1
    1
      ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/newserver/NewServerLinker.java
  4. 0
    53
      ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/profiles/AddNicknameValidator.java
  5. 0
    54
      ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/profiles/EditNicknameValidator.java
  6. 0
    104
      ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/profiles/ProfileManagerController.java
  7. 0
    159
      ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/profiles/ProfileManagerDialog.java
  8. 0
    335
      ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/profiles/ProfileManagerDialogLinker.java
  9. 0
    584
      ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/profiles/ProfileManagerModel.java
  10. 0
    73
      ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/profiles/ProfileNameDocumentFilter.java
  11. 0
    57
      ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/profiles/ProfileNameValidator.java
  12. 0
    52
      ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/profiles/ProfileRenameValidator.java
  13. 0
    53
      ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/profiles/UniqueProfileNameValidator.java
  14. 0
    7
      ui_swing/src/com/dmdirc/addons/ui_swing/injection/DialogModule.java
  15. 1
    1
      ui_swing/src/com/dmdirc/addons/ui_swing/wizard/firstrun/SwingFirstRunWizard.java
  16. 0
    59
      ui_swing/test/com/dmdirc/addons/ui_swing/dialogs/profiles/AddNicknameValidatorTest.java
  17. 0
    74
      ui_swing/test/com/dmdirc/addons/ui_swing/dialogs/profiles/EditNicknameValidatorTest.java
  18. 0
    121
      ui_swing/test/com/dmdirc/addons/ui_swing/dialogs/profiles/ProfileManagerControllerTest.java
  19. 0
    778
      ui_swing/test/com/dmdirc/addons/ui_swing/dialogs/profiles/ProfileManagerModelTest.java
  20. 0
    87
      ui_swing/test/com/dmdirc/addons/ui_swing/dialogs/profiles/ProfileNameValidatorTest.java

+ 5
- 19
ui_swing/src/com/dmdirc/addons/ui_swing/components/menubar/SettingsMenu.java View File

@@ -42,12 +42,8 @@ public class SettingsMenu extends JMenu {
42 42
 
43 43
     /** Serial version UID. */
44 44
     private static final long serialVersionUID = 1;
45
-    /** Old provider of profile manager dialogs. */
46
-    private final DialogProvider<com.dmdirc.addons.ui_swing.dialogs.profiles.ProfileManagerDialog>
47
-            oldProfileDialogProvider;
48 45
     /** Provider of profile manager dialogs. */
49
-    private final DialogProvider<ProfileManagerDialog>
50
-            newProfileDialogProvider;
46
+    private final DialogProvider<ProfileManagerDialog> profileDialogProvider;
51 47
     /** Provider of action manager dialogs. */
52 48
     private final DialogProvider<ActionsManagerDialog> actionsDialogProvider;
53 49
     /** Provider of preferences dialogs. */
@@ -57,16 +53,12 @@ public class SettingsMenu extends JMenu {
57 53
 
58 54
     @Inject
59 55
     public SettingsMenu(
60
-            final DialogProvider<com.dmdirc.addons.ui_swing.dialogs.profiles.ProfileManagerDialog>
61
-                    oldProfileDialogProvider,
62
-            final DialogProvider<ProfileManagerDialog>
63
-                    newProfileDialogProvider,
56
+            final DialogProvider<ProfileManagerDialog> profileDialogProvider,
64 57
             final DialogProvider<ActionsManagerDialog> actionsDialogProvider,
65 58
             final DialogProvider<SwingPreferencesDialog> prefsDialogProvider,
66 59
             final DialogProvider<AliasManagerDialog> aliasDialogProvider) {
67 60
         super("Settings");
68
-        this.oldProfileDialogProvider = oldProfileDialogProvider;
69
-        this.newProfileDialogProvider = newProfileDialogProvider;
61
+        this.profileDialogProvider = profileDialogProvider;
70 62
         this.actionsDialogProvider = actionsDialogProvider;
71 63
         this.prefsDialogProvider = prefsDialogProvider;
72 64
         this.aliasDialogProvider = aliasDialogProvider;
@@ -91,14 +83,8 @@ public class SettingsMenu extends JMenu {
91 83
 
92 84
         menuItem = new JMenuItem();
93 85
         menuItem.setMnemonic('p');
94
-        menuItem.setText("Old Profile Manager");
95
-        menuItem.addActionListener(e -> oldProfileDialogProvider.displayOrRequestFocus());
96
-        add(menuItem);
97
-
98
-        menuItem = new JMenuItem();
99
-        menuItem.setMnemonic('p');
100
-        menuItem.setText("New Profile Manager");
101
-        menuItem.addActionListener(e -> newProfileDialogProvider.displayOrRequestFocus());
86
+        menuItem.setText("Profile Manager");
87
+        menuItem.addActionListener(e -> profileDialogProvider.displayOrRequestFocus());
102 88
         add(menuItem);
103 89
 
104 90
         menuItem = new JMenuItem();

+ 1
- 2
ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/newserver/NewServerDialog.java View File

@@ -27,11 +27,10 @@ import com.dmdirc.addons.ui_swing.components.NoBorderJCheckBox;
27 27
 import com.dmdirc.addons.ui_swing.components.text.TextLabel;
28 28
 import com.dmdirc.addons.ui_swing.components.validating.ValidationFactory;
29 29
 import com.dmdirc.addons.ui_swing.dialogs.StandardDialog;
30
-import com.dmdirc.addons.ui_swing.dialogs.profiles.ProfileManagerDialog;
30
+import com.dmdirc.addons.ui_swing.dialogs.profile.ProfileManagerDialog;
31 31
 import com.dmdirc.addons.ui_swing.injection.DialogProvider;
32 32
 import com.dmdirc.addons.ui_swing.injection.MainWindow;
33 33
 import com.dmdirc.config.profiles.Profile;
34
-import com.dmdirc.interfaces.config.ConfigProvider;
35 34
 import com.dmdirc.interfaces.ui.NewServerDialogModel;
36 35
 import com.dmdirc.ui.IconManager;
37 36
 

+ 1
- 1
ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/newserver/NewServerLinker.java View File

@@ -24,7 +24,7 @@ package com.dmdirc.addons.ui_swing.dialogs.newserver;
24 24
 
25 25
 import com.dmdirc.addons.ui_swing.components.renderers.PropertyListCellRenderer;
26 26
 import com.dmdirc.addons.ui_swing.components.vetoable.VetoableComboBoxModel;
27
-import com.dmdirc.addons.ui_swing.dialogs.profiles.ProfileManagerDialog;
27
+import com.dmdirc.addons.ui_swing.dialogs.profile.ProfileManagerDialog;
28 28
 import com.dmdirc.addons.ui_swing.injection.DialogProvider;
29 29
 import com.dmdirc.config.profiles.Profile;
30 30
 import com.dmdirc.interfaces.ui.NewServerDialogModel;

+ 0
- 53
ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/profiles/AddNicknameValidator.java View File

@@ -1,53 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2014 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.ui_swing.dialogs.profiles;
24
-
25
-import com.dmdirc.util.validators.NicknameValidator;
26
-import com.dmdirc.util.validators.ValidationResponse;
27
-
28
-/**
29
- * Validates new nicknames being added to a profile.
30
- */
31
-public class AddNicknameValidator extends NicknameValidator {
32
-
33
-    /** Model used to query for validation. */
34
-    private final ProfileManagerModel model;
35
-
36
-    /**
37
-     * Creates a new add nickname validator.
38
-     *
39
-     * @param model Model used to query for information
40
-     */
41
-    public AddNicknameValidator(final ProfileManagerModel model) {
42
-        this.model = model;
43
-    }
44
-
45
-    @Override
46
-    public ValidationResponse validate(final String object) {
47
-        if (model.getNicknames().contains(object)) {
48
-            return new ValidationResponse("Duplicate nickname exists");
49
-        }
50
-        return super.validate(object);
51
-    }
52
-
53
-}

+ 0
- 54
ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/profiles/EditNicknameValidator.java View File

@@ -1,54 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2014 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.ui_swing.dialogs.profiles;
24
-
25
-import com.dmdirc.util.validators.ValidationResponse;
26
-
27
-/**
28
- * Validates a nickname that is being edited.
29
- */
30
-public class EditNicknameValidator extends AddNicknameValidator {
31
-
32
-    /** Model used to query for validation. */
33
-    private final ProfileManagerModel model;
34
-
35
-    /**
36
-     * Creates a new edit nickname validator.
37
-     *
38
-     * @param model Model used to query for information
39
-     */
40
-    public EditNicknameValidator(final ProfileManagerModel model) {
41
-        super(model);
42
-        this.model = model;
43
-    }
44
-
45
-    @Override
46
-    public ValidationResponse validate(final String object) {
47
-        final String nickname = (String) model.getSelectedNickname();
48
-        if (nickname == null || nickname.equals(object)) {
49
-            return new ValidationResponse();
50
-        }
51
-        return super.validate(object);
52
-    }
53
-
54
-}

+ 0
- 104
ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/profiles/ProfileManagerController.java View File

@@ -1,104 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2014 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.ui_swing.dialogs.profiles;
24
-
25
-import com.dmdirc.actions.wrappers.Profile;
26
-import com.dmdirc.interfaces.config.IdentityFactory;
27
-
28
-/**
29
- * This controller reacts to all actions in the profile manager dialog.
30
- */
31
-public class ProfileManagerController {
32
-
33
-    /** Dialog shown to user. */
34
-    private final ProfileManagerDialog dialog;
35
-    /** Model used to store state. */
36
-    private final ProfileManagerModel model;
37
-    /** Factory to use when creating new profiles. */
38
-    private final IdentityFactory identityFactory;
39
-
40
-    public ProfileManagerController(final ProfileManagerDialog dialog,
41
-            final ProfileManagerModel model, final IdentityFactory identityFactory) {
42
-        this.dialog = dialog;
43
-        this.model = model;
44
-        this.identityFactory = identityFactory;
45
-    }
46
-
47
-    /**
48
-     * Adds a new profile.
49
-     *
50
-     * @param name Name of the profile
51
-     */
52
-    public void addProfile(final String name) {
53
-        model.addProfile(new Profile(name, identityFactory));
54
-    }
55
-
56
-    /** Deletes the active profile. */
57
-    public void deleteProfile() {
58
-        model.deleteProfile((Profile) model.getSelectedProfile());
59
-        if (model.getProfiles().isEmpty()) {
60
-            model.addProfile(new Profile("New Profile", identityFactory));
61
-        }
62
-    }
63
-
64
-    /**
65
-     * Adds the specified nickname.
66
-     *
67
-     * @param nickname New nickname
68
-     */
69
-    public void addNickname(final String nickname) {
70
-        model.addNickname(nickname);
71
-    }
72
-
73
-    /**
74
-     * Edits the selected nickname.
75
-     *
76
-     * @param nickname New nickname
77
-     */
78
-    public void editNickname(final String nickname) {
79
-        model.editNickname((String) model.getSelectedNickname(), nickname);
80
-    }
81
-
82
-    /**
83
-     * Deletes the selected nickname.
84
-     */
85
-    public void deleteNickname() {
86
-        model.deleteNickname(model.getSelectedNickname());
87
-    }
88
-
89
-    /**
90
-     * Closes the dialog.
91
-     */
92
-    public void closeDialog() {
93
-        dialog.dispose();
94
-    }
95
-
96
-    /**
97
-     * Saves the model and closes the dialog.
98
-     */
99
-    public void saveAndCloseDialog() {
100
-        model.save();
101
-        closeDialog();
102
-    }
103
-
104
-}

+ 0
- 159
ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/profiles/ProfileManagerDialog.java View File

@@ -1,159 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2014 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.ui_swing.dialogs.profiles;
24
-
25
-import com.dmdirc.ClientModule.GlobalConfig;
26
-import com.dmdirc.actions.wrappers.Profile;
27
-import com.dmdirc.addons.ui_swing.components.renderers.PropertyListCellRenderer;
28
-import com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList;
29
-import com.dmdirc.addons.ui_swing.components.text.TextLabel;
30
-import com.dmdirc.addons.ui_swing.components.validating.ValidationFactory;
31
-import com.dmdirc.addons.ui_swing.dialogs.StandardDialog;
32
-import com.dmdirc.addons.ui_swing.injection.MainWindow;
33
-import com.dmdirc.interfaces.config.IdentityController;
34
-import com.dmdirc.interfaces.config.IdentityFactory;
35
-import com.dmdirc.ui.IconManager;
36
-
37
-import java.awt.Window;
38
-
39
-import javax.inject.Inject;
40
-import javax.swing.Box;
41
-import javax.swing.JButton;
42
-import javax.swing.JLabel;
43
-import javax.swing.JList;
44
-import javax.swing.JScrollPane;
45
-import javax.swing.JTextField;
46
-import javax.swing.ListSelectionModel;
47
-
48
-import net.miginfocom.swing.MigLayout;
49
-
50
-/** Profile editing dialog. */
51
-public class ProfileManagerDialog extends StandardDialog {
52
-
53
-    /** Serial version UID. */
54
-    private static final long serialVersionUID = 3;
55
-    /** Model used to store state. */
56
-    private final ProfileManagerModel model;
57
-    /** Dialog controller, used to perform actions. */
58
-    private final ProfileManagerController controller;
59
-    /** Dialog linker. */
60
-    private final ProfileManagerDialogLinker linker;
61
-    /** List of profiles. */
62
-    private final JList<Profile> profileList = new JList<>();
63
-    /** Icon manager. */
64
-    private final IconManager iconManager;
65
-    /** List of nicknames for a profile. */
66
-    private final ReorderableJList<String> nicknames = new ReorderableJList<>();
67
-    /** Adds a new nickname to the active profile. */
68
-    private final JButton addNickname = new JButton("Add");
69
-    /** Edits the active nickname in the active profile. */
70
-    private final JButton editNickname = new JButton("Edit");
71
-    /** Deletes the selected nickname from the active profile. */
72
-    private final JButton deleteNickname = new JButton("Delete");
73
-    /** Edits the name of the active profile. */
74
-    private final JTextField name;
75
-    /** Edits the realname for the active profile. */
76
-    private final JTextField realname;
77
-    /** Edits the ident for the active profile. */
78
-    private final JTextField ident;
79
-    /** Adds a new profile to the list. */
80
-    private final JButton addProfile = new JButton("Add");
81
-    /** Deletes the active profile. */
82
-    private final JButton deleteProfile = new JButton("Delete");
83
-
84
-    /**
85
-     * Creates a new instance of ProfileEditorDialog.
86
-     *
87
-     * @param mainFrame          Main frame
88
-     * @param identityFactory    Identity factory to create new identities
89
-     * @param identityController Identity controller to retrieve identities from
90
-     * @param iconManager        Icon manager to retrieve icons
91
-     */
92
-    @Inject
93
-    public ProfileManagerDialog(
94
-            @MainWindow final Window mainFrame,
95
-            final IdentityFactory identityFactory,
96
-            final IdentityController identityController,
97
-            @GlobalConfig final IconManager iconManager) {
98
-        super(mainFrame, ModalityType.DOCUMENT_MODAL);
99
-        setTitle("Profile Manager");
100
-        this.model = new ProfileManagerModel(identityController, identityFactory);
101
-        this.controller = new ProfileManagerController(this, model, identityFactory);
102
-        this.iconManager = iconManager;
103
-        realname = new JTextField();
104
-        ident = new JTextField();
105
-        name = new JTextField();
106
-        linker = new ProfileManagerDialogLinker(controller, model, this, iconManager);
107
-        linker.bindAddNickname(addNickname);
108
-        linker.bindAddProfile(addProfile);
109
-        linker.bindCancelButton(getCancelButton());
110
-        linker.bindDeleteNickname(deleteNickname);
111
-        linker.bindDeleteProfile(deleteProfile);
112
-        linker.bindEditNickname(editNickname);
113
-        linker.bindProfileList(profileList);
114
-        linker.bindOKButton(getOkButton());
115
-        linker.bindProfileIdent(ident);
116
-        linker.bindProfileName(name);
117
-        linker.bindProfileNicknames(nicknames);
118
-        linker.bindProfileRealnames(realname);
119
-        initComponents();
120
-        model.load();
121
-    }
122
-
123
-    /** Initialises the components. */
124
-    private void initComponents() {
125
-        profileList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
126
-        nicknames.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
127
-        profileList.setCellRenderer(new PropertyListCellRenderer<>(profileList.getCellRenderer(),
128
-                Profile.class, "name"));
129
-
130
-        setLayout(new MigLayout("fill, wmin 700, wmax 700, flowy"));
131
-
132
-        add(new TextLabel("Profiles describe the information needed to connect "
133
-                + "to a server.  You can use a different profile for each "
134
-                + "connection."), "spanx 3");
135
-        add(new JScrollPane(profileList), "spany 3, growy, "
136
-                + "wmin 200, wmax 200");
137
-        add(addProfile, "grow");
138
-        add(deleteProfile, "grow, wrap");
139
-        add(new JLabel("Name: "), "align label, span 2, split 2, flowx, sgx label");
140
-        add(ValidationFactory.getValidatorPanel(name, model.getNameValidator(), iconManager),
141
-                "growx, pushx, sgx textinput");
142
-        add(new JLabel("Nicknames: "), "align label, span 2, split 2, flowx, sgx label, aligny 50%");
143
-        add(ValidationFactory.getValidatorPanel(new JScrollPane(nicknames), nicknames,
144
-                model.getNicknamesValidator(), iconManager), "grow, push");
145
-        add(Box.createGlue(), "flowx, span 4, split 4, sgx label");
146
-        add(addNickname, "grow");
147
-        add(editNickname, "grow");
148
-        add(deleteNickname, "grow");
149
-        add(new JLabel("Realname: "), "align label, span 2, split 2, flowx, sgx label");
150
-        add(ValidationFactory.getValidatorPanel(realname, model.getRealnameValidator(), iconManager),
151
-                "growx, pushx, sgx textinput");
152
-        add(new JLabel("Ident: "), "align label, span 2, split 2, flowx, sgx label");
153
-        add(ValidationFactory.getValidatorPanel(ident, model.getIdentValidator(), iconManager),
154
-                "growx, pushx, sgx textinput");
155
-        add(getLeftButton(), "flowx, split 2, right, sg button");
156
-        add(getRightButton(), "right, sg button");
157
-    }
158
-
159
-}

+ 0
- 335
ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/profiles/ProfileManagerDialogLinker.java View File

@@ -1,335 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2014 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.ui_swing.dialogs.profiles;
24
-
25
-import com.dmdirc.actions.wrappers.Profile;
26
-import com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList;
27
-import com.dmdirc.addons.ui_swing.components.vetoable.VetoableListSelectionModel;
28
-import com.dmdirc.addons.ui_swing.dialogs.StandardInputDialog;
29
-import com.dmdirc.addons.ui_swing.dialogs.StandardQuestionDialog;
30
-import com.dmdirc.ui.IconManager;
31
-
32
-import java.awt.Dialog.ModalityType;
33
-import java.beans.PropertyVetoException;
34
-
35
-import javax.swing.DefaultListModel;
36
-import javax.swing.JButton;
37
-import javax.swing.JList;
38
-import javax.swing.JTextField;
39
-import javax.swing.ListSelectionModel;
40
-import javax.swing.event.DocumentEvent;
41
-import javax.swing.event.DocumentListener;
42
-
43
-/**
44
- * Links the UI code with the model and controller.
45
- */
46
-public class ProfileManagerDialogLinker {
47
-
48
-    /** Dialog controller. */
49
-    private final ProfileManagerController controller;
50
-    /** Dialog model. */
51
-    private final ProfileManagerModel model;
52
-    /** Dialog. */
53
-    private final ProfileManagerDialog dialog;
54
-    /** The icon manager to use for validating text fields. */
55
-    private final IconManager iconManager;
56
-
57
-    public ProfileManagerDialogLinker(
58
-            final ProfileManagerController controller,
59
-            final ProfileManagerModel model,
60
-            final ProfileManagerDialog dialog,
61
-            final IconManager iconManager) {
62
-        this.controller = controller;
63
-        this.model = model;
64
-        this.dialog = dialog;
65
-        this.iconManager = iconManager;
66
-    }
67
-
68
-    /**
69
-     * Binds the profile list to the model.
70
-     *
71
-     * @param list List to bind
72
-     */
73
-    public void bindProfileList(final JList<Profile> list) {
74
-        list.setModel(new DefaultListModel<>());
75
-        final VetoableListSelectionModel listModel = new VetoableListSelectionModel();
76
-        list.setSelectionModel(listModel);
77
-        listModel.addVetoableSelectionListener(evt -> {
78
-            if (!model.isChangeProfileAllowed()) {
79
-                throw new PropertyVetoException("", evt);
80
-            }
81
-        });
82
-        listModel.addListSelectionListener(e -> model.setSelectedProfile(list.getSelectedValue()));
83
-        model.addPropertyChangeListener("profiles", evt -> {
84
-            ((DefaultListModel<Profile>) list.getModel()).clear();
85
-            for (Profile profile : model.getProfiles()) {
86
-                ((DefaultListModel<Profile>) list.getModel()).addElement(profile);
87
-            }
88
-            if (list.getSelectedValue() != model.getSelectedProfile()) {
89
-                list.setSelectedValue(model.getSelectedProfile(), true);
90
-            }
91
-        });
92
-        model.addPropertyChangeListener("name", evt -> list.repaint());
93
-        for (Profile profile : model.getProfiles()) {
94
-            ((DefaultListModel<Profile>) list.getModel()).addElement(profile);
95
-        }
96
-    }
97
-
98
-    /**
99
-     * Binds the nicknames list to the model.
100
-     *
101
-     * @param nicknames list to bind
102
-     */
103
-    public void bindProfileNicknames(final ReorderableJList<String> nicknames) {
104
-        nicknames.setModel(new DefaultListModel<>());
105
-        nicknames.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
106
-        nicknames.getSelectionModel().addListSelectionListener(
107
-                e -> model.setSelectedNickname(nicknames.getSelectedValue()));
108
-        model.addPropertyChangeListener("selectedprofile", evt -> {
109
-            nicknames.getModel().clear();
110
-            for (String nickname : model.getNicknames()) {
111
-                nicknames.getModel().addElement(nickname);
112
-            }
113
-            nicknames.setSelectedValue(model.getSelectedNickname(), true);
114
-            nicknames.setEnabled(model.isManipulateProfileAllowed());
115
-        });
116
-        model.addPropertyChangeListener("profiles",
117
-                evt -> nicknames.setEnabled(model.isManipulateProfileAllowed()));
118
-        model.addPropertyChangeListener("nicknames", evt -> {
119
-            nicknames.getModel().clear();
120
-            for (String nickname : model.getNicknames()) {
121
-                nicknames.getModel().addElement(nickname);
122
-            }
123
-            nicknames.setSelectedValue(model.getSelectedNickname(), true);
124
-            nicknames.setEnabled(model.isManipulateProfileAllowed());
125
-        });
126
-        nicknames.setEnabled(model.isManipulateProfileAllowed());
127
-    }
128
-
129
-    /**
130
-     * Binds the add nickname button to the controller.
131
-     *
132
-     * @param addNickname Button to bind
133
-     */
134
-    public void bindAddNickname(final JButton addNickname) {
135
-        addNickname.addActionListener(e -> new StandardInputDialog(dialog, ModalityType.DOCUMENT_MODAL, iconManager,
136
-                "Add nickname", "Enter nickname to add:", new AddNicknameValidator(model),
137
-                controller::addNickname).display());
138
-        model.addPropertyChangeListener("selectedprofile",
139
-                evt -> addNickname.setEnabled(model.isManipulateProfileAllowed()));
140
-        model.addPropertyChangeListener("profiles",
141
-                evt -> addNickname.setEnabled(model.isManipulateProfileAllowed()));
142
-        addNickname.setEnabled(model.isManipulateProfileAllowed());
143
-    }
144
-
145
-    /**
146
-     * Binds the edit nickname button to the controller.
147
-     *
148
-     * @param editNickname Button to bind
149
-     */
150
-    public void bindEditNickname(final JButton editNickname) {
151
-        editNickname.addActionListener(e -> {
152
-            final StandardInputDialog inputDialog = new StandardInputDialog(dialog,
153
-                    ModalityType.DOCUMENT_MODAL, iconManager,
154
-                    "Add nickname", "Enter edited nickname:",
155
-                    new EditNicknameValidator(model), controller::editNickname);
156
-            inputDialog.setText((String) model.getSelectedNickname());
157
-            inputDialog.display();
158
-        });
159
-        model.addPropertyChangeListener("selectednickname",
160
-                evt -> editNickname.setEnabled(model.isManipulateNicknameAllowed()));
161
-        model.addPropertyChangeListener("nicknames",
162
-                evt -> editNickname.setEnabled(model.isManipulateNicknameAllowed()));
163
-        editNickname.setEnabled(model.isManipulateNicknameAllowed());
164
-    }
165
-
166
-    /**
167
-     * Binds the delete nickname button to the controller.
168
-     *
169
-     * @param deleteNickname Button to bind
170
-     */
171
-    public void bindDeleteNickname(final JButton deleteNickname) {
172
-        deleteNickname.addActionListener(e -> new StandardQuestionDialog(dialog, ModalityType.DOCUMENT_MODAL,
173
-                "Delete nickname?", "Are you sure you want to delete this nickname?",
174
-                controller::deleteNickname).display());
175
-        model.addPropertyChangeListener("selectednickname",
176
-                evt -> deleteNickname.setEnabled(model.isManipulateNicknameAllowed()));
177
-        model.addPropertyChangeListener("nicknames",
178
-                evt -> deleteNickname.setEnabled(model.isManipulateNicknameAllowed()));
179
-        deleteNickname.setEnabled(model.isManipulateNicknameAllowed());
180
-    }
181
-
182
-    /**
183
-     * Binds the profile name to the model.
184
-     *
185
-     * @param profileName Text field to bind
186
-     */
187
-    public void bindProfileName(final JTextField profileName) {
188
-        profileName.getDocument().addDocumentListener(new DocumentListener() {
189
-            @Override
190
-            public void insertUpdate(final DocumentEvent e) {
191
-                model.setName(profileName.getText());
192
-                profileName.setEnabled(model.isManipulateProfileAllowed());
193
-            }
194
-
195
-            @Override
196
-            public void removeUpdate(final DocumentEvent e) {
197
-                model.setName(profileName.getText());
198
-                profileName.setEnabled(model.isManipulateProfileAllowed());
199
-            }
200
-
201
-            @Override
202
-            public void changedUpdate(final DocumentEvent e) {
203
-                if (!model.isNameValid().isFailure()) {
204
-                    model.setName(profileName.getText());
205
-                }
206
-                profileName.setEnabled(model.isManipulateProfileAllowed());
207
-            }
208
-        });
209
-        model.addPropertyChangeListener("selectedprofile", evt -> {
210
-            profileName.setText(model.getName());
211
-            profileName.setEnabled(model.isManipulateProfileAllowed());
212
-        });
213
-        model.addPropertyChangeListener("profiles", evt -> {
214
-            profileName.setText(model.getName());
215
-            profileName.setEnabled(model.isManipulateProfileAllowed());
216
-        });
217
-        profileName.setEnabled(model.isManipulateProfileAllowed());
218
-    }
219
-
220
-    /**
221
-     * Binds the profile realname to the model.
222
-     *
223
-     * @param profileRealname Textfield to bind
224
-     */
225
-    public void bindProfileRealnames(final JTextField profileRealname) {
226
-        profileRealname.getDocument().addDocumentListener(new DocumentListener() {
227
-            @Override
228
-            public void insertUpdate(final DocumentEvent e) {
229
-                model.setRealname(profileRealname.getText());
230
-                profileRealname.setEnabled(model.isManipulateProfileAllowed());
231
-            }
232
-
233
-            @Override
234
-            public void removeUpdate(final DocumentEvent e) {
235
-                model.setRealname(profileRealname.getText());
236
-                profileRealname.setEnabled(model.isManipulateProfileAllowed());
237
-            }
238
-
239
-            @Override
240
-            public void changedUpdate(final DocumentEvent e) {
241
-                model.setRealname(profileRealname.getText());
242
-                profileRealname.setEnabled(model.isManipulateProfileAllowed());
243
-            }
244
-        });
245
-        model.addPropertyChangeListener("selectedprofile", evt -> {
246
-            profileRealname.setText(model.getRealname());
247
-            profileRealname.setEnabled(model.isManipulateProfileAllowed());
248
-        });
249
-        profileRealname.setEnabled(model.isManipulateProfileAllowed());
250
-    }
251
-
252
-    /**
253
-     * Binds the profile ident to the model.
254
-     *
255
-     * @param profileIdent Textfield to bind
256
-     */
257
-    public void bindProfileIdent(final JTextField profileIdent) {
258
-        profileIdent.getDocument().addDocumentListener(new DocumentListener() {
259
-            @Override
260
-            public void insertUpdate(final DocumentEvent e) {
261
-                model.setIdent(profileIdent.getText());
262
-                profileIdent.setEnabled(model.isManipulateProfileAllowed());
263
-            }
264
-
265
-            @Override
266
-            public void removeUpdate(final DocumentEvent e) {
267
-                model.setIdent(profileIdent.getText());
268
-                profileIdent.setEnabled(model.isManipulateProfileAllowed());
269
-            }
270
-
271
-            @Override
272
-            public void changedUpdate(final DocumentEvent e) {
273
-                model.setIdent(profileIdent.getText());
274
-                profileIdent.setEnabled(model.isManipulateProfileAllowed());
275
-            }
276
-        });
277
-        model.addPropertyChangeListener("selectedprofile",
278
-                evt -> profileIdent.setEnabled(model.isManipulateProfileAllowed()));
279
-        model.addPropertyChangeListener("profiles",
280
-                evt -> profileIdent.setEnabled(model.isManipulateProfileAllowed()));
281
-        profileIdent.setEnabled(model.isManipulateProfileAllowed());
282
-    }
283
-
284
-    /**
285
-     * Binds the add profile button to the controller.
286
-     *
287
-     * @param addProfile Button to bind
288
-     */
289
-    public void bindAddProfile(final JButton addProfile) {
290
-        addProfile.addActionListener(e -> {
291
-            final StandardInputDialog inputDialog = new StandardInputDialog(dialog,
292
-                    ModalityType.DOCUMENT_MODAL, iconManager,
293
-                    "Add profile", "New profile name:",
294
-                    new ProfileNameValidator(model.getProfiles()), controller::addProfile);
295
-            inputDialog.setDocumentFilter(new ProfileNameDocumentFilter());
296
-            inputDialog.setText((String) model.getSelectedNickname());
297
-            inputDialog.display();
298
-        });
299
-    }
300
-
301
-    /**
302
-     * Binds the delete profile button to the controller.
303
-     *
304
-     * @param deleteProfile Button to bind
305
-     */
306
-    public void bindDeleteProfile(final JButton deleteProfile) {
307
-        deleteProfile.addActionListener(e -> new StandardQuestionDialog(dialog, ModalityType.DOCUMENT_MODAL,
308
-                "Delete profile?", "Are you sure you want to delete this profile?",
309
-                controller::deleteProfile).display());
310
-        model.addPropertyChangeListener("profiles",
311
-                evt -> deleteProfile.setEnabled(model.isManipulateProfileAllowed()));
312
-        deleteProfile.setEnabled(model.isManipulateProfileAllowed());
313
-    }
314
-
315
-    /**
316
-     * Binds the OK button to the controller.
317
-     *
318
-     * @param okButton Button to bind
319
-     */
320
-    public void bindOKButton(final JButton okButton) {
321
-        okButton.addActionListener(e -> controller.saveAndCloseDialog());
322
-        model.addPropertyChangeListener(evt -> okButton.setEnabled(model.isOKAllowed()));
323
-        okButton.setEnabled(model.isOKAllowed());
324
-    }
325
-
326
-    /**
327
-     * Binds the cancel button to the controller.
328
-     *
329
-     * @param cancelButton Button to bind
330
-     */
331
-    public void bindCancelButton(final JButton cancelButton) {
332
-        cancelButton.addActionListener(e -> controller.closeDialog());
333
-    }
334
-
335
-}

+ 0
- 584
ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/profiles/ProfileManagerModel.java View File

@@ -1,584 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2014 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.ui_swing.dialogs.profiles;
24
-
25
-import com.dmdirc.actions.wrappers.Profile;
26
-import com.dmdirc.interfaces.config.ConfigProvider;
27
-import com.dmdirc.interfaces.config.IdentityController;
28
-import com.dmdirc.interfaces.config.IdentityFactory;
29
-import com.dmdirc.util.validators.FileNameValidator;
30
-import com.dmdirc.util.validators.IdentValidator;
31
-import com.dmdirc.util.validators.ListNotEmptyValidator;
32
-import com.dmdirc.util.validators.NotEmptyValidator;
33
-import com.dmdirc.util.validators.ValidationResponse;
34
-import com.dmdirc.util.validators.Validator;
35
-import com.dmdirc.util.validators.ValidatorChain;
36
-
37
-import com.google.common.collect.ImmutableList;
38
-
39
-import java.beans.PropertyChangeListener;
40
-import java.beans.PropertyChangeListenerProxy;
41
-import java.beans.PropertyChangeSupport;
42
-import java.io.IOException;
43
-import java.util.ArrayList;
44
-import java.util.Collections;
45
-import java.util.List;
46
-import java.util.stream.Collectors;
47
-
48
-
49
-/**
50
- * Model used to store state for the profile manager dialog.
51
- */
52
-public class ProfileManagerModel {
53
-
54
-    /** Profile change support. */
55
-    private final PropertyChangeSupport pcs;
56
-    /** Identity Controller. */
57
-    private final IdentityController identityController;
58
-    /** Identity Factory. */
59
-    private final IdentityFactory identityFactory;
60
-    /** List of known profiles. */
61
-    private List<Profile> profiles = new ArrayList<>();
62
-    /** List of profiles to be displayed. */
63
-    private final List<Profile> displayedProfiles = new ArrayList<>();
64
-    /** Selected profile. */
65
-    private Profile selectedProfile;
66
-    /** Selected nickname. */
67
-    private String selectedNickname;
68
-
69
-    /**
70
-     * Creates a new model.
71
-     *
72
-     * @param identityController Identity manager to retrieve profiles from.
73
-     * @param identityFactory    Factory to use when creating new profiles.
74
-     */
75
-    public ProfileManagerModel(
76
-            final IdentityController identityController,
77
-            final IdentityFactory identityFactory) {
78
-        pcs = new PropertyChangeSupport(this);
79
-        this.identityController = identityController;
80
-        this.identityFactory = identityFactory;
81
-    }
82
-
83
-    /**
84
-     * Load model with data.
85
-     */
86
-    public void load() {
87
-        final List<ConfigProvider> identities = identityController.getProvidersByType("profile");
88
-        profiles.addAll(identities.stream().map(identity -> new Profile(identityFactory, identity))
89
-                .collect(Collectors.toList()));
90
-        updateDisplayedProfiles();
91
-        if (!profiles.isEmpty()) {
92
-            selectedProfile = profiles.get(0);
93
-        }
94
-        final PropertyChangeListener[] listeners = pcs.getPropertyChangeListeners();
95
-        for (PropertyChangeListener listener : listeners) {
96
-            if (listener instanceof PropertyChangeListenerProxy) {
97
-                final PropertyChangeListenerProxy proxy = (PropertyChangeListenerProxy) listener;
98
-                pcs.firePropertyChange(proxy.getPropertyName(), null, null);
99
-            }
100
-        }
101
-    }
102
-
103
-    /**
104
-     * Updates the list of displayed profiles, showing only those not marked deleted.
105
-     */
106
-    private void updateDisplayedProfiles() {
107
-        displayedProfiles.clear();
108
-        displayedProfiles.addAll(profiles.stream()
109
-                .filter(profile -> !profile.isDeleted())
110
-                .collect(Collectors.toList()));
111
-    }
112
-
113
-    /**
114
-     * Gets the list of displayable profiles.
115
-     *
116
-     * @return List of profiles to display
117
-     */
118
-    public List<Profile> getProfiles() {
119
-        return ImmutableList.copyOf(displayedProfiles);
120
-    }
121
-
122
-    /**
123
-     * Sets the list of profiles.
124
-     *
125
-     * @param profiles List of profiles to display
126
-     */
127
-    public void setProfiles(final List<Profile> profiles) {
128
-        this.profiles = new ArrayList<>(profiles);
129
-        updateDisplayedProfiles();
130
-        if (!profiles.contains(selectedProfile)) {
131
-            upadateSelectedProfile(null);
132
-        }
133
-        if (selectedProfile == null && !profiles.isEmpty()) {
134
-            upadateSelectedProfile(profiles.get(0));
135
-        }
136
-        pcs.firePropertyChange("profiles", null, null);
137
-    }
138
-
139
-    /**
140
-     * Adds the specified profile to the list.
141
-     *
142
-     * @param profile New profile
143
-     */
144
-    public void addProfile(final Profile profile) {
145
-        profiles.add(profile);
146
-        updateDisplayedProfiles();
147
-        upadateSelectedProfile(profile);
148
-        pcs.firePropertyChange("profiles", null, null);
149
-    }
150
-
151
-    /**
152
-     * Marks the selected profile as deleted.
153
-     *
154
-     * @param profile Profile to delete
155
-     */
156
-    public void deleteProfile(final Profile profile) {
157
-        if (profile == null) {
158
-            return;
159
-        }
160
-        profile.setDeleted(true);
161
-        final int selected = displayedProfiles.indexOf(selectedProfile);
162
-        displayedProfiles.remove(profile);
163
-        final int size = displayedProfiles.size();
164
-        Profile newSelectedProfile = null;
165
-        if (profile != selectedProfile) {
166
-            newSelectedProfile = selectedProfile;
167
-        } else if (selected >= size && size > 0) {
168
-            newSelectedProfile = displayedProfiles.get(size - 1);
169
-        } else if (selected <= 0 && size > 0) {
170
-            newSelectedProfile = displayedProfiles.get(0);
171
-        } else if (selected - 1 >= 0 && size != 0) {
172
-            newSelectedProfile = displayedProfiles.get(selected - 1);
173
-        }
174
-        upadateSelectedProfile(newSelectedProfile);
175
-        pcs.firePropertyChange("profiles", null, null);
176
-    }
177
-
178
-    /**
179
-     * Updates the selected profile. This method clears the selected nickname, the update method is
180
-     * not called by this method.
181
-     *
182
-     * @param profile Newly selected profile, may be null
183
-     */
184
-    private void upadateSelectedProfile(final Profile profile) {
185
-        selectedProfile = profile;
186
-        selectedNickname = null;
187
-    }
188
-
189
-    /**
190
-     * Sets the selected profile.
191
-     *
192
-     * @param selectedProfile Profile to select, null ignored
193
-     */
194
-    public void setSelectedProfile(final Object selectedProfile) {
195
-        if (selectedProfile != null
196
-                && !profiles.isEmpty()
197
-                && profiles.contains(selectedProfile)) {
198
-            upadateSelectedProfile((Profile) selectedProfile);
199
-        }
200
-        pcs.firePropertyChange("selectedprofile", null, null);
201
-    }
202
-
203
-    /**
204
-     * Retrieves the selected profile.
205
-     *
206
-     * @return Selected profile (String)
207
-     */
208
-    public Object getSelectedProfile() {
209
-        return selectedProfile;
210
-    }
211
-
212
-    /**
213
-     * Retrieves the list of nicknames for the active profile, this will return an empty list if
214
-     * there is no selected profile.
215
-     *
216
-     * @return List of nicknames
217
-     */
218
-    public List<String> getNicknames() {
219
-        if (selectedProfile == null) {
220
-            return Collections.emptyList();
221
-        }
222
-        return selectedProfile.getNicknames();
223
-    }
224
-
225
-    /**
226
-     * Sets the list of nicknames for the active profile. Will do nothing if there is no active
227
-     * profile.
228
-     *
229
-     * @param nicknames List of nicknames
230
-     */
231
-    public void setNicknames(final List<String> nicknames) {
232
-        if (selectedProfile == null) {
233
-            return;
234
-        }
235
-        selectedProfile.setNicknames(nicknames);
236
-        pcs.firePropertyChange("nicknames", null, null);
237
-    }
238
-
239
-    /**
240
-     * Adds the specified nickname to the list of nicknames in the active profile. Will do nothing
241
-     * if there is no active profile.
242
-     *
243
-     * @param nickname New nickname
244
-     */
245
-    public void addNickname(final String nickname) {
246
-        if (selectedProfile == null) {
247
-            return;
248
-        }
249
-        selectedProfile.addNickname(nickname);
250
-        selectedNickname = nickname;
251
-        pcs.firePropertyChange("nicknames", null, null);
252
-    }
253
-
254
-    /**
255
-     * Deletes the specified nickname from the active profile. This method will do nothing if there
256
-     * is no active profile.
257
-     *
258
-     * @param nickname Nickname to be deleted (This method will do nothing if this is not a String)
259
-     */
260
-    public void deleteNickname(final Object nickname) {
261
-        if (nickname instanceof String) {
262
-            deleteNickname((String) nickname);
263
-        }
264
-    }
265
-
266
-    /**
267
-     * Deletes the specified nickname from the active profile. This method will do nothing if there
268
-     * is no active profile.
269
-     *
270
-     * @param nickname Nickname to be deleted
271
-     */
272
-    public void deleteNickname(final String nickname) {
273
-        if (selectedProfile == null || nickname == null) {
274
-            return;
275
-        }
276
-        final int selected = selectedProfile.getNicknames().indexOf(nickname);
277
-        selectedProfile.delNickname(nickname);
278
-        final int size = selectedProfile.getNicknames().size();
279
-        String newSelectedNickname = null;
280
-        if (!nickname.equals(selectedNickname)) {
281
-            newSelectedNickname = selectedNickname;
282
-        } else if (selected >= size && size > 0) {
283
-            newSelectedNickname = selectedProfile.getNicknames().get(size - 1);
284
-        } else if (selected <= 0 && size > 0) {
285
-            newSelectedNickname = selectedProfile.getNicknames().get(0);
286
-        } else if (selected - 1 >= 0 && size != 0) {
287
-            newSelectedNickname = selectedProfile.getNicknames().get(selected - 1);
288
-        }
289
-        selectedNickname = newSelectedNickname;
290
-        pcs.firePropertyChange("nicknames", null, null);
291
-    }
292
-
293
-    /**
294
-     * Alters the specified nickname.
295
-     *
296
-     * @param nickname Nickname to be edited
297
-     * @param edited   Resultant nickname
298
-     */
299
-    public void editNickname(final String nickname, final String edited) {
300
-        selectedNickname = edited;
301
-        selectedProfile.editNickname(nickname, edited);
302
-        selectedNickname = edited;
303
-        pcs.firePropertyChange("nicknames", null, null);
304
-    }
305
-
306
-    /**
307
-     * Sets the selected nickname on the active profile. This method expects a String, it will do
308
-     * nothing if the parameter is not. If the specified nickname is not found the selection will be
309
-     * cleared.
310
-     *
311
-     * @param selectedNickname Nickname to be selected, may be null. (This method will do nothing if
312
-     *                         this is not a String)
313
-     */
314
-    public void setSelectedNickname(final Object selectedNickname) {
315
-        if (selectedProfile != null
316
-                && selectedNickname instanceof String
317
-                && selectedProfile.getNicknames().contains(selectedNickname)) {
318
-            this.selectedNickname = (String) selectedNickname;
319
-            pcs.firePropertyChange("selectednickname", null, null);
320
-        }
321
-    }
322
-
323
-    /**
324
-     * Retrieves the selected nickname from the active profile.
325
-     *
326
-     * @return Selected nickname (String) or an empty string if there is no active profile
327
-     */
328
-    public Object getSelectedNickname() {
329
-        if (selectedProfile == null) {
330
-            return "";
331
-        }
332
-        return selectedNickname;
333
-    }
334
-
335
-    /**
336
-     * Retrieves the name of the active profile.
337
-     *
338
-     * @return Active profile name or an empty string if there is no active profile
339
-     */
340
-    public String getName() {
341
-        if (selectedProfile == null) {
342
-            return "";
343
-        }
344
-        return selectedProfile.getName();
345
-    }
346
-
347
-    /**
348
-     * Sets the name of the active profile. This method will do nothing if there is no active
349
-     * profile.
350
-     *
351
-     * @param name New profile name
352
-     */
353
-    public void setName(final String name) {
354
-        if (selectedProfile != null) {
355
-            selectedProfile.setName(name);
356
-            pcs.firePropertyChange("name", null, null);
357
-        }
358
-    }
359
-
360
-    /**
361
-     * Retrieves the realname in the active profile.
362
-     *
363
-     * @return Active profile realname or an empty string if there is no active profile
364
-     */
365
-    public String getRealname() {
366
-        if (selectedProfile == null) {
367
-            return "";
368
-        }
369
-        return selectedProfile.getRealname();
370
-    }
371
-
372
-    /**
373
-     * Sets the realname in the active profile. This method will do nothing if there is no active
374
-     * profile.
375
-     *
376
-     * @param realname New profile real name
377
-     */
378
-    public void setRealname(final String realname) {
379
-        if (selectedProfile != null) {
380
-            selectedProfile.setRealname(realname);
381
-            pcs.firePropertyChange("realname", null, null);
382
-        }
383
-    }
384
-
385
-    /**
386
-     * Retrieves the ident of the active profile. This method will return an empty string if there
387
-     * is no active profile.
388
-     *
389
-     * @return Active profile ident or an empty string if there is no active profile
390
-     */
391
-    public String getIdent() {
392
-        if (selectedProfile == null) {
393
-            return "";
394
-        }
395
-        return selectedProfile.getIdent();
396
-    }
397
-
398
-    /**
399
-     * Sets the ident of the active profile. This method will do nothing if there is no active
400
-     * profile.
401
-     *
402
-     * @param ident New profile ident
403
-     */
404
-    public void setIdent(final String ident) {
405
-        if (selectedProfile != null) {
406
-            selectedProfile.setIdent(ident);
407
-            pcs.firePropertyChange("ident", null, null);
408
-        }
409
-    }
410
-
411
-    /**
412
-     * Checks whether is it possible to manipulate a profile.
413
-     *
414
-     * @return true when a profile is selected
415
-     */
416
-    public boolean isManipulateProfileAllowed() {
417
-        return getSelectedProfile() != null;
418
-    }
419
-
420
-    /**
421
-     * Checks whether is it possible to manipulate a nickname.
422
-     *
423
-     * @return true when a nickname is selected
424
-     */
425
-    public boolean isManipulateNicknameAllowed() {
426
-        return getSelectedProfile() != null && getSelectedNickname() != null;
427
-    }
428
-
429
-    /**
430
-     * Is it possible to change profile?
431
-     *
432
-     * @return true if all validators for the selected profile pass
433
-     */
434
-    public boolean isChangeProfileAllowed() {
435
-        return !isNameValid().isFailure()
436
-                && !isNicknamesValid().isFailure()
437
-                && !isIdentValid().isFailure()
438
-                && !isRealnameValid().isFailure();
439
-    }
440
-
441
-    /**
442
-     * Is it possible to save and close the dialog?
443
-     *
444
-     * @return true if all other validators pass and there is at least one profile
445
-     */
446
-    public boolean isOKAllowed() {
447
-        return !profiles.isEmpty()
448
-                && !isNameValid().isFailure()
449
-                && !isNicknamesValid().isFailure()
450
-                && !isIdentValid().isFailure()
451
-                && !isRealnameValid().isFailure();
452
-    }
453
-
454
-    /**
455
-     * Retrieves the profile name validator.
456
-     *
457
-     * @return Passes if the name is a non empty non duplicate filename
458
-     */
459
-    public Validator<String> getNameValidator() {
460
-        return ValidatorChain.<String>builder()
461
-                .addValidator(new FileNameValidator())
462
-                .addValidator(new ProfileRenameValidator(this))
463
-                .build();
464
-    }
465
-
466
-    /**
467
-     * Is the profile name valid? If there is no active profile the validation passes.
468
-     *
469
-     * @return Passes if the name is a non empty non duplicate filename
470
-     */
471
-    public ValidationResponse isNameValid() {
472
-        if (selectedProfile == null) {
473
-            return new ValidationResponse();
474
-        }
475
-        return getNameValidator().validate(selectedProfile.getName());
476
-    }
477
-
478
-    /**
479
-     * Are the nicknames in the active profile valid? If there is no active profile the validation
480
-     * passes.
481
-     *
482
-     * @return passes when there are nicknames present
483
-     */
484
-    public ValidationResponse isNicknamesValid() {
485
-        if (selectedProfile == null) {
486
-            return new ValidationResponse();
487
-        }
488
-        return getNicknamesValidator().validate(selectedProfile.getNicknames());
489
-    }
490
-
491
-    /**
492
-     * Retrieves the nicknames validator.
493
-     *
494
-     * @return Passes if the nicknames list is non empty
495
-     */
496
-    public Validator<List<String>> getNicknamesValidator() {
497
-        return new ListNotEmptyValidator<>();
498
-    }
499
-
500
-    /**
501
-     * Retrieves the realname validator.
502
-     *
503
-     * @return Passes if the realname is a non empty string
504
-     */
505
-    public Validator<String> getRealnameValidator() {
506
-        return new NotEmptyValidator();
507
-    }
508
-
509
-    /**
510
-     * Is the realname in the active profile valid? If there is no active profile the validation
511
-     * passes.
512
-     *
513
-     * @return passes the realname is valid
514
-     */
515
-    public ValidationResponse isRealnameValid() {
516
-        if (selectedProfile == null) {
517
-            return new ValidationResponse();
518
-        }
519
-        return getRealnameValidator().validate(selectedProfile.getRealname());
520
-    }
521
-
522
-    /**
523
-     * Retrieves the ident validator.
524
-     *
525
-     * @return Passes if the ident is an empty string and a valid ident
526
-     */
527
-    public Validator<String> getIdentValidator() {
528
-        return ValidatorChain.<String>builder()
529
-                .addValidator(new IdentValidator())
530
-                .build();
531
-    }
532
-
533
-    /**
534
-     * Is the ident in the active profile valid? If there is no active profile the validation
535
-     * passes.
536
-     *
537
-     * @return passes the ident is valid
538
-     */
539
-    public ValidationResponse isIdentValid() {
540
-        if (selectedProfile == null) {
541
-            return new ValidationResponse();
542
-        }
543
-        return getIdentValidator().validate(selectedProfile.getIdent());
544
-    }
545
-
546
-    /**
547
-     * This method saves any changes made in the model to disk. All profiles marked for deletion are
548
-     * removed and then all remaining profiles are have their save method called.
549
-     */
550
-    public void save() {
551
-        for (Profile profile : profiles) {
552
-            if (profile.isDeleted()) {
553
-                try {
554
-                    profile.delete();
555
-                } catch (IOException ex) {
556
-                    // TODO: handle somehow
557
-                }
558
-            } else {
559
-                profile.save();
560
-            }
561
-        }
562
-    }
563
-
564
-    /**
565
-     * Adds a property change listener to all property change events in the model.
566
-     *
567
-     * @param listener Listener to add
568
-     */
569
-    public void addPropertyChangeListener(final PropertyChangeListener listener) {
570
-        pcs.addPropertyChangeListener(listener);
571
-    }
572
-
573
-    /**
574
-     * Adds a property change listener to a given property on this model.
575
-     *
576
-     * @param propertyName Property to listen on
577
-     * @param listener     Listener to add
578
-     */
579
-    public void addPropertyChangeListener(final String propertyName,
580
-            final PropertyChangeListener listener) {
581
-        pcs.addPropertyChangeListener(propertyName, listener);
582
-    }
583
-
584
-}

+ 0
- 73
ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/profiles/ProfileNameDocumentFilter.java View File

@@ -1,73 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2014 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.ui_swing.dialogs.profiles;
24
-
25
-import javax.swing.text.AttributeSet;
26
-import javax.swing.text.BadLocationException;
27
-import javax.swing.text.DocumentFilter;
28
-
29
-/**
30
- * Filters whitespace from a document.
31
- */
32
-public class ProfileNameDocumentFilter extends DocumentFilter {
33
-
34
-    /** Invalid filename characters. */
35
-    private static final String INVALID_CHARS = "[^A-Za-z0-9\\-_!]";
36
-
37
-    @Override
38
-    public void insertString(final DocumentFilter.FilterBypass fb,
39
-            final int offset, final String string, final AttributeSet attr)
40
-            throws BadLocationException {
41
-
42
-        if (string != null && !string.isEmpty()) {
43
-            replace(fb, offset, string.length(), string, attr);
44
-        }
45
-    }
46
-
47
-    @Override
48
-    public void remove(final DocumentFilter.FilterBypass fb, final int offset,
49
-            final int length) throws BadLocationException {
50
-
51
-        replace(fb, offset, length, "", null);
52
-    }
53
-
54
-    @Override
55
-    public void replace(final DocumentFilter.FilterBypass fb, final int offset,
56
-            final int length, final String text, final AttributeSet attrs)
57
-            throws BadLocationException {
58
-
59
-        fb.replace(offset, length, sanitise(text), attrs);
60
-    }
61
-
62
-    /**
63
-     * Sanitises the proposed value.
64
-     *
65
-     * @param proposedValue String to sanitise
66
-     *
67
-     * @return Sanitised string
68
-     */
69
-    private String sanitise(final String proposedValue) {
70
-        return proposedValue.replaceAll(INVALID_CHARS, "");
71
-    }
72
-
73
-}

+ 0
- 57
ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/profiles/ProfileNameValidator.java View File

@@ -1,57 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2014 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.ui_swing.dialogs.profiles;
24
-
25
-import com.dmdirc.actions.wrappers.Profile;
26
-import com.dmdirc.util.validators.FileNameValidator;
27
-import com.dmdirc.util.validators.ValidationResponse;
28
-import com.dmdirc.util.validators.Validator;
29
-import com.dmdirc.util.validators.ValidatorChain;
30
-
31
-import java.util.List;
32
-
33
-/**
34
- * Validator to ensure a profile name is both unique and a valid name to be saved to disk.
35
- */
36
-public class ProfileNameValidator implements Validator<String> {
37
-
38
-    private final ValidatorChain<String> validator;
39
-
40
-    /**
41
-     * Creates a new profile name validator.
42
-     *
43
-     * @param profiles List of profiles to check uniqueness
44
-     */
45
-    public ProfileNameValidator(final List<Profile> profiles) {
46
-        validator = ValidatorChain.<String>builder()
47
-                .addValidator(new UniqueProfileNameValidator(profiles))
48
-                .addValidator(new FileNameValidator())
49
-                .build();
50
-    }
51
-
52
-    @Override
53
-    public ValidationResponse validate(final String object) {
54
-        return validator.validate(object == null ? "" : object.trim());
55
-    }
56
-
57
-}

+ 0
- 52
ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/profiles/ProfileRenameValidator.java View File

@@ -1,52 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2014 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.ui_swing.dialogs.profiles;
24
-
25
-import com.dmdirc.actions.wrappers.Profile;
26
-import com.dmdirc.util.validators.ValidationResponse;
27
-import com.dmdirc.util.validators.Validator;
28
-
29
-/**
30
- * Ensures profile names are unique.
31
- */
32
-public class ProfileRenameValidator implements Validator<String> {
33
-
34
-    /** Profile model. */
35
-    private final ProfileManagerModel model;
36
-
37
-    public ProfileRenameValidator(final ProfileManagerModel model) {
38
-        this.model = model;
39
-    }
40
-
41
-    @Override
42
-    public ValidationResponse validate(final String object) {
43
-        for (Profile targetprofile : model.getProfiles()) {
44
-            if (targetprofile != model.getSelectedProfile()
45
-                    && targetprofile.getName().equalsIgnoreCase(object)) {
46
-                return new ValidationResponse("Profile names must be unique");
47
-            }
48
-        }
49
-        return new ValidationResponse();
50
-    }
51
-
52
-}

+ 0
- 53
ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/profiles/UniqueProfileNameValidator.java View File

@@ -1,53 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2014 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.ui_swing.dialogs.profiles;
24
-
25
-import com.dmdirc.actions.wrappers.Profile;
26
-import com.dmdirc.util.validators.ValidationResponse;
27
-import com.dmdirc.util.validators.Validator;
28
-
29
-import java.util.List;
30
-
31
-/**
32
- * Validates a profile name ensuring its uniqueness and validity as a filename.
33
- */
34
-public class UniqueProfileNameValidator implements Validator<String> {
35
-
36
-    /** List of profiles to validate. */
37
-    private final List<Profile> profiles;
38
-
39
-    public UniqueProfileNameValidator(final List<Profile> profiles) {
40
-        this.profiles = profiles;
41
-    }
42
-
43
-    @Override
44
-    public ValidationResponse validate(final String object) {
45
-        for (Profile targetprofile : profiles) {
46
-            if (targetprofile.getName().equalsIgnoreCase(object)) {
47
-                return new ValidationResponse("Profile names must be unique");
48
-            }
49
-        }
50
-        return new ValidationResponse();
51
-    }
52
-
53
-}

+ 0
- 7
ui_swing/src/com/dmdirc/addons/ui_swing/injection/DialogModule.java View File

@@ -117,13 +117,6 @@ public class DialogModule {
117 117
         return new DialogProvider<>(provider);
118 118
     }
119 119
 
120
-    @Provides
121
-    @Singleton
122
-    public DialogProvider<com.dmdirc.addons.ui_swing.dialogs.profiles.ProfileManagerDialog> getOldProfileManagerDialogProvider(
123
-            final Provider<com.dmdirc.addons.ui_swing.dialogs.profiles.ProfileManagerDialog> provider) {
124
-        return new DialogProvider<>(provider);
125
-    }
126
-
127 120
     @Provides
128 121
     @Singleton
129 122
     public DialogProvider<ProfileManagerDialog> getNewProfileManagerDialogProvider(

+ 1
- 1
ui_swing/src/com/dmdirc/addons/ui_swing/wizard/firstrun/SwingFirstRunWizard.java View File

@@ -25,7 +25,7 @@ package com.dmdirc.addons.ui_swing.wizard.firstrun;
25 25
 import com.dmdirc.ClientModule.GlobalConfig;
26 26
 import com.dmdirc.ClientModule.UserConfig;
27 27
 import com.dmdirc.DMDircMBassador;
28
-import com.dmdirc.addons.ui_swing.dialogs.profiles.ProfileManagerDialog;
28
+import com.dmdirc.addons.ui_swing.dialogs.profile.ProfileManagerDialog;
29 29
 import com.dmdirc.addons.ui_swing.injection.DialogProvider;
30 30
 import com.dmdirc.addons.ui_swing.injection.MainWindow;
31 31
 import com.dmdirc.addons.ui_swing.wizard.WizardDialog;

+ 0
- 59
ui_swing/test/com/dmdirc/addons/ui_swing/dialogs/profiles/AddNicknameValidatorTest.java View File

@@ -1,59 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2014 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
20
- * THE SOFTWARE.
21
- */
22
-package com.dmdirc.addons.ui_swing.dialogs.profiles;
23
-
24
-import java.util.Arrays;
25
-
26
-import org.junit.Test;
27
-
28
-import static org.junit.Assert.*;
29
-import static org.mockito.Mockito.*;
30
-
31
-/**
32
- * Tests the nickname validator.
33
- */
34
-public class AddNicknameValidatorTest {
35
-
36
-    /**
37
-     * Test of validate method, of class AddNicknameValidator.
38
-     */
39
-    @Test
40
-    public void testValidateValid() {
41
-        final ProfileManagerModel model = mock(ProfileManagerModel.class);
42
-        when(model.getNicknames()).thenReturn(Arrays.asList(
43
-                new String[]{"nickname1", "nickname2",}));
44
-        final AddNicknameValidator instance = new AddNicknameValidator(model);
45
-        assertTrue(instance.validate("nickname1").isFailure());
46
-    }
47
-
48
-    /**
49
-     * Test of validate method, of class AddNicknameValidator.
50
-     */
51
-    @Test
52
-    public void testValidateInvalid() {
53
-        final ProfileManagerModel model = mock(ProfileManagerModel.class);
54
-        when(model.getNicknames()).thenReturn(Arrays.asList(
55
-                new String[]{"nickname1", "nickname2",}));
56
-        final AddNicknameValidator instance = new AddNicknameValidator(model);
57
-        assertFalse(instance.validate("nickname").isFailure());
58
-    }
59
-}

+ 0
- 74
ui_swing/test/com/dmdirc/addons/ui_swing/dialogs/profiles/EditNicknameValidatorTest.java View File

@@ -1,74 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2014 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
20
- * THE SOFTWARE.
21
- */
22
-package com.dmdirc.addons.ui_swing.dialogs.profiles;
23
-
24
-import java.util.Arrays;
25
-
26
-import org.junit.Test;
27
-
28
-import static org.junit.Assert.*;
29
-import static org.mockito.Mockito.*;
30
-
31
-/**
32
- * Tests the edit nickname validator.
33
- */
34
-public class EditNicknameValidatorTest {
35
-
36
-    /**
37
-     * Test of validate method, of class EditNicknameValidatorTest.
38
-     */
39
-    @Test
40
-    public void testValidateNull() {
41
-        final ProfileManagerModel model = mock(ProfileManagerModel.class);
42
-        when(model.getSelectedNickname()).thenReturn(null);
43
-        when(model.getNicknames()).thenReturn(Arrays.asList(
44
-                new String[]{"nickname1", "nickname2",}));
45
-        final EditNicknameValidator instance = new EditNicknameValidator(model);
46
-        assertFalse(instance.validate("nickname").isFailure());
47
-    }
48
-
49
-    /**
50
-     * Test of validate method, of class EditNicknameValidatorTest.
51
-     */
52
-    @Test
53
-    public void testValidateEquals() {
54
-        final ProfileManagerModel model = mock(ProfileManagerModel.class);
55
-        when(model.getSelectedNickname()).thenReturn("nickname");
56
-        when(model.getNicknames()).thenReturn(Arrays.asList(
57
-                new String[]{"nickname1", "nickname2",}));
58
-        final EditNicknameValidator instance = new EditNicknameValidator(model);
59
-        assertFalse(instance.validate("nickname").isFailure());
60
-    }
61
-
62
-    /**
63
-     * Test of validate method, of class EditNicknameValidatorTest.
64
-     */
65
-    @Test
66
-    public void testValidateInvalid() {
67
-        final ProfileManagerModel model = mock(ProfileManagerModel.class);
68
-        when(model.getSelectedNickname()).thenReturn("nickname");
69
-        when(model.getNicknames()).thenReturn(Arrays.asList(
70
-                new String[]{"nickname1", "nickname2",}));
71
-        final EditNicknameValidator instance = new EditNicknameValidator(model);
72
-        assertFalse(instance.validate("nickname3").isFailure());
73
-    }
74
-}

+ 0
- 121
ui_swing/test/com/dmdirc/addons/ui_swing/dialogs/profiles/ProfileManagerControllerTest.java View File

@@ -1,121 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2014 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
20
- * THE SOFTWARE.
21
- */
22
-package com.dmdirc.addons.ui_swing.dialogs.profiles;
23
-
24
-import com.dmdirc.actions.wrappers.Profile;
25
-import com.dmdirc.interfaces.config.IdentityFactory;
26
-
27
-import org.junit.Before;
28
-import org.junit.Test;
29
-import org.junit.runner.RunWith;
30
-import org.mockito.Mock;
31
-import org.mockito.runners.MockitoJUnitRunner;
32
-
33
-import static org.mockito.Mockito.mock;
34
-import static org.mockito.Mockito.verify;
35
-import static org.mockito.Mockito.when;
36
-
37
-/**
38
- * Tests for ProfileManagerController.
39
- */
40
-@RunWith(MockitoJUnitRunner.class)
41
-public class ProfileManagerControllerTest {
42
-
43
-    @Mock private ProfileManagerDialog dialog;
44
-    @Mock private ProfileManagerModel model;
45
-    @Mock private IdentityFactory identityFactory;
46
-
47
-    private ProfileManagerController instance;
48
-
49
-    @Before
50
-    public void setup() {
51
-        instance = new ProfileManagerController(dialog, model, identityFactory);
52
-    }
53
-
54
-    /**
55
-     * Test of addProfile method, of class ProfileManagerController.
56
-     */
57
-    @Test
58
-    public void testAddProfile() {
59
-        instance.addProfile("New Profile");
60
-        verify(model).addProfile(new Profile("New Profile", identityFactory));
61
-    }
62
-
63
-    /**
64
-     * Test of deleteProfile method, of class ProfileManagerController.
65
-     */
66
-    @Test
67
-    public void testDeleteProfile() {
68
-        final Profile selectedProfile = mock(Profile.class);
69
-        when(model.getSelectedProfile()).thenReturn(selectedProfile);
70
-        instance.deleteProfile();
71
-        verify(model).deleteProfile(selectedProfile);
72
-    }
73
-
74
-    /**
75
-     * Test of addNickname method, of class ProfileManagerController.
76
-     */
77
-    @Test
78
-    public void testAddNickname() {
79
-        instance.addNickname("test");
80
-        verify(model).addNickname("test");
81
-    }
82
-
83
-    /**
84
-     * Test of editNickname method, of class ProfileManagerController.
85
-     */
86
-    @Test
87
-    public void testEditNickname() {
88
-        when(model.getSelectedNickname()).thenReturn("test");
89
-        instance.editNickname("test2");
90
-        verify(model).editNickname("test", "test2");
91
-    }
92
-
93
-    /**
94
-     * Test of deleteNickname method, of class ProfileManagerController.
95
-     */
96
-    @Test
97
-    public void testDeleteNickname() {
98
-        when(model.getSelectedNickname()).thenReturn("test");
99
-        instance.deleteNickname();
100
-        verify(model).deleteNickname((Object) "test");
101
-    }
102
-
103
-    /**
104
-     * Test of closeDialog method, of class ProfileManagerController.
105
-     */
106
-    @Test
107
-    public void testCloseDialog() {
108
-        instance.closeDialog();
109
-        verify(dialog).dispose();
110
-    }
111
-
112
-    /**
113
-     * Test of saveAndCloseDialog method, of class ProfileManagerController.
114
-     */
115
-    @Test
116
-    public void testSaveAndCloseDialog() {
117
-        instance.saveAndCloseDialog();
118
-        verify(model).save();
119
-        verify(dialog).dispose();
120
-    }
121
-}

+ 0
- 778
ui_swing/test/com/dmdirc/addons/ui_swing/dialogs/profiles/ProfileManagerModelTest.java View File

@@ -1,778 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2014 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.ui_swing.dialogs.profiles;
24
-
25
-import com.dmdirc.actions.wrappers.Profile;
26
-import com.dmdirc.interfaces.config.ConfigProvider;
27
-import com.dmdirc.interfaces.config.IdentityController;
28
-import com.dmdirc.interfaces.config.IdentityFactory;
29
-
30
-import java.io.IOException;
31
-import java.util.ArrayList;
32
-import java.util.Arrays;
33
-import java.util.Collections;
34
-import java.util.List;
35
-
36
-import org.junit.Before;
37
-import org.junit.Test;
38
-import org.junit.runner.RunWith;
39
-import org.mockito.Mock;
40
-import org.mockito.runners.MockitoJUnitRunner;
41
-
42
-import static org.junit.Assert.assertEquals;
43
-import static org.junit.Assert.assertFalse;
44
-import static org.junit.Assert.assertNotSame;
45
-import static org.junit.Assert.assertNull;
46
-import static org.junit.Assert.assertTrue;
47
-import static org.mockito.Mockito.mock;
48
-import static org.mockito.Mockito.verify;
49
-import static org.mockito.Mockito.when;
50
-
51
-/**
52
- * Test for ProfileManagerModel
53
- */
54
-@RunWith(MockitoJUnitRunner.class)
55
-public class ProfileManagerModelTest {
56
-
57
-    @Mock private IdentityController manager;
58
-    @Mock private IdentityFactory identityFactory;
59
-
60
-    private Profile defaultProfile;
61
-
62
-    private Profile createProfile(final String prefix) {
63
-        final List<String> nicknames = new ArrayList<>();
64
-        nicknames.add(prefix + "nickname");
65
-
66
-        final ConfigProvider configProvider = mock(ConfigProvider.class);
67
-        when(configProvider.getName()).thenReturn(prefix + "profile");
68
-        when(configProvider.getOption("identity", "name")).thenReturn(prefix + "profile");
69
-        when(configProvider.getOptionList("profile", "nicknames")).thenReturn(nicknames);
70
-        when(configProvider.getOption("profile", "realname")).thenReturn(prefix + "realname");
71
-        when(configProvider.getOption("profile", "ident")).thenReturn(prefix + "ident");
72
-
73
-        return new Profile(identityFactory, configProvider);
74
-    }
75
-
76
-    private ProfileManagerModel createModel() {
77
-        defaultProfile = createProfile("1");
78
-        final ProfileManagerModel model = new ProfileManagerModel(manager, identityFactory);
79
-        model.addProfile(defaultProfile);
80
-        return model;
81
-    }
82
-
83
-    @Before
84
-    public void setup() {
85
-        final List<ConfigProvider> identities = Collections.emptyList();
86
-        manager = mock(IdentityController.class);
87
-        when(manager.getProvidersByType("profile")).thenReturn(identities);
88
-    }
89
-
90
-    /**
91
-     * Test creating profiles from identities.
92
-     */
93
-    @Test
94
-    public void testLoad() {
95
-        final List<String> nicknames = new ArrayList<>();
96
-        nicknames.add("nickname");
97
-        final ConfigProvider configProvider = mock(ConfigProvider.class);
98
-        when(configProvider.getName()).thenReturn("profile");
99
-        when(configProvider.getOption("identity", "name")).thenReturn("profile");
100
-        when(configProvider.getOptionList("profile", "nicknames")).thenReturn(nicknames);
101
-        when(configProvider.getOption("profile", "realname")).thenReturn("realname");
102
-        when(configProvider.getOption("profile", "ident")).thenReturn("ident");
103
-        final List<ConfigProvider> identities = new ArrayList<>();
104
-        identities.add(configProvider);
105
-        final IdentityController im = mock(IdentityController.class);
106
-        when(im.getProvidersByType("profile")).thenReturn(identities);
107
-
108
-        final ProfileManagerModel instance = new ProfileManagerModel(im, identityFactory);
109
-        instance.load();
110
-
111
-        assertEquals(Arrays.asList(new Profile[]{new Profile(identityFactory, configProvider), }), instance.getProfiles());
112
-    }
113
-
114
-    /**
115
-     * Test of setProfiles method, of class ProfileManagerModel.
116
-     */
117
-    @Test
118
-    public void testGetAndSetProfiles() {
119
-        final List<Profile> newProfiles = Arrays.asList(
120
-                new Profile[]{createProfile("2"),});
121
-        final ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
122
-        assertEquals(Collections.emptyList(), instance.getProfiles());
123
-        instance.setProfiles(newProfiles);
124
-        assertEquals(newProfiles, instance.getProfiles());
125
-    }
126
-
127
-    /**
128
-     * Test of addProfiles method, of class ProfileManagerModel.
129
-     */
130
-    @Test
131
-    public void testAddProfiles() {
132
-        final Profile newProfile = createProfile("2");
133
-        final ProfileManagerModel instance = createModel();
134
-        assertEquals(Arrays.asList(new Profile[]{defaultProfile,}), instance.getProfiles());
135
-        final List<Profile> newProfiles = new ArrayList<>();
136
-        newProfiles.add(defaultProfile);
137
-        newProfiles.add(newProfile);
138
-        instance.addProfile(newProfile);
139
-        assertEquals(newProfiles, instance.getProfiles());
140
-    }
141
-
142
-    /**
143
-     * Test deleting a null profile.
144
-     */
145
-    @Test
146
-    public void testDeleteProfileNullProfile() {
147
-        final Profile first = createProfile("1");
148
-        final ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
149
-        instance.addProfile(first);
150
-        instance.setSelectedProfile(first);
151
-        assertEquals(first, instance.getSelectedProfile());
152
-        instance.deleteProfile(null);
153
-        assertEquals(first, instance.getSelectedProfile());
154
-    }
155
-
156
-    /**
157
-     * Test selected profile behaviour upon deleting profiles.
158
-     */
159
-    @Test
160
-    public void testDeleteProfileNotSelected() {
161
-        final Profile first = createProfile("1");
162
-        final Profile second = createProfile("2");
163
-        final ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
164
-        instance.addProfile(first);
165
-        instance.addProfile(second);
166
-        instance.setSelectedProfile(second);
167
-        assertEquals(second, instance.getSelectedProfile());
168
-        instance.deleteProfile(first);
169
-        assertEquals(second, instance.getSelectedProfile());
170
-    }
171
-
172
-    /**
173
-     * Test selected profile behaviour upon deleting profiles.
174
-     */
175
-    @Test
176
-    public void testDeleteProfileLastProfile() {
177
-        final Profile first = createProfile("1");
178
-        final Profile second = createProfile("2");
179
-        final ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
180
-        instance.addProfile(first);
181
-        instance.addProfile(second);
182
-        instance.setSelectedProfile(second);
183
-        assertEquals(second, instance.getSelectedProfile());
184
-        instance.deleteProfile(second);
185
-        assertEquals(first, instance.getSelectedProfile());
186
-    }
187
-
188
-    /**
189
-     * Test selected profile behaviour upon deleting profiles.
190
-     */
191
-    @Test
192
-    public void testDeleteProfileFirstProfile() {
193
-        final Profile first = createProfile("1");
194
-        final Profile second = createProfile("2");
195
-        final ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
196
-        instance.addProfile(first);
197
-        instance.addProfile(second);
198
-        instance.setSelectedProfile(first);
199
-        assertEquals(first, instance.getSelectedProfile());
200
-        instance.deleteProfile(first);
201
-        assertEquals(second, instance.getSelectedProfile());
202
-    }
203
-
204
-    /**
205
-     * Test selected profile behaviour upon deleting profiles.
206
-     */
207
-    @Test
208
-    public void testDeleteProfileMiddleProfile() {
209
-        final Profile first = createProfile("1");
210
-        final Profile second = createProfile("2");
211
-        final Profile third = createProfile("3");
212
-        final ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
213
-        instance.addProfile(first);
214
-        instance.addProfile(second);
215
-        instance.addProfile(third);
216
-        instance.setSelectedProfile(second);
217
-        assertEquals(second, instance.getSelectedProfile());
218
-        instance.deleteProfile(second);
219
-        assertEquals(first, instance.getSelectedProfile());
220
-    }
221
-
222
-    /**
223
-     * Test deleting a null profile.
224
-     */
225
-    @Test
226
-    public void testDeleteProfileOnlyProfile() {
227
-        final Profile first = createProfile("1");
228
-        final ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
229
-        instance.addProfile(first);
230
-        instance.setSelectedProfile(first);
231
-        assertEquals(first, instance.getSelectedProfile());
232
-        instance.deleteProfile(first);
233
-        assertNull(instance.getSelectedProfile());
234
-    }
235
-
236
-    /**
237
-     * Test of setSelectedProfile method, of class ProfileManagerModel.
238
-     */
239
-    @Test
240
-    public void testGetAndSetSelectedProfile() {
241
-        final Profile profile2 = createProfile("2");
242
-        final Profile profile3 = createProfile("3");
243
-        final Profile profile4 = createProfile("4");
244
-        final ProfileManagerModel instance = createModel();
245
-        assertEquals(defaultProfile, instance.getSelectedProfile());
246
-        instance.addProfile(profile2);
247
-        assertEquals(profile2, instance.getSelectedProfile());
248
-        instance.addProfile(profile3);
249
-        instance.setSelectedProfile(profile2);
250
-        assertEquals(profile2, instance.getSelectedProfile());
251
-        instance.setSelectedProfile(profile4);
252
-        assertNotSame(profile4, instance.getSelectedProfile());
253
-    }
254
-
255
-    /**
256
-     * Test of getNicknames method, of class ProfileManagerModel.
257
-     */
258
-    @Test
259
-    public void testGetAndSetNicknames() {
260
-        final ProfileManagerModel instance = createModel();
261
-        final List<String> expResult = defaultProfile.getNicknames();
262
-        List<String> result = instance.getNicknames();
263
-        assertEquals(expResult, result);
264
-        result = Arrays.asList(new String[]{"foo", "bar",});
265
-        instance.setNicknames(result);
266
-        assertEquals(result, instance.getNicknames());
267
-    }
268
-
269
-    /**
270
-     * Test of addNickname method, of class ProfileManagerModel.
271
-     */
272
-    @Test
273
-    public void testAddNickname() {
274
-        final String nickname = "foo";
275
-        final ProfileManagerModel instance = createModel();
276
-        assertEquals(defaultProfile.getNicknames(), instance.getNicknames());
277
-        final List<String> nicknames = new ArrayList<>(defaultProfile.getNicknames());
278
-        instance.addNickname(nickname);
279
-        nicknames.add(nickname);
280
-        assertEquals(nicknames, instance.getNicknames());
281
-    }
282
-
283
-    /**
284
-     * Test of deleteNickname method, of class ProfileManagerModel.
285
-     */
286
-    @Test
287
-    public void testDeleteNicknameObject() {
288
-        final ProfileManagerModel instance = createModel();
289
-        final List<String> nicknames = new ArrayList<>(instance.getNicknames());
290
-        Object nickname = (Object) "";
291
-        assertEquals(nicknames, instance.getNicknames());
292
-        instance.deleteNickname(nickname);
293
-        assertEquals(nicknames, instance.getNicknames());
294
-        nickname = new Object();
295
-        assertEquals(nicknames, instance.getNicknames());
296
-        instance.deleteNickname(nickname);
297
-        assertEquals(nicknames, instance.getNicknames());
298
-    }
299
-
300
-    /**
301
-     * Test selected nickname behaviour upon deleting nickname.
302
-     */
303
-    @Test
304
-    public void testDeleteNicknameNullSelectedProfile() {
305
-        final ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
306
-        assertNull(instance.getSelectedProfile());
307
-        assertTrue(instance.getNicknames().isEmpty());
308
-        instance.deleteNickname("1nickname");
309
-    }
310
-
311
-    /**
312
-     * Test selected nickname behaviour upon deleting nickname.
313
-     */
314
-    @Test
315
-    public void testDeleteNicknameNullNickname() {
316
-        final Profile profile = createProfile("1");
317
-        final String first = "1nickname";
318
-        final ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
319
-        instance.addProfile(profile);
320
-        instance.setSelectedProfile(profile);
321
-        instance.setSelectedNickname(first);
322
-        assertEquals(first, instance.getSelectedNickname());
323
-        instance.deleteNickname(null);
324
-        assertEquals(first, instance.getSelectedNickname());
325
-    }
326
-
327
-    /**
328
-     * Test selected nickname behaviour upon deleting nickname.
329
-     */
330
-    @Test
331
-    public void testDeleteNicknameNotSelected() {
332
-        final Profile profile = createProfile("1");
333
-        final String first = "1nickname";
334
-        final String second = "1nickname2";
335
-        final ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
336
-        instance.addProfile(profile);
337
-        instance.setSelectedProfile(profile);
338
-        instance.addNickname(second);
339
-        instance.setSelectedNickname(second);
340
-        assertEquals(second, instance.getSelectedNickname());
341
-        instance.deleteNickname(first);
342
-        assertEquals(second, instance.getSelectedNickname());
343
-    }
344
-
345
-    /**
346
-     * Test selected nickname behaviour upon deleting nickname.
347
-     */
348
-    @Test
349
-    public void testDeleteNicknameLastNickname() {
350
-        final Profile profile = createProfile("1");
351
-        final String first = "1nickname";
352
-        final String second = "1nickname2";
353
-        final ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
354
-        instance.addProfile(profile);
355
-        instance.setSelectedProfile(profile);
356
-        instance.addNickname(second);
357
-        instance.setSelectedNickname(second);
358
-        assertEquals(second, instance.getSelectedNickname());
359
-        instance.deleteNickname(second);
360
-        assertEquals(first, instance.getSelectedNickname());
361
-    }
362
-
363
-    /**
364
-     * Test selected nickname behaviour upon deleting nickname.
365
-     */
366
-    @Test
367
-    public void testDeleteNicknameFirstNickname() {
368
-        final Profile profile = createProfile("1");
369
-        final String first = "1nickname";
370
-        final String second = "1nickname2";
371
-        final ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
372
-        instance.addProfile(profile);
373
-        instance.setSelectedProfile(profile);
374
-        instance.addNickname(second);
375
-        instance.setSelectedNickname(first);
376
-        assertEquals(first, instance.getSelectedNickname());
377
-        instance.deleteNickname(first);
378
-        assertEquals(second, instance.getSelectedNickname());
379
-    }
380
-
381
-    /**
382
-     * Test selected nickname behaviour upon deleting nickname.
383
-     */
384
-    @Test
385
-    public void testDeleteNicknameMiddleNickname() {
386
-        final Profile profile = createProfile("1");
387
-        final String first = "1nickname";
388
-        final String second = "1nickname2";
389
-        final String third = "1nickname3";
390
-        final ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
391
-        instance.addProfile(profile);
392
-        instance.setSelectedProfile(profile);
393
-        instance.addNickname(second);
394
-        instance.addNickname(third);
395
-        instance.setSelectedNickname(second);
396
-        assertEquals(second, instance.getSelectedNickname());
397
-        instance.deleteNickname(second);
398
-        assertEquals(first, instance.getSelectedNickname());
399
-    }
400
-
401
-    /**
402
-     * Test selected nickname behaviour upon deleting nickname.
403
-     */
404
-    @Test
405
-    public void testDeleteNicknameOnlyNickname() {
406
-        final Profile profile = createProfile("1");
407
-        final String first = "1nickname";
408
-        final ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
409
-        instance.addProfile(profile);
410
-        instance.setSelectedProfile(profile);
411
-        instance.setSelectedNickname(first);
412
-        assertEquals(first, instance.getSelectedNickname());
413
-        instance.deleteNickname(first);
414
-        assertNull(instance.getSelectedNickname());
415
-    }
416
-
417
-    /**
418
-     * Test of setSelectedNickname method, of class ProfileManagerModel.
419
-     */
420
-    @Test
421
-    public void testGetAndSetSelectedNickname() {
422
-        final String selectedNickname = "1nickname";
423
-        final ProfileManagerModel instance = createModel();
424
-        assertNull(instance.getSelectedNickname());
425
-        instance.setSelectedNickname(selectedNickname);
426
-        assertEquals(selectedNickname, instance.getSelectedNickname());
427
-        instance.setSelectedNickname("foo");
428
-        assertNotSame("foo", instance.getSelectedNickname());
429
-    }
430
-
431
-    /**
432
-     * Test of editNickname method, of class ProfileManagerModel.
433
-     */
434
-    @Test
435
-    public void testEditNickname() {
436
-        final ProfileManagerModel instance = createModel();
437
-        final List<String> nicknames = new ArrayList<>(instance.getNicknames());
438
-        final String nickname = nicknames.get(0);
439
-        assertEquals(nicknames, instance.getNicknames());
440
-        instance.editNickname(nickname, "foo");
441
-        final int index = nicknames.indexOf(nickname);
442
-        nicknames.remove(nickname);
443
-        nicknames.add(index, "foo");
444
-        assertEquals(nicknames, instance.getNicknames());
445
-    }
446
-
447
-    /**
448
-     * Test of getName method, of class ProfileManagerModel.
449
-     */
450
-    @Test
451
-    public void testGetAndSetName() {
452
-        final ProfileManagerModel instance = createModel();
453
-        final String name = defaultProfile.getName();
454
-        final String newName = "foo";
455
-        assertEquals(name, instance.getName());
456
-        instance.setName(newName);
457
-        assertEquals(newName, ((Profile) instance.getSelectedProfile()).getName());
458
-    }
459
-
460
-    /**
461
-     * Test of getRealname method, of class ProfileManagerModel.
462
-     */
463
-    @Test
464
-    public void testGetAndSetRealname() {
465
-        final ProfileManagerModel instance = createModel();
466
-        final String name = "1realname";
467
-        final String newName = "foo";
468
-        assertEquals(name, instance.getRealname());
469
-        instance.setRealname(newName);
470
-        assertEquals(newName, ((Profile) instance.getSelectedProfile()).getRealname());
471
-    }
472
-
473
-    /**
474
-     * Test of getIdent method, of class ProfileManagerModel.
475
-     */
476
-    @Test
477
-    public void testGetAndSetIdent() {
478
-        final ProfileManagerModel instance = createModel();
479
-        final String name = "1ident";
480
-        final String newName = "foo";
481
-        assertEquals(name, instance.getIdent());
482
-        instance.setIdent(newName);
483
-        assertEquals(newName, ((Profile) instance.getSelectedProfile()).getIdent());
484
-    }
485
-
486
-    /**
487
-     * Test of isManipulateProfileAllowed method, of class ProfileManagerModel.
488
-     */
489
-    @Test
490
-    public void testIsManipulateProfileAllowed() {
491
-        final ProfileManagerModel instance = createModel();
492
-        assertTrue(instance.isManipulateProfileAllowed());
493
-        instance.setProfiles(Arrays.asList(new Profile[]{}));
494
-        assertFalse(instance.isManipulateProfileAllowed());
495
-    }
496
-
497
-    /**
498
-     * Test of isManipulateNicknameAllowed method, of class ProfileManagerModel.
499
-     */
500
-    @Test
501
-    public void testIsManipulateNicknameAllowed() {
502
-        final ProfileManagerModel instance = createModel();
503
-        assertFalse(instance.isManipulateNicknameAllowed());
504
-        instance.setSelectedNickname("1nickname");
505
-        assertTrue(instance.isManipulateNicknameAllowed());
506
-    }
507
-
508
-    @Test
509
-    public void testIsChangeProfileAllowed() {
510
-        final Profile profile = new Profile("New Profile", null);
511
-        profile.setName("*");
512
-        profile.setRealname("");
513
-        profile.setIdent("*");
514
-        final ProfileManagerModel instance = createModel();
515
-        assertTrue(instance.isChangeProfileAllowed());
516
-        instance.setProfiles(Arrays.asList(new Profile[]{profile,}));
517
-        assertFalse(instance.isChangeProfileAllowed());
518
-        profile.setName("profile");
519
-        assertFalse(instance.isChangeProfileAllowed());
520
-        profile.addNickname("nickname");
521
-        assertFalse(instance.isChangeProfileAllowed());
522
-        profile.setRealname("realname");
523
-        assertFalse(instance.isChangeProfileAllowed());
524
-        profile.setIdent("ident");
525
-        assertTrue(instance.isChangeProfileAllowed());
526
-    }
527
-
528
-    /**
529
-     * Test of isOKAllowed method, of class ProfileManagerModel.
530
-     */
531
-    @Test
532
-    public void testIsOKAllowed() {
533
-        final Profile profile = new Profile("New Profile", null);
534
-        profile.setName("*");
535
-        profile.setRealname("");
536
-        profile.setIdent("*");
537
-        final ProfileManagerModel instance = createModel();
538
-        assertTrue(instance.isOKAllowed());
539
-        instance.setProfiles(Arrays.asList(new Profile[]{}));
540
-        assertFalse(instance.isOKAllowed());
541
-        instance.setProfiles(Arrays.asList(new Profile[]{profile,}));
542
-        assertFalse(instance.isOKAllowed());
543
-        profile.setName("profile");
544
-        assertFalse(instance.isOKAllowed());
545
-        profile.addNickname("nickname");
546
-        assertFalse(instance.isOKAllowed());
547
-        profile.setRealname("realname");
548
-        assertFalse(instance.isOKAllowed());
549
-        profile.setIdent("ident");
550
-        assertTrue(instance.isOKAllowed());
551
-    }
552
-
553
-    /**
554
-     * Test of isNameValid method, of class ProfileManagerModel.
555
-     */
556
-    @Test
557
-    public void testIsNameInValid() {
558
-        final ProfileManagerModel instance = createModel();
559
-        instance.setProfiles(Arrays.asList(defaultProfile));
560
-        instance.setName("\\");
561
-        assertTrue(instance.isNameValid().isFailure());
562
-    }
563
-
564
-    /**
565
-     * Test of isNameValid method, of class ProfileManagerModel.
566
-     */
567
-    @Test
568
-    public void testIsNameValid() {
569
-        final ProfileManagerModel instance = createModel();
570
-        instance.setProfiles(Arrays.asList(defaultProfile));
571
-        instance.setName("profile");
572
-        assertFalse(instance.isNameValid().isFailure());
573
-    }
574
-
575
-    /**
576
-     * Test of isNicknamesValid method, of class ProfileManagerModel.
577
-     */
578
-    @Test
579
-    public void testIsNicknamesInValid() {
580
-        final ProfileManagerModel instance = createModel();
581
-        instance.setProfiles(Arrays.asList(defaultProfile));
582
-        instance.setNicknames(Arrays.asList(new String[]{}));
583
-        assertTrue(instance.isNicknamesValid().isFailure());
584
-    }
585
-
586
-    /**
587
-     * Test of isNicknamesValid method, of class ProfileManagerModel.
588
-     */
589
-    @Test
590
-    public void testIsNicknamesValid() {
591
-        final ProfileManagerModel instance = createModel();
592
-        instance.setProfiles(Arrays.asList(defaultProfile));
593
-        instance.setNicknames(Arrays.asList(new String[]{"nickname"}));
594
-        assertFalse(instance.isNicknamesValid().isFailure());
595
-    }
596
-
597
-    /**
598
-     * Test of isRealnameValid method, of class ProfileManagerModel.
599
-     */
600
-    @Test
601
-    public void testIsRealnameInValid() {
602
-        final ProfileManagerModel instance = createModel();
603
-        instance.setProfiles(Arrays.asList(defaultProfile));
604
-        instance.setRealname("");
605
-        assertTrue(instance.isRealnameValid().isFailure());
606
-    }
607
-
608
-    /**
609
-     * Test of isRealnameValid method, of class ProfileManagerModel.
610
-     */
611
-    @Test
612
-    public void testIsRealnameValid() {
613
-        final ProfileManagerModel instance = createModel();
614
-        instance.setProfiles(Arrays.asList(defaultProfile));
615
-        instance.setRealname("realname");
616
-        assertFalse(instance.isRealnameValid().isFailure());
617
-    }
618
-
619
-    /**
620
-     * Test of isIdentValid method, of class ProfileManagerModel.
621
-     */
622
-    @Test
623
-    public void testIsIdentInValid() {
624
-        final ProfileManagerModel instance = createModel();
625
-        instance.setProfiles(Arrays.asList(defaultProfile));
626
-        instance.setIdent("*");
627
-        assertTrue(instance.isIdentValid().isFailure());
628
-    }
629
-
630
-    /**
631
-     * Test of isIdentValid method, of class ProfileManagerModel.
632
-     */
633
-    @Test
634
-    public void testIsIdentValid() {
635
-        final ProfileManagerModel instance = createModel();
636
-        instance.setProfiles(Arrays.asList(defaultProfile));
637
-        instance.setIdent("ident");
638
-        assertFalse(instance.isIdentValid().isFailure());
639
-    }
640
-
641
-    /**
642
-     * Test of isIdentValid method, of class ProfileManagerModel.
643
-     */
644
-    @Test
645
-    public void testIsIdentValidEmptyString() {
646
-        final ProfileManagerModel instance = createModel();
647
-        instance.setProfiles(Arrays.asList(defaultProfile));
648
-        instance.setIdent("");
649
-        assertFalse(instance.isIdentValid().isFailure());
650
-    }
651
-
652
-    /**
653
-     * Test getters without selected profiles.
654
-     */
655
-    @Test
656
-    public void testNullSelectedProfileGetters() {
657
-        final ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
658
-        assertTrue("".equals(instance.getSelectedNickname()));
659
-        assertTrue("".equals(instance.getName()));
660
-        assertTrue("".equals(instance.getRealname()));
661
-        assertTrue("".equals(instance.getIdent()));
662
-        assertTrue(instance.getNicknames().isEmpty());
663
-    }
664
-
665
-    /**
666
-     * Test validators without selected profiles.
667
-     */
668
-    @Test
669
-    public void testNullSelectedProfileValidators() {
670
-        final ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
671
-        assertFalse(instance.isNameValid().isFailure());
672
-        assertFalse(instance.isNicknamesValid().isFailure());
673
-        assertFalse(instance.isRealnameValid().isFailure());
674
-        assertFalse(instance.isIdentValid().isFailure());
675
-    }
676
-
677
-    /**
678
-     * Test setters without selected profiles.
679
-     */
680
-    @Test
681
-    public void testNullSelectedProfileSetSelectedNickname() {
682
-        final String test = "test";
683
-        final ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
684
-        assertTrue("".equals(instance.getSelectedNickname()));
685
-        instance.setSelectedNickname(test);
686
-        assertTrue("".equals(instance.getSelectedNickname()));
687
-    }
688
-
689
-    /**
690
-     * Test setters without selected profiles.
691
-     */
692
-    @Test
693
-    public void testNullSelectedProfileSetName() {
694
-        final String test = "test";
695
-        final ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
696
-        assertTrue("".equals(instance.getName()));
697
-        instance.setName(test);
698
-        assertTrue("".equals(instance.getName()));
699
-    }
700
-
701
-    /**
702
-     * Test setters without selected profiles.
703
-     */
704
-    @Test
705
-    public void testNullSelectedProfileSetRealname() {
706
-        final String test = "test";
707
-        final ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
708
-        assertTrue("".equals(instance.getRealname()));
709
-        instance.setRealname(test);
710
-        assertTrue("".equals(instance.getRealname()));
711
-    }
712
-
713
-    /**
714
-     * Test setters without selected profiles.
715
-     */
716
-    @Test
717
-    public void testNullSelectedProfileSetIdent() {
718
-        final String test = "test";
719
-        final ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
720
-        assertTrue("".equals(instance.getIdent()));
721
-        instance.setIdent(test);
722
-        assertTrue("".equals(instance.getIdent()));
723
-    }
724
-
725
-    /**
726
-     * Test setters without selected profiles.
727
-     */
728
-    @Test
729
-    public void testNullSelectedProfileSetNicknames() {
730
-        final String test = "test";
731
-        final ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
732
-        assertTrue(instance.getNicknames().isEmpty());
733
-        instance.setNicknames(Arrays.asList(new String[]{test, }));
734
-        assertTrue(instance.getNicknames().isEmpty());
735
-    }
736
-
737
-    /**
738
-     * Test setters without selected profiles.
739
-     */
740
-    @Test
741
-    public void testNullSelectedProfileAddNickname() {
742
-        final String test = "test";
743
-        final ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
744
-        assertTrue(instance.getNicknames().isEmpty());
745
-        instance.addNickname(test);
746
-        assertTrue(instance.getNicknames().isEmpty());
747
-    }
748
-
749
-    /**
750
-     * Test setters without selected profiles.
751
-     */
752
-    @Test
753
-    public void testNullSelectedProfileDeleteNickname() {
754
-        final String test = "test";
755
-        final ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
756
-        assertTrue(instance.getNicknames().isEmpty());
757
-        instance.deleteNickname(test);
758
-        assertTrue(instance.getNicknames().isEmpty());
759
-    }
760
-
761
-    /**
762
-     * Test method save of class ProfileManagerModel
763
-     *
764
-     * @throws IOException
765
-     */
766
-    @Test
767
-    public void save() throws IOException {
768
-        final Profile first = mock(Profile.class);
769
-        final Profile second = mock(Profile.class);
770
-        when(first.isDeleted()).thenReturn(false);
771
-        when(second.isDeleted()).thenReturn(true);
772
-        final ProfileManagerModel instance = new ProfileManagerModel(manager, identityFactory);
773
-        instance.setProfiles(Arrays.asList(new Profile[]{first, second, }));
774
-        instance.save();
775
-        verify(first).save();
776
-        verify(second).delete();
777
-    }
778
-}

+ 0
- 87
ui_swing/test/com/dmdirc/addons/ui_swing/dialogs/profiles/ProfileNameValidatorTest.java View File

@@ -1,87 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2014 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
20
- * THE SOFTWARE.
21
- */
22
-package com.dmdirc.addons.ui_swing.dialogs.profiles;
23
-
24
-import com.dmdirc.actions.wrappers.Profile;
25
-
26
-import java.util.ArrayList;
27
-import java.util.List;
28
-
29
-import org.junit.Before;
30
-import org.junit.Test;
31
-import org.junit.runner.RunWith;
32
-import org.mockito.Mock;
33
-import org.mockito.runners.MockitoJUnitRunner;
34
-
35
-import static org.junit.Assert.assertFalse;
36
-import static org.junit.Assert.assertTrue;
37
-import static org.mockito.Mockito.when;
38
-
39
-/**
40
- * ProfileNameValidator tests.
41
- */
42
-@RunWith(MockitoJUnitRunner.class)
43
-public class ProfileNameValidatorTest {
44
-
45
-    @Mock private Profile other;
46
-    @Mock private Profile selected;
47
-    @Mock private ProfileManagerModel model;
48
-    private List<Profile> profiles;
49
-
50
-    @Before
51
-    public void setup() {
52
-        when(other.getName()).thenReturn("other");
53
-        when(selected.getName()).thenReturn("selected");
54
-        profiles = new ArrayList<>(2);
55
-        profiles.add(selected);
56
-        profiles.add(other);
57
-        when(model.getProfiles()).thenReturn(profiles);
58
-        when(model.getSelectedProfile()).thenReturn(selected);
59
-    }
60
-
61
-    /**
62
-     * Test of validate method, of class ProfileNameValidator.
63
-     */
64
-    @Test
65
-    public void testValidateNoDupes() {
66
-        final ProfileRenameValidator instance = new ProfileRenameValidator(model);
67
-        assertFalse(instance.validate("Random").isFailure());
68
-    }
69
-
70
-    /**
71
-     * Test of validate method, of class ProfileNameValidator.
72
-     */
73
-    @Test
74
-    public void testValidateNonSelectedDupe() {
75
-        final ProfileRenameValidator instance = new ProfileRenameValidator(model);
76
-        assertTrue(instance.validate("other").isFailure());
77
-    }
78
-
79
-    /**
80
-     * Test of validate method, of class ProfileNameValidator.
81
-     */
82
-    @Test
83
-    public void testValidateSelectedDupe() {
84
-        final ProfileRenameValidator instance = new ProfileRenameValidator(model);
85
-        assertFalse(instance.validate("selected").isFailure());
86
-    }
87
-}

Loading…
Cancel
Save