Browse Source

Channel list UI.

Fixes-Issue: CLIENT-8
Change-Id: Ib0598492cd63a59896634f4a74758c34d0d6853b
Reviewed-on: http://gerrit.dmdirc.com/2212
Reviewed-by: Chris Smith <chris@dmdirc.com>
Automatic-Compile: DMDirc Build Manager
tags/0.7rc1
Greg Holmes 12 years ago
parent
commit
3359e6b15c

+ 25
- 3
src/com/dmdirc/addons/ui_swing/adapters/ObservableListTableModelAdapter.java View File

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.adapters;
24 24
 
25
+import com.dmdirc.addons.ui_swing.UIUtilities;
25 26
 import com.dmdirc.util.ListObserver;
26 27
 import com.dmdirc.util.ObservableList;
27 28
 
@@ -67,21 +68,42 @@ public abstract class ObservableListTableModelAdapter<T> extends AbstractTableMo
67 68
         @Override
68 69
         public void onItemsAdded(final Object source, final int startIndex,
69 70
                 final int endIndex) {
70
-            fireTableRowsInserted(startIndex, endIndex);
71
+            UIUtilities.invokeLater(new Runnable() {
72
+
73
+                /** {@inheritDoc} */
74
+                @Override
75
+                public void run() {
76
+                    fireTableRowsInserted(startIndex, endIndex);
77
+                }
78
+            });
71 79
         }
72 80
 
73 81
         /** {@inheritDoc} */
74 82
         @Override
75 83
         public void onItemsRemoved(final Object source, final int startIndex,
76 84
                 final int endIndex) {
77
-            fireTableRowsDeleted(startIndex, endIndex);
85
+            UIUtilities.invokeLater(new Runnable() {
86
+
87
+                /** {@inheritDoc} */
88
+                @Override
89
+                public void run() {
90
+                    fireTableRowsDeleted(startIndex, endIndex);
91
+                }
92
+            });
78 93
         }
79 94
 
80 95
         /** {@inheritDoc} */
81 96
         @Override
82 97
         public void onItemsChanged(final Object source, final int startIndex,
83 98
                 final int endIndex) {
84
-            fireTableRowsUpdated(startIndex, endIndex);
99
+            UIUtilities.invokeLater(new Runnable() {
100
+
101
+                /** {@inheritDoc} */
102
+                @Override
103
+                public void run() {
104
+                    fireTableRowsUpdated(startIndex, endIndex);
105
+                }
106
+            });
85 107
         }
86 108
     }
87 109
 

+ 14
- 1
src/com/dmdirc/addons/ui_swing/components/menubar/ChannelMenu.java View File

@@ -29,6 +29,7 @@ import com.dmdirc.addons.ui_swing.MainFrame;
29 29
 import com.dmdirc.addons.ui_swing.SwingController;
30 30
 import com.dmdirc.addons.ui_swing.components.frames.TextFrame;
31 31
 import com.dmdirc.addons.ui_swing.dialogs.ChannelJoinDialog;
32
+import com.dmdirc.addons.ui_swing.dialogs.channellist.ChannelListDialog;
32 33
 
33 34
 import java.awt.Dialog.ModalityType;
34 35
 import java.awt.event.ActionEvent;
@@ -56,7 +57,7 @@ public class ChannelMenu extends JMenu implements ActionListener,
56 57
     /** Main frame. */
57 58
     private final MainFrame mainFrame;
58 59
     /** Menu items to be disabled/enabled. */
59
-    private JMenuItem csd, join;
60
+    private JMenuItem csd, join, list;
60 61
 
61 62
     /**
62 63
      * Creates a new channel menu.
@@ -92,6 +93,13 @@ public class ChannelMenu extends JMenu implements ActionListener,
92 93
         csd.setActionCommand("ChannelSettings");
93 94
         csd.addActionListener(this);
94 95
         add(csd);
96
+
97
+        list = new JMenuItem();
98
+        list.setText("List channels...");
99
+        list.setMnemonic('l');
100
+        list.setActionCommand("ListChannels");
101
+        list.addActionListener(this);
102
+        add(list);
95 103
     }
96 104
 
97 105
     /** {@inheritDoc} */
@@ -107,6 +115,8 @@ public class ChannelMenu extends JMenu implements ActionListener,
107 115
             if (activeWindow instanceof Channel) {
108 116
                 controller.showChannelSettingsDialog(((Channel) activeWindow));
109 117
             }
118
+        } else if (e.getActionCommand().equals("ListChannels")) {
119
+            new ChannelListDialog(controller).display();
110 120
         }
111 121
     }
112 122
 
@@ -123,6 +133,9 @@ public class ChannelMenu extends JMenu implements ActionListener,
123 133
         csd.setEnabled(activeWindow instanceof Channel && activeWindow
124 134
                 .getServer() != null && activeWindow.getServer().getState()
125 135
                 == ServerState.CONNECTED);
136
+        list.setEnabled(activeWindow instanceof Channel && activeWindow
137
+                .getServer() != null && activeWindow.getServer().getState()
138
+                == ServerState.CONNECTED);
126 139
     }
127 140
 
128 141
     /** {@inheritDoc} */

+ 2
- 0
src/com/dmdirc/addons/ui_swing/dialogs/StandardDialog.java View File

@@ -68,6 +68,7 @@ public class StandardDialog extends JDialog {
68 68
             setIconImages(owner.getIconImages());
69 69
         }
70 70
         orderButtons(new JButton(), new JButton());
71
+        setDefaultCloseOperation(DISPOSE_ON_CLOSE);
71 72
     }
72 73
 
73 74
     /**
@@ -83,6 +84,7 @@ public class StandardDialog extends JDialog {
83 84
             setIconImages(owner.getIconImages());
84 85
         }
85 86
         orderButtons(new JButton(), new JButton());
87
+        setDefaultCloseOperation(DISPOSE_ON_CLOSE);
86 88
     }
87 89
 
88 90
     /**

+ 70
- 0
src/com/dmdirc/addons/ui_swing/dialogs/channellist/ChannelListDialog.java View File

@@ -0,0 +1,70 @@
1
+/*
2
+ * Copyright (c) 2006-2011 DMDirc Developers
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.addons.ui_swing.dialogs.channellist;
24
+
25
+import com.dmdirc.addons.ui_swing.SwingController;
26
+import com.dmdirc.addons.ui_swing.dialogs.StandardDialog;
27
+
28
+import java.awt.event.ActionEvent;
29
+import java.awt.event.ActionListener;
30
+
31
+import net.miginfocom.swing.MigLayout;
32
+
33
+/**
34
+ * Provides a UI to search for channels in DMDirc.
35
+ */
36
+public class ChannelListDialog extends StandardDialog implements
37
+        ActionListener {
38
+
39
+    /** Serial version UID. */
40
+    private static final long serialVersionUID = 1L;
41
+    /** List panel. */
42
+    private ChannelListPanel list;
43
+
44
+    public ChannelListDialog(final SwingController controller) {
45
+        super(controller.getMainFrame(), ModalityType.MODELESS);
46
+        setTitle("Channel List");
47
+        list = new ChannelListPanel(controller.getMainFrame().getActiveFrame().getContainer().getServer());
48
+        layoutComponents();
49
+        getCancelButton().setText("Close");
50
+        getCancelButton().addActionListener(this);
51
+    }
52
+
53
+    /** Lays out the components in this dialog. */
54
+    private void layoutComponents() {
55
+        setLayout(new MigLayout("fill, wmin 40%, hmin 40%, hidemode 3"));
56
+        add(list, "grow, push, wrap");
57
+        add(getCancelButton(), "split, right");
58
+    }
59
+
60
+    /**
61
+     * {@inheritDoc}
62
+     *
63
+     * @param e Action event
64
+     */
65
+    @Override
66
+    public void actionPerformed(final ActionEvent e) {
67
+        dispose();
68
+    }
69
+
70
+}

+ 64
- 0
src/com/dmdirc/addons/ui_swing/dialogs/channellist/ChannelListPanel.java View File

@@ -0,0 +1,64 @@
1
+/*
2
+ * Copyright (c) 2006-2011 DMDirc Developers
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.addons.ui_swing.dialogs.channellist;
24
+
25
+import com.dmdirc.Server;
26
+import com.dmdirc.lists.GroupListManager;
27
+
28
+import javax.swing.JPanel;
29
+
30
+import net.miginfocom.swing.MigLayout;
31
+
32
+/**
33
+ * Panel to perform and display a group list search.
34
+ */
35
+public class ChannelListPanel extends JPanel {
36
+
37
+    /** Serial version UID. */
38
+    private static final long serialVersionUID = 1L;
39
+    /** Search terms. */
40
+    private SearchTermsPanel searchTerms;
41
+    /** Search results. */
42
+    private ResultsPanel results;
43
+    /** Group list manager to show results/perform searching. */
44
+    private GroupListManager manager;
45
+
46
+    /**
47
+     * Creates a new panel to perform a group list search on a server.
48
+     *
49
+     * @param server Server on which to perform search
50
+     */
51
+    public ChannelListPanel(final Server server) {
52
+        manager = new GroupListManager(server);
53
+        searchTerms = new SearchTermsPanel(manager);
54
+        results = new ResultsPanel(manager);
55
+        layoutComponents();
56
+    }
57
+
58
+    /** Lays out the components in the panel. */
59
+    private void layoutComponents() {
60
+        setLayout(new MigLayout("fill, hidemode 3, ins 0"));
61
+        add(searchTerms, "growx, wrap");
62
+        add(results, "grow, push");
63
+    }
64
+}

+ 62
- 0
src/com/dmdirc/addons/ui_swing/dialogs/channellist/ResultsPanel.java View File

@@ -0,0 +1,62 @@
1
+/*
2
+ * Copyright (c) 2006-2011 DMDirc Developers
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.addons.ui_swing.dialogs.channellist;
24
+
25
+import com.dmdirc.addons.ui_swing.components.PackingTable;
26
+import com.dmdirc.lists.GroupListManager;
27
+
28
+import javax.swing.JPanel;
29
+import javax.swing.JScrollPane;
30
+
31
+import net.miginfocom.swing.MigLayout;
32
+
33
+/**
34
+ * Displays the results of a group list search in a table.
35
+ */
36
+public class ResultsPanel extends JPanel {
37
+
38
+    /** Serial version UID. */
39
+    private static final long serialVersionUID = 1L;
40
+    /** Group list manager to perform searches on. */
41
+    private GroupListManager manager;
42
+
43
+    /**
44
+     * Creates a new panel to show group list results.
45
+     *
46
+     * @param manager Group manager to show results
47
+     */
48
+    public ResultsPanel(final GroupListManager manager) {
49
+        this.manager = manager;
50
+        layoutComponents();
51
+    }
52
+
53
+    /** Lays out the components in the panel. */
54
+    private void layoutComponents() {
55
+        final JScrollPane sp = new JScrollPane();
56
+        final PackingTable table = new PackingTable(
57
+                new ChannelListTableModel(manager), sp);
58
+        sp.setViewportView(table);
59
+        setLayout(new MigLayout("fill, hidemode 3, ins 0"));
60
+        add(sp, "grow, push");
61
+    }
62
+}

+ 79
- 0
src/com/dmdirc/addons/ui_swing/dialogs/channellist/SearchTermsPanel.java View File

@@ -0,0 +1,79 @@
1
+/*
2
+ * Copyright (c) 2006-2011 DMDirc Developers
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.addons.ui_swing.dialogs.channellist;
24
+
25
+import com.dmdirc.lists.GroupListManager;
26
+
27
+import java.awt.event.ActionEvent;
28
+import java.awt.event.ActionListener;
29
+
30
+import javax.swing.JButton;
31
+import javax.swing.JLabel;
32
+import javax.swing.JPanel;
33
+import javax.swing.JTextField;
34
+
35
+import net.miginfocom.swing.MigLayout;
36
+
37
+/**
38
+ * Gathers input for a group list search and begins the search.
39
+ */
40
+public class SearchTermsPanel extends JPanel implements ActionListener {
41
+
42
+    /** Serial version UID. */
43
+    private static final long serialVersionUID = 1L;
44
+    /** Group list manager to perform searches on. */
45
+    private GroupListManager manager;
46
+    /** Search terms input field. */
47
+    private JTextField searchTerms;
48
+
49
+    /**
50
+     * Creates a new panel to gather input for a group list search.
51
+     *
52
+     * @param manager Group list manager to perform search with
53
+     */
54
+    public SearchTermsPanel(final GroupListManager manager) {
55
+        this.manager = manager;
56
+        searchTerms = new JTextField();
57
+        layoutComponents();
58
+    }
59
+
60
+    /** Lays out the components in the panel. */
61
+    private void layoutComponents() {
62
+        final JButton search = new JButton("Search");
63
+        search.addActionListener(this);
64
+        setLayout(new MigLayout("fill, hidemode 3, ins 0"));
65
+        add(new JLabel("Search terms: "), "align label");
66
+        add(searchTerms, "growx, pushx");
67
+        add(search, "");
68
+    }
69
+
70
+    /**
71
+     * {@inheritDoc}
72
+     *
73
+     * @param e Action event
74
+     */
75
+    @Override
76
+    public void actionPerformed(final ActionEvent e) {
77
+        manager.startSearch(searchTerms.getText());
78
+    }
79
+}

Loading…
Cancel
Save