Bläddra i källkod

* Added Formatter.hasFormat

* Added topics pane to channel settings dialog

git-svn-id: http://svn.dmdirc.com/trunk@494 00569f92-eb28-0410-84fd-f71c24880f
tags/0.3
Chris Smith 17 år sedan
förälder
incheckning
9592e243b1

+ 56
- 38
src/uk/org/ownage/dmdirc/ui/ChannelSettingsDialog.java Visa fil

@@ -61,12 +61,6 @@ public class ChannelSettingsDialog extends StandardDialog
61 61
     
62 62
     private Channel channel;
63 63
     
64
-    private JTabbedPane tabbedPane;
65
-    private JPanel settingsPanel;
66
-    private JPanel identitiesPanel;
67
-    private JButton button1;
68
-    private JButton button2;
69
-    private JPanel modesPanel;
70 64
     private Hashtable<String, JCheckBox> modeCheckBoxes;
71 65
     private Hashtable<String, ParamModePanel> modeInputs;
72 66
     
@@ -83,32 +77,20 @@ public class ChannelSettingsDialog extends StandardDialog
83 77
         initListeners();
84 78
     }
85 79
     
86
-    /** Initialises GUI components. */
80
+    // <editor-fold defaultstate="collapsed" desc=" UI initialisation code ">
81
+    /** Initialises the main UI components. */
87 82
     private void initComponents() {
88
-        // --- Set up the main interface
89
-        
90 83
         GridBagConstraints constraints = new GridBagConstraints();
84
+        final JTabbedPane tabbedPane = new JTabbedPane();
91 85
         
92 86
         setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
93
-        setResizable(false);
94
-        
95
-        setTitle("Channel settings for " + channel);
96
-        
97 87
         getContentPane().setLayout(new GridBagLayout());
88
+        setTitle("Channel settings for " + channel);
89
+        setResizable(false);
98 90
         
99
-        settingsPanel = new JPanel(new GridBagLayout());
100
-        //settingsPanel.setPreferredSize(new Dimension(400,400));
101
-        
102
-        identitiesPanel = new JPanel(new GridBagLayout());
103
-        //identitiesPanel.setPreferredSize(new Dimension(400,400));
104
-        
105
-        tabbedPane = new JTabbedPane();
106
-        tabbedPane.addTab("IRC Settings", settingsPanel);
107
-        tabbedPane.addTab("Client Settings", identitiesPanel);
108
-        
109
-        button1 = new JButton();
91
+        final JButton button1 = new JButton();
110 92
         button1.setPreferredSize(new Dimension(100, 25));
111
-        button2 = new JButton();
93
+        final JButton button2 = new JButton();
112 94
         button2.setPreferredSize(new Dimension(100, 25));
113 95
         
114 96
         constraints.gridx = 0;
@@ -131,25 +113,45 @@ public class ChannelSettingsDialog extends StandardDialog
131 113
         
132 114
         orderButtons(button1, button2);
133 115
         
134
-        // --- Set up the channel settings page
116
+        initIrcTab(tabbedPane);
135 117
         
136
-        settingsPanel.setBorder(new EmptyBorder(10, 10, 10, 10));
118
+        pack();
119
+    }
120
+    
121
+    /**
122
+     * Initialises the IRC Settings tab.
123
+     * @param tabbedPane The pane to add the IRC Settings tab to
124
+     */
125
+    private void initIrcTab(JTabbedPane tabbedPane) {
126
+        final JPanel settingsPanel = new JPanel(new GridBagLayout());
137 127
         
138
-        constraints = new GridBagConstraints();
139
-        constraints.fill = GridBagConstraints.BOTH;
140
-        constraints.anchor = GridBagConstraints.NORTH;
141
-        modesPanel = new JPanel(new GridBagLayout());
142
-        modesPanel.setBorder(new TitledBorder(new EtchedBorder(),"Channel Modes"));
143
-        //modesPanel.setPreferredSize(new Dimension(380, 200));
144
-        settingsPanel.add(modesPanel, constraints);
128
+        tabbedPane.addTab("IRC Settings", settingsPanel);
145 129
         
146
-        final IRCParser parser = channel.getServer().getParser();
130
+        settingsPanel.setBorder(new EmptyBorder(10, 10, 10, 10));
147 131
         
132
+        initModesPanel(settingsPanel);
133
+        initTopicsPanel(settingsPanel);
134
+    }
135
+    
136
+    /**
137
+     * Initialises the modes panel.
138
+     * @param parent The panel to add the modes panel to
139
+     */
140
+    private void initModesPanel(JPanel parent) {
141
+        final GridBagConstraints constraints = new GridBagConstraints();
142
+        final JPanel modesPanel = new JPanel(new GridBagLayout());
143
+        final IRCParser parser = channel.getServer().getParser();
148 144
         final String booleanModes = parser.getBoolChanModes();
149 145
         final String ourBooleanModes = channel.getChannelInfo().getModeStr();
150 146
         final String paramModes = parser.getSetOnlyChanModes()+parser.getSetUnsetChanModes();
151 147
         final String listModes = parser.getListChanModes();
152 148
         
149
+        constraints.fill = GridBagConstraints.BOTH;
150
+        constraints.anchor = GridBagConstraints.NORTH;
151
+        
152
+        modesPanel.setBorder(new TitledBorder(new EtchedBorder(),"Channel Modes"));
153
+        parent.add(modesPanel, constraints);
154
+        
153 155
         modeCheckBoxes = new Hashtable<String, JCheckBox>();
154 156
         
155 157
         constraints.gridx = 0;
@@ -203,13 +205,29 @@ public class ChannelSettingsDialog extends StandardDialog
203 205
             constraints.gridy++;
204 206
         }
205 207
         
206
-        pack();
207 208
     }
208 209
     
210
+    /**
211
+     * Initialises the topic panel.
212
+     * @param parent The panel to add the topics panel to
213
+     */
214
+    private void initTopicsPanel(JPanel parent) {
215
+        final GridBagConstraints constraints = new GridBagConstraints();
216
+        final JPanel topicsPanel = new JPanel(new GridBagLayout());
217
+        
218
+        constraints.fill = GridBagConstraints.BOTH;
219
+        constraints.anchor = GridBagConstraints.NORTH;
220
+        constraints.gridy = 1;
221
+        
222
+        topicsPanel.setBorder(new TitledBorder(new EtchedBorder(),"Channel Topic"));
223
+        parent.add(topicsPanel, constraints);
224
+    }
225
+    // </editor-fold>
226
+    
209 227
     /** Initialises listeners for this dialog. */
210 228
     private void initListeners() {
211
-        button1.addActionListener(this);
212
-        button2.addActionListener(this);
229
+        getOkButton().addActionListener(this);
230
+        getCancelButton().addActionListener(this);
213 231
     }
214 232
     
215 233
     /**

+ 13
- 0
src/uk/org/ownage/dmdirc/ui/messages/Formatter.java Visa fil

@@ -69,6 +69,19 @@ public final class Formatter {
69 69
         }
70 70
     }
71 71
     
72
+    /**
73
+     * Determines whether the formatter knows of a specific message type.
74
+     * @param messageType the message type to check
75
+     * @return True iff there is a matching format, false otherwise
76
+     */
77
+    public static boolean hashFormat(String messageType) {
78
+        if (properties == null) {
79
+            initialise();
80
+        }
81
+        
82
+        return properties.containsKey(messageType);
83
+    }
84
+    
72 85
     /**
73 86
      * Returns the default format strings for the client.
74 87
      * @return The default format strings

Laddar…
Avbryt
Spara