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

Added key components and boolean comparison

git-svn-id: http://svn.dmdirc.com/trunk@1567 00569f92-eb28-0410-84fd-f71c24880f
tags/0.5
Chris Smith 17 роки тому
джерело
коміт
639302e773

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

@@ -98,6 +98,18 @@ public enum CoreActionComparison implements ActionComparison {
98 98
         public String getName() { return "contains"; }
99 99
     },
100 100
     
101
+    /** Checks if two boolean values are equal. */
102
+    BOOL_IS {
103
+        /** {@inheritDoc} */
104
+        public boolean test(final Object arg1, final Object arg2) {
105
+            return ((Boolean) arg1).equals(Boolean.valueOf((String) arg2));
106
+        }
107
+        /** {@inheritDoc} */
108
+        public Class appliesTo() { return Boolean.class; }
109
+        /** {@inheritDoc} */
110
+        public String getName() { return "is"; }
111
+    },
112
+    
101 113
     /** Checks if the colour is the same as another colour. */
102 114
     COLOUR_EQUALS {
103 115
         /** {@inheritDoc} */

+ 57
- 2
src/com/dmdirc/actions/CoreActionComponent.java Переглянути файл

@@ -27,6 +27,7 @@ import com.dmdirc.Server;
27 27
 import com.dmdirc.parser.ChannelClientInfo;
28 28
 
29 29
 import java.awt.Color;
30
+import java.awt.event.KeyEvent;
30 31
 import java.util.GregorianCalendar;
31 32
 
32 33
 /**
@@ -70,7 +71,7 @@ public enum CoreActionComponent implements ActionComponent {
70 71
         public Class getType() { return String.class; }
71 72
         /** {@inheritDoc} */
72 73
         public String getName() { return "away reason"; }
73
-    },  
74
+    },
74 75
     
75 76
     /** Returns the nickname for the server. */
76 77
     SERVER_MYNICKNAME {
@@ -82,7 +83,7 @@ public enum CoreActionComponent implements ActionComponent {
82 83
         public Class getType() { return String.class; }
83 84
         /** {@inheritDoc} */
84 85
         public String getName() { return "nickname"; }
85
-    },    
86
+    },
86 87
     
87 88
     /** Returns the name of the channel. */
88 89
     CHANNEL_NAME {
@@ -190,6 +191,60 @@ public enum CoreActionComponent implements ActionComponent {
190 191
         public Class getType() { return String.class; }
191 192
         /** {@inheritDoc} */
192 193
         public String getName() { return "full date"; }
194
+    },
195
+    
196
+    /** Returns the name of the key that was pressed. */
197
+    KEYEVENT_KEYNAME {
198
+        /** {@inheritDoc} */
199
+        public Object get(final Object argument) { return KeyEvent.getKeyText(((KeyEvent) argument).getKeyCode()); }
200
+        /** {@inheritDoc} */
201
+        public Class appliesTo() { return KeyEvent.class; }
202
+        /** {@inheritDoc} */
203
+        public Class getType() { return String.class; }
204
+        /** {@inheritDoc} */
205
+        public String getName() { return "key name"; }
206
+    },
207
+    
208
+    /** Returns the state of the control key for a key press event. */
209
+    KEYEVENT_CTRLSTATE {
210
+        /** {@inheritDoc} */
211
+        public Object get(final Object argument) {
212
+            return Boolean.valueOf((((KeyEvent) argument).getModifiers() & KeyEvent.CTRL_DOWN_MASK) != 0);
213
+        }
214
+        /** {@inheritDoc} */
215
+        public Class appliesTo() { return KeyEvent.class; }
216
+        /** {@inheritDoc} */
217
+        public Class getType() { return String.class; }
218
+        /** {@inheritDoc} */
219
+        public String getName() { return "control key state"; }
220
+    },
221
+    
222
+    /** Returns the state of the shift key for a key press event. */
223
+    KEYEVENT_SHIFTSTATE {
224
+        /** {@inheritDoc} */
225
+        public Object get(final Object argument) {
226
+            return Boolean.valueOf((((KeyEvent) argument).getModifiers() & KeyEvent.SHIFT_DOWN_MASK) != 0);
227
+        }
228
+        /** {@inheritDoc} */
229
+        public Class appliesTo() { return KeyEvent.class; }
230
+        /** {@inheritDoc} */
231
+        public Class getType() { return String.class; }
232
+        /** {@inheritDoc} */
233
+        public String getName() { return "shift key state"; }
234
+    },
235
+    
236
+    /** Returns the state of the shift key for a key press event. */
237
+    KEYEVENT_ALTSTATE {
238
+        /** {@inheritDoc} */
239
+        public Object get(final Object argument) {
240
+            return Boolean.valueOf((((KeyEvent) argument).getModifiers() & KeyEvent.ALT_DOWN_MASK) != 0);
241
+        }
242
+        /** {@inheritDoc} */
243
+        public Class appliesTo() { return KeyEvent.class; }
244
+        /** {@inheritDoc} */
245
+        public Class getType() { return String.class; }
246
+        /** {@inheritDoc} */
247
+        public String getName() { return "alt key state"; }
193 248
     };
194 249
     
195 250
     /** {@inheritDoc} */

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