ソースを参照

Added custom window icon

Added custom window container
Server notification targets now support window:foo syntax

git-svn-id: http://svn.dmdirc.com/trunk@2482 00569f92-eb28-0410-84fd-f71c24880f
tags/0.5.5
Chris Smith 16年前
コミット
3da6557215

+ 123
- 0
src/com/dmdirc/CustomWindow.java ファイルの表示

@@ -0,0 +1,123 @@
1
+/*
2
+ * Copyright (c) 2006-2007 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;
24
+
25
+import com.dmdirc.ui.WindowManager;
26
+import com.dmdirc.ui.interfaces.Window;
27
+
28
+/**
29
+ *
30
+ * @author chris
31
+ */
32
+public class CustomWindow extends FrameContainer {
33
+    
34
+    /** This custom window's name. */
35
+    private final String name;
36
+    
37
+    /** This custom window's title. */
38
+    private final String title;
39
+    
40
+    private final Window window;
41
+    
42
+    private Window parent = null;
43
+    
44
+    public CustomWindow(final String name, final String title, final Window parent) {
45
+        super();
46
+        
47
+        this.name = name;
48
+        this.title = title;
49
+        this.parent = parent;
50
+        
51
+        icon = IconManager.getIconManager().getIcon("custom");
52
+        
53
+        window = Main.getUI().getWindow(this);
54
+        window.setTitle(title);
55
+        window.setFrameIcon(icon);
56
+        
57
+        WindowManager.addWindow(parent, window);
58
+        
59
+        window.setVisible(true);
60
+    }
61
+    
62
+    public CustomWindow(final String name, final String title) {
63
+        super();
64
+        
65
+        this.name = name;
66
+        this.title = title;
67
+        
68
+        icon = IconManager.getIconManager().getIcon("custom");
69
+        
70
+        window = Main.getUI().getWindow(this);
71
+        window.setTitle(title);
72
+        window.setFrameIcon(icon);
73
+        
74
+        WindowManager.addWindow(window);
75
+        
76
+        window.setVisible(true);
77
+    }    
78
+
79
+    /** {@inheritDoc} */
80
+    @Override    
81
+    public Window getFrame() {
82
+        return window;
83
+    }
84
+
85
+    /** {@inheritDoc} */
86
+    @Override    
87
+    public String toString() {
88
+        return name;
89
+    }
90
+
91
+    /** {@inheritDoc} */
92
+    @Override    
93
+    public void close() {
94
+        window.setVisible(false);
95
+        
96
+        WindowManager.removeWindow(window);
97
+    }
98
+
99
+    /** {@inheritDoc} */
100
+    @Override
101
+    public Server getServer() {
102
+        return parent == null ? null : parent.getContainer().getServer();
103
+    }
104
+
105
+    /**
106
+     * Retrieves this custom window's name.
107
+     *
108
+     * @return This custom window's name
109
+     */
110
+    public String getName() {
111
+        return name;
112
+    }
113
+
114
+    /**
115
+     * Retrieves this custom window's title.
116
+     *
117
+     * @return This custom window's title
118
+     */    
119
+    public String getTitle() {
120
+        return title;
121
+    }
122
+
123
+}

+ 10
- 0
src/com/dmdirc/Server.java ファイルの表示

@@ -840,6 +840,16 @@ public final class Server extends WritableFrameContainer implements Serializable
840 840
             addLineToAll(messageType, args);
841 841
         } else if ("active".equals(target)) {
842 842
             addLineToActive(messageType, args);
843
+        } else if (target.startsWith("window:")) {
844
+            final String windowName = target.substring(7);
845
+            
846
+            Window targetWindow = WindowManager.findCustomWindow(getFrame(), windowName);
847
+            
848
+            if (targetWindow == null) {
849
+                targetWindow = new CustomWindow(windowName, windowName, getFrame()).getFrame();
850
+            }
851
+            
852
+            targetWindow.addLine(messageType, args);
843 853
         } else if (target.startsWith("lastcommand:")) {
844 854
             final Object[] escapedargs = new Object[args.length];
845 855
             

+ 17
- 17
src/com/dmdirc/config/defaults/defaults ファイルの表示

@@ -2,33 +2,33 @@ identity.name = DMDirc default settings
2 2
 identity.globaldefault = true
3 3
 
4 4
 general.submitErrors=true
5
-        
5
+
6 6
 general.commandchar=/
7 7
 general.silencechar=.
8
-        
8
+
9 9
 general.reconnectmessage=Reconnecting
10 10
 general.closemessage=DMDirc exiting
11 11
 general.quitmessage=Using DMDirc
12 12
 general.partmessage=Using DMDirc
13 13
 general.cyclemessage=Cycling
14 14
 general.kickmessage=Bye!
15
-        
15
+
16 16
 general.hidequeries=false
17
-        
17
+
18 18
 general.closechannelsonquit=false
19 19
 general.closequeriesonquit=false
20
-        
20
+
21 21
 general.closechannelsondisconnect=false
22 22
 general.closequeriesondisconnect=false
23
-        
23
+
24 24
 general.reconnectonconnectfailure=true
25 25
 general.reconnectondisconnect=true
26 26
 general.reconnectdelay=5
27
-        
27
+
28 28
 general.server=blueyonder.uk.quakenet.org
29 29
 general.port=7000
30 30
 general.password=
31
-        
31
+
32 32
 notifications.authNotice=server
33 33
 notifications.unknownNotice=server
34 34
 notifications.connectError=server
@@ -42,7 +42,7 @@ notifications.privateCTCPreply=lastcommand:ctcp %1$s %4$S
42 42
 notifications.wallusers=server
43 43
 notifications.wallops=server
44 44
 notifications.walldesync=server
45
-        
45
+
46 46
 notifications.numeric_301=group:whois
47 47
 notifications.numeric_307=group:whois
48 48
 notifications.numeric_311=group:whois
@@ -73,7 +73,7 @@ notifications.numeric_671=group:whois
73 73
 notifications.numeric_705=server
74 74
 
75 75
 notifications.whois=lastcommand:whois %4$s( %4$s)?
76
-        
76
+
77 77
 ui.backgroundcolour=0
78 78
 ui.foregroundcolour=1
79 79
 ui.framemanagerPosition=left
@@ -85,29 +85,29 @@ ui.showversion=true
85 85
 ui.quickCopy=false
86 86
 ui.pasteProtectionLimit=1
87 87
 ui.stylelinks=true
88
-        
88
+
89 89
 ui.treeviewActiveBold=true
90 90
 treeview.sortwindows=true
91 91
 treeview.sortservers=true
92
-        
92
+
93 93
 channel.splitusermodes=false
94 94
 channel.sendwho=false
95 95
 channel.showmodeprefix=true
96 96
 general.whotime=60000
97
-        
97
+
98 98
 tabcompletion.casesensitive=false
99
-        
99
+
100 100
 logging.dateFormat=EEE, d MMM yyyy HH:mm:ss Z
101 101
 logging.programLogging=true
102 102
 logging.debugLogging=true
103 103
 logging.debugLoggingSysOut=true
104
-        
104
+
105 105
 server.friendlymodes=true
106 106
 server.pingtimeout=60000
107
-        
107
+
108 108
 updater.frequency=86400
109 109
 updater.lastcheck=0
110
-        
110
+
111 111
 actions.textcolour=12
112 112
 actions.eventcolour=3
113 113
 actions.highlightcolour=4

バイナリ
src/com/dmdirc/res/custom.png ファイルの表示


+ 31
- 4
src/com/dmdirc/ui/WindowManager.java ファイルの表示

@@ -22,7 +22,7 @@
22 22
 
23 23
 package com.dmdirc.ui;
24 24
 
25
-import com.dmdirc.Main;
25
+import com.dmdirc.CustomWindow;
26 26
 import com.dmdirc.logger.Logger;
27 27
 import com.dmdirc.ui.interfaces.FrameManager;
28 28
 import com.dmdirc.ui.interfaces.Window;
@@ -35,11 +35,14 @@ import java.util.Map.Entry;
35 35
 
36 36
 public class WindowManager {
37 37
     
38
-    private final static List<Window> rootWindows = new ArrayList<Window>();
38
+    private final static List<Window> rootWindows
39
+            = new ArrayList<Window>();
39 40
     
40
-    private final static Map<Window, List<Window>> childWindows = new HashMap<Window, List<Window>>();
41
+    private final static Map<Window, List<Window>> childWindows
42
+            = new HashMap<Window, List<Window>>();
41 43
     
42
-    private final static List<FrameManager> frameManagers = new ArrayList<FrameManager>();
44
+    private final static List<FrameManager> frameManagers
45
+            = new ArrayList<FrameManager>();
43 46
     
44 47
     private WindowManager() {
45 48
         // Shouldn't be instansiated
@@ -104,6 +107,30 @@ public class WindowManager {
104 107
         }
105 108
     }
106 109
     
110
+    public static Window findCustomWindow(final String name) {
111
+        Logger.doAssertion(name != null);
112
+        
113
+        return findCustomWindow(rootWindows, name);
114
+    }
115
+    
116
+    public static Window findCustomWindow(final Window parent, final String name) {
117
+        Logger.doAssertion(parent != null, name != null);
118
+        Logger.doAssertion(childWindows.containsKey(parent));
119
+        
120
+        return findCustomWindow(childWindows.get(parent), name);
121
+    }
122
+    
123
+    private static Window findCustomWindow(final List<Window> windows, final String name) {
124
+        for (Window window : windows) {
125
+            if (window.getContainer() instanceof CustomWindow
126
+                    && ((CustomWindow) window.getContainer()).getName().equals(name)) {
127
+                return window;
128
+            }
129
+        }
130
+        
131
+        return null;
132
+    }
133
+    
107 134
     private static Window getParent(final Window window) {
108 135
         for (Entry<Window, List<Window>> entry : childWindows.entrySet()) {
109 136
             if (entry.getValue().contains(window)) {

読み込み中…
キャンセル
保存