Преглед на файлове

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 години
родител
ревизия
bec66870a7

+ 3
- 2
src/com/dmdirc/Channel.java Целия файл

@@ -96,6 +96,7 @@ public class Channel extends MessageTarget implements ConfigChangeListener {
96 96
      */
97 97
     public Channel(final Server newServer, final ChannelInfo newChannelInfo) {
98 98
         super("channel-inactive", newChannelInfo.getName(),
99
+                Styliser.stipControlCodes(newChannelInfo.getName()),
99 100
                 new ConfigManager(newServer.getProtocol(), newServer.getIrcd(),
100 101
                 newServer.getNetwork(), newServer.getAddress(), newChannelInfo.getName()));
101 102
 
@@ -298,7 +299,7 @@ public class Channel extends MessageTarget implements ConfigChangeListener {
298 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,7 +508,7 @@ public class Channel extends MessageTarget implements ConfigChangeListener {
507 508
         res[3] = client.getClient().getHostname();
508 509
 
509 510
         if (showColours) {
510
-            final Map map = client.getMap();
511
+            final Map<?,?> map = client.getMap();
511 512
             String prefix = null;
512 513
             Color colour;
513 514
 

+ 2
- 19
src/com/dmdirc/CustomWindow.java Целия файл

@@ -33,9 +33,6 @@ import com.dmdirc.ui.interfaces.Window;
33 33
  */
34 34
 public class CustomWindow extends FrameContainer {
35 35
 
36
-    /** This custom window's title. */
37
-    private final String title;
38
-
39 36
     /** The window used by this container. */
40 37
     private Window window;
41 38
 
@@ -51,13 +48,11 @@ public class CustomWindow extends FrameContainer {
51 48
      */
52 49
     public CustomWindow(final String name, final String title,
53 50
             final Window parent) {
54
-        super("custom", name, parent.getConfigManager());
51
+        super("custom", name, title, parent.getConfigManager());
55 52
 
56
-        this.title = title;
57 53
         this.parent = parent;
58 54
 
59 55
         window = Main.getUI().getWindow(this);
60
-        window.setTitle(title);
61 56
 
62 57
         WindowManager.addWindow(parent, window);
63 58
 
@@ -71,12 +66,9 @@ public class CustomWindow extends FrameContainer {
71 66
      * @param title The parent of this custom window
72 67
      */
73 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 71
         window = Main.getUI().getWindow(this);
79
-        window.setTitle(title);
80 72
 
81 73
         WindowManager.addWindow(this);
82 74
 
@@ -118,13 +110,4 @@ public class CustomWindow extends FrameContainer {
118 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 Целия файл

@@ -79,6 +79,9 @@ public abstract class FrameContainer {
79 79
     /** The name of this container. */
80 80
     private String name;
81 81
 
82
+    /** The title of this container. */
83
+    private String title;
84
+
82 85
     /** The transcoder to use for this container. */
83 86
     private final StringTranscoder transcoder;
84 87
     
@@ -96,12 +99,15 @@ public abstract class FrameContainer {
96 99
      * 
97 100
      * @param icon The icon to use for this container
98 101
      * @param name The name of this container
102
+     * @param title The title of this container
99 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 108
         this.config = config;
104 109
         this.name = name;
110
+        this.title = title;
105 111
         this.styliser = new Styliser(this);
106 112
         this.document = new IRCDocument(this);
107 113
 
@@ -236,6 +242,32 @@ public abstract class FrameContainer {
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 272
      * Closes this container (and it's associated frame).
241 273
      */

+ 1
- 2
src/com/dmdirc/GlobalWindow.java Целия файл

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

+ 5
- 3
src/com/dmdirc/MessageTarget.java Целия файл

@@ -37,11 +37,13 @@ public abstract class MessageTarget extends WritableFrameContainer {
37 37
      * 
38 38
      * @param icon The icon to use for this target
39 39
      * @param name The name of this target
40
+     * @param title The title of this target
40 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 Целия файл

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

+ 2
- 3
src/com/dmdirc/Raw.java Целия файл

@@ -53,13 +53,12 @@ public final class Raw extends WritableFrameContainer implements DataInListener,
53 53
      * @param commandParser Command parser to use
54 54
      */
55 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 58
         this.server = newServer;
59 59
 
60 60
         window = Main.getUI().getInputWindow(this, commandParser);
61 61
         WindowManager.addWindow(server, this);
62
-        window.setTitle("(Raw log)");
63 62
         window.getInputHandler().setTabCompleter(server.getTabCompleter());
64 63
 
65 64
         window.open();
@@ -135,7 +134,7 @@ public final class Raw extends WritableFrameContainer implements DataInListener,
135 134
     @Override
136 135
     public void sendLine(final String line) {
137 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 Целия файл

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

+ 5
- 3
src/com/dmdirc/WritableFrameContainer.java Целия файл

@@ -54,11 +54,13 @@ public abstract class WritableFrameContainer extends FrameContainer {
54 54
      * 
55 55
      * @param icon The icon to use for this container
56 56
      * @param name The name of this container
57
+     * @param title The title of this container
57 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 Целия файл

@@ -1,46 +0,0 @@
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 Целия файл

@@ -51,4 +51,12 @@ public interface FrameInfoListener extends EventListener {
51 51
      */
52 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 Целия файл

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

+ 1
- 1
test/com/dmdirc/harness/TestWritableFrameContainer.java Целия файл

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

Loading…
Отказ
Запис