|
@@ -24,6 +24,8 @@ package com.dmdirc;
|
24
|
24
|
|
25
|
25
|
import com.dmdirc.interfaces.Connection;
|
26
|
26
|
import com.dmdirc.interfaces.GroupChat;
|
|
27
|
+import com.dmdirc.interfaces.PrivateChat;
|
|
28
|
+import com.dmdirc.interfaces.WindowModel;
|
27
|
29
|
|
28
|
30
|
import java.io.Serializable;
|
29
|
31
|
import java.util.Comparator;
|
|
@@ -33,7 +35,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
33
|
35
|
/**
|
34
|
36
|
* Compares FrameContainers by name.
|
35
|
37
|
*/
|
36
|
|
-public class FrameContainerComparator implements Comparator<FrameContainer>, Serializable {
|
|
38
|
+public class WindowModelComparator implements Comparator<WindowModel>, Serializable {
|
37
|
39
|
|
38
|
40
|
/** A version number for this class. */
|
39
|
41
|
private static final long serialVersionUID = 1;
|
|
@@ -53,7 +55,7 @@ public class FrameContainerComparator implements Comparator<FrameContainer>, Ser
|
53
|
55
|
"item1.toString() returns a non-null value",
|
54
|
56
|
"item2.toString() returns a non-null value"
|
55
|
57
|
})
|
56
|
|
- public int compare(final FrameContainer item1, final FrameContainer item2) {
|
|
58
|
+ public int compare(final WindowModel item1, final WindowModel item2) {
|
57
|
59
|
checkNotNull(item1);
|
58
|
60
|
checkNotNull(item2);
|
59
|
61
|
checkNotNull(item1.getName());
|
|
@@ -83,8 +85,8 @@ public class FrameContainerComparator implements Comparator<FrameContainer>, Ser
|
83
|
85
|
* @return True iff the new container should be before the old container
|
84
|
86
|
*/
|
85
|
87
|
private static boolean sortBefore(
|
86
|
|
- final FrameContainer item1,
|
87
|
|
- final FrameContainer item2) {
|
|
88
|
+ final WindowModel item1,
|
|
89
|
+ final WindowModel item2) {
|
88
|
90
|
return getPosition(item1) < getPosition(item2);
|
89
|
91
|
}
|
90
|
92
|
|
|
@@ -96,8 +98,8 @@ public class FrameContainerComparator implements Comparator<FrameContainer>, Ser
|
96
|
98
|
*
|
97
|
99
|
* @return True iff the new container should be after the old container
|
98
|
100
|
*/
|
99
|
|
- private static boolean sortAfter(final FrameContainer item1,
|
100
|
|
- final FrameContainer item2) {
|
|
101
|
+ private static boolean sortAfter(final WindowModel item1,
|
|
102
|
+ final WindowModel item2) {
|
101
|
103
|
return getPosition(item1) > getPosition(item2);
|
102
|
104
|
}
|
103
|
105
|
|
|
@@ -108,14 +110,15 @@ public class FrameContainerComparator implements Comparator<FrameContainer>, Ser
|
108
|
110
|
*
|
109
|
111
|
* @return Position of the frame container
|
110
|
112
|
*/
|
111
|
|
- private static int getPosition(final FrameContainer item) {
|
|
113
|
+ private static int getPosition(final WindowModel item) {
|
|
114
|
+ // TODO: At some point theses will be separate from WindowModels.
|
112
|
115
|
if (item instanceof GlobalWindow) {
|
113
|
116
|
return 0;
|
114
|
117
|
} else if (item instanceof Connection) {
|
115
|
118
|
return 1;
|
116
|
119
|
} else if (item instanceof GroupChat) {
|
117
|
120
|
return 2;
|
118
|
|
- } else if (item instanceof Query) {
|
|
121
|
+ } else if (item instanceof PrivateChat) {
|
119
|
122
|
return 3;
|
120
|
123
|
} else {
|
121
|
124
|
return 4;
|