Browse Source

Window titles are now handled by the core

Fixes issue 3996

Change-Id: I562e5db0da3af91b880cd98c9af11712750bf9f0
Reviewed-on: http://gerrit.dmdirc.com/1118
Automatic-Compile: Gregory Holmes <greg@dmdirc.com>
Reviewed-by: Gregory Holmes <greg@dmdirc.com>
tags/0.6.4rc1
Chris Smith 14 years ago
parent
commit
bec66870a7

+ 3
- 2
src/com/dmdirc/Channel.java View File

96
      */
96
      */
97
     public Channel(final Server newServer, final ChannelInfo newChannelInfo) {
97
     public Channel(final Server newServer, final ChannelInfo newChannelInfo) {
98
         super("channel-inactive", newChannelInfo.getName(),
98
         super("channel-inactive", newChannelInfo.getName(),
99
+                Styliser.stipControlCodes(newChannelInfo.getName()),
99
                 new ConfigManager(newServer.getProtocol(), newServer.getIrcd(),
100
                 new ConfigManager(newServer.getProtocol(), newServer.getIrcd(),
100
                 newServer.getNetwork(), newServer.getAddress(), newChannelInfo.getName()));
101
                 newServer.getNetwork(), newServer.getAddress(), newChannelInfo.getName()));
101
 
102
 
298
             temp = temp + " - " + Styliser.stipControlCodes(channelInfo.getTopic());
299
             temp = temp + " - " + Styliser.stipControlCodes(channelInfo.getTopic());
299
         }
300
         }
300
 
301
 
301
-        window.setTitle(temp);
302
+        setTitle(temp);
302
     }
303
     }
303
 
304
 
304
     /**
305
     /**
507
         res[3] = client.getClient().getHostname();
508
         res[3] = client.getClient().getHostname();
508
 
509
 
509
         if (showColours) {
510
         if (showColours) {
510
-            final Map map = client.getMap();
511
+            final Map<?,?> map = client.getMap();
511
             String prefix = null;
512
             String prefix = null;
512
             Color colour;
513
             Color colour;
513
 
514
 

+ 2
- 19
src/com/dmdirc/CustomWindow.java View File

33
  */
33
  */
34
 public class CustomWindow extends FrameContainer {
34
 public class CustomWindow extends FrameContainer {
35
 
35
 
36
-    /** This custom window's title. */
37
-    private final String title;
38
-
39
     /** The window used by this container. */
36
     /** The window used by this container. */
40
     private Window window;
37
     private Window window;
41
 
38
 
51
      */
48
      */
52
     public CustomWindow(final String name, final String title,
49
     public CustomWindow(final String name, final String title,
53
             final Window parent) {
50
             final Window parent) {
54
-        super("custom", name, parent.getConfigManager());
51
+        super("custom", name, title, parent.getConfigManager());
55
 
52
 
56
-        this.title = title;
57
         this.parent = parent;
53
         this.parent = parent;
58
 
54
 
59
         window = Main.getUI().getWindow(this);
55
         window = Main.getUI().getWindow(this);
60
-        window.setTitle(title);
61
 
56
 
62
         WindowManager.addWindow(parent, window);
57
         WindowManager.addWindow(parent, window);
63
 
58
 
71
      * @param title The parent of this custom window
66
      * @param title The parent of this custom window
72
      */
67
      */
73
     public CustomWindow(final String name, final String title) {
68
     public CustomWindow(final String name, final String title) {
74
-        super("custom", name, IdentityManager.getGlobalConfig());
75
-
76
-        this.title = title;
69
+        super("custom", name, title, IdentityManager.getGlobalConfig());
77
 
70
 
78
         window = Main.getUI().getWindow(this);
71
         window = Main.getUI().getWindow(this);
79
-        window.setTitle(title);
80
 
72
 
81
         WindowManager.addWindow(this);
73
         WindowManager.addWindow(this);
82
 
74
 
118
         return parent == null ? null : parent.getContainer().getServer();
110
         return parent == null ? null : parent.getContainer().getServer();
119
     }
111
     }
120
 
112
 
121
-    /**
122
-     * Retrieves this custom window's title.
123
-     *
124
-     * @return This custom window's title
125
-     */
126
-    public String getTitle() {
127
-        return title;
128
-    }
129
-
130
 }
113
 }

+ 34
- 2
src/com/dmdirc/FrameContainer.java View File

79
     /** The name of this container. */
79
     /** The name of this container. */
80
     private String name;
80
     private String name;
81
 
81
 
82
+    /** The title of this container. */
83
+    private String title;
84
+
82
     /** The transcoder to use for this container. */
85
     /** The transcoder to use for this container. */
83
     private final StringTranscoder transcoder;
86
     private final StringTranscoder transcoder;
84
     
87
     
96
      * 
99
      * 
97
      * @param icon The icon to use for this container
100
      * @param icon The icon to use for this container
98
      * @param name The name of this container
101
      * @param name The name of this container
102
+     * @param title The title of this container
99
      * @param config The config manager for this container
103
      * @param config The config manager for this container
100
-     * @since 0.6.3m2
104
+     * @since 0.6.4
101
      */
105
      */
102
-    public FrameContainer(final String icon, final String name, final ConfigManager config) {
106
+    public FrameContainer(final String icon, final String name,
107
+            final String title, final ConfigManager config) {
103
         this.config = config;
108
         this.config = config;
104
         this.name = name;
109
         this.name = name;
110
+        this.title = title;
105
         this.styliser = new Styliser(this);
111
         this.styliser = new Styliser(this);
106
         this.document = new IRCDocument(this);
112
         this.document = new IRCDocument(this);
107
 
113
 
236
         }
242
         }
237
     }
243
     }
238
 
244
 
245
+    /**
246
+     * Retrieves the title which should be used by this container's windows.
247
+     *
248
+     * @return This container's title
249
+     * @since 0.6.4
250
+     */
251
+    public String getTitle() {
252
+        return title;
253
+    }
254
+
255
+    /**
256
+     * Changes the title of this container, and notifies any
257
+     * {@link FrameInfoListener}s of the change.
258
+     *
259
+     * @param title The new title for this frame.
260
+     */
261
+    public void setTitle(final String title) {
262
+        this.title = title;
263
+
264
+        synchronized (listeners) {
265
+            for (FrameInfoListener listener : listeners.get(FrameInfoListener.class)) {
266
+                listener.titleChanged(this, name);
267
+            }
268
+        }
269
+    }
270
+
239
     /**
271
     /**
240
      * Closes this container (and it's associated frame).
272
      * Closes this container (and it's associated frame).
241
      */
273
      */

+ 1
- 2
src/com/dmdirc/GlobalWindow.java View File

51
 
51
 
52
     /** Creates a new instance of GlobalWindow. */
52
     /** Creates a new instance of GlobalWindow. */
53
     public GlobalWindow() {
53
     public GlobalWindow() {
54
-        super("icon", "Global", IdentityManager.getGlobalConfig());
54
+        super("icon", "Global", "(Global)", IdentityManager.getGlobalConfig());
55
 
55
 
56
         tabCompleter = new TabCompleter();
56
         tabCompleter = new TabCompleter();
57
         tabCompleter.addEntries(TabCompletionType.COMMAND,
57
         tabCompleter.addEntries(TabCompletionType.COMMAND,
61
 
61
 
62
         window = Main.getUI().getInputWindow(this, GlobalCommandParser.getGlobalCommandParser());
62
         window = Main.getUI().getInputWindow(this, GlobalCommandParser.getGlobalCommandParser());
63
 
63
 
64
-        window.setTitle("(Global)");
65
         window.getInputHandler().setTabCompleter(tabCompleter);
64
         window.getInputHandler().setTabCompleter(tabCompleter);
66
 
65
 
67
         WindowManager.addWindow(this);
66
         WindowManager.addWindow(this);

+ 5
- 3
src/com/dmdirc/MessageTarget.java View File

37
      * 
37
      * 
38
      * @param icon The icon to use for this target
38
      * @param icon The icon to use for this target
39
      * @param name The name of this target
39
      * @param name The name of this target
40
+     * @param title The title of this target
40
      * @param config The config manager to use for this target
41
      * @param config The config manager to use for this target
41
-     * @since 0.6.3m2
42
+     * @since 0.6.4
42
      */
43
      */
43
-    public MessageTarget(final String icon, final String name, final ConfigManager config) {
44
-        super(icon, name, config);
44
+    public MessageTarget(final String icon, final String name,
45
+            final String title, final ConfigManager config) {
46
+        super(icon, name, title, config);
45
     }
47
     }
46
 
48
 
47
     /**
49
     /**

+ 4
- 3
src/com/dmdirc/Query.java View File

74
      */
74
      */
75
     public Query(final Server newServer, final String newHost) {
75
     public Query(final Server newServer, final String newHost) {
76
         super("query", newServer.getParser().parseHostmask(newHost)[0],
76
         super("query", newServer.getParser().parseHostmask(newHost)[0],
77
+                newServer.getParser().parseHostmask(newHost)[0],
77
                 newServer.getConfigManager());
78
                 newServer.getConfigManager());
78
 
79
 
79
         this.server = newServer;
80
         this.server = newServer;
133
             return;
134
             return;
134
         }
135
         }
135
 
136
 
136
-        for (String part : splitLine(window.getTranscoder().encode(line))) {
137
+        for (String part : splitLine(getTranscoder().encode(line))) {
137
             if (!part.isEmpty()) {
138
             if (!part.isEmpty()) {
138
                 server.getParser().sendMessage(getNickname(), part);
139
                 server.getParser().sendMessage(getNickname(), part);
139
 
140
 
182
 
183
 
183
         if (maxLineLength >= action.length() + 2) {
184
         if (maxLineLength >= action.length() + 2) {
184
             server.getParser().sendAction(getNickname(),
185
             server.getParser().sendAction(getNickname(),
185
-                    window.getTranscoder().encode(action));
186
+                    getTranscoder().encode(action));
186
 
187
 
187
             doNotification("querySelfAction", CoreActionType.QUERY_SELF_ACTION,
188
             doNotification("querySelfAction", CoreActionType.QUERY_SELF_ACTION,
188
                     server.getParser().getLocalClient(), action);
189
                     server.getParser().getLocalClient(), action);
235
      * Updates the QueryWindow's title.
236
      * Updates the QueryWindow's title.
236
      */
237
      */
237
     private void updateTitle() {
238
     private void updateTitle() {
238
-        window.setTitle(getNickname());
239
+        setTitle(getNickname());
239
     }
240
     }
240
 
241
 
241
     /**
242
     /**

+ 2
- 3
src/com/dmdirc/Raw.java View File

53
      * @param commandParser Command parser to use
53
      * @param commandParser Command parser to use
54
      */
54
      */
55
     public Raw(final Server newServer, final CommandParser commandParser) {
55
     public Raw(final Server newServer, final CommandParser commandParser) {
56
-        super("raw", "Raw", newServer.getConfigManager());
56
+        super("raw", "Raw", "(Raw log)", newServer.getConfigManager());
57
 
57
 
58
         this.server = newServer;
58
         this.server = newServer;
59
 
59
 
60
         window = Main.getUI().getInputWindow(this, commandParser);
60
         window = Main.getUI().getInputWindow(this, commandParser);
61
         WindowManager.addWindow(server, this);
61
         WindowManager.addWindow(server, this);
62
-        window.setTitle("(Raw log)");
63
         window.getInputHandler().setTabCompleter(server.getTabCompleter());
62
         window.getInputHandler().setTabCompleter(server.getTabCompleter());
64
 
63
 
65
         window.open();
64
         window.open();
135
     @Override
134
     @Override
136
     public void sendLine(final String line) {
135
     public void sendLine(final String line) {
137
         if (!line.isEmpty()) {
136
         if (!line.isEmpty()) {
138
-            server.sendLine(window.getTranscoder().encode(line));
137
+            sendLine(getTranscoder().encode(line));
139
         }
138
         }
140
     }
139
     }
141
 
140
 

+ 2
- 2
src/com/dmdirc/Server.java View File

173
      * @param profile The profile to use
173
      * @param profile The profile to use
174
      */
174
      */
175
     public Server(final URI uri, final Identity profile) {
175
     public Server(final URI uri, final Identity profile) {
176
-        super("server-disconnected", uri.getHost(),
176
+        super("server-disconnected", uri.getHost(), uri.getHost(),
177
                 new ConfigManager(uri.getScheme(), "", "", uri.getHost()));
177
                 new ConfigManager(uri.getScheme(), "", "", uri.getHost()));
178
 
178
 
179
         this.address = uri;
179
         this.address = uri;
1240
 
1240
 
1241
                 setName(Formatter.formatMessage(getConfigManager(),
1241
                 setName(Formatter.formatMessage(getConfigManager(),
1242
                         "serverName", arguments));
1242
                         "serverName", arguments));
1243
-                window.setTitle(Formatter.formatMessage(getConfigManager(),
1243
+                setTitle(Formatter.formatMessage(getConfigManager(),
1244
                         "serverTitle", arguments));
1244
                         "serverTitle", arguments));
1245
             }
1245
             }
1246
         }
1246
         }

+ 5
- 3
src/com/dmdirc/WritableFrameContainer.java View File

54
      * 
54
      * 
55
      * @param icon The icon to use for this container
55
      * @param icon The icon to use for this container
56
      * @param name The name of this container
56
      * @param name The name of this container
57
+     * @param title The title of this container
57
      * @param config The config manager for this container
58
      * @param config The config manager for this container
58
-     * @since 0.6.3m2
59
+     * @since 0.6.4
59
      */
60
      */
60
-    public WritableFrameContainer(final String icon, final String name, final ConfigManager config) {
61
-        super(icon, name, config);
61
+    public WritableFrameContainer(final String icon, final String name,
62
+            final String title, final ConfigManager config) {
63
+        super(icon, name, title, config);
62
     }
64
     }
63
     
65
     
64
     /**
66
     /**

+ 0
- 46
src/com/dmdirc/interfaces/FrameInfoAdapter.java View File

1
-/*
2
- * Copyright (c) 2006-2010 Chris Smith, Shane Mc Cormack, Gregory Holmes
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.interfaces;
24
-
25
-import com.dmdirc.FrameContainer;
26
-
27
-/**
28
- * An adapter for {@link FrameInfoListener}.
29
- *
30
- * @author chris
31
- */
32
-public class FrameInfoAdapter implements FrameInfoListener {
33
-
34
-    /** {@inheritDoc} */
35
-    @Override
36
-    public void iconChanged(final FrameContainer window, final String icon) {
37
-        // Do nothing
38
-    }
39
-
40
-    /** {@inheritDoc} */
41
-    @Override
42
-    public void nameChanged(final FrameContainer window, final String name) {
43
-        // Do nothing
44
-    }
45
-
46
-}

+ 8
- 0
src/com/dmdirc/interfaces/FrameInfoListener.java View File

51
      */
51
      */
52
     void nameChanged(final FrameContainer window, final String name);
52
     void nameChanged(final FrameContainer window, final String name);
53
 
53
 
54
+    /**
55
+     * Called when a window's title is changed.
56
+     *
57
+     * @param window The window whose title changed
58
+     * @param title The new title for the window
59
+     */
60
+    void titleChanged(final FrameContainer window, final String title);
61
+
54
 }
62
 }

+ 31
- 30
src/com/dmdirc/ui/interfaces/Window.java View File

32
  * by all windows. It is assumed that all windows have a main text area.
32
  * by all windows. It is assumed that all windows have a main text area.
33
  */
33
  */
34
 public interface Window {
34
 public interface Window {
35
-    
35
+
36
     /**
36
     /**
37
      * Formats the arguments using the Formatter, then adds the result to the
37
      * Formats the arguments using the Formatter, then adds the result to the
38
      * main text area.
38
      * main text area.
43
      */
43
      */
44
     @Deprecated
44
     @Deprecated
45
     void addLine(String messageType, Object... args);
45
     void addLine(String messageType, Object... args);
46
-    
46
+
47
     /**
47
     /**
48
      * Formats the arguments using the Formatter, then adds the result to the
48
      * Formats the arguments using the Formatter, then adds the result to the
49
      * main text area.
49
      * main text area.
54
      */
54
      */
55
     @Deprecated
55
     @Deprecated
56
     void addLine(StringBuffer messageType, Object... args);
56
     void addLine(StringBuffer messageType, Object... args);
57
-    
57
+
58
     /**
58
     /**
59
      * Adds the specified raw line to the window, without using a formatter.
59
      * Adds the specified raw line to the window, without using a formatter.
60
-     * 
60
+     *
61
      * @param line The line to be added
61
      * @param line The line to be added
62
      * @param timestamp Whether or not to display the timestamp for this line
62
      * @param timestamp Whether or not to display the timestamp for this line
63
      * @deprecated Use corresponding methods in {@link FrameContainer} instead
63
      * @deprecated Use corresponding methods in {@link FrameContainer} instead
64
      */
64
      */
65
     @Deprecated
65
     @Deprecated
66
     void addLine(final String line, final boolean timestamp);
66
     void addLine(final String line, final boolean timestamp);
67
-    
67
+
68
     /**
68
     /**
69
      * Clears the main text area of the command window.
69
      * Clears the main text area of the command window.
70
      *
70
      *
72
      */
72
      */
73
     @Deprecated
73
     @Deprecated
74
     void clear();
74
     void clear();
75
-    
75
+
76
     /**
76
     /**
77
      * Retrieves the config manager for this command window.
77
      * Retrieves the config manager for this command window.
78
      *
78
      *
79
      * @return This window's config manager
79
      * @return This window's config manager
80
      */
80
      */
81
     ConfigManager getConfigManager();
81
     ConfigManager getConfigManager();
82
-    
82
+
83
     /**
83
     /**
84
      * Retrieves the container that owns this command window.
84
      * Retrieves the container that owns this command window.
85
      *
85
      *
86
      * @return The container that owns this command window.
86
      * @return The container that owns this command window.
87
      */
87
      */
88
     FrameContainer getContainer();
88
     FrameContainer getContainer();
89
-    
89
+
90
     /**
90
     /**
91
      * Determines if the current window is visible.
91
      * Determines if the current window is visible.
92
      *
92
      *
93
      * @return boolean visibility
93
      * @return boolean visibility
94
      */
94
      */
95
     boolean isVisible();
95
     boolean isVisible();
96
-    
96
+
97
     /**
97
     /**
98
      * Sets the visibility of this window.
98
      * Sets the visibility of this window.
99
-     * 
99
+     *
100
      * @param isVisible Whether the window should be visible or not
100
      * @param isVisible Whether the window should be visible or not
101
      */
101
      */
102
     void setVisible(boolean isVisible);
102
     void setVisible(boolean isVisible);
103
-    
103
+
104
     /**
104
     /**
105
      * Retrives the current title of this window.
105
      * Retrives the current title of this window.
106
-     * 
106
+     *
107
      * @return This window's title
107
      * @return This window's title
108
      */
108
      */
109
     String getTitle();
109
     String getTitle();
110
-    
110
+
111
     /**
111
     /**
112
      * Determines if this frame is currently maximised.
112
      * Determines if this frame is currently maximised.
113
-     * 
113
+     *
114
      * @return true if the frame is maximised, false otherwise
114
      * @return true if the frame is maximised, false otherwise
115
      */
115
      */
116
     boolean isMaximum();
116
     boolean isMaximum();
117
-    
117
+
118
     /**
118
     /**
119
      * Sets the title of this window.
119
      * Sets the title of this window.
120
-     * 
120
+     *
121
      * @param title The new title to be used.
121
      * @param title The new title to be used.
122
+     * @deprecated Should use {@link FrameContainer#setTitle(java.lang.String)}
122
      */
123
      */
124
+    @Deprecated
123
     void setTitle(String title);
125
     void setTitle(String title);
124
-    
126
+
125
     /**
127
     /**
126
      * Opens this window.
128
      * Opens this window.
127
      */
129
      */
128
     void open();
130
     void open();
129
-    
131
+
130
     /**
132
     /**
131
      * Restores this window.
133
      * Restores this window.
132
-     * 
134
+     *
133
      * @since 0.6.3m1
135
      * @since 0.6.3m1
134
      */
136
      */
135
     void restore();
137
     void restore();
136
-    
137
-    
138
-    /** 
138
+
139
+    /**
139
      * Maximises this window.
140
      * Maximises this window.
140
-     * 
141
+     *
141
      * @since 0.6.3m1
142
      * @since 0.6.3m1
142
      */
143
      */
143
     void maximise();
144
     void maximise();
144
-    
145
+
145
     /**
146
     /**
146
      * Toggles Maximise State.
147
      * Toggles Maximise State.
147
-     * 
148
+     *
148
      * @since 0.6.3m1
149
      * @since 0.6.3m1
149
      */
150
      */
150
     void toggleMaximise();
151
     void toggleMaximise();
151
-    
152
+
152
     /**
153
     /**
153
      * Minimises this window.
154
      * Minimises this window.
154
      */
155
      */
155
     void minimise();
156
     void minimise();
156
-    
157
+
157
     /**
158
     /**
158
      * Returns the transcoder that is being used by the UI.
159
      * Returns the transcoder that is being used by the UI.
159
-     * 
160
+     *
160
      * @return This window's transcoder
161
      * @return This window's transcoder
161
      * @deprecated Use {@link FrameContainer#getTranscoder()} instead
162
      * @deprecated Use {@link FrameContainer#getTranscoder()} instead
162
      */
163
      */
163
     @Deprecated
164
     @Deprecated
164
     StringTranscoder getTranscoder();
165
     StringTranscoder getTranscoder();
165
-    
166
+
166
     /** Closes this window. */
167
     /** Closes this window. */
167
     void close();
168
     void close();
168
 
169
 
170
      * Requests that this object's frame be activated.
171
      * Requests that this object's frame be activated.
171
      */
172
      */
172
     public void activateFrame();
173
     public void activateFrame();
173
-    
174
+
174
 }
175
 }

+ 1
- 1
test/com/dmdirc/harness/TestWritableFrameContainer.java View File

35
     private final int lineLength;
35
     private final int lineLength;
36
 
36
 
37
     public TestWritableFrameContainer(final int lineLength, final ConfigManager cm) {
37
     public TestWritableFrameContainer(final int lineLength, final ConfigManager cm) {
38
-        super("raw", "Raw", cm);
38
+        super("raw", "Raw", "(Raw)", cm);
39
 
39
 
40
         this.lineLength = lineLength;
40
         this.lineLength = lineLength;
41
     }
41
     }

Loading…
Cancel
Save