瀏覽代碼

Added ChannelClientProperty, and made Channel objects ensure their clients have proper maps in their misc properties

git-svn-id: http://svn.dmdirc.com/trunk@1078 00569f92-eb28-0410-84fd-f71c24880f
tags/0.4
Chris Smith 17 年之前
父節點
當前提交
544f05a117
共有 2 個檔案被更改,包括 48 行新增0 行删除
  1. 14
    0
      src/uk/org/ownage/dmdirc/Channel.java
  2. 34
    0
      src/uk/org/ownage/dmdirc/ChannelClientProperty.java

+ 14
- 0
src/uk/org/ownage/dmdirc/Channel.java 查看文件

@@ -27,6 +27,7 @@ import java.beans.PropertyVetoException;
27 27
 import java.lang.reflect.InvocationTargetException;
28 28
 import java.net.URL;
29 29
 import java.util.ArrayList;
30
+import java.util.HashMap;
30 31
 
31 32
 import javax.swing.ImageIcon;
32 33
 import javax.swing.JInternalFrame;
@@ -376,6 +377,16 @@ public final class Channel implements IChannelMessage, IChannelGotNames,
376 377
         return frame.equals(target);
377 378
     }
378 379
     
380
+    /**
381
+     * Ensures that a channel client's map is set up correctly.
382
+     * @param target The ChannelClientInfo to check
383
+     */
384
+    private void mapClient(final ChannelClientInfo target) {
385
+        if (target.getMiscObject() == null) {
386
+            target.setMiscObject(new HashMap<ChannelClientProperty, Object>());
387
+        }
388
+    }
389
+    
379 390
     /**
380 391
      * Called whenever a message is sent to this channel. NB that the ChannelClient
381 392
      * passed may be null if the message was not sent by a client on the channel
@@ -441,6 +452,7 @@ public final class Channel implements IChannelMessage, IChannelGotNames,
441 452
         
442 453
         final ArrayList<String> names = new ArrayList<String>();
443 454
         for (ChannelClientInfo channelClient : cChannel.getChannelClients()) {
455
+            mapClient(channelClient);
444 456
             names.add(channelClient.getNickname());
445 457
         }
446 458
         tabCompleter.replaceEntries(names);
@@ -494,6 +506,8 @@ public final class Channel implements IChannelMessage, IChannelGotNames,
494 506
         
495 507
         final StringBuffer buff = new StringBuffer("channelJoin");
496 508
         
509
+        mapClient(cChannelClient);
510
+        
497 511
         ActionManager.processEvent(CoreActionType.CHANNEL_JOIN, buff, this, cChannelClient);
498 512
         
499 513
         frame.addLine(buff, "", client.getNickname(), client.getIdent(),

+ 34
- 0
src/uk/org/ownage/dmdirc/ChannelClientProperty.java 查看文件

@@ -0,0 +1,34 @@
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 uk.org.ownage.dmdirc;
24
+
25
+/**
26
+ * Represents the properties that can be set on a channel client.
27
+ * @author chris
28
+ */
29
+public enum ChannelClientProperty {
30
+    
31
+    COLOUR_FOREGROUND,
32
+    COLOUR_BACKGROUND;
33
+    
34
+}

Loading…
取消
儲存