Search in sources :

Example 1 with DefaultOperationContext

use of org.opennms.features.topology.app.internal.DefaultOperationContext in project opennms by OpenNMS.

the class TopologyContextMenu method updateMenu.

public void updateMenu(GraphContainer graphContainer, UI mainWindow, OperationManager operationManager, List<VertexRef> targets) {
    final OperationContext operationContext = new DefaultOperationContext(mainWindow, graphContainer, OperationContext.DisplayLocation.CONTEXTMENU);
    // Clear Menu
    removeAllItems();
    // Rebuild menu
    MenuBuilder menuBuilder = new MenuBuilder();
    for (OperationServiceWrapper operationServiceWrapper : operationManager.getOperationWrappers()) {
        if (operationServiceWrapper.getContextMenuPosition() != null) {
            MenuItem item = new OperationMenuItem(operationServiceWrapper);
            menuBuilder.addMenuItem(item, operationServiceWrapper.getContextMenuPosition().isEmpty() ? null : operationServiceWrapper.getContextMenuPosition().split("\\|"));
        }
    }
    addNavigateToItems(menuBuilder, targets, operationContext);
    MenuBar menu = menuBuilder.build(targets, operationContext, this::notifyMenuUpdateListener);
    addItems(menu);
}
Also used : DefaultOperationContext(org.opennms.features.topology.app.internal.DefaultOperationContext) OperationContext(org.opennms.features.topology.api.OperationContext) DefaultOperationContext(org.opennms.features.topology.app.internal.DefaultOperationContext) MenuBar(com.vaadin.ui.MenuBar)

Example 2 with DefaultOperationContext

use of org.opennms.features.topology.app.internal.DefaultOperationContext in project opennms by OpenNMS.

the class TopologyMenuBar method updateMenu.

// Builds the menu
public void updateMenu(GraphContainer graphContainer, UI mainWindow, OperationManager operationManager) {
    final DefaultOperationContext operationContext = new DefaultOperationContext(mainWindow, graphContainer, OperationContext.DisplayLocation.MENUBAR);
    final ArrayList<VertexRef> targets = new ArrayList<>(graphContainer.getSelectionManager().getSelectedVertexRefs());
    // Clear menu
    removeItems();
    // Build new Menu
    MenuBuilder menuBuilder = new MenuBuilder();
    menuBuilder.setTopLevelMenuOrder(operationManager.getTopLevelMenuOrder());
    menuBuilder.setSubMenuGroupOrder(operationManager.getSubMenuGroupOrder());
    for (OperationServiceWrapper operationServiceWrapper : operationManager.getOperationWrappers()) {
        if (operationServiceWrapper.getMenuPosition() != null) {
            // if menu position is null, there is no place to put it
            org.opennms.features.topology.app.internal.menu.MenuItem item = new OperationMenuItem(operationServiceWrapper);
            menuBuilder.addMenuItem(item, operationServiceWrapper.getMenuPosition().split("\\|"));
        }
    }
    menuBuilder.apply(this, targets, operationContext, this::notifyMenuUpdateListener);
}
Also used : DefaultOperationContext(org.opennms.features.topology.app.internal.DefaultOperationContext) ArrayList(java.util.ArrayList) VertexRef(org.opennms.features.topology.api.topo.VertexRef)

Aggregations

DefaultOperationContext (org.opennms.features.topology.app.internal.DefaultOperationContext)2 MenuBar (com.vaadin.ui.MenuBar)1 ArrayList (java.util.ArrayList)1 OperationContext (org.opennms.features.topology.api.OperationContext)1 VertexRef (org.opennms.features.topology.api.topo.VertexRef)1