use of com.exalttech.trex.ui.components.CustomTreeItem in project trex-stateless-gui by cisco-system-traffic-generator.
the class MainViewController method createPortItem.
/**
* Render port tree item
*
* @param port
* @return
*/
private TreeItem createPortItem(Port port) {
CustomTreeItem root = new CustomTreeItem("Port " + port.getIndex(), port.getOwner(), PortState.getPortStatus(port.getStatus()).getIcon(), TreeItemType.PORT);
root.setTooltipText(port.getStatus());
root.setMenu(rightClickPortMenu);
root.setReturnedValue(String.valueOf(port.getIndex()));
portTreeItemMap.put(port.getIndex(), root);
CustomTreeItem profileItem = new CustomTreeItem("Profile", null, null, TreeItemType.PORT_PROFILE);
profileItem.setMenu(rightClickProfileMenu);
profileItem.setReturnedValue(String.valueOf(port.getIndex()));
root.getChildren().add(profileItem);
return root;
}
use of com.exalttech.trex.ui.components.CustomTreeItem in project trex-stateless-gui by cisco-system-traffic-generator.
the class MainViewController method handleTreeItemSelectionChanged.
/**
* Handle treeitem selection changed
*/
private void handleTreeItemSelectionChanged() {
updateHeaderBtnStat();
CustomTreeItem selected = (CustomTreeItem) devicesTree.getSelectionModel().getSelectedItem();
// update acquire/release port icon state
updateAcquireReleaseBtnState(true);
if (selected != null) {
if (profileLoaded) {
updateCurrentProfileMultiplier();
}
try {
stopRefreshingService();
// show table container by default
hideShowStatTable(true);
portViewVisibilityProperty.setValue(false);
systemInfoVisibilityProperty.setValue(false);
switch(selected.getTreeItemType()) {
case DEVICES:
systemInfoVisibilityProperty.setValue(true);
buildSystemInfoTable();
break;
case PORT:
updateAcquireReleaseBtnState(false);
loadPortModel();
portViewVisibilityProperty.setValue(true);
break;
case PORT_PROFILE:
doAssignProfile = false;
viewProfile();
break;
default:
break;
}
} catch (Exception ex) {
LOG.error(ex);
}
}
}
use of com.exalttech.trex.ui.components.CustomTreeItem in project trex-stateless-gui by cisco-system-traffic-generator.
the class MainViewController method updateDevicesTree.
/**
* Load and render devices tree
*
* @throws UnsupportedEncodingException
*/
private void updateDevicesTree() {
if (devicesTree.getRoot() == null) {
TreeItem root = new CustomTreeItem("TRex-" + ConnectionManager.getInstance().getIPAddress(), TreeItemType.DEVICES, rightClickGlobalMenu);
root.setExpanded(true);
portManager.getPortList().stream().forEach(port -> {
root.getChildren().add(createPortItem(port));
});
devicesTree.setRoot(root);
devicesTree.getSelectionModel().select(0);
} else {
portManager.getPortList().stream().forEach(port -> {
if (portTreeItemMap.get(port.getIndex()) != null) {
CustomTreeItem item = portTreeItemMap.get(port.getIndex());
item.setTooltipText(port.getStatus());
item.updateItemValue("Port " + port.getIndex(), port.getOwner(), PortState.getPortStatus(port.getStatus()).getIcon());
} else {
devicesTree.getRoot().getChildren().add(createPortItem(port));
}
});
}
}
use of com.exalttech.trex.ui.components.CustomTreeItem in project trex-stateless-gui by cisco-system-traffic-generator.
the class MainViewController method onPortListUpdated.
/**
*
* @param successfullyUpdated
*/
@Override
public void onPortListUpdated(boolean successfullyUpdated) {
if (successfullyUpdated) {
updateDevicesTree();
updateHeaderBtnStat();
enableDisableStartStopAllBtn();
if (isFirstPortStatusRequest) {
isFirstPortStatusRequest = false;
reAcquireOwnedPorts();
}
CustomTreeItem selected = (CustomTreeItem) devicesTree.getSelectionModel().getSelectedItem();
if (selected != null && selected.getTreeItemType() == TreeItemType.PORT) {
updateAcquireReleaseBtnState(false);
} else if (selected != null && selected.getTreeItemType() == TreeItemType.PORT_PROFILE && !portManager.isCurrentUserOwner(getSelectedPortIndex())) {
viewProfile();
}
} else {
LOG.info("Server went down ... handling it");
resetApplication(true);
}
}
Aggregations