Browse Source

DCC Plugin now uses its own icons. Fixes issue 1253.

URL Builder now supports plugin:// URLs. Fixes issue 1252.

git-svn-id: http://svn.dmdirc.com/trunk@4077 00569f92-eb28-0410-84fd-f71c24880f
tags/0.6
Chris Smith 16 years ago
parent
commit
cb1d3b464b

+ 3
- 1
src/com/dmdirc/addons/dcc/DCCChatWindow.java View File

@@ -52,7 +52,7 @@ public class DCCChatWindow extends DCCFrame implements DCCChatInterface {
52 52
 	 * @param targetNick Nickname of target
53 53
 	 */
54 54
 	public DCCChatWindow(final DCCPlugin plugin, final DCCChat dcc, final String title, final String nick, final String targetNick) {
55
-		super(plugin, title, false);
55
+		super(plugin, title, "dcc-chat-inactive", false);
56 56
 		this.dcc = dcc;
57 57
 		dcc.setHandler(this);
58 58
 		nickname = nick;
@@ -115,6 +115,7 @@ public class DCCChatWindow extends DCCFrame implements DCCChatInterface {
115 115
 		final StringBuffer buff = new StringBuffer("DCCChatInfo");
116 116
 		ActionManager.processEvent(DCCActions.DCC_CHAT_SOCKETCLOSED, buff, this);
117 117
 		addLine(buff, "Socket closed");
118
+        setIcon("dcc-chat-inactive");
118 119
 	}
119 120
 	
120 121
 	/**
@@ -127,6 +128,7 @@ public class DCCChatWindow extends DCCFrame implements DCCChatInterface {
127 128
 		final StringBuffer buff = new StringBuffer("DCCChatInfo");
128 129
 		ActionManager.processEvent(DCCActions.DCC_CHAT_SOCKETOPENED, buff, this);
129 130
 		addLine(buff, "Socket opened");
131
+        setIcon("dcc-chat-active");
130 132
 	}
131 133
 	
132 134
 	/**

+ 7
- 4
src/com/dmdirc/addons/dcc/DCCFrame.java View File

@@ -157,9 +157,10 @@ public abstract class DCCFrame extends WritableFrameContainer {
157 157
 	 *
158 158
 	 * @param plugin The DCCPlugin that owns this frame
159 159
 	 * @param title The title of this window
160
+     * @param icon The icon to use
160 161
 	 */
161
-	public DCCFrame(final DCCPlugin plugin, final String title) {
162
-		this(plugin, title, true);
162
+	public DCCFrame(final DCCPlugin plugin, final String title, final String icon) {
163
+		this(plugin, title, icon, true);
163 164
 	}
164 165
 	
165 166
 	/**
@@ -168,9 +169,11 @@ public abstract class DCCFrame extends WritableFrameContainer {
168 169
 	 * @param plugin The DCCPlugin that owns this frame
169 170
 	 * @param title The title of this window
170 171
 	 * @param defaultWindow Create default (empty) window.
172
+     * @param icon The icon to use
171 173
 	 */
172
-	public DCCFrame(final DCCPlugin plugin, final String title, final boolean defaultWindow) {
173
-		super("raw", IdentityManager.getGlobalConfig());
174
+	public DCCFrame(final DCCPlugin plugin, final String title,
175
+            final String icon ,final boolean defaultWindow) {
176
+		super(icon, IdentityManager.getGlobalConfig());
174 177
 		this.title = title;
175 178
 		this.plugin = plugin;
176 179
 

+ 10
- 1
src/com/dmdirc/addons/dcc/DCCPlugin.java View File

@@ -358,7 +358,7 @@ public final class DCCPlugin extends Plugin implements ActionListener {
358 358
 	 * Create the container window.
359 359
 	 */
360 360
 	protected void createContainer() {
361
-		container = new DCCFrame(this, "DCCs"){};
361
+		container = new DCCFrame(this, "DCCs", "dcc"){};
362 362
 		final TextLabel label = new TextLabel("This is a placeholder window to group DCCs together.");
363 363
 		label.setText(label.getText()+"\n\nClosing this window will close all the active DCCs");
364 364
 		((TextFrame)container.getFrame()).getContentPane().add(label);
@@ -415,6 +415,15 @@ public final class DCCPlugin extends Plugin implements ActionListener {
415 415
 		defaults.setOption(MY_DOMAIN, "send.blocksize", "1024");
416 416
 		defaults.setOption(MY_DOMAIN, "receive.autoaccept", "false");
417 417
 		defaults.setOption(MY_DOMAIN, "general.ip", "");
418
+        
419
+        final String url = "plugin://dcc:com/dmdirc/addons/dcc/res/";
420
+        defaults.setOption("icon", "dcc", url + "transfers.png");
421
+        defaults.setOption("icon", "dcc-chat-active", url + "chat.png");
422
+        defaults.setOption("icon", "dcc-chat-inactive", url + "chat-inactive.png");
423
+        defaults.setOption("icon", "dcc-send-active", url + "send.png");
424
+        defaults.setOption("icon", "dcc-send-inactive", url + "send-inactive.png");
425
+        defaults.setOption("icon", "dcc-receive-active", url + "receive.png");
426
+        defaults.setOption("icon", "dcc-receive-inactive", url + "receive-inactive.png");
418 427
 		
419 428
 		defaults.setOption("formatter", "DCCChatStarting", "Starting DCC Chat with: %1$s on %2$s:%3$s");
420 429
 		defaults.setOption("formatter", "DCCChatInfo", "%1$s");

+ 6
- 1
src/com/dmdirc/addons/dcc/DCCSendWindow.java View File

@@ -88,7 +88,8 @@ public class DCCSendWindow extends DCCFrame implements DCCSendInterface, ActionL
88 88
 	 * @param targetNick Nickname of target
89 89
 	 */
90 90
 	public DCCSendWindow(final DCCPlugin plugin, final DCCSend dcc, final String title, final String nick, final String targetNick) {
91
-		super(plugin, title);
91
+		super(plugin, title, dcc.getType() == DCCSend.TransferType.SEND ? 
92
+            "dcc-send-inactive" : "dcc-receive-inactive");
92 93
 		this.dcc = dcc;
93 94
 		dcc.setHandler(this);
94 95
 		nickname = nick;
@@ -216,6 +217,8 @@ public class DCCSendWindow extends DCCFrame implements DCCSendInterface, ActionL
216 217
 			status.setText("Status: Transfer Failed.");
217 218
 		}
218 219
 		updateSpeedAndTime();
220
+        setIcon(dcc.getType() == DCCSend.TransferType.SEND ? 
221
+            "dcc-send-active" : "dcc-receive-active");
219 222
 	}
220 223
 	
221 224
 	/**
@@ -228,6 +231,8 @@ public class DCCSendWindow extends DCCFrame implements DCCSendInterface, ActionL
228 231
 		ActionManager.processEvent(DCCActions.DCC_SEND_SOCKETOPENED, null, this);
229 232
 		status.setText("Status: Socket Opened");
230 233
 		timeStarted = System.currentTimeMillis();
234
+        setIcon(dcc.getType() == DCCSend.TransferType.SEND ? 
235
+            "dcc-send-inactive" : "dcc-receive-inactive");
231 236
 	}
232 237
 	
233 238
 	/**

+ 24
- 0
src/com/dmdirc/util/URLBuilder.java View File

@@ -24,6 +24,7 @@ package com.dmdirc.util;
24 24
 
25 25
 import com.dmdirc.logger.ErrorLevel;
26 26
 import com.dmdirc.logger.Logger;
27
+import com.dmdirc.plugins.PluginManager;
27 28
 import com.dmdirc.ui.themes.ThemeManager;
28 29
 
29 30
 import java.net.MalformedURLException;
@@ -98,6 +99,19 @@ public final class URLBuilder {
98 99
         return buildJarURL(ThemeManager.getThemeDirectory() + theme + ".zip", path);
99 100
     }
100 101
     
102
+    /**
103
+     * Builds an URL pointing to a resource within a DMDirc plugin.
104
+     * 
105
+     * @param plugin The plugin which the resource is located in
106
+     * @param path The path within the theme of the resource
107
+     * @return An URL corresponding to the specified resource, or null on failure
108
+     */
109
+    public static URL buildPluginURL(final String plugin, final String path) {
110
+        return buildJarURL(
111
+                PluginManager.getPluginManager().getPluginInfoByName(plugin).getFullFilename(),
112
+                path);
113
+    }
114
+    
101 115
     /**
102 116
      * Constructs an URL corresponding to the described resource.
103 117
      * 
@@ -106,6 +120,7 @@ public final class URLBuilder {
106 120
      * <li>jar://path/to/jarfile:path/inside/jarfile
107 121
      * <li>zip://path/to/zipfile:path/inside/zipfile
108 122
      * <li>theme://theme_name:file/inside/theme
123
+     * <li>plugin://plugin_name:file/inside/plugin
109 124
      * <li>http://server/path
110 125
      * <li>https://server/path
111 126
      * <li>[file://]/path/on/filesystem</ul>
@@ -124,6 +139,15 @@ public final class URLBuilder {
124 139
             } else {
125 140
                 return buildJarURL(spec.substring(6, offset), spec.substring(offset + 1));
126 141
             }
142
+        } else if (spec.startsWith("plugin://")) {
143
+            final int offset = spec.indexOf(':', 8);
144
+            
145
+            if (offset < 0) {
146
+                Logger.userError(ErrorLevel.LOW, "Invalid URL, must contain ':': " + spec);
147
+                return null;
148
+            } else {
149
+                return buildPluginURL(spec.substring(9, offset), spec.substring(offset + 1));
150
+            }            
127 151
         } else if (spec.startsWith("theme://")) {
128 152
             final int offset = spec.indexOf(':', 8);
129 153
             

Loading…
Cancel
Save