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

* Added Raw class

* Remove default ServerFrame window
* Added AddLine method to ServerFrame
* Automatically create a new server window (quakenet)
* Server instances now create an IRC Parser and Raw instance
* Added PortInputVerifier class to NewServerDialog

git-svn-id: http://svn.dmdirc.com/trunk@21 00569f92-eb28-0410-84fd-f71c24880f
tags/0.1
Chris Smith преди 17 години
родител
ревизия
319b35ecd6
променени са 7 файла, в които са добавени 105 реда и са изтрити 4 реда
  1. 2
    0
      src/dmdirc/Main.java
  2. 59
    0
      src/dmdirc/Raw.java
  3. 16
    1
      src/dmdirc/Server.java
  4. 1
    3
      src/dmdirc/ui/MainFrame.java
  5. 19
    0
      src/dmdirc/ui/NewServerDialog.java
  6. 3
    0
      src/dmdirc/ui/ServerFrame.form
  7. 5
    0
      src/dmdirc/ui/ServerFrame.java

+ 2
- 0
src/dmdirc/Main.java Целия файл

58
         
58
         
59
         MainFrame frame = MainFrame.getMainFrame();
59
         MainFrame frame = MainFrame.getMainFrame();
60
         
60
         
61
+        Server serv = new Server("irc.quakenet.org", 6667);
62
+        
61
     }
63
     }
62
     
64
     
63
 }
65
 }

+ 59
- 0
src/dmdirc/Raw.java Целия файл

1
+/*
2
+ * Copyright (c) 2006-2007 Chris Smith, Shane Mc Cormack
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 dmdirc;
24
+
25
+import dmdirc.parser.IRCParser;
26
+import dmdirc.ui.MainFrame;
27
+import dmdirc.ui.ServerFrame;
28
+
29
+/**
30
+ *
31
+ * @author chris
32
+ */
33
+public class Raw {
34
+    
35
+    private Server server;
36
+    private ServerFrame frame;
37
+    
38
+    /** Creates a new instance of Raw */
39
+    public Raw(Server server) {
40
+        this.server = server;
41
+        
42
+        frame = new ServerFrame();
43
+        
44
+        MainFrame.getMainFrame().addChild(frame);
45
+        
46
+        server.AddDataIn(new IRCParser.IDataIn() {
47
+            public void onDataIn(IRCParser tParser, String sData) {
48
+                Raw.this.frame.addLine("<<< "+sData);
49
+            }
50
+        });
51
+        
52
+        server.AddDataOut(new IRCParser.IDataOut() {
53
+            public void onDataOut(IRCParser tparser, String sData) {
54
+                Raw.this.frame.addLine(">>> "+sData);
55
+            }
56
+        });
57
+    }
58
+    
59
+}

+ 16
- 1
src/dmdirc/Server.java Целия файл

51
     private IRCParser parser;
51
     private IRCParser parser;
52
     
52
     
53
     /** Creates a new instance of Server */
53
     /** Creates a new instance of Server */
54
-    public Server() {
54
+    public Server(String server, int port) {
55
         
55
         
56
         channels = new Vector(0,1);
56
         channels = new Vector(0,1);
57
         
57
         
60
         frame = new ServerFrame();
60
         frame = new ServerFrame();
61
         
61
         
62
         MainFrame.getMainFrame().addChild(frame);
62
         MainFrame.getMainFrame().addChild(frame);
63
+        
64
+        parser = new IRCParser();
65
+        
66
+        Raw raw = new Raw(this);
67
+        
68
+        try {
69
+            parser.connect(server, port);
70
+            parser.run();
71
+        } catch (Exception ex) {
72
+            frame.addLine("ERROR: "+ex.getMessage());
73
+        }
63
     }
74
     }
64
     
75
     
65
     /**
76
     /**
69
         ServerManager.getServerManager().unregisterServer(this);
80
         ServerManager.getServerManager().unregisterServer(this);
70
     }
81
     }
71
     
82
     
83
+    public void AddDataIn (Object eMethod) { parser.AddDataIn(eMethod); }
84
+    public void AddDataOut (Object eMethod) { parser.AddDataOut(eMethod); }
85
+    public void AddMOTDEnd (Object eMethod) { parser.AddMOTDEnd(eMethod); }
86
+    
72
 }
87
 }

+ 1
- 3
src/dmdirc/ui/MainFrame.java Целия файл

36
     /**
36
     /**
37
      * Singleton instance of MainFrame
37
      * Singleton instance of MainFrame
38
      */
38
      */
39
-    private static MainFrame me = null;
39
+    private static MainFrame me;
40
     
40
     
41
     /**
41
     /**
42
      * Returns the singleton instance of MainFrame
42
      * Returns the singleton instance of MainFrame
53
     public MainFrame() {
53
     public MainFrame() {
54
         initComponents();
54
         initComponents();
55
         setVisible(true);
55
         setVisible(true);
56
-        ServerFrame test = new ServerFrame();
57
-        desktopPane.add(test);
58
         
56
         
59
         miAddServer.addActionListener(new ActionListener() {
57
         miAddServer.addActionListener(new ActionListener() {
60
             public void actionPerformed(ActionEvent actionEvent) {
58
             public void actionPerformed(ActionEvent actionEvent) {

+ 19
- 0
src/dmdirc/ui/NewServerDialog.java Целия файл

27
 import java.awt.event.ActionListener;
27
 import java.awt.event.ActionListener;
28
 import java.awt.event.WindowEvent;
28
 import java.awt.event.WindowEvent;
29
 import java.awt.event.WindowListener;
29
 import java.awt.event.WindowListener;
30
+import javax.swing.InputVerifier;
31
+import javax.swing.JComponent;
32
+import javax.swing.JTextField;
30
 
33
 
31
 /**
34
 /**
32
  *
35
  *
46
             jCheckBox1.setEnabled(false);
49
             jCheckBox1.setEnabled(false);
47
         }
50
         }
48
         
51
         
52
+        jTextField2.setInputVerifier(new PortVerifier());
53
+        
49
         addCallbacks();
54
         addCallbacks();
50
         
55
         
51
         setVisible(true);
56
         setVisible(true);
200
     // End of variables declaration//GEN-END:variables
205
     // End of variables declaration//GEN-END:variables
201
     
206
     
202
 }
207
 }
208
+
209
+class PortVerifier extends InputVerifier {
210
+    
211
+    public boolean verify(JComponent jComponent) {
212
+        JTextField tf = (JTextField)jComponent;
213
+        try {
214
+            Integer port = Integer.parseInt(tf.getText());
215
+            return (port > 0 && port <= 65535);
216
+        } catch (Exception e) {
217
+            return false;
218
+        }
219
+    }
220
+    
221
+}

+ 3
- 0
src/dmdirc/ui/ServerFrame.form Целия файл

1
 <?xml version="1.0" encoding="UTF-8" ?>
1
 <?xml version="1.0" encoding="UTF-8" ?>
2
 
2
 
3
 <Form version="1.3" type="org.netbeans.modules.form.forminfo.JInternalFrameFormInfo">
3
 <Form version="1.3" type="org.netbeans.modules.form.forminfo.JInternalFrameFormInfo">
4
+  <Properties>
5
+    <Property name="title" type="java.lang.String" value="Server Frame"/>
6
+  </Properties>
4
   <SyntheticProperties>
7
   <SyntheticProperties>
5
     <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
8
     <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
6
   </SyntheticProperties>
9
   </SyntheticProperties>

+ 5
- 0
src/dmdirc/ui/ServerFrame.java Целия файл

36
         setVisible(true);
36
         setVisible(true);
37
     }
37
     }
38
     
38
     
39
+    public void addLine(String line) {
40
+        jTextArea1.append(line+"\n");
41
+    }
42
+    
39
     /** This method is called from within the constructor to
43
     /** This method is called from within the constructor to
40
      * initialize the form.
44
      * initialize the form.
41
      * WARNING: Do NOT modify this code. The content of this method is
45
      * WARNING: Do NOT modify this code. The content of this method is
47
         jTextArea1 = new javax.swing.JTextArea();
51
         jTextArea1 = new javax.swing.JTextArea();
48
         jTextField1 = new javax.swing.JTextField();
52
         jTextField1 = new javax.swing.JTextField();
49
 
53
 
54
+        setTitle("Server Frame");
50
         jTextArea1.setColumns(20);
55
         jTextArea1.setColumns(20);
51
         jTextArea1.setRows(5);
56
         jTextArea1.setRows(5);
52
         jScrollPane1.setViewportView(jTextArea1);
57
         jScrollPane1.setViewportView(jTextArea1);

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