Search in sources :

Example 1 with CustomTreeItem

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;
}
Also used : CustomTreeItem(com.exalttech.trex.ui.components.CustomTreeItem)

Example 2 with CustomTreeItem

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);
        }
    }
}
Also used : CustomTreeItem(com.exalttech.trex.ui.components.CustomTreeItem) TrafficException(com.exalttech.trex.remote.exceptions.TrafficException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) InvalidRPCResponseException(com.exalttech.trex.remote.exceptions.InvalidRPCResponseException) IncorrectRPCMethodException(com.exalttech.trex.remote.exceptions.IncorrectRPCMethodException) PortAcquireException(com.exalttech.trex.remote.exceptions.PortAcquireException) IOException(java.io.IOException)

Example 3 with CustomTreeItem

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));
            }
        });
    }
}
Also used : CustomTreeItem(com.exalttech.trex.ui.components.CustomTreeItem) CustomTreeItem(com.exalttech.trex.ui.components.CustomTreeItem)

Example 4 with CustomTreeItem

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);
    }
}
Also used : CustomTreeItem(com.exalttech.trex.ui.components.CustomTreeItem)

Aggregations

CustomTreeItem (com.exalttech.trex.ui.components.CustomTreeItem)4 IncorrectRPCMethodException (com.exalttech.trex.remote.exceptions.IncorrectRPCMethodException)1 InvalidRPCResponseException (com.exalttech.trex.remote.exceptions.InvalidRPCResponseException)1 PortAcquireException (com.exalttech.trex.remote.exceptions.PortAcquireException)1 TrafficException (com.exalttech.trex.remote.exceptions.TrafficException)1 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1