Explorar el Código

Add some base classes for events.

pull/1/head
Greg Holmes hace 10 años
padre
commit
d2f09046b5

+ 30
- 0
src/com/dmdirc/events/ActionEvent.java Ver fichero

@@ -0,0 +1,30 @@
1
+/*
2
+ * Copyright (c) 2006-2014 DMDirc Developers
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.events;
24
+
25
+/**
26
+ * Base class for all action events.
27
+ */
28
+public abstract class ActionEvent extends DMDircEvent {
29
+    
30
+}

+ 55
- 0
src/com/dmdirc/events/ChannelDisplayableEvent.java Ver fichero

@@ -0,0 +1,55 @@
1
+/*
2
+ * Copyright (c) 2006-2014 DMDirc Developers
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.events;
24
+
25
+import com.dmdirc.Channel;
26
+
27
+import java.util.concurrent.atomic.AtomicReference;
28
+
29
+/**
30
+ * Base type for displayable events that occur in channels.
31
+ */
32
+public abstract class ChannelDisplayableEvent extends ChannelEvent implements DisplayableEvent {
33
+
34
+    /** The display format to use for this event. */
35
+    private final AtomicReference<String> displayFormatRef = new AtomicReference<>("");
36
+
37
+    public ChannelDisplayableEvent(final long timestamp, final Channel channel) {
38
+        super(timestamp, channel);
39
+    }
40
+
41
+    public ChannelDisplayableEvent(final Channel channel) {
42
+        super(channel);
43
+    }
44
+
45
+    @Override
46
+    public String getDisplayFormat() {
47
+        return displayFormatRef.get();
48
+    }
49
+
50
+    @Override
51
+    public void setDisplayFormat(String format) {
52
+        this.displayFormatRef.set(format);
53
+    }
54
+
55
+}

+ 58
- 0
src/com/dmdirc/events/ChannelDisplayableUserEvent.java Ver fichero

@@ -0,0 +1,58 @@
1
+/*
2
+ * Copyright (c) 2006-2014 DMDirc Developers
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.events;
24
+
25
+import com.dmdirc.Channel;
26
+import com.dmdirc.parser.interfaces.ChannelClientInfo;
27
+
28
+import java.util.concurrent.atomic.AtomicReference;
29
+
30
+/**
31
+ * Base type for displayable events that occur in channels against users.
32
+ */
33
+public abstract class ChannelDisplayableUserEvent extends ChannelUserEvent implements
34
+        DisplayableEvent {
35
+
36
+    /** The display format to use for this event. */
37
+    private final AtomicReference<String> displayFormatRef = new AtomicReference<>("");
38
+
39
+    public ChannelDisplayableUserEvent(final long timestamp, final Channel channel,
40
+            final ChannelClientInfo user) {
41
+        super(timestamp, channel, user);
42
+    }
43
+
44
+    public ChannelDisplayableUserEvent(final Channel channel, final ChannelClientInfo user) {
45
+        super(channel, user);
46
+    }
47
+
48
+    @Override
49
+    public String getDisplayFormat() {
50
+        return displayFormatRef.get();
51
+    }
52
+
53
+    @Override
54
+    public void setDisplayFormat(String format) {
55
+        this.displayFormatRef.set(format);
56
+    }
57
+
58
+}

+ 1
- 15
src/com/dmdirc/events/ChannelEvent.java Ver fichero

@@ -24,19 +24,15 @@ package com.dmdirc.events;
24 24
 
25 25
 import com.dmdirc.Channel;
26 26
 
27
-import java.util.concurrent.atomic.AtomicReference;
28
-
29 27
 import static com.google.common.base.Preconditions.checkNotNull;
30 28
 
31 29
 /**
32 30
  * Base type for events that occur in channels.
33 31
  */
34
-public abstract class ChannelEvent extends DMDircEvent implements DisplayableEvent {
32
+public abstract class ChannelEvent extends DMDircEvent {
35 33
 
36 34
     /** The channel that this event occurred on. */
37 35
     private final Channel channel;
38
-    /** The display format to use for this event. */
39
-    private final AtomicReference<String> displayFormatRef = new AtomicReference<>("");
40 36
 
41 37
     public ChannelEvent(final long timestamp, final Channel channel) {
42 38
         super(timestamp);
@@ -51,14 +47,4 @@ public abstract class ChannelEvent extends DMDircEvent implements DisplayableEve
51 47
         return channel;
52 48
     }
53 49
 
54
-    @Override
55
-    public String getDisplayFormat() {
56
-        return displayFormatRef.get();
57
-    }
58
-
59
-    @Override
60
-    public void setDisplayFormat(String format) {
61
-        this.displayFormatRef.set(format);
62
-    }
63
-
64 50
 }

+ 30
- 0
src/com/dmdirc/events/PluginEvent.java Ver fichero

@@ -0,0 +1,30 @@
1
+/*
2
+ * Copyright (c) 2006-2014 DMDirc Developers
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.events;
24
+
25
+/**
26
+ * Base class for all plugin events.
27
+ */
28
+public abstract class PluginEvent extends DMDircEvent {
29
+    
30
+}

+ 56
- 0
src/com/dmdirc/events/QueryDisplayableEvent.java Ver fichero

@@ -0,0 +1,56 @@
1
+/*
2
+ * Copyright (c) 2006-2014 DMDirc Developers
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.events;
24
+
25
+import com.dmdirc.Query;
26
+
27
+import java.util.concurrent.atomic.AtomicReference;
28
+
29
+/**
30
+ * Base type for displayable events that occur in queries.
31
+ */
32
+public abstract class QueryDisplayableEvent extends QueryEvent implements
33
+        DisplayableEvent {
34
+
35
+    /** The display format to use for this event. */
36
+    private final AtomicReference<String> displayFormatRef = new AtomicReference<>("");
37
+
38
+    public QueryDisplayableEvent(final long timestamp, final Query query) {
39
+        super(timestamp, query);
40
+    }
41
+
42
+    public QueryDisplayableEvent(final Query query) {
43
+        super(query);
44
+    }
45
+
46
+    @Override
47
+    public String getDisplayFormat() {
48
+        return displayFormatRef.get();
49
+    }
50
+
51
+    @Override
52
+    public void setDisplayFormat(String format) {
53
+        this.displayFormatRef.set(format);
54
+    }
55
+
56
+}

+ 50
- 0
src/com/dmdirc/events/QueryEvent.java Ver fichero

@@ -0,0 +1,50 @@
1
+/*
2
+ * Copyright (c) 2006-2014 DMDirc Developers
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.events;
24
+
25
+import com.dmdirc.Query;
26
+
27
+import static com.google.common.base.Preconditions.checkNotNull;
28
+
29
+/**
30
+ * Base type for events that occur in queries.
31
+ */
32
+public abstract class QueryEvent extends DMDircEvent {
33
+
34
+    /** The query that this event occurred on. */
35
+    private final Query query;
36
+
37
+    public QueryEvent(final long timestamp, final Query query) {
38
+        super(timestamp);
39
+        this.query = checkNotNull(query);
40
+    }
41
+
42
+    public QueryEvent(final Query query) {
43
+        this.query = checkNotNull(query);
44
+    }
45
+
46
+    public Query getQuery() {
47
+        return query;
48
+    }
49
+
50
+}

Loading…
Cancelar
Guardar