Bri Prebilic Cole

GUI -- General GUI backend cleanup and bug fixes. Added custom formatters for ex…

…isting tables, unit test for Enum Formatter, and more glyphs.

Change-Id: I956f1faf6a59e535094d45b811980f822b084be0
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.cell;
18 +
19 +import org.junit.Test;
20 +import org.onosproject.ui.table.CellFormatter;
21 +
22 +import static org.junit.Assert.assertEquals;
23 +
24 +/**
25 + * Unit tests for {@link EnumFormatter}.
26 + */
27 +public class EnumFormatterTest {
28 +
29 + enum TestEnum {
30 + ADDED,
31 + PENDING_ADD,
32 + WAITING_AUDIT_COMPLETE
33 + }
34 +
35 + private CellFormatter fmt = EnumFormatter.INSTANCE;
36 +
37 + @Test
38 + public void nullValue() {
39 + assertEquals("null value", "", fmt.format(null));
40 + }
41 +
42 + @Test
43 + public void noUnderscores() {
44 + assertEquals("All caps", "Added", fmt.format(TestEnum.ADDED));
45 + }
46 +
47 + @Test
48 + public void underscores() {
49 + assertEquals("All caps with underscores",
50 + "Pending Add", fmt.format(TestEnum.PENDING_ADD));
51 + }
52 +
53 + @Test
54 + public void multiUnderscores() {
55 + assertEquals("All caps with underscores",
56 + "Waiting Audit Complete",
57 + fmt.format(TestEnum.WAITING_AUDIT_COMPLETE));
58 + }
59 +
60 +}
...@@ -39,6 +39,8 @@ import java.util.Collections; ...@@ -39,6 +39,8 @@ import java.util.Collections;
39 import java.util.List; 39 import java.util.List;
40 import java.util.Set; 40 import java.util.Set;
41 41
42 +import static org.apache.commons.lang.WordUtils.capitalizeFully;
43 +
42 /** 44 /**
43 * Message handler for device view related messages. 45 * Message handler for device view related messages.
44 */ 46 */
...@@ -157,7 +159,7 @@ public class DeviceViewMessageHandler extends UiMessageHandler { ...@@ -157,7 +159,7 @@ public class DeviceViewMessageHandler extends UiMessageHandler {
157 ObjectNode data = MAPPER.createObjectNode(); 159 ObjectNode data = MAPPER.createObjectNode();
158 160
159 data.put(ID, deviceId.toString()); 161 data.put(ID, deviceId.toString());
160 - data.put(TYPE, device.type().toString()); 162 + data.put(TYPE, capitalizeFully(device.type().toString()));
161 data.put(TYPE_IID, getTypeIconId(device)); 163 data.put(TYPE_IID, getTypeIconId(device));
162 data.put(MFR, device.manufacturer()); 164 data.put(MFR, device.manufacturer());
163 data.put(HW, device.hwVersion()); 165 data.put(HW, device.hwVersion());
...@@ -190,8 +192,8 @@ public class DeviceViewMessageHandler extends UiMessageHandler { ...@@ -190,8 +192,8 @@ public class DeviceViewMessageHandler extends UiMessageHandler {
190 LinkService ls = get(LinkService.class); 192 LinkService ls = get(LinkService.class);
191 String name = p.annotations().value(AnnotationKeys.PORT_NAME); 193 String name = p.annotations().value(AnnotationKeys.PORT_NAME);
192 194
193 - port.put(ID, p.number().toString()); 195 + port.put(ID, capitalizeFully(p.number().toString()));
194 - port.put(TYPE, p.type().toString()); 196 + port.put(TYPE, capitalizeFully(p.type().toString()));
195 port.put(SPEED, p.portSpeed()); 197 port.put(SPEED, p.portSpeed());
196 port.put(ENABLED, p.isEnabled()); 198 port.put(ENABLED, p.isEnabled());
197 port.put(NAME, name != null ? name : ""); 199 port.put(NAME, name != null ? name : "");
......
...@@ -22,14 +22,14 @@ import com.google.common.collect.ImmutableSet; ...@@ -22,14 +22,14 @@ import com.google.common.collect.ImmutableSet;
22 import org.onosproject.net.DeviceId; 22 import org.onosproject.net.DeviceId;
23 import org.onosproject.net.flow.FlowEntry; 23 import org.onosproject.net.flow.FlowEntry;
24 import org.onosproject.net.flow.FlowRuleService; 24 import org.onosproject.net.flow.FlowRuleService;
25 -import org.onosproject.net.flow.TrafficSelector;
26 -import org.onosproject.net.flow.TrafficTreatment;
27 import org.onosproject.net.flow.criteria.Criterion; 25 import org.onosproject.net.flow.criteria.Criterion;
28 import org.onosproject.net.flow.instructions.Instruction; 26 import org.onosproject.net.flow.instructions.Instruction;
29 import org.onosproject.ui.RequestHandler; 27 import org.onosproject.ui.RequestHandler;
30 import org.onosproject.ui.UiMessageHandler; 28 import org.onosproject.ui.UiMessageHandler;
29 +import org.onosproject.ui.table.CellFormatter;
31 import org.onosproject.ui.table.TableModel; 30 import org.onosproject.ui.table.TableModel;
32 import org.onosproject.ui.table.TableRequestHandler; 31 import org.onosproject.ui.table.TableRequestHandler;
32 +import org.onosproject.ui.table.cell.EnumFormatter;
33 import org.onosproject.ui.table.cell.IntComparator; 33 import org.onosproject.ui.table.cell.IntComparator;
34 import org.onosproject.ui.table.cell.LongComparator; 34 import org.onosproject.ui.table.cell.LongComparator;
35 35
...@@ -37,9 +37,6 @@ import java.util.Collection; ...@@ -37,9 +37,6 @@ import java.util.Collection;
37 import java.util.List; 37 import java.util.List;
38 import java.util.Set; 38 import java.util.Set;
39 39
40 -import static org.apache.commons.lang.WordUtils.capitalizeFully;
41 -
42 -
43 /** 40 /**
44 * Message handler for flow view related messages. 41 * Message handler for flow view related messages.
45 */ 42 */
...@@ -95,6 +92,10 @@ public class FlowViewMessageHandler extends UiMessageHandler { ...@@ -95,6 +92,10 @@ public class FlowViewMessageHandler extends UiMessageHandler {
95 tm.setComparator(TIMEOUT, IntComparator.INSTANCE); 92 tm.setComparator(TIMEOUT, IntComparator.INSTANCE);
96 tm.setComparator(PACKETS, LongComparator.INSTANCE); 93 tm.setComparator(PACKETS, LongComparator.INSTANCE);
97 tm.setComparator(BYTES, LongComparator.INSTANCE); 94 tm.setComparator(BYTES, LongComparator.INSTANCE);
95 +
96 + tm.setFormatter(SELECTOR, new SelectorFormatter());
97 + tm.setFormatter(TREATMENT, new TreatmentFormatter());
98 + tm.setFormatter(STATE, EnumFormatter.INSTANCE);
98 return tm; 99 return tm;
99 } 100 }
100 101
...@@ -116,73 +117,50 @@ public class FlowViewMessageHandler extends UiMessageHandler { ...@@ -116,73 +117,50 @@ public class FlowViewMessageHandler extends UiMessageHandler {
116 .cell(GROUP_ID, flow.groupId().id()) 117 .cell(GROUP_ID, flow.groupId().id())
117 .cell(TABLE_ID, flow.tableId()) 118 .cell(TABLE_ID, flow.tableId())
118 .cell(PRIORITY, flow.priority()) 119 .cell(PRIORITY, flow.priority())
119 - .cell(SELECTOR, getSelectorString(flow)) 120 + .cell(SELECTOR, flow)
120 - .cell(TREATMENT, getTreatmentString(flow)) 121 + .cell(TREATMENT, flow)
121 .cell(TIMEOUT, flow.timeout()) 122 .cell(TIMEOUT, flow.timeout())
122 .cell(PERMANENT, flow.isPermanent()) 123 .cell(PERMANENT, flow.isPermanent())
123 - .cell(STATE, capitalizeFully(flow.state().toString())) 124 + .cell(STATE, flow.state())
124 .cell(PACKETS, flow.packets()) 125 .cell(PACKETS, flow.packets())
125 .cell(BYTES, flow.bytes()); 126 .cell(BYTES, flow.bytes());
126 } 127 }
127 128
128 - private String getSelectorString(FlowEntry f) { 129 + private final class SelectorFormatter implements CellFormatter {
129 - String result; 130 + @Override
130 - TrafficSelector selector = f.selector(); 131 + public String format(Object value) {
131 - Set<Criterion> criteria = selector.criteria(); 132 + FlowEntry flow = (FlowEntry) value;
133 + Set<Criterion> criteria = flow.selector().criteria();
132 134
133 if (criteria.isEmpty()) { 135 if (criteria.isEmpty()) {
134 - result = "(No traffic selectors for this flow)"; 136 + return "(No traffic selector criteria for this flow)";
135 - } else { 137 + }
136 - StringBuilder sb = new StringBuilder("Criteria = "); 138 + StringBuilder sb = new StringBuilder("Criteria: ");
137 for (Criterion c : criteria) { 139 for (Criterion c : criteria) {
138 - sb.append(capitalizeFully(c.type().toString())).append(COMMA); 140 + sb.append(c).append(COMMA);
139 } 141 }
140 - result = removeTrailingComma(sb).toString(); 142 + removeTrailingComma(sb);
143 +
144 + return sb.toString();
141 } 145 }
142 - return result;
143 } 146 }
144 147
145 - private String getTreatmentString(FlowEntry f) { 148 + private final class TreatmentFormatter implements CellFormatter {
146 - TrafficTreatment treatment = f.treatment(); 149 + @Override
147 - List<Instruction> deferred = treatment.deferred(); 150 + public String format(Object value) {
148 - List<Instruction> immediate = treatment.immediate(); 151 + FlowEntry flow = (FlowEntry) value;
149 - boolean haveDef = !deferred.isEmpty(); 152 + List<Instruction> instructions = flow.treatment().allInstructions();
150 - boolean haveImm = !immediate.isEmpty();
151 - boolean both = haveDef && haveImm;
152 - boolean neither = !haveDef && !haveImm;
153 - String result;
154 153
155 - if (neither) { 154 + if (instructions.isEmpty()) {
156 - result = "(No traffic treatment instructions for this flow)"; 155 + return "(No traffic treatment instructions for this flow)";
157 - } else {
158 - StringBuilder sb = new StringBuilder();
159 - addDeferred(sb, deferred);
160 - if (both) {
161 - sb.append(COMMA);
162 } 156 }
163 - addImmediate(sb, immediate); 157 + StringBuilder sb = new StringBuilder("Treatment Instructions: ");
164 - result = sb.toString(); 158 + for (Instruction i : instructions) {
165 - } 159 + sb.append(i).append(COMMA);
166 - return result;
167 - }
168 -
169 - private void addDeferred(StringBuilder sb, List<Instruction> deferred) {
170 - if (!deferred.isEmpty()) {
171 - sb.append("Deferred instructions = ");
172 - for (Instruction i : deferred) {
173 - sb.append(capitalizeFully(i.type().toString())).append(COMMA);
174 } 160 }
175 removeTrailingComma(sb); 161 removeTrailingComma(sb);
176 - }
177 - }
178 162
179 - private void addImmediate(StringBuilder sb, List<Instruction> immediate) { 163 + return sb.toString();
180 - if (!immediate.isEmpty()) {
181 - sb.append("Immediate instructions = ");
182 - for (Instruction i : immediate) {
183 - sb.append(capitalizeFully(i.type().toString())).append(COMMA);
184 - }
185 - removeTrailingComma(sb);
186 } 164 }
187 } 165 }
188 166
......
...@@ -123,9 +123,9 @@ public class GroupViewMessageHandler extends UiMessageHandler { ...@@ -123,9 +123,9 @@ public class GroupViewMessageHandler extends UiMessageHandler {
123 123
124 for (GroupBucket b : buckets) { 124 for (GroupBucket b : buckets) {
125 sb.append("Bytes: ") 125 sb.append("Bytes: ")
126 - .append(Long.toString(b.bytes())) 126 + .append(b.bytes())
127 .append(" Packets: ") 127 .append(" Packets: ")
128 - .append(Long.toString(b.packets())) 128 + .append(b.packets())
129 .append(" Actions: ") 129 .append(" Actions: ")
130 .append(b.treatment().allInstructions()) 130 .append(b.treatment().allInstructions())
131 .append(COMMA); 131 .append(COMMA);
......
...@@ -17,16 +17,19 @@ package org.onosproject.ui.impl; ...@@ -17,16 +17,19 @@ package org.onosproject.ui.impl;
17 17
18 import com.fasterxml.jackson.databind.node.ObjectNode; 18 import com.fasterxml.jackson.databind.node.ObjectNode;
19 import com.google.common.collect.ImmutableSet; 19 import com.google.common.collect.ImmutableSet;
20 +import org.onlab.packet.IpAddress;
20 import org.onosproject.net.AnnotationKeys; 21 import org.onosproject.net.AnnotationKeys;
21 import org.onosproject.net.Host; 22 import org.onosproject.net.Host;
22 import org.onosproject.net.host.HostService; 23 import org.onosproject.net.host.HostService;
23 import org.onosproject.ui.RequestHandler; 24 import org.onosproject.ui.RequestHandler;
24 import org.onosproject.ui.UiMessageHandler; 25 import org.onosproject.ui.UiMessageHandler;
26 +import org.onosproject.ui.table.CellFormatter;
25 import org.onosproject.ui.table.TableModel; 27 import org.onosproject.ui.table.TableModel;
26 import org.onosproject.ui.table.TableRequestHandler; 28 import org.onosproject.ui.table.TableRequestHandler;
27 import org.onosproject.ui.table.cell.HostLocationFormatter; 29 import org.onosproject.ui.table.cell.HostLocationFormatter;
28 30
29 import java.util.Collection; 31 import java.util.Collection;
32 +import java.util.Set;
30 33
31 import static com.google.common.base.Strings.isNullOrEmpty; 34 import static com.google.common.base.Strings.isNullOrEmpty;
32 35
...@@ -72,6 +75,7 @@ public class HostViewMessageHandler extends UiMessageHandler { ...@@ -72,6 +75,7 @@ public class HostViewMessageHandler extends UiMessageHandler {
72 protected TableModel createTableModel() { 75 protected TableModel createTableModel() {
73 TableModel tm = super.createTableModel(); 76 TableModel tm = super.createTableModel();
74 tm.setFormatter(LOCATION, HostLocationFormatter.INSTANCE); 77 tm.setFormatter(LOCATION, HostLocationFormatter.INSTANCE);
78 + tm.setFormatter(IPS, new IpSetFormatter());
75 return tm; 79 return tm;
76 } 80 }
77 81
...@@ -97,5 +101,30 @@ public class HostViewMessageHandler extends UiMessageHandler { ...@@ -97,5 +101,30 @@ public class HostViewMessageHandler extends UiMessageHandler {
97 return HOST_ICON_PREFIX + 101 return HOST_ICON_PREFIX +
98 (isNullOrEmpty(hostType) ? "endstation" : hostType); 102 (isNullOrEmpty(hostType) ? "endstation" : hostType);
99 } 103 }
104 +
105 + private final class IpSetFormatter implements CellFormatter {
106 + private static final String COMMA = ", ";
107 +
108 + @Override
109 + public String format(Object value) {
110 + Set<IpAddress> ips = (Set<IpAddress>) value;
111 + if (ips.isEmpty()) {
112 + return "(No IP Addresses for this host)";
113 + }
114 + StringBuilder sb = new StringBuilder();
115 + for (IpAddress ip : ips) {
116 + sb.append(ip.toString())
117 + .append(COMMA);
118 + }
119 + removeTrailingComma(sb);
120 + return sb.toString();
121 + }
122 +
123 + private StringBuilder removeTrailingComma(StringBuilder sb) {
124 + int pos = sb.lastIndexOf(COMMA);
125 + sb.delete(pos, sb.length());
126 + return sb;
127 + }
128 + }
100 } 129 }
101 } 130 }
......
...@@ -18,6 +18,7 @@ package org.onosproject.ui.impl; ...@@ -18,6 +18,7 @@ package org.onosproject.ui.impl;
18 import com.fasterxml.jackson.databind.node.ObjectNode; 18 import com.fasterxml.jackson.databind.node.ObjectNode;
19 import com.google.common.collect.ImmutableSet; 19 import com.google.common.collect.ImmutableSet;
20 import org.onosproject.net.ConnectPoint; 20 import org.onosproject.net.ConnectPoint;
21 +import org.onosproject.net.NetworkResource;
21 import org.onosproject.net.flow.criteria.Criterion; 22 import org.onosproject.net.flow.criteria.Criterion;
22 import org.onosproject.net.flow.instructions.Instruction; 23 import org.onosproject.net.flow.instructions.Instruction;
23 import org.onosproject.net.intent.ConnectivityIntent; 24 import org.onosproject.net.intent.ConnectivityIntent;
...@@ -32,6 +33,7 @@ import org.onosproject.net.intent.PointToPointIntent; ...@@ -32,6 +33,7 @@ import org.onosproject.net.intent.PointToPointIntent;
32 import org.onosproject.net.intent.SinglePointToMultiPointIntent; 33 import org.onosproject.net.intent.SinglePointToMultiPointIntent;
33 import org.onosproject.ui.RequestHandler; 34 import org.onosproject.ui.RequestHandler;
34 import org.onosproject.ui.UiMessageHandler; 35 import org.onosproject.ui.UiMessageHandler;
36 +import org.onosproject.ui.table.CellFormatter;
35 import org.onosproject.ui.table.TableModel; 37 import org.onosproject.ui.table.TableModel;
36 import org.onosproject.ui.table.TableRequestHandler; 38 import org.onosproject.ui.table.TableRequestHandler;
37 import org.onosproject.ui.table.cell.AppIdFormatter; 39 import org.onosproject.ui.table.cell.AppIdFormatter;
...@@ -86,7 +88,10 @@ public class IntentViewMessageHandler extends UiMessageHandler { ...@@ -86,7 +88,10 @@ public class IntentViewMessageHandler extends UiMessageHandler {
86 protected TableModel createTableModel() { 88 protected TableModel createTableModel() {
87 TableModel tm = super.createTableModel(); 89 TableModel tm = super.createTableModel();
88 tm.setComparator(PRIORITY, IntComparator.INSTANCE); 90 tm.setComparator(PRIORITY, IntComparator.INSTANCE);
91 +
89 tm.setFormatter(APP_ID, AppIdFormatter.INSTANCE); 92 tm.setFormatter(APP_ID, AppIdFormatter.INSTANCE);
93 + tm.setFormatter(RESOURCES, new ResourcesFormatter());
94 + tm.setFormatter(DETAILS, new DetailsFormatter());
90 return tm; 95 return tm;
91 } 96 }
92 97
...@@ -103,137 +108,168 @@ public class IntentViewMessageHandler extends UiMessageHandler { ...@@ -103,137 +108,168 @@ public class IntentViewMessageHandler extends UiMessageHandler {
103 .cell(KEY, intent.key()) 108 .cell(KEY, intent.key())
104 .cell(TYPE, intent.getClass().getSimpleName()) 109 .cell(TYPE, intent.getClass().getSimpleName())
105 .cell(PRIORITY, intent.priority()) 110 .cell(PRIORITY, intent.priority())
106 - .cell(RESOURCES, formatResources(intent)) 111 + .cell(RESOURCES, intent)
107 - .cell(DETAILS, formatDetails(intent)); 112 + .cell(DETAILS, intent);
113 + }
114 +
115 + private final class ResourcesFormatter implements CellFormatter {
116 + private static final String COMMA = ", ";
117 +
118 + @Override
119 + public String format(Object value) {
120 + Intent intent = (Intent) value;
121 + Collection<NetworkResource> resources = intent.resources();
122 + if (resources.isEmpty()) {
123 + return "(No resources for this intent)";
124 + }
125 + StringBuilder sb = new StringBuilder("Resources: ");
126 + for (NetworkResource nr : resources) {
127 + sb.append(nr).append(COMMA);
128 + }
129 + removeTrailingComma(sb);
130 +
131 + return sb.toString();
108 } 132 }
109 133
134 + private StringBuilder removeTrailingComma(StringBuilder sb) {
135 + int pos = sb.lastIndexOf(COMMA);
136 + sb.delete(pos, sb.length());
137 + return sb;
138 + }
139 + }
110 140
111 - // == TODO: Review -- Move the following code to a helper class? 141 + private final class DetailsFormatter implements CellFormatter {
112 - private StringBuilder details = new StringBuilder(); 142 + @Override
143 + public String format(Object value) {
144 + return formatDetails((Intent) value, new StringBuilder()).toString();
145 + }
113 146
114 - private void appendMultiPointsDetails(Set<ConnectPoint> points) { 147 + private StringBuilder formatDetails(Intent intent, StringBuilder sb) {
148 + if (intent instanceof ConnectivityIntent) {
149 + buildConnectivityDetails((ConnectivityIntent) intent, sb);
150 + }
151 +
152 + if (intent instanceof HostToHostIntent) {
153 + buildHostToHostDetails((HostToHostIntent) intent, sb);
154 +
155 + } else if (intent instanceof PointToPointIntent) {
156 + buildPointToPointDetails((PointToPointIntent) intent, sb);
157 +
158 + } else if (intent instanceof MultiPointToSinglePointIntent) {
159 + buildMPToSPDetails((MultiPointToSinglePointIntent) intent, sb);
160 +
161 + } else if (intent instanceof SinglePointToMultiPointIntent) {
162 + buildSPToMPDetails((SinglePointToMultiPointIntent) intent, sb);
163 +
164 + } else if (intent instanceof PathIntent) {
165 + buildPathDetails((PathIntent) intent, sb);
166 +
167 + } else if (intent instanceof LinkCollectionIntent) {
168 + buildLinkConnectionDetails((LinkCollectionIntent) intent, sb);
169 + }
170 +
171 + if (sb.length() == 0) {
172 + sb.append("(No details for this intent)");
173 + } else {
174 + sb.insert(0, "Details: ");
175 + }
176 + return sb;
177 + }
178 +
179 + private void appendMultiPointsDetails(Set<ConnectPoint> points,
180 + StringBuilder sb) {
115 for (ConnectPoint point : points) { 181 for (ConnectPoint point : points) {
116 - details.append(point.elementId()) 182 + sb.append(point.elementId())
117 .append('/') 183 .append('/')
118 .append(point.port()) 184 .append(point.port())
119 .append(' '); 185 .append(' ');
120 } 186 }
121 } 187 }
122 188
123 - private void buildConnectivityDetails(ConnectivityIntent intent) { 189 + private void buildConnectivityDetails(ConnectivityIntent intent,
190 + StringBuilder sb) {
124 Set<Criterion> criteria = intent.selector().criteria(); 191 Set<Criterion> criteria = intent.selector().criteria();
125 List<Instruction> instructions = intent.treatment().allInstructions(); 192 List<Instruction> instructions = intent.treatment().allInstructions();
126 List<Constraint> constraints = intent.constraints(); 193 List<Constraint> constraints = intent.constraints();
127 194
128 if (!criteria.isEmpty()) { 195 if (!criteria.isEmpty()) {
129 - details.append("selector=").append(criteria); 196 + sb.append("Selector: ").append(criteria);
130 } 197 }
131 if (!instructions.isEmpty()) { 198 if (!instructions.isEmpty()) {
132 - details.append("treatment=").append(instructions); 199 + sb.append("Treatment: ").append(instructions);
133 } 200 }
134 if (constraints != null && !constraints.isEmpty()) { 201 if (constraints != null && !constraints.isEmpty()) {
135 - details.append("constraints=").append(constraints); 202 + sb.append("Constraints: ").append(constraints);
136 } 203 }
137 } 204 }
138 205
139 - private void buildHostToHostDetails(HostToHostIntent intent) { 206 + private void buildHostToHostDetails(HostToHostIntent intent,
140 - details.append(" host1=") 207 + StringBuilder sb) {
208 + sb.append(" Host 1: ")
141 .append(intent.one()) 209 .append(intent.one())
142 - .append(", host2=") 210 + .append(", Host 2: ")
143 .append(intent.two()); 211 .append(intent.two());
144 } 212 }
145 213
146 - private void buildPointToPointDetails(PointToPointIntent intent) { 214 + private void buildPointToPointDetails(PointToPointIntent intent,
215 + StringBuilder sb) {
147 ConnectPoint ingress = intent.ingressPoint(); 216 ConnectPoint ingress = intent.ingressPoint();
148 ConnectPoint egress = intent.egressPoint(); 217 ConnectPoint egress = intent.egressPoint();
149 - details.append(" ingress=") 218 + sb.append(" Ingress: ")
150 .append(ingress.elementId()) 219 .append(ingress.elementId())
151 .append('/') 220 .append('/')
152 .append(ingress.port()) 221 .append(ingress.port())
153 222
154 - .append(", egress=") 223 + .append(", Egress: ")
155 .append(egress.elementId()) 224 .append(egress.elementId())
156 .append('/') 225 .append('/')
157 .append(egress.port()) 226 .append(egress.port())
158 .append(' '); 227 .append(' ');
159 } 228 }
160 229
161 - private void buildMPToSPDetails(MultiPointToSinglePointIntent intent) { 230 + private void buildMPToSPDetails(MultiPointToSinglePointIntent intent,
231 + StringBuilder sb) {
162 ConnectPoint egress = intent.egressPoint(); 232 ConnectPoint egress = intent.egressPoint();
163 233
164 - details.append(" ingress="); 234 + sb.append(" Ingress=");
165 - appendMultiPointsDetails(intent.ingressPoints()); 235 + appendMultiPointsDetails(intent.ingressPoints(), sb);
166 236
167 - details.append(", egress=") 237 + sb.append(", Egress=")
168 .append(egress.elementId()) 238 .append(egress.elementId())
169 .append('/') 239 .append('/')
170 .append(egress.port()) 240 .append(egress.port())
171 .append(' '); 241 .append(' ');
172 } 242 }
173 243
174 - private void buildSPToMPDetails(SinglePointToMultiPointIntent intent) { 244 + private void buildSPToMPDetails(SinglePointToMultiPointIntent intent,
245 + StringBuilder sb) {
175 ConnectPoint ingress = intent.ingressPoint(); 246 ConnectPoint ingress = intent.ingressPoint();
176 247
177 - details.append(" ingress=") 248 + sb.append(" Ingress=")
178 .append(ingress.elementId()) 249 .append(ingress.elementId())
179 .append('/') 250 .append('/')
180 .append(ingress.port()) 251 .append(ingress.port())
181 - .append(", egress="); 252 + .append(", Egress=");
182 253
183 - appendMultiPointsDetails(intent.egressPoints()); 254 + appendMultiPointsDetails(intent.egressPoints(), sb);
184 } 255 }
185 256
186 - private void buildPathDetails(PathIntent intent) { 257 + private void buildPathDetails(PathIntent intent, StringBuilder sb) {
187 - details.append(" path=") 258 + sb.append(" path=")
188 .append(intent.path().links()) 259 .append(intent.path().links())
189 .append(", cost=") 260 .append(", cost=")
190 .append(intent.path().cost()); 261 .append(intent.path().cost());
191 } 262 }
192 263
193 - private void buildLinkConnectionDetails(LinkCollectionIntent intent) { 264 + private void buildLinkConnectionDetails(LinkCollectionIntent intent,
194 - details.append(" links=") 265 + StringBuilder sb) {
266 + sb.append(" links=")
195 .append(intent.links()) 267 .append(intent.links())
196 .append(", egress="); 268 .append(", egress=");
197 269
198 - appendMultiPointsDetails(intent.egressPoints()); 270 + appendMultiPointsDetails(intent.egressPoints(), sb);
199 - }
200 -
201 - private String formatDetails(Intent intent) {
202 - if (intent instanceof ConnectivityIntent) {
203 - buildConnectivityDetails((ConnectivityIntent) intent);
204 - }
205 -
206 - if (intent instanceof HostToHostIntent) {
207 - buildHostToHostDetails((HostToHostIntent) intent);
208 -
209 - } else if (intent instanceof PointToPointIntent) {
210 - buildPointToPointDetails((PointToPointIntent) intent);
211 -
212 - } else if (intent instanceof MultiPointToSinglePointIntent) {
213 - buildMPToSPDetails((MultiPointToSinglePointIntent) intent);
214 -
215 - } else if (intent instanceof SinglePointToMultiPointIntent) {
216 - buildSPToMPDetails((SinglePointToMultiPointIntent) intent);
217 -
218 - } else if (intent instanceof PathIntent) {
219 - buildPathDetails((PathIntent) intent);
220 -
221 - } else if (intent instanceof LinkCollectionIntent) {
222 - buildLinkConnectionDetails((LinkCollectionIntent) intent);
223 - }
224 -
225 - if (details.length() == 0) {
226 - details.append("(No details for this intent)");
227 - } else {
228 - details.insert(0, "Details: ");
229 - }
230 - return details.toString();
231 } 271 }
232 272
233 - private String formatResources(Intent intent) {
234 - return (intent.resources().isEmpty() ?
235 - "(No resources for this intent)" :
236 - "Resources: " + intent.resources());
237 } 273 }
238 } 274 }
239 } 275 }
......
...@@ -28,6 +28,7 @@ import org.onosproject.ui.impl.TopologyViewMessageHandlerBase.BiLink; ...@@ -28,6 +28,7 @@ import org.onosproject.ui.impl.TopologyViewMessageHandlerBase.BiLink;
28 import org.onosproject.ui.table.TableModel; 28 import org.onosproject.ui.table.TableModel;
29 import org.onosproject.ui.table.TableRequestHandler; 29 import org.onosproject.ui.table.TableRequestHandler;
30 import org.onosproject.ui.table.cell.ConnectPointFormatter; 30 import org.onosproject.ui.table.cell.ConnectPointFormatter;
31 +import org.onosproject.ui.table.cell.EnumFormatter;
31 32
32 import java.util.Collection; 33 import java.util.Collection;
33 import java.util.Map; 34 import java.util.Map;
...@@ -83,6 +84,7 @@ public class LinkViewMessageHandler extends UiMessageHandler { ...@@ -83,6 +84,7 @@ public class LinkViewMessageHandler extends UiMessageHandler {
83 TableModel tm = super.createTableModel(); 84 TableModel tm = super.createTableModel();
84 tm.setFormatter(ONE, ConnectPointFormatter.INSTANCE); 85 tm.setFormatter(ONE, ConnectPointFormatter.INSTANCE);
85 tm.setFormatter(TWO, ConnectPointFormatter.INSTANCE); 86 tm.setFormatter(TWO, ConnectPointFormatter.INSTANCE);
87 + tm.setFormatter(TYPE, EnumFormatter.INSTANCE);
86 return tm; 88 return tm;
87 } 89 }
88 90
...@@ -113,7 +115,7 @@ public class LinkViewMessageHandler extends UiMessageHandler { ...@@ -113,7 +115,7 @@ public class LinkViewMessageHandler extends UiMessageHandler {
113 if (link.two != null && link.two.type() != link.one.type()) { 115 if (link.two != null && link.two.type() != link.one.type()) {
114 sb.append(" / ").append(link.two.type()); 116 sb.append(" / ").append(link.two.type());
115 } 117 }
116 - return sb.toString().toLowerCase(); 118 + return sb.toString();
117 } 119 }
118 120
119 private String linkState(BiLink link) { 121 private String linkState(BiLink link) {
......
...@@ -152,6 +152,40 @@ ...@@ -152,6 +152,40 @@
152 '4.3S57.5,83.5,55.1,83.5zM84.2,63.2c0-2.3-1.9-4.3-4.3-4.3s-4.3,' + 152 '4.3S57.5,83.5,55.1,83.5zM84.2,63.2c0-2.3-1.9-4.3-4.3-4.3s-4.3,' +
153 '1.9-4.3,4.3s1.9,4.3,4.3,4.3S84.2,65.5,84.2,63.2z', 153 '1.9-4.3,4.3s1.9,4.3,4.3,4.3S84.2,65.5,84.2,63.2z',
154 154
155 + portTable: 'M15.9,19.1h-8v-13h8V19.1z M90.5,6.1H75.6v13h14.9V6.1' +
156 + 'z M71.9,6.1H56.9v13h14.9V6.1z M53.2,6.1H38.3v13h14.9V6.1z M34.5,' +
157 + '6.1H19.6v13h14.9V6.1z M102.2,6.1h-8v13h8V6.1z M102.6,23.6v78.5H' +
158 + '8.2V23.6H102.6z M85.5,37.7c0-0.7-0.4-1.3-0.9-1.3H26.2c-0.5,0-' +
159 + '0.9,0.6-0.9,1.3v34.6c0,0.7,0.4,1.3,0.9,1.3h11v9.6c0,1.1,0.5,2,' +
160 + '1.2,2h9.1c0,0.2,0,0.3,0,0.5v3c0,1.1,0.5,2,1.2,2h13.5c0.6,0,1.2-' +
161 + '0.9,1.2-2v-3c0-0.2,0-0.3,0-0.5h9.1c0.6,0,1.2-0.9,1.2-2v-9.6h11' +
162 + 'c0.5,0,0.9-0.6,0.9-1.3V37.7z M30.2,40h-1v8h1V40zM75.2,40h-2.1v8' +
163 + 'h2.1V40z M67.7,40h-2.1v8h2.1V40z M60.2,40h-2.1v8h2.1V40z M52.7,' +
164 + '40h-2.1v8h2.1V40z M45.2,40h-2.1v8h2.1V40zM37.7,40h-2.1v8h2.1V40' +
165 + 'z M81.6,40h-1v8h1V40z',
166 +
167 + groupTable: 'M16,19.1H8v-13h8V19.1z M90.6,6.1H75.7v13h14.9V6.1z ' +
168 + 'M71.9,6.1H57v13h14.9V6.1z M53.3,6.1H38.4v13h14.9V6.1z M34.6,6.1' +
169 + 'H19.7v13h14.9V6.1z M102.3,6.1h-8v13h8V6.1z M45.7,52.7c0.2-5.6,' +
170 + '2.6-10.7,6.2-14.4c-2.6-1.5-5.7-2.5-8.9-2.5c-9.8,0-17.7,7.9-17.7,' +
171 + '17.7c0,6.3,3.3,11.9,8.3,15C34.8,61.5,39.4,55.6,45.7,52.7z M51.9,' +
172 + '68.8c-3.1-3.1-5.2-7.2-6-11.7c-4.7,2.8-7.9,7.6-8.6,13.2c1.8,0.6,' +
173 + '3.6,0.9,5.6,0.9C46.2,71.2,49.3,70.3,51.9,68.8z M55.2,71.5c-3.5,' +
174 + '2.4-7.7,3.7-12.2,3.7c-1.9,0-3.8-0.3-5.6-0.7C38.5,83.2,45.9,90,' +
175 + '54.9,90c9,0,16.4-6.7,17.5-15.4c-1.6,0.4-3.4,0.6-5.1,0.6C62.8,' +
176 + '75.2,58.6,73.8,55.2,71.5z M54.9,50.6c1.9,0,3.8,0.3,5.6,0.7c-0.5' +
177 + '-4.1-2.5-7.9-5.4-10.6c-2.9,2.7-4.8,6.4-5.3,10.5C51.5,50.8,53.2,' +
178 + '50.6,54.9,50.6z M49.7,55.4c0.5,4.3,2.4,8.1,5.4,10.9c2.9-2.8,4.9' +
179 + '-6.6,5.4-10.8c-1.8-0.6-3.6-0.9-5.6-0.9C53.1,54.6,51.4,54.9,49.7,' +
180 + '55.4z M102.3,23.6v78.5H8V23.6H102.3z M89,53.5c0-12-9.7-21.7-' +
181 + '21.7-21.7c-4.5,0-8.7,1.4-12.2,3.7c-3.5-2.4-7.7-3.7-12.2-3.7c-12,' +
182 + '0-21.7,9.7-21.7,21.7c0,8.5,4.9,15.9,12,19.4C33.6,84.6,43.2,94,' +
183 + '54.9,94c11.7,0,21.2-9.3,21.7-20.9C84,69.7,89,62.2,89,53.5z M' +
184 + '64.3,57.3c-0.8,4.4-2.9,8.4-5.9,11.5c2.6,1.5,5.7,2.5,8.9,2.5c1.8,' +
185 + '0,3.6-0.3,5.2-0.8C72,64.9,68.8,60.1,64.3,57.3z M67.3,35.8c-3.3,0' +
186 + '-6.3,0.9-8.9,2.5c3.7,3.8,6.1,8.9,6.2,14.6c6.1,3.1,10.6,8.9,11.7,' +
187 + '15.8C81.5,65.6,85,60,85,53.5C85,43.8,77.1,35.8,67.3,35.8z',
188 +
155 // --- Topology toolbar specific glyphs ---------------------- 189 // --- Topology toolbar specific glyphs ----------------------
156 190
157 summary: "M95.8,9.2H14.2c-2.8,0-5,2.2-5,5v81.5c0,2.8,2.2,5,5," + 191 summary: "M95.8,9.2H14.2c-2.8,0-5,2.2-5,5v81.5c0,2.8,2.2,5,5," +
......
...@@ -130,7 +130,7 @@ ...@@ -130,7 +130,7 @@
130 bns.button( 130 bns.button(
131 btnsDiv, 131 btnsDiv,
132 bName + '-ports', 132 bName + '-ports',
133 - 'chain', 133 + 'portTable',
134 function () { 134 function () {
135 ns.navTo(portPath, { devId: details.id }); 135 ns.navTo(portPath, { devId: details.id });
136 }, 136 },
...@@ -142,9 +142,6 @@ ...@@ -142,9 +142,6 @@
142 var tr = tbody.append('tr'); 142 var tr = tbody.append('tr');
143 143
144 portCols.forEach(function (col) { 144 portCols.forEach(function (col) {
145 - if (col === 'type' || col === 'id') {
146 - port[col] = fs.cap(port[col]);
147 - }
148 tr.append('td').html(port[col]); 145 tr.append('td').html(port[col]);
149 }); 146 });
150 } 147 }
......
...@@ -257,7 +257,7 @@ ...@@ -257,7 +257,7 @@
257 }); 257 });
258 tps.addAction({ 258 tps.addAction({
259 id: 'ports-table-btn', 259 id: 'ports-table-btn',
260 - gid: 'chain', 260 + gid: 'portTable',
261 cb: function () { 261 cb: function () {
262 ns.navTo(portPath, { devId: data.props['URI'] }); 262 ns.navTo(portPath, { devId: data.props['URI'] });
263 }, 263 },
......
...@@ -20,12 +20,15 @@ ...@@ -20,12 +20,15 @@
20 describe('factory: fw/svg/glyph.js', function() { 20 describe('factory: fw/svg/glyph.js', function() {
21 var $log, fs, gs, d3Elem, svg; 21 var $log, fs, gs, d3Elem, svg;
22 22
23 - var numBaseGlyphs = 39, 23 + var numBaseGlyphs = 41,
24 vbBird = '352 224 113 112', 24 vbBird = '352 224 113 112',
25 vbGlyph = '0 0 110 110', 25 vbGlyph = '0 0 110 110',
26 vbBadge = '0 0 10 10', 26 vbBadge = '0 0 10 10',
27 longPrefix = 'M95.8,9.2H14.2c-2.8,0-5,2.2-5,5v81.5c0,2.8,2.2,5,5,' + 27 longPrefix = 'M95.8,9.2H14.2c-2.8,0-5,2.2-5,5v81.5c0,2.8,2.2,5,5,' +
28 '5h81.5c2.8,0,5-2.2,5-5V14.2C100.8,11.5,98.5,9.2,95.8,9.2z ', 28 '5h81.5c2.8,0,5-2.2,5-5V14.2C100.8,11.5,98.5,9.2,95.8,9.2z ',
29 + tablePrefix = 'M15.9,19.1h-8v-13h8V19.1z M90.5,6.1H75.6v13h14.9V6.1' +
30 + 'z M71.9,6.1H56.9v13h14.9V6.1z M53.2,6.1H38.3v13h14.9V6.1z M34.5,' +
31 + '6.1H19.6v13h14.9V6.1z M102.2,6.1h-8v13h8V6.1z ',
29 prefixLookup = { 32 prefixLookup = {
30 bird: 'M427.7,300.4', 33 bird: 'M427.7,300.4',
31 unknown: 'M35,40a5', 34 unknown: 'M35,40a5',
...@@ -42,7 +45,9 @@ describe('factory: fw/svg/glyph.js', function() { ...@@ -42,7 +45,9 @@ describe('factory: fw/svg/glyph.js', function() {
42 refresh: 'M102.6,40.8L88.4', 45 refresh: 'M102.6,40.8L88.4',
43 46
44 // navigation specific glyphs 47 // navigation specific glyphs
45 - flowTable: 'M15.9,19.1h-8v-13h', 48 + flowTable: tablePrefix + 'M102.2,23.6H7.9v',
49 + portTable: tablePrefix + 'M102.6,23.6v78.5H',
50 + groupTable: 'M16,19.1H8v-13h',
46 51
47 // toolbar specific glyphs 52 // toolbar specific glyphs
48 summary: longPrefix + 'M16.7', 53 summary: longPrefix + 'M16.7',
...@@ -81,7 +86,8 @@ describe('factory: fw/svg/glyph.js', function() { ...@@ -81,7 +86,8 @@ describe('factory: fw/svg/glyph.js', function() {
81 glyphIds = [ 86 glyphIds = [
82 'unknown', 'node', 'switch', 'roadm', 'endstation', 'router', 87 'unknown', 'node', 'switch', 'roadm', 'endstation', 'router',
83 'bgpSpeaker', 'chain', 'crown', 'lock', 'topo', 'refresh', 88 'bgpSpeaker', 'chain', 'crown', 'lock', 'topo', 'refresh',
84 - 'flowTable', 'summary', 'details', 'ports', 'map', 'cycleLabels', 89 + 'flowTable', 'portTable', 'groupTable',
90 + 'summary', 'details', 'ports', 'map', 'cycleLabels',
85 'oblique', 'filters', 'resetZoom', 'relatedIntents', 'nextIntent', 91 'oblique', 'filters', 'resetZoom', 'relatedIntents', 'nextIntent',
86 'prevIntent', 'intentTraffic', 'allTraffic', 'flows', 'eqMaster' 92 'prevIntent', 'intentTraffic', 'allTraffic', 'flows', 'eqMaster'
87 ], 93 ],
......