GUI -- Enhanced DefaultCellComparator to utilize Comparable implementation if av…
…ailable on the objects being compared, defaulting to string comparison otherwise. - Deleted obsolete comparators. Change-Id: Ifeb74c05f73bd974d1afb3dc27527a5c7ad1bc12
Showing
14 changed files
with
123 additions
and
296 deletions
... | @@ -43,6 +43,9 @@ import static com.google.common.base.Preconditions.checkNotNull; | ... | @@ -43,6 +43,9 @@ import static com.google.common.base.Preconditions.checkNotNull; |
43 | * The table also provides a mechanism for defining how cell values for a | 43 | * The table also provides a mechanism for defining how cell values for a |
44 | * particular column should be formatted into strings, to help facilitate | 44 | * particular column should be formatted into strings, to help facilitate |
45 | * the encoding of the table data into a JSON structure. | 45 | * the encoding of the table data into a JSON structure. |
46 | + * <p> | ||
47 | + * Note that it is expected that all values for a particular column will | ||
48 | + * be the same class. | ||
46 | */ | 49 | */ |
47 | public class TableModel { | 50 | public class TableModel { |
48 | 51 | ... | ... |
... | @@ -20,7 +20,11 @@ package org.onosproject.ui.table.cell; | ... | @@ -20,7 +20,11 @@ package org.onosproject.ui.table.cell; |
20 | import org.onosproject.ui.table.CellComparator; | 20 | import org.onosproject.ui.table.CellComparator; |
21 | 21 | ||
22 | /** | 22 | /** |
23 | - * A default cell comparator. Implements a lexicographical compare function | 23 | + * A default cell comparator. |
24 | + * <p> | ||
25 | + * Verifies that the objects being compared are the same class. | ||
26 | + * Looks to see if the objects being compared implement comparable and, if so, | ||
27 | + * delegates to that; otherwise, implements a lexicographical compare function | ||
24 | * (i.e. string sorting). Uses the objects' toString() method and then | 28 | * (i.e. string sorting). Uses the objects' toString() method and then |
25 | * compares the resulting strings. Note that null values are acceptable and | 29 | * compares the resulting strings. Note that null values are acceptable and |
26 | * are considered "smaller" than any non-null value. | 30 | * are considered "smaller" than any non-null value. |
... | @@ -31,7 +35,13 @@ public final class DefaultCellComparator extends AbstractCellComparator { | ... | @@ -31,7 +35,13 @@ public final class DefaultCellComparator extends AbstractCellComparator { |
31 | private DefaultCellComparator() { } | 35 | private DefaultCellComparator() { } |
32 | 36 | ||
33 | @Override | 37 | @Override |
38 | + @SuppressWarnings("unchecked") | ||
34 | protected int nonNullCompare(Object o1, Object o2) { | 39 | protected int nonNullCompare(Object o1, Object o2) { |
40 | + if (o1 instanceof Comparable) { | ||
41 | + // if o2 is not the same class as o1, then compareTo will | ||
42 | + // throw ClassCastException for us | ||
43 | + return ((Comparable) o1).compareTo(o2); | ||
44 | + } | ||
35 | return o1.toString().compareTo(o2.toString()); | 45 | return o1.toString().compareTo(o2.toString()); |
36 | } | 46 | } |
37 | 47 | ... | ... |
1 | -/* | ||
2 | - * Copyright 2015 Open Networking Laboratory | ||
3 | - * | ||
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | - * you may not use this file except in compliance with the License. | ||
6 | - * You may obtain a copy of the License at | ||
7 | - * | ||
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | - * | ||
10 | - * Unless required by applicable law or agreed to in writing, software | ||
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | - * See the License for the specific language governing permissions and | ||
14 | - * limitations under the License. | ||
15 | - * | ||
16 | - */ | ||
17 | - | ||
18 | -package org.onosproject.ui.table.cell; | ||
19 | - | ||
20 | -import org.onosproject.ui.table.CellComparator; | ||
21 | - | ||
22 | -/** | ||
23 | - * An integer-based cell comparator. | ||
24 | - * Note that null values are acceptable and are considered "smaller" than | ||
25 | - * any non-null value. | ||
26 | - */ | ||
27 | -public final class IntComparator extends AbstractCellComparator { | ||
28 | - | ||
29 | - // non-instantiable | ||
30 | - private IntComparator() { } | ||
31 | - | ||
32 | - @Override | ||
33 | - protected int nonNullCompare(Object o1, Object o2) { | ||
34 | - return ((int) o1) - ((int) o2); | ||
35 | - } | ||
36 | - | ||
37 | - /** | ||
38 | - * An instance of this class. | ||
39 | - */ | ||
40 | - public static final CellComparator INSTANCE = new IntComparator(); | ||
41 | -} |
1 | -/* | ||
2 | - * Copyright 2015 Open Networking Laboratory | ||
3 | - * | ||
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | - * you may not use this file except in compliance with the License. | ||
6 | - * You may obtain a copy of the License at | ||
7 | - * | ||
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | - * | ||
10 | - * Unless required by applicable law or agreed to in writing, software | ||
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | - * See the License for the specific language governing permissions and | ||
14 | - * limitations under the License. | ||
15 | - * | ||
16 | - */ | ||
17 | - | ||
18 | -package org.onosproject.ui.table.cell; | ||
19 | - | ||
20 | -import org.onosproject.ui.table.CellComparator; | ||
21 | - | ||
22 | -/** | ||
23 | - * A long-based cell comparator. | ||
24 | - * Note that null values are acceptable and are considered "smaller" than | ||
25 | - * any non-null value. | ||
26 | - */ | ||
27 | -public final class LongComparator extends AbstractCellComparator { | ||
28 | - | ||
29 | - // non-instantiable | ||
30 | - private LongComparator() { } | ||
31 | - | ||
32 | - @Override | ||
33 | - protected int nonNullCompare(Object o1, Object o2) { | ||
34 | - long diff = ((long) o1) - ((long) o2); | ||
35 | - return diff == 0 ? 0 : (diff < 0 ? -1 : 1); | ||
36 | - } | ||
37 | - | ||
38 | - /** | ||
39 | - * An instance of this class. | ||
40 | - */ | ||
41 | - public static final CellComparator INSTANCE = new LongComparator(); | ||
42 | -} |
... | @@ -20,7 +20,6 @@ import org.junit.Test; | ... | @@ -20,7 +20,6 @@ import org.junit.Test; |
20 | import org.onosproject.ui.table.TableModel.SortDir; | 20 | import org.onosproject.ui.table.TableModel.SortDir; |
21 | import org.onosproject.ui.table.cell.DefaultCellFormatter; | 21 | import org.onosproject.ui.table.cell.DefaultCellFormatter; |
22 | import org.onosproject.ui.table.cell.HexFormatter; | 22 | import org.onosproject.ui.table.cell.HexFormatter; |
23 | -import org.onosproject.ui.table.cell.IntComparator; | ||
24 | 23 | ||
25 | import static org.junit.Assert.*; | 24 | import static org.junit.Assert.*; |
26 | 25 | ||
... | @@ -35,6 +34,10 @@ public class TableModelTest { | ... | @@ -35,6 +34,10 @@ public class TableModelTest { |
35 | private static final String BAR = "bar"; | 34 | private static final String BAR = "bar"; |
36 | private static final String ZOO = "zoo"; | 35 | private static final String ZOO = "zoo"; |
37 | 36 | ||
37 | + private enum StarWars { | ||
38 | + LUKE_SKYWALKER, LEIA_ORGANA, HAN_SOLO, C3PO, R2D2, JABBA_THE_HUTT | ||
39 | + } | ||
40 | + | ||
38 | private static class ParenFormatter implements CellFormatter { | 41 | private static class ParenFormatter implements CellFormatter { |
39 | @Override | 42 | @Override |
40 | public String format(Object value) { | 43 | public String format(Object value) { |
... | @@ -220,9 +223,6 @@ public class TableModelTest { | ... | @@ -220,9 +223,6 @@ public class TableModelTest { |
220 | public void tableNumberSort() { | 223 | public void tableNumberSort() { |
221 | initUnsortedTable(); | 224 | initUnsortedTable(); |
222 | 225 | ||
223 | - // first, tell the table to use an integer-based comparator | ||
224 | - tm.setComparator(BAR, IntComparator.INSTANCE); | ||
225 | - | ||
226 | // sort by number | 226 | // sort by number |
227 | tm.sort(BAR, SortDir.ASC); | 227 | tm.sort(BAR, SortDir.ASC); |
228 | 228 | ||
... | @@ -251,8 +251,7 @@ public class TableModelTest { | ... | @@ -251,8 +251,7 @@ public class TableModelTest { |
251 | public void sortAndFormat() { | 251 | public void sortAndFormat() { |
252 | initUnsortedTable(); | 252 | initUnsortedTable(); |
253 | 253 | ||
254 | - // set integer-based comparator and hex formatter | 254 | + // set hex formatter |
255 | - tm.setComparator(BAR, IntComparator.INSTANCE); | ||
256 | tm.setFormatter(BAR, HexFormatter.INSTANCE); | 255 | tm.setFormatter(BAR, HexFormatter.INSTANCE); |
257 | 256 | ||
258 | // sort by number | 257 | // sort by number |
... | @@ -320,4 +319,26 @@ public class TableModelTest { | ... | @@ -320,4 +319,26 @@ public class TableModelTest { |
320 | assertEquals("null sort dir", SortDir.ASC, TableModel.sortDir(null)); | 319 | assertEquals("null sort dir", SortDir.ASC, TableModel.sortDir(null)); |
321 | } | 320 | } |
322 | 321 | ||
322 | + | ||
323 | + @Test | ||
324 | + public void enumSort() { | ||
325 | + tm = new TableModel(FOO); | ||
326 | + tm.addRow().cell(FOO, StarWars.HAN_SOLO); | ||
327 | + tm.addRow().cell(FOO, StarWars.C3PO); | ||
328 | + tm.addRow().cell(FOO, StarWars.JABBA_THE_HUTT); | ||
329 | + tm.addRow().cell(FOO, StarWars.LEIA_ORGANA); | ||
330 | + tm.addRow().cell(FOO, StarWars.R2D2); | ||
331 | + tm.addRow().cell(FOO, StarWars.LUKE_SKYWALKER); | ||
332 | + | ||
333 | + tm.sort(FOO, SortDir.ASC); | ||
334 | + | ||
335 | + // verify expected results | ||
336 | + StarWars[] ordered = StarWars.values(); | ||
337 | + TableModel.Row[] rows = tm.getRows(); | ||
338 | + assertEquals("wrong length?", ordered.length, rows.length); | ||
339 | + int nr = rows.length; | ||
340 | + for (int i = 0; i < nr; i++) { | ||
341 | + assertEquals(UNEX_SORT + i, ordered[i], rows[i].get(FOO)); | ||
342 | + } | ||
343 | + } | ||
323 | } | 344 | } | ... | ... |
... | @@ -27,20 +27,13 @@ import static org.junit.Assert.assertTrue; | ... | @@ -27,20 +27,13 @@ import static org.junit.Assert.assertTrue; |
27 | */ | 27 | */ |
28 | public class DefaultCellComparatorTest { | 28 | public class DefaultCellComparatorTest { |
29 | 29 | ||
30 | - private static class TestClass { | ||
31 | - @Override | ||
32 | - public String toString() { | ||
33 | - return SOME; | ||
34 | - } | ||
35 | - } | ||
36 | - | ||
37 | private static final String SOME = "SoMeStRiNg"; | 30 | private static final String SOME = "SoMeStRiNg"; |
38 | private static final String OTHER = "OtherSTRING"; | 31 | private static final String OTHER = "OtherSTRING"; |
39 | - private static final int NUMBER = 42; | ||
40 | - private static final TestClass OBJECT = new TestClass(); | ||
41 | 32 | ||
42 | private CellComparator cmp = DefaultCellComparator.INSTANCE; | 33 | private CellComparator cmp = DefaultCellComparator.INSTANCE; |
43 | 34 | ||
35 | + // default comparator should detect Comparable<T> impls and use that | ||
36 | + | ||
44 | @Test | 37 | @Test |
45 | public void sameString() { | 38 | public void sameString() { |
46 | assertTrue("same string", cmp.compare(SOME, SOME) == 0); | 39 | assertTrue("same string", cmp.compare(SOME, SOME) == 0); |
... | @@ -57,28 +50,98 @@ public class DefaultCellComparatorTest { | ... | @@ -57,28 +50,98 @@ public class DefaultCellComparatorTest { |
57 | } | 50 | } |
58 | 51 | ||
59 | @Test | 52 | @Test |
60 | - public void someVsObject() { | 53 | + public void someVsNull() { |
61 | - assertTrue("some vs object", cmp.compare(SOME, OBJECT) == 0); | 54 | + assertTrue("some vs null", cmp.compare(SOME, null) > 0); |
62 | } | 55 | } |
63 | 56 | ||
64 | @Test | 57 | @Test |
65 | - public void otherVsObject() { | 58 | + public void nullVsSome() { |
66 | - assertTrue("other vs object", cmp.compare(OTHER, OBJECT) < 0); | 59 | + assertTrue("null vs some", cmp.compare(null, SOME) < 0); |
67 | } | 60 | } |
68 | 61 | ||
62 | + @Test(expected = ClassCastException.class) | ||
63 | + public void mismatch() { | ||
64 | + cmp.compare(42, SOME); | ||
65 | + } | ||
66 | + | ||
67 | + | ||
69 | @Test | 68 | @Test |
70 | - public void otherVsNumber() { | 69 | + public void strElevenTwo() { |
71 | - assertTrue("other vs 42", cmp.compare(OTHER, NUMBER) > 0); | 70 | + assertTrue("str 11 vs 2", cmp.compare("11", "2") < 0); |
72 | } | 71 | } |
73 | 72 | ||
74 | @Test | 73 | @Test |
75 | - public void someVsNull() { | 74 | + public void intElevenTwo() { |
76 | - assertTrue("some vs null", cmp.compare(SOME, null) > 0); | 75 | + assertTrue("int 11 vs 2", cmp.compare(11, 2) > 0); |
77 | } | 76 | } |
78 | 77 | ||
78 | + | ||
79 | @Test | 79 | @Test |
80 | - public void nullVsSome() { | 80 | + public void intSmallBig() { |
81 | - assertTrue("null vs some", cmp.compare(null, SOME) < 0); | 81 | + assertTrue("int 2 vs 4", cmp.compare(2, 4) < 0); |
82 | + } | ||
83 | + | ||
84 | + @Test | ||
85 | + public void intBigSmall() { | ||
86 | + assertTrue("int 4 vs 2", cmp.compare(4, 2) > 0); | ||
87 | + } | ||
88 | + | ||
89 | + @Test | ||
90 | + public void intEqual() { | ||
91 | + assertTrue("int 4 vs 4", cmp.compare(4, 4) == 0); | ||
92 | + } | ||
93 | + | ||
94 | + @Test | ||
95 | + public void longSmallBig() { | ||
96 | + assertTrue("long 2 vs 4", cmp.compare(2L, 4L) < 0); | ||
82 | } | 97 | } |
83 | 98 | ||
99 | + @Test | ||
100 | + public void longBigSmall() { | ||
101 | + assertTrue("long 4 vs 2", cmp.compare(4L, 2L) > 0); | ||
102 | + } | ||
103 | + | ||
104 | + @Test | ||
105 | + public void longEqual() { | ||
106 | + assertTrue("long 4 vs 4", cmp.compare(4L, 4L) == 0); | ||
107 | + } | ||
108 | + | ||
109 | + | ||
110 | + private enum SmallStarWars { C3PO, R2D2, LUKE } | ||
111 | + | ||
112 | + @Test | ||
113 | + public void swEpisodeI() { | ||
114 | + assertTrue("c3po r2d2", | ||
115 | + cmp.compare(SmallStarWars.C3PO, SmallStarWars.R2D2) < 0); | ||
116 | + } | ||
117 | + | ||
118 | + @Test | ||
119 | + public void swEpisodeII() { | ||
120 | + assertTrue("r2d2 c3po", | ||
121 | + cmp.compare(SmallStarWars.R2D2, SmallStarWars.C3PO) > 0); | ||
122 | + } | ||
123 | + | ||
124 | + @Test | ||
125 | + public void swEpisodeIII() { | ||
126 | + assertTrue("luke c3po", | ||
127 | + cmp.compare(SmallStarWars.LUKE, SmallStarWars.C3PO) > 0); | ||
128 | + } | ||
129 | + | ||
130 | + @Test | ||
131 | + public void swEpisodeIV() { | ||
132 | + assertTrue("c3po luke", | ||
133 | + cmp.compare(SmallStarWars.C3PO, SmallStarWars.LUKE) < 0); | ||
134 | + } | ||
135 | + | ||
136 | + @Test | ||
137 | + public void swEpisodeV() { | ||
138 | + assertTrue("luke r2d2", | ||
139 | + cmp.compare(SmallStarWars.LUKE, SmallStarWars.R2D2) > 0); | ||
140 | + } | ||
141 | + | ||
142 | + @Test | ||
143 | + public void swEpisodeVI() { | ||
144 | + assertTrue("r2d2 luke", | ||
145 | + cmp.compare(SmallStarWars.R2D2, SmallStarWars.LUKE) < 0); | ||
146 | + } | ||
84 | } | 147 | } | ... | ... |
1 | -/* | ||
2 | - * Copyright 2015 Open Networking Laboratory | ||
3 | - * | ||
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | - * you may not use this file except in compliance with the License. | ||
6 | - * You may obtain a copy of the License at | ||
7 | - * | ||
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | - * | ||
10 | - * Unless required by applicable law or agreed to in writing, software | ||
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | - * See the License for the specific language governing permissions and | ||
14 | - * limitations under the License. | ||
15 | - * | ||
16 | - */ | ||
17 | - | ||
18 | -package org.onosproject.ui.table.cell; | ||
19 | - | ||
20 | -import org.junit.Test; | ||
21 | -import org.onosproject.ui.table.CellComparator; | ||
22 | - | ||
23 | -import static org.junit.Assert.assertTrue; | ||
24 | - | ||
25 | -/** | ||
26 | - * Unit tests for {@link IntComparator}. | ||
27 | - */ | ||
28 | -public class IntComparatorTest { | ||
29 | - | ||
30 | - private CellComparator cmp = IntComparator.INSTANCE; | ||
31 | - | ||
32 | - @Test | ||
33 | - public void twoNulls() { | ||
34 | - assertTrue("two nulls", cmp.compare(null, null) == 0); | ||
35 | - } | ||
36 | - | ||
37 | - @Test | ||
38 | - public void nullVsNegValue() { | ||
39 | - assertTrue("null vs neg value", cmp.compare(null, -5) < 0); | ||
40 | - } | ||
41 | - | ||
42 | - @Test | ||
43 | - public void nullVsPosValue() { | ||
44 | - assertTrue("null vs pos value", cmp.compare(null, 5) < 0); | ||
45 | - } | ||
46 | - | ||
47 | - @Test | ||
48 | - public void negValueVsNull() { | ||
49 | - assertTrue("neg value vs null", cmp.compare(-5, null) > 0); | ||
50 | - } | ||
51 | - | ||
52 | - @Test | ||
53 | - public void posValueVsNull() { | ||
54 | - assertTrue("pos value vs null", cmp.compare(5, null) > 0); | ||
55 | - } | ||
56 | - | ||
57 | - | ||
58 | - @Test | ||
59 | - public void smallVsBig() { | ||
60 | - assertTrue("small vs big", cmp.compare(25, 75) < 0); | ||
61 | - } | ||
62 | - | ||
63 | - @Test | ||
64 | - public void bigVsSmall() { | ||
65 | - assertTrue("big vs small", cmp.compare(75, 25) > 0); | ||
66 | - } | ||
67 | - | ||
68 | - @Test | ||
69 | - public void sameValue() { | ||
70 | - assertTrue("same value", cmp.compare(50, 50) == 0); | ||
71 | - } | ||
72 | -} |
1 | -/* | ||
2 | - * Copyright 2015 Open Networking Laboratory | ||
3 | - * | ||
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | - * you may not use this file except in compliance with the License. | ||
6 | - * You may obtain a copy of the License at | ||
7 | - * | ||
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | - * | ||
10 | - * Unless required by applicable law or agreed to in writing, software | ||
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | - * See the License for the specific language governing permissions and | ||
14 | - * limitations under the License. | ||
15 | - * | ||
16 | - */ | ||
17 | - | ||
18 | -package org.onosproject.ui.table.cell; | ||
19 | - | ||
20 | -import org.junit.Test; | ||
21 | -import org.onosproject.ui.table.CellComparator; | ||
22 | - | ||
23 | -import static org.junit.Assert.assertTrue; | ||
24 | - | ||
25 | -/** | ||
26 | - * Unit tests for {@link LongComparator}. | ||
27 | - */ | ||
28 | -public class LongComparatorTest { | ||
29 | - | ||
30 | - private CellComparator cmp = LongComparator.INSTANCE; | ||
31 | - | ||
32 | - @Test | ||
33 | - public void twoNulls() { | ||
34 | - assertTrue("two nulls", cmp.compare(null, null) == 0); | ||
35 | - } | ||
36 | - | ||
37 | - @Test | ||
38 | - public void nullVsNegValue() { | ||
39 | - assertTrue("null vs neg value", cmp.compare(null, -5L) < 0); | ||
40 | - } | ||
41 | - | ||
42 | - @Test | ||
43 | - public void nullVsPosValue() { | ||
44 | - assertTrue("null vs pos value", cmp.compare(null, 5L) < 0); | ||
45 | - } | ||
46 | - | ||
47 | - @Test | ||
48 | - public void negValueVsNull() { | ||
49 | - assertTrue("neg value vs null", cmp.compare(-5L, null) > 0); | ||
50 | - } | ||
51 | - | ||
52 | - @Test | ||
53 | - public void posValueVsNull() { | ||
54 | - assertTrue("pos value vs null", cmp.compare(5L, null) > 0); | ||
55 | - } | ||
56 | - | ||
57 | - | ||
58 | - @Test | ||
59 | - public void smallVsBig() { | ||
60 | - assertTrue("small vs big", cmp.compare(25L, 75L) < 0); | ||
61 | - } | ||
62 | - | ||
63 | - @Test | ||
64 | - public void bigVsSmall() { | ||
65 | - assertTrue("big vs small", cmp.compare(75L, 25L) > 0); | ||
66 | - } | ||
67 | - | ||
68 | - @Test | ||
69 | - public void sameValue() { | ||
70 | - assertTrue("same value", cmp.compare(50L, 50L) == 0); | ||
71 | - } | ||
72 | -} |
... | @@ -26,7 +26,6 @@ import org.onosproject.ui.RequestHandler; | ... | @@ -26,7 +26,6 @@ import org.onosproject.ui.RequestHandler; |
26 | import org.onosproject.ui.UiMessageHandler; | 26 | import org.onosproject.ui.UiMessageHandler; |
27 | import org.onosproject.ui.table.TableModel; | 27 | import org.onosproject.ui.table.TableModel; |
28 | import org.onosproject.ui.table.TableRequestHandler; | 28 | import org.onosproject.ui.table.TableRequestHandler; |
29 | -import org.onosproject.ui.table.cell.IntComparator; | ||
30 | import org.onosproject.ui.table.cell.TimeFormatter; | 29 | import org.onosproject.ui.table.cell.TimeFormatter; |
31 | 30 | ||
32 | import java.util.Collection; | 31 | import java.util.Collection; |
... | @@ -73,7 +72,6 @@ public class ClusterViewMessageHandler extends UiMessageHandler { | ... | @@ -73,7 +72,6 @@ public class ClusterViewMessageHandler extends UiMessageHandler { |
73 | @Override | 72 | @Override |
74 | protected TableModel createTableModel() { | 73 | protected TableModel createTableModel() { |
75 | TableModel tm = super.createTableModel(); | 74 | TableModel tm = super.createTableModel(); |
76 | - tm.setComparator(TCP_PORT, IntComparator.INSTANCE); | ||
77 | tm.setFormatter(UPDATED, new TimeFormatter()); | 75 | tm.setFormatter(UPDATED, new TimeFormatter()); |
78 | return tm; | 76 | return tm; |
79 | } | 77 | } | ... | ... |
... | @@ -31,7 +31,6 @@ import org.onosproject.ui.RequestHandler; | ... | @@ -31,7 +31,6 @@ import org.onosproject.ui.RequestHandler; |
31 | import org.onosproject.ui.UiMessageHandler; | 31 | import org.onosproject.ui.UiMessageHandler; |
32 | import org.onosproject.ui.table.TableModel; | 32 | import org.onosproject.ui.table.TableModel; |
33 | import org.onosproject.ui.table.TableRequestHandler; | 33 | import org.onosproject.ui.table.TableRequestHandler; |
34 | -import org.onosproject.ui.table.cell.IntComparator; | ||
35 | 34 | ||
36 | import java.util.ArrayList; | 35 | import java.util.ArrayList; |
37 | import java.util.Collection; | 36 | import java.util.Collection; |
... | @@ -108,13 +107,6 @@ public class DeviceViewMessageHandler extends UiMessageHandler { | ... | @@ -108,13 +107,6 @@ public class DeviceViewMessageHandler extends UiMessageHandler { |
108 | } | 107 | } |
109 | 108 | ||
110 | @Override | 109 | @Override |
111 | - protected TableModel createTableModel() { | ||
112 | - TableModel tm = super.createTableModel(); | ||
113 | - tm.setComparator(NUM_PORTS, IntComparator.INSTANCE); | ||
114 | - return tm; | ||
115 | - } | ||
116 | - | ||
117 | - @Override | ||
118 | protected void populateTable(TableModel tm, ObjectNode payload) { | 110 | protected void populateTable(TableModel tm, ObjectNode payload) { |
119 | DeviceService ds = get(DeviceService.class); | 111 | DeviceService ds = get(DeviceService.class); |
120 | MastershipService ms = get(MastershipService.class); | 112 | MastershipService ms = get(MastershipService.class); | ... | ... |
... | @@ -30,8 +30,6 @@ import org.onosproject.ui.table.CellFormatter; | ... | @@ -30,8 +30,6 @@ import org.onosproject.ui.table.CellFormatter; |
30 | import org.onosproject.ui.table.TableModel; | 30 | import org.onosproject.ui.table.TableModel; |
31 | import org.onosproject.ui.table.TableRequestHandler; | 31 | import org.onosproject.ui.table.TableRequestHandler; |
32 | import org.onosproject.ui.table.cell.EnumFormatter; | 32 | import org.onosproject.ui.table.cell.EnumFormatter; |
33 | -import org.onosproject.ui.table.cell.IntComparator; | ||
34 | -import org.onosproject.ui.table.cell.LongComparator; | ||
35 | 33 | ||
36 | import java.util.Collection; | 34 | import java.util.Collection; |
37 | import java.util.List; | 35 | import java.util.List; |
... | @@ -86,13 +84,6 @@ public class FlowViewMessageHandler extends UiMessageHandler { | ... | @@ -86,13 +84,6 @@ public class FlowViewMessageHandler extends UiMessageHandler { |
86 | @Override | 84 | @Override |
87 | protected TableModel createTableModel() { | 85 | protected TableModel createTableModel() { |
88 | TableModel tm = super.createTableModel(); | 86 | TableModel tm = super.createTableModel(); |
89 | - tm.setComparator(GROUP_ID, IntComparator.INSTANCE); | ||
90 | - tm.setComparator(TABLE_ID, IntComparator.INSTANCE); | ||
91 | - tm.setComparator(PRIORITY, IntComparator.INSTANCE); | ||
92 | - tm.setComparator(TIMEOUT, IntComparator.INSTANCE); | ||
93 | - tm.setComparator(PACKETS, LongComparator.INSTANCE); | ||
94 | - tm.setComparator(BYTES, LongComparator.INSTANCE); | ||
95 | - | ||
96 | tm.setFormatter(SELECTOR, new SelectorFormatter()); | 87 | tm.setFormatter(SELECTOR, new SelectorFormatter()); |
97 | tm.setFormatter(TREATMENT, new TreatmentFormatter()); | 88 | tm.setFormatter(TREATMENT, new TreatmentFormatter()); |
98 | tm.setFormatter(STATE, EnumFormatter.INSTANCE); | 89 | tm.setFormatter(STATE, EnumFormatter.INSTANCE); | ... | ... |
... | @@ -29,8 +29,6 @@ import org.onosproject.ui.table.CellFormatter; | ... | @@ -29,8 +29,6 @@ import org.onosproject.ui.table.CellFormatter; |
29 | import org.onosproject.ui.table.TableModel; | 29 | import org.onosproject.ui.table.TableModel; |
30 | import org.onosproject.ui.table.TableRequestHandler; | 30 | import org.onosproject.ui.table.TableRequestHandler; |
31 | import org.onosproject.ui.table.cell.EnumFormatter; | 31 | import org.onosproject.ui.table.cell.EnumFormatter; |
32 | -import org.onosproject.ui.table.cell.IntComparator; | ||
33 | -import org.onosproject.ui.table.cell.LongComparator; | ||
34 | 32 | ||
35 | import java.util.Collection; | 33 | import java.util.Collection; |
36 | import java.util.List; | 34 | import java.util.List; |
... | @@ -77,11 +75,6 @@ public class GroupViewMessageHandler extends UiMessageHandler { | ... | @@ -77,11 +75,6 @@ public class GroupViewMessageHandler extends UiMessageHandler { |
77 | @Override | 75 | @Override |
78 | protected TableModel createTableModel() { | 76 | protected TableModel createTableModel() { |
79 | TableModel tm = super.createTableModel(); | 77 | TableModel tm = super.createTableModel(); |
80 | - | ||
81 | - tm.setComparator(ID, IntComparator.INSTANCE); | ||
82 | - tm.setComparator(PACKETS, LongComparator.INSTANCE); | ||
83 | - tm.setComparator(BYTES, LongComparator.INSTANCE); | ||
84 | - | ||
85 | tm.setFormatter(TYPE, EnumFormatter.INSTANCE); | 78 | tm.setFormatter(TYPE, EnumFormatter.INSTANCE); |
86 | tm.setFormatter(BUCKETS, new BucketFormatter()); | 79 | tm.setFormatter(BUCKETS, new BucketFormatter()); |
87 | return tm; | 80 | return tm; | ... | ... |
... | @@ -37,7 +37,6 @@ import org.onosproject.ui.table.CellFormatter; | ... | @@ -37,7 +37,6 @@ import org.onosproject.ui.table.CellFormatter; |
37 | import org.onosproject.ui.table.TableModel; | 37 | import org.onosproject.ui.table.TableModel; |
38 | import org.onosproject.ui.table.TableRequestHandler; | 38 | import org.onosproject.ui.table.TableRequestHandler; |
39 | import org.onosproject.ui.table.cell.AppIdFormatter; | 39 | import org.onosproject.ui.table.cell.AppIdFormatter; |
40 | -import org.onosproject.ui.table.cell.IntComparator; | ||
41 | 40 | ||
42 | import java.util.Collection; | 41 | import java.util.Collection; |
43 | import java.util.List; | 42 | import java.util.List; |
... | @@ -87,8 +86,6 @@ public class IntentViewMessageHandler extends UiMessageHandler { | ... | @@ -87,8 +86,6 @@ public class IntentViewMessageHandler extends UiMessageHandler { |
87 | @Override | 86 | @Override |
88 | protected TableModel createTableModel() { | 87 | protected TableModel createTableModel() { |
89 | TableModel tm = super.createTableModel(); | 88 | TableModel tm = super.createTableModel(); |
90 | - tm.setComparator(PRIORITY, IntComparator.INSTANCE); | ||
91 | - | ||
92 | tm.setFormatter(APP_ID, AppIdFormatter.INSTANCE); | 89 | tm.setFormatter(APP_ID, AppIdFormatter.INSTANCE); |
93 | tm.setFormatter(RESOURCES, new ResourcesFormatter()); | 90 | tm.setFormatter(RESOURCES, new ResourcesFormatter()); |
94 | tm.setFormatter(DETAILS, new DetailsFormatter()); | 91 | tm.setFormatter(DETAILS, new DetailsFormatter()); | ... | ... |
... | @@ -26,7 +26,6 @@ import org.onosproject.ui.RequestHandler; | ... | @@ -26,7 +26,6 @@ import org.onosproject.ui.RequestHandler; |
26 | import org.onosproject.ui.UiMessageHandler; | 26 | import org.onosproject.ui.UiMessageHandler; |
27 | import org.onosproject.ui.table.TableModel; | 27 | import org.onosproject.ui.table.TableModel; |
28 | import org.onosproject.ui.table.TableRequestHandler; | 28 | import org.onosproject.ui.table.TableRequestHandler; |
29 | -import org.onosproject.ui.table.cell.LongComparator; | ||
30 | 29 | ||
31 | import java.util.Collection; | 30 | import java.util.Collection; |
32 | 31 | ||
... | @@ -72,19 +71,6 @@ public class PortViewMessageHandler extends UiMessageHandler { | ... | @@ -72,19 +71,6 @@ public class PortViewMessageHandler extends UiMessageHandler { |
72 | } | 71 | } |
73 | 72 | ||
74 | @Override | 73 | @Override |
75 | - protected TableModel createTableModel() { | ||
76 | - TableModel tm = super.createTableModel(); | ||
77 | - tm.setComparator(PKT_RX, LongComparator.INSTANCE); | ||
78 | - tm.setComparator(PKT_TX, LongComparator.INSTANCE); | ||
79 | - tm.setComparator(BYTES_RX, LongComparator.INSTANCE); | ||
80 | - tm.setComparator(BYTES_TX, LongComparator.INSTANCE); | ||
81 | - tm.setComparator(PKT_RX_DRP, LongComparator.INSTANCE); | ||
82 | - tm.setComparator(PKT_TX_DRP, LongComparator.INSTANCE); | ||
83 | - tm.setComparator(DURATION, LongComparator.INSTANCE); | ||
84 | - return tm; | ||
85 | - } | ||
86 | - | ||
87 | - @Override | ||
88 | protected void populateTable(TableModel tm, ObjectNode payload) { | 74 | protected void populateTable(TableModel tm, ObjectNode payload) { |
89 | String uri = string(payload, "devId"); | 75 | String uri = string(payload, "devId"); |
90 | if (!Strings.isNullOrEmpty(uri)) { | 76 | if (!Strings.isNullOrEmpty(uri)) { | ... | ... |
-
Please register or login to post a comment