/** * Changes the base topology to {@link #m_metaTopologyProvider} and optionally executes callbacks (e.g. to reset criteria, set default SZL, etc.) * @param container The GraphContainer. * @param callbacks Define callbacks to execute AFTER the topology provider has changed. */ private void execute(GraphContainer container, GraphContainer.Callback... callbacks) { LOG.debug("Active provider is: {}", m_metaTopologyProvider); // only change if provider changed final String currentMetaTopologyId = container.getMetaTopologyId(); if(currentMetaTopologyId == null || !currentMetaTopologyId.equals(m_metaTopologyProvider.getId())) { container.setMetaTopologyId(m_metaTopologyProvider.getId()); container.selectTopologyProvider(m_metaTopologyProvider.getDefaultGraphProvider(), callbacks); } }
/** * Changes the base topology to {@link #m_metaTopologyProvider} and optionally executes callbacks (e.g. to reset criteria, set default SZL, etc.) * @param container The GraphContainer. * @param callbacks Define callbacks to execute AFTER the topology provider has changed. */ private void execute(GraphContainer container, GraphContainer.Callback... callbacks) { LOG.debug("Active provider is: {}", m_metaTopologyProvider); // only change if provider changed final String currentMetaTopologyId = container.getMetaTopologyId(); if(currentMetaTopologyId == null || !currentMetaTopologyId.equals(m_metaTopologyProvider.getId())) { container.setMetaTopologyId(m_metaTopologyProvider.getId()); container.selectTopologyProvider(m_metaTopologyProvider.getDefaultGraphProvider(), callbacks); } }
@Override public void onFocusSearchResult(SearchResult searchResult, OperationContext operationContext) { final GraphContainer graphContainer = operationContext.getGraphContainer(); final DefaultVertexRef vertexRef = new DefaultVertexRef(searchResult.getNamespace(), searchResult.getId(), searchResult.getLabel()); if (graphContainer.getTopologyServiceClient().getVertex(vertexRef) == null) { // The vertex to add to focus is not in the current layer // Find the GraphProvider it belongs to Optional<GraphProvider> first = graphContainer.getTopologyServiceClient().getGraphProviders().stream() .filter(eachProvider -> eachProvider.getNamespace().equals(searchResult.getNamespace())) .findFirst(); // If there is a graph provider (which should) select it if (first.isPresent() && first.get().getVertex(vertexRef) != null) { graphContainer.selectTopologyProvider(first.get()); graphContainer.clearCriteria(); } } super.onFocusSearchResult(searchResult, operationContext); }
@Override public void onFocusSearchResult(SearchResult searchResult, OperationContext operationContext) { final GraphContainer graphContainer = operationContext.getGraphContainer(); final DefaultVertexRef vertexRef = new DefaultVertexRef(searchResult.getNamespace(), searchResult.getId(), searchResult.getLabel()); if (graphContainer.getTopologyServiceClient().getVertex(vertexRef) == null) { // The vertex to add to focus is not in the current layer // Find the GraphProvider it belongs to Optional<GraphProvider> first = graphContainer.getTopologyServiceClient().getGraphProviders().stream() .filter(eachProvider -> eachProvider.getNamespace().equals(searchResult.getNamespace())) .findFirst(); // If there is a graph provider (which should) select it if (first.isPresent() && first.get().getVertex(vertexRef) != null) { graphContainer.selectTopologyProvider(first.get()); graphContainer.clearCriteria(); } } super.onFocusSearchResult(searchResult, operationContext); }
private static void handleClick(GraphContainer graphContainer, GraphProvider targetGraphProvider, List<VertexRef> verticesToFocus, Breadcrumb breadcrumb) { final String targetNamespace = targetGraphProvider.getNamespace(); final String currentNamespace = graphContainer.getTopologyServiceClient().getNamespace(); // Only Change the layer if namespace is different, otherwise we would switch to the current layer if (!currentNamespace.equals(targetNamespace)) { BreadcrumbCriteria breadcrumbCriteria = getBreadcrumbCriteria(graphContainer); graphContainer.selectTopologyProvider(targetGraphProvider, Callbacks.applyDefaults(), (graphContainer1, graphProvider) -> graphContainer1.addCriteria(breadcrumbCriteria)); breadcrumbCriteria.setNewRoot(breadcrumb); } // Reset focus getCriteriaForGraphContainer(graphContainer, VertexHopGraphProvider.VertexHopCriteria.class).forEach(graphContainer::removeCriteria); // Set elements to focus verticesToFocus.forEach(v -> graphContainer.addCriteria(new VertexHopGraphProvider.DefaultVertexHopCriteria(v))); // Render graphContainer.setDirty(true); graphContainer.redoLayout(); }
private static void handleClick(GraphContainer graphContainer, GraphProvider targetGraphProvider, List<VertexRef> verticesToFocus, Breadcrumb breadcrumb) { final String targetNamespace = targetGraphProvider.getNamespace(); final String currentNamespace = graphContainer.getTopologyServiceClient().getNamespace(); // Only Change the layer if namespace is different, otherwise we would switch to the current layer if (!currentNamespace.equals(targetNamespace)) { BreadcrumbCriteria breadcrumbCriteria = getBreadcrumbCriteria(graphContainer); graphContainer.selectTopologyProvider(targetGraphProvider, Callbacks.applyDefaults(), (graphContainer1, graphProvider) -> graphContainer1.addCriteria(breadcrumbCriteria)); breadcrumbCriteria.setNewRoot(breadcrumb); } // Reset focus getCriteriaForGraphContainer(graphContainer, VertexHopGraphProvider.VertexHopCriteria.class).forEach(graphContainer::removeCriteria); // Set elements to focus verticesToFocus.forEach(v -> graphContainer.addCriteria(new VertexHopGraphProvider.DefaultVertexHopCriteria(v))); // Render graphContainer.setDirty(true); graphContainer.redoLayout(); }
private void handleLayerButton(GraphContainer graphContainer) { // Toggle layer button boolean enableLayerButton = graphContainer.getTopologyServiceClient().getGraphProviders().size() > 1; layerButton.setEnabled(enableLayerButton); // update the layer layout layerLayout.removeAllComponents(); if (enableLayerButton) { graphContainer.getTopologyServiceClient().getGraphProviders().forEach(topologyProvider -> { boolean selected = topologyProvider.getNamespace().equals(graphContainer.getTopologyServiceClient().getNamespace()); final TopologyProviderInfo topologyProviderInfo = topologyProvider.getTopologyProviderInfo(); final Label nameLabel = new Label(topologyProviderInfo.getName()); VerticalLayout verticalLayout = new VerticalLayout(); verticalLayout.addComponent(nameLabel); verticalLayout.addStyleName(Styles.LAYOUT); if (selected) { verticalLayout.addStyleName(Styles.SELECTED); } verticalLayout.addLayoutClickListener((event) -> graphContainer.selectTopologyProvider(topologyProvider, Callbacks.applyDefaults())); layerLayout.addComponent(verticalLayout); }); } else { setLayerLayoutVisible(false); } }
private void handleLayerButton(GraphContainer graphContainer) { // Toggle layer button boolean enableLayerButton = graphContainer.getTopologyServiceClient().getGraphProviders().size() > 1; layerButton.setEnabled(enableLayerButton); // update the layer layout layerLayout.removeAllComponents(); if (enableLayerButton) { graphContainer.getTopologyServiceClient().getGraphProviders().forEach(topologyProvider -> { boolean selected = topologyProvider.getNamespace().equals(graphContainer.getTopologyServiceClient().getNamespace()); final TopologyProviderInfo topologyProviderInfo = topologyProvider.getTopologyProviderInfo(); final Label nameLabel = new Label(topologyProviderInfo.getName()); VerticalLayout verticalLayout = new VerticalLayout(); verticalLayout.addComponent(nameLabel); verticalLayout.addStyleName(Styles.LAYOUT); if (selected) { verticalLayout.addStyleName(Styles.SELECTED); } verticalLayout.addLayoutClickListener((event) -> graphContainer.selectTopologyProvider(topologyProvider, Callbacks.applyDefaults())); layerLayout.addComponent(verticalLayout); }); } else { setLayerLayoutVisible(false); } }