Переглянути джерело

FrameContainer.getConfigManager is now abstract, fix imports DF decided not to bother adding, add initial popup menu work

git-svn-id: http://svn.dmdirc.com/trunk@2827 00569f92-eb28-0410-84fd-f71c24880f
tags/0.5.5
Chris Smith 16 роки тому
джерело
коміт
c1cd344c78

+ 1
- 10
src/com/dmdirc/FrameContainer.java Переглянути файл

@@ -100,16 +100,7 @@ public abstract class FrameContainer {
100 100
      *
101 101
      * @return the associated config manager
102 102
      */
103
-    public ConfigManager getConfigManager() {
104
-        if (getServer() == null) {
105
-            Logger.appError(ErrorLevel.LOW, "getConfigManager() called when" +
106
-                    "getServer() = null", new UnsupportedOperationException(
107
-                    "My name: " + toString()));
108
-            return IdentityManager.getGlobalConfig();
109
-        } else {
110
-            return getServer().getConfigManager();
111
-        }
112
-    }
103
+    public abstract ConfigManager getConfigManager();
113 104
 
114 105
     /**
115 106
      * Requests that this object's frame be activated.

+ 7
- 0
src/com/dmdirc/Query.java Переглянути файл

@@ -26,6 +26,7 @@ import com.dmdirc.actions.ActionManager;
26 26
 import com.dmdirc.actions.CoreActionType;
27 27
 import com.dmdirc.commandparser.CommandManager;
28 28
 import com.dmdirc.commandparser.CommandType;
29
+import com.dmdirc.config.ConfigManager;
29 30
 import com.dmdirc.logger.ErrorLevel;
30 31
 import com.dmdirc.logger.Logger;
31 32
 import com.dmdirc.parser.ClientInfo;
@@ -385,4 +386,10 @@ public final class Query extends MessageTarget implements
385 386
         Main.getUI().getMainWindow().setActiveFrame(window);
386 387
     }
387 388
     
389
+    /** {@inheritDoc} */
390
+    @Override
391
+    public ConfigManager getConfigManager() {
392
+        return server.getConfigManager();
393
+    }    
394
+    
388 395
 }

+ 8
- 0
src/com/dmdirc/Raw.java Переглянути файл

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc;
24 24
 
25
+import com.dmdirc.config.ConfigManager;
25 26
 import com.dmdirc.logger.ErrorLevel;
26 27
 import com.dmdirc.logger.Logger;
27 28
 import com.dmdirc.parser.IRCParser;
@@ -139,4 +140,11 @@ public final class Raw extends WritableFrameContainer implements IDataIn,
139 140
     public int getMaxLineLength() {
140 141
         return server.getMaxLineLength();
141 142
     }
143
+
144
+    /** {@inheritDoc} */
145
+    @Override
146
+    public ConfigManager getConfigManager() {
147
+        return server.getConfigManager();
148
+    }
149
+    
142 150
 }

+ 3
- 1
src/com/dmdirc/addons/dcc/DCCFrame.java Переглянути файл

@@ -35,6 +35,8 @@ import com.dmdirc.commandparser.commands.GlobalCommand;
35 35
 
36 36
 import com.dmdirc.IconManager;
37 37
 import com.dmdirc.Server;
38
+import com.dmdirc.config.ConfigManager;
39
+import com.dmdirc.config.IdentityManager;
38 40
 import com.dmdirc.ui.WindowManager;
39 41
 import com.dmdirc.ui.interfaces.InputWindow;
40 42
 
@@ -234,5 +236,5 @@ public abstract class DCCFrame extends WritableFrameContainer {
234 236
 		myWindow.setVisible(false);
235 237
 		Main.getUI().getMainWindow().delChild(myWindow);
236 238
 		WindowManager.removeWindow(myWindow);
237
-	}
239
+	}   
238 240
 }

+ 7
- 0
src/com/dmdirc/addons/logging/HistoryWindow.java Переглянути файл

@@ -26,6 +26,7 @@ import com.dmdirc.FrameContainer;
26 26
 import com.dmdirc.IconManager;
27 27
 import com.dmdirc.Main;
28 28
 import com.dmdirc.Server;
29
+import com.dmdirc.config.ConfigManager;
29 30
 import com.dmdirc.config.IdentityManager;
30 31
 import com.dmdirc.ui.WindowManager;
31 32
 import com.dmdirc.ui.interfaces.Window;
@@ -99,4 +100,10 @@ public class HistoryWindow extends FrameContainer {
99 100
     public Server getServer() {
100 101
         return parent.getContainer().getServer();
101 102
     }
103
+    
104
+    /** {@inheritDoc} */
105
+    @Override
106
+    public ConfigManager getConfigManager() {
107
+        return parent.getConfigManager();
108
+    }    
102 109
 }

+ 49
- 0
src/com/dmdirc/commandparser/PopupMenu.java Переглянути файл

@@ -0,0 +1,49 @@
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.commandparser;
24
+
25
+import java.util.ArrayList;
26
+import java.util.Collection;
27
+import java.util.List;
28
+
29
+/**
30
+ *
31
+ * @author chris
32
+ */
33
+public class PopupMenu {
34
+    
35
+    private final List<PopupMenuItem> items = new ArrayList<PopupMenuItem>();
36
+    
37
+    public List<PopupMenuItem> getItems() {
38
+        return items;
39
+    }
40
+
41
+    public boolean add(final PopupMenuItem e) {
42
+        return items.add(e);
43
+    }
44
+
45
+    public boolean addAll(final Collection<? extends PopupMenuItem> c) {
46
+        return items.addAll(c);
47
+    }    
48
+
49
+}

+ 70
- 0
src/com/dmdirc/commandparser/PopupMenuItem.java Переглянути файл

@@ -0,0 +1,70 @@
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.commandparser;
24
+
25
+/**
26
+ *
27
+ * @author chris
28
+ */
29
+public class PopupMenuItem {
30
+    
31
+    private boolean divider = false;
32
+    private PopupMenu submenu = null;
33
+    private String name;
34
+    private String command;
35
+    
36
+    public PopupMenuItem() {
37
+        divider = true;
38
+    }
39
+    
40
+    public PopupMenuItem(final String name) {
41
+        this.name = name;
42
+        this.submenu = new PopupMenu();
43
+    }
44
+    
45
+    public PopupMenuItem(final String name, final String command) {
46
+        this.name = name;
47
+        this.command = command;
48
+    }
49
+    
50
+    public boolean isDivider() {
51
+        return divider;
52
+    }
53
+    
54
+    public boolean isSubMenu() {
55
+        return submenu != null;
56
+    }
57
+    
58
+    public PopupMenu getSubMenu() {
59
+        return submenu;
60
+    }
61
+    
62
+    public String getName() {
63
+        return name;
64
+    }
65
+    
66
+    public String getCommand(final Object... arguments) {
67
+        return CommandManager.getCommandChar() + String.format(command, arguments);
68
+    }
69
+
70
+}

Завантаження…
Відмінити
Зберегти