Andrea Campanella
Committed by Gerrit Code Review

ONOS-3182 added swap functionality

Change-Id: Idc521a330c5bb3c0e0a47f66a90dfa95855e610f
......@@ -84,6 +84,7 @@ public class PathPainterTopovMessageHandler extends UiMessageHandler {
return ImmutableSet.of(
new SetSrcHandler(),
new SetDstHandler(),
new SwapSrcDstHandler(),
new NextPathHandler(),
new PrevPathHandler()
);
......@@ -124,6 +125,20 @@ public class PathPainterTopovMessageHandler extends UiMessageHandler {
}
}
private final class SwapSrcDstHandler extends RequestHandler {
public SwapSrcDstHandler() {
super(PAINTER_SWAP_SRC_DST);
}
@Override
public void process(long sid, ObjectNode payload) {
ElementId temp = src;
src = dst;
dst = temp;
findAndSendPaths();
}
}
private final class NextPathHandler extends RequestHandler {
public NextPathHandler() {
super(PAINTER_NEXT_PATH);
......
......@@ -28,6 +28,7 @@
// constants
var srcMessage = 'ppTopovSetSrc',
dstMessage = 'ppTopovSetDst',
swapMessage = 'ppTopovSwapSrcDst',
modeMessage = 'ppTopovSetMode',
nextPathMessage = 'ppTopovNextPath',
prevPathMessage = 'ppTopovPrevPath';
......@@ -58,11 +59,16 @@
flash.flash('Destination node: ' + node.id);
}
function nextPath(node) {
function swapSrcDst() {
wss.sendEvent(swapMessage)
flash.flash('Source and destination swap');
}
function nextPath() {
wss.sendEvent(nextPathMessage);
}
function prevPath(node) {
function prevPath() {
wss.sendEvent(prevPathMessage);
}
......@@ -97,7 +103,8 @@
setDst: setDst,
setMode: setMode,
nextPath: nextPath,
prevPath: prevPath
prevPath: prevPath,
swapSrcDst: swapSrcDst
};
}]);
}());
......
......@@ -16,8 +16,7 @@
var overlay = {
// NOTE: this must match the ID defined in AppUiTopovOverlay
overlayId: 'pp-overlay',
// FIXME: new icon for the overlay
glyphId: '*star4',
glyphId: 'topo',
tooltip: 'Path Painter Topo Overlay',
// These glyphs get installed using the overlayId as a prefix.
......@@ -68,7 +67,6 @@
// FIXME: use into [ and ] instead of 1 and 2
// FIXME: new icons for src/dst
// TODO: add keys for shortest paths & disjoint paths modes
// TODO: add key for src/dst swap; with its own icon
keyBindings: {
1: {
cb: function () { pps.setSrc(selection); },
......@@ -80,6 +78,11 @@
tt: 'Set destination node',
gid: 'triangleDown'
},
3: {
cb: function () { pps.swapSrcDst(); },
tt: 'Swap source and destination nodes',
gid: 'refresh'
},
leftArrow: {
cb: function () { pps.prevPath(); },
tt: 'Highlight previous path',
......@@ -92,7 +95,7 @@
},
_keyOrder: [
'1', '2', 'leftArrow', 'rightArrow'
'1', '2', '3', 'leftArrow', 'rightArrow'
]
},
......
......@@ -167,7 +167,7 @@
// generate radio button set for overlays; start with 'none'
var rset = [{
gid: 'topo',
gid: 'unknown',
tooltip: 'No Overlay',
cb: function () {
tov.tbSelection(null, switchOverlayActions);
......