/** * Determines if the given vertex has "links" to vertices from other layers. * * @param vertex The vertex to check * @return True if links to other layers exists, false otherwise */ private boolean getTargets(Vertex vertex) { return !m_graphContainer.getTopologyServiceClient().getOppositeVertices(vertex).isEmpty(); }
@Override protected boolean enabled(GraphContainer container) { return BusinessServicesTopologyProvider.TOPOLOGY_NAMESPACE.equals(container.getTopologyServiceClient().getNamespace()); }
private static List<VertexRef> getOppositeVertices(GraphContainer graphContainer, String targetNamespace, VertexRef sourceVertex) { // Find the vertices in other graphs that this vertex links to final Collection<VertexRef> oppositeVertices = graphContainer.getTopologyServiceClient().getOppositeVertices(sourceVertex); // Filter the vertices for those matching the target namespace final List<VertexRef> targetVertices = oppositeVertices.stream() .filter(v -> v.getNamespace().matches(targetNamespace)) .collect(Collectors.toList()); return targetVertices; }
@Override public boolean isEnabled(List<VertexRef> targets, OperationContext operationContext) { // Only enable the operation the vertex links to other graphs return targets.stream().findFirst() .map(v -> operationContext.getGraphContainer().getTopologyServiceClient().getOppositeVertices(v).size() > 0) .orElse(false); } }
private static List<VertexRef> getOppositeVertices(GraphContainer graphContainer, String targetNamespace, VertexRef sourceVertex) { // Find the vertices in other graphs that this vertex links to final Collection<VertexRef> oppositeVertices = graphContainer.getTopologyServiceClient().getOppositeVertices(sourceVertex); // Filter the vertices for those matching the target namespace final List<VertexRef> targetVertices = oppositeVertices.stream() .filter(v -> v.getNamespace().matches(targetNamespace)) .collect(Collectors.toList()); return targetVertices; }
@Override public Map<String, String> createHistory(GraphContainer container) { return ImmutableMap .<String, String>builder() .put(getClass().getName() + "." + getLabel(), Boolean.toString(isChecked(container))) .put(getClass().getName() + ".selectedLayer", container.getTopologyServiceClient().getNamespace()) .build(); }
@Override public boolean isVisible(List<VertexRef> targets, OperationContext operationContext) { // Only display the operation, when we have a single vertex selected, and the topology contains multiple graphs return targets.size() == 1 && operationContext.getGraphContainer().getTopologyServiceClient().getGraphProviders().size() > 1; }
@Override protected Optional<VertexRef> findSingleSelectedItem(GraphContainer container) { Collection<VertexRef> selectedVertexRefs = container.getSelectionManager().getSelectedVertexRefs(); if (selectedVertexRefs.size() == 1) { final VertexRef vertexRef = selectedVertexRefs.iterator().next(); Vertex vertex = container.getTopologyServiceClient().getVertex(vertexRef); return Optional.ofNullable(vertex); } return Optional.empty(); } }
@Override public void graphChanged(GraphContainer graphContainer){ if(graphContainer == null) return; Set<VertexRef> newDisplayableVertexRefs = new HashSet<VertexRef>(graphContainer.getGraph().getDisplayVertices()); if(!m_displayableVertexRefs.equals(newDisplayableVertexRefs)){ synchronized (m_displayableVertexRefs){ m_displayableVertexRefs.clear(); m_displayableVertexRefs.addAll(newDisplayableVertexRefs); } } fireVertexRefsUpdated(getVerticesInFocus(), graphContainer.getTopologyServiceClient()); }
private TopologyServiceClient getGraphProvider() { UI ui = UI.getCurrent(); if (ui instanceof WidgetContext) { return ((WidgetContext) ui).getGraphContainer().getTopologyServiceClient(); } return null; }
private static String getLayerName(GraphContainer container, String namespace) { Objects.requireNonNull(container); Objects.requireNonNull(namespace); return container.getTopologyServiceClient().getGraphProviderBy(namespace).getTopologyProviderInfo().getName(); } }
@Override public void graphChanged(GraphContainer graphContainer){ if(graphContainer == null) return; Set<VertexRef> newDisplayableVertexRefs = new HashSet<VertexRef>(graphContainer.getGraph().getDisplayVertices()); if(!m_displayableVertexRefs.equals(newDisplayableVertexRefs)){ synchronized (m_displayableVertexRefs){ m_displayableVertexRefs.clear(); m_displayableVertexRefs.addAll(newDisplayableVertexRefs); } } fireVertexRefsUpdated(getVerticesInFocus(), graphContainer.getTopologyServiceClient()); }
private static String getLayerName(GraphContainer container, String namespace) { Objects.requireNonNull(container); Objects.requireNonNull(namespace); return container.getTopologyServiceClient().getGraphProviderBy(namespace).getTopologyProviderInfo().getName(); } }
@Override public void selectionChanged(SelectionContext selectionContext) { if(selectionContext == null) return; Collection<VertexRef> selectedVertexRefs = selectionContext.getSelectedVertexRefs(); if(!selectedVertexRefs.equals(m_selectedVertices)) { synchronized (m_selectedVertices) { m_selectedVertices.clear(); m_selectedVertices.addAll(selectedVertexRefs); } } fireVertexRefsUpdated(getVerticesInFocus(), selectionContext.getGraphContainer().getTopologyServiceClient()); }
@Override public void buttonClick(Button.ClickEvent event) { List<Criteria> defaultCriteriaList = graphContainer.getTopologyServiceClient().getDefaults().getCriteria(); if (defaultCriteriaList != null && !defaultCriteriaList.isEmpty()) { defaultCriteriaList.forEach(graphContainer::addCriteria); graphContainer.redoLayout(); noDefaultsAvailable.setVisible(false); } else { noDefaultsAvailable.setVisible(true); } } });
protected static Vertex getVertexItem(final OperationContext operationContext, final VertexRef target) { Vertex vertex = operationContext.getGraphContainer().getTopologyServiceClient().getVertex(target, operationContext.getGraphContainer().getCriteria()); if (vertex == null) { LoggerFactory.getLogger(AbstractOperation.class).debug("Null vertex found for vertex reference: {}:{}", target.getNamespace(), target.getId()); return null; } else { return vertex; } }
protected static Vertex getVertexItem(final OperationContext operationContext, final VertexRef target) { Vertex vertex = operationContext.getGraphContainer().getTopologyServiceClient().getVertex(target, operationContext.getGraphContainer().getCriteria()); if (vertex == null) { LoggerFactory.getLogger(AbstractOperation.class).debug("Null vertex found for vertex reference: {}:{}", target.getNamespace(), target.getId()); return null; } else { return vertex; } }
@Override protected boolean enabled(GraphContainer container) { final TopologyServiceClient client = container.getTopologyServiceClient(); return client.getMetaTopologyId() != null && client.getNamespace() != null && client.getInfo().isHierarchical(); } }
@Override public void execute(List<VertexRef> targets, OperationContext operationContext) { if (operationContext != null && operationContext.getGraphContainer() != null) { ((SFreeTopologyProvider) operationContext.getGraphContainer().getTopologyServiceClient()).setType(SFreeTopologyProvider.Type.BarabasiAlbert); operationContext.getGraphContainer().redoLayout(); } }
private void updateTabVisibility() { for (int i=0; i<tabSheet.getComponentCount(); i++) { TabSheet.Tab tab = tabSheet.getTab(i); if (tab.getComponent() instanceof SelectionAwareTable) { ContentType contentType = ((SelectionAwareTable) tab.getComponent()).getContentType(); boolean visible = m_graphContainer.getTopologyServiceClient().contributesTo(contentType); tab.setVisible(visible); } } }