GUI -- Deleted deprecated table classes.
Change-Id: I2e8c93ceee4b0e9776d27e528e4d1f036e5d7519
Showing
3 changed files
with
0 additions
and
213 deletions
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 | -package org.onosproject.ui.table; | ||
18 | - | ||
19 | -import com.fasterxml.jackson.databind.ObjectMapper; | ||
20 | -import com.fasterxml.jackson.databind.node.ObjectNode; | ||
21 | - | ||
22 | -import java.util.HashMap; | ||
23 | -import java.util.Map; | ||
24 | - | ||
25 | - | ||
26 | -/** | ||
27 | - * Provides a partial implementation of {@link TableRow}. | ||
28 | - */ | ||
29 | -@Deprecated | ||
30 | -public abstract class AbstractTableRow implements TableRow { | ||
31 | - | ||
32 | - private static final ObjectMapper MAPPER = new ObjectMapper(); | ||
33 | - | ||
34 | - private final Map<String, String> cells = new HashMap<>(); | ||
35 | - | ||
36 | - @Override | ||
37 | - public String get(String key) { | ||
38 | - return cells.get(key); | ||
39 | - } | ||
40 | - | ||
41 | - @Override | ||
42 | - public ObjectNode toJsonNode() { | ||
43 | - ObjectNode result = MAPPER.createObjectNode(); | ||
44 | - for (String id : columnIds()) { | ||
45 | - result.put(id, cells.get(id)); | ||
46 | - } | ||
47 | - return result; | ||
48 | - } | ||
49 | - | ||
50 | - /** | ||
51 | - * Subclasses must provide the list of column IDs. | ||
52 | - * | ||
53 | - * @return array of column IDs | ||
54 | - */ | ||
55 | - protected abstract String[] columnIds(); | ||
56 | - | ||
57 | - /** | ||
58 | - * Add a column ID to cell value binding. | ||
59 | - * | ||
60 | - * @param id the column ID | ||
61 | - * @param value the cell value | ||
62 | - */ | ||
63 | - protected void add(String id, String value) { | ||
64 | - cells.put(id, value); | ||
65 | - } | ||
66 | - | ||
67 | - /** | ||
68 | - * Add a column ID to cell value binding. | ||
69 | - * Note that value.toString() is invoked. | ||
70 | - * | ||
71 | - * @param id the column ID | ||
72 | - * @param value the cell value | ||
73 | - */ | ||
74 | - protected void add(String id, Object value) { | ||
75 | - cells.put(id, value.toString()); | ||
76 | - } | ||
77 | - | ||
78 | - /** | ||
79 | - * Concatenates an arbitrary number of objects, using their | ||
80 | - * toString() methods. | ||
81 | - * | ||
82 | - * @param items the items to concatenate | ||
83 | - * @return a concatenated string | ||
84 | - */ | ||
85 | - protected static String concat(Object... items) { | ||
86 | - StringBuilder sb = new StringBuilder(); | ||
87 | - for (Object o : items) { | ||
88 | - sb.append(o); | ||
89 | - } | ||
90 | - return sb.toString(); | ||
91 | - } | ||
92 | -} |
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 | -package org.onosproject.ui.table; | ||
18 | - | ||
19 | -import java.util.Comparator; | ||
20 | - | ||
21 | -/** | ||
22 | - * Comparator for {@link TableRow}. | ||
23 | - */ | ||
24 | -@Deprecated | ||
25 | -public class RowComparator implements Comparator<TableRow> { | ||
26 | - /** Designates the sort direction. */ | ||
27 | - public enum Direction { | ||
28 | - /** Sort Ascending. */ | ||
29 | - ASC, | ||
30 | - /** Sort Descending. */ | ||
31 | - DESC | ||
32 | - } | ||
33 | - | ||
34 | - public static final String DESC_STR = "desc"; | ||
35 | - | ||
36 | - private final String colId; | ||
37 | - private final Direction dir; | ||
38 | - | ||
39 | - /** | ||
40 | - * Constructs a comparator for table rows that uses the given | ||
41 | - * column ID and direction. | ||
42 | - * | ||
43 | - * @param colId the column to sort on | ||
44 | - * @param dir the direction to sort in | ||
45 | - */ | ||
46 | - public RowComparator(String colId, Direction dir) { | ||
47 | - if (colId == null || dir == null) { | ||
48 | - throw new NullPointerException("Null parameters not allowed"); | ||
49 | - } | ||
50 | - this.colId = colId; | ||
51 | - this.dir = dir; | ||
52 | - } | ||
53 | - | ||
54 | - @Override | ||
55 | - public int compare(TableRow a, TableRow b) { | ||
56 | - String cellA = a.get(colId); | ||
57 | - String cellB = b.get(colId); | ||
58 | - | ||
59 | - if (dir.equals(Direction.ASC)) { | ||
60 | - return cellA.compareTo(cellB); | ||
61 | - } | ||
62 | - return cellB.compareTo(cellA); | ||
63 | - } | ||
64 | - | ||
65 | - /** | ||
66 | - * Returns the sort direction constant for the given string. | ||
67 | - * The expected strings are "asc" and "desc"; defaults to "asc". | ||
68 | - * | ||
69 | - * @param s the direction as a string | ||
70 | - * @return the constant | ||
71 | - */ | ||
72 | - public static Direction direction(String s) { | ||
73 | - return DESC_STR.equals(s) ? Direction.DESC : Direction.ASC; | ||
74 | - } | ||
75 | -} |
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 | -package org.onosproject.ui.table; | ||
18 | - | ||
19 | - | ||
20 | -import com.fasterxml.jackson.databind.node.ObjectNode; | ||
21 | - | ||
22 | -/** | ||
23 | - * Defines a table row abstraction to support sortable tables on the GUI. | ||
24 | - */ | ||
25 | -@Deprecated | ||
26 | -public interface TableRow { | ||
27 | - | ||
28 | - // TODO: Define TableCell interface and return that, rather than String | ||
29 | - // The hope is that this will allow us to write a generic mechanism for | ||
30 | - // selecting a comparator based on the cell type for the column, to be | ||
31 | - // used for sorting the table rows. | ||
32 | - /** | ||
33 | - * Returns the value of the cell for the given column ID. | ||
34 | - * | ||
35 | - * @param key the column ID | ||
36 | - * @return the cell value | ||
37 | - */ | ||
38 | - String get(String key); | ||
39 | - | ||
40 | - /** | ||
41 | - * Returns this table row in the form of a JSON object. | ||
42 | - * | ||
43 | - * @return the JSON node | ||
44 | - */ | ||
45 | - ObjectNode toJsonNode(); | ||
46 | -} |
-
Please register or login to post a comment