Przeglądaj źródła

* Added method to Channel to get the Server it's associated with

* Channel frames now have instances of a channel command parser
* Implemented CommandManager.loadChannelCommands

git-svn-id: http://svn.dmdirc.com/trunk@182 00569f92-eb28-0410-84fd-f71c24880f
tags/0.1
Chris Smith 17 lat temu
rodzic
commit
713f61fa51

+ 4
- 0
src/uk/org/ownage/dmdirc/Channel.java Wyświetl plik

@@ -146,5 +146,9 @@ public class Channel implements IRCParser.IChannelMessage,
146 146
         }
147 147
         frame.addLine("* "+source+" "+sMessage);
148 148
     }
149
+
150
+    public Server getServer() {
151
+        return server;
152
+    }
149 153
     
150 154
 }

+ 24
- 7
src/uk/org/ownage/dmdirc/commandparser/CommandManager.java Wyświetl plik

@@ -34,16 +34,27 @@ import uk.org.ownage.dmdirc.commandparser.commands.server.*;
34 34
 public class CommandManager {
35 35
     
36 36
     /**
37
-     * The commands that have been instansiated
37
+     * The server commands that have been instansiated
38 38
      */
39 39
     private static Vector<Command> serverCommands;
40
-           
40
+    /**
41
+     * The channel commands that have been instansiated
42
+     */
43
+    private static Vector<Command> channelCommands;
44
+    
41 45
     /**
42 46
      * Loads all channel commands into the specified parser
43 47
      * @param parser The parser to load commands into
44 48
      */
45 49
     public static void loadChannelCommands(CommandParser parser) {
46
-        throw new UnsupportedOperationException("Not implemented yet");        
50
+        if (channelCommands == null) {
51
+            channelCommands = new Vector<Command>(0,1);
52
+            
53
+        }
54
+        
55
+        for (Command com : channelCommands) {
56
+            parser.registerCommand(com);
57
+        }
47 58
     }
48 59
     
49 60
     /**
@@ -53,17 +64,23 @@ public class CommandManager {
53 64
     public static void loadServerCommands(CommandParser parser) {
54 65
         if (serverCommands == null) {
55 66
             serverCommands = new Vector<Command>(0,1);
56
-
67
+            
57 68
             serverCommands.add(new Test());
58 69
             serverCommands.add(new Quit());
59 70
             serverCommands.add(new QuitDefault());
60 71
         }
61
-
72
+        
62 73
         for (Command com : serverCommands) {
63 74
             parser.registerCommand(com);
64 75
         }
65
-    }    
76
+    }
66 77
     
78
+    /**
79
+     * Retrieves the server command identified by the specified signature
80
+     * @param signature The signature to look for
81
+     * @return A server command with a matching signature, or null if none
82
+     * were found.
83
+     */
67 84
     public static ServerCommand getServerCommad(String signature) {
68 85
         if (serverCommands == null) {
69 86
             return null;
@@ -73,7 +90,7 @@ public class CommandManager {
73 90
             if (com.getSignature().equals(signature)) {
74 91
                 return (ServerCommand) com;
75 92
             }
76
-        }        
93
+        }
77 94
         
78 95
         return null;
79 96
     }

+ 6
- 1
src/uk/org/ownage/dmdirc/ui/ChannelFrame.java Wyświetl plik

@@ -35,6 +35,7 @@ import javax.swing.plaf.basic.BasicInternalFrameUI;
35 35
 import javax.swing.text.BadLocationException;
36 36
 import javax.swing.text.StyledDocument;
37 37
 import uk.org.ownage.dmdirc.Channel;
38
+import uk.org.ownage.dmdirc.commandparser.ChannelCommandParser;
38 39
 import uk.org.ownage.dmdirc.commandparser.CommandWindow;
39 40
 import uk.org.ownage.dmdirc.logger.ErrorLevel;
40 41
 import uk.org.ownage.dmdirc.logger.Logger;
@@ -66,6 +67,8 @@ public class ChannelFrame extends javax.swing.JInternalFrame implements CommandW
66 67
      */
67 68
     private JScrollBar scrollBar;
68 69
     
70
+    private ChannelCommandParser commandParser;
71
+    
69 72
     /** Creates new form ChannelFrame */
70 73
     public ChannelFrame(Channel parent) {
71 74
         this.parent = parent;
@@ -77,12 +80,14 @@ public class ChannelFrame extends javax.swing.JInternalFrame implements CommandW
77 80
         setVisible(true);
78 81
         setResizable(true);
79 82
         
83
+        commandParser = new ChannelCommandParser(parent.getServer(), parent);
84
+        
80 85
         scrollBar = jScrollPane1.getVerticalScrollBar();
81 86
         
82 87
         jTextField1.addActionListener(new ActionListener() {
83 88
             public void actionPerformed(ActionEvent actionEvent) {
84 89
                 try {
85
-                    ChannelFrame.this.parent.sendLine(jTextField1.getText());
90
+                    ChannelFrame.this.commandParser.parseCommand(ChannelFrame.this, jTextField1.getText());
86 91
                 } catch (Exception e) {
87 92
                     Logger.error(ErrorLevel.ERROR, e);
88 93
                 }

Ładowanie…
Anuluj
Zapisz