public String selectedNodeId() { if (editorSession != null && editorSession.getSelectionControl().getSelectedItems().size() == 1) { return editorSession.getSelectionControl().getSelectedItems().iterator().next(); } else { return null; } }
private static void clearSelection(final EditorSession session) { if (null != session.getSelectionControl()) { session.getSelectionControl().clearSelection(); } } }
@SuppressWarnings("unchecked") public void show(final Command callback) { if (null != session) { final SelectionControl selectionControl = featuresSessionProvider.getSelectionControl(session); if (!Objects.isNull(selectionControl)) { selectionControl.getSelectedItemDefinition().ifPresent(selectedItemDefinition -> { if (selectedItemDefinition instanceof Element) { render((Element) selectedItemDefinition, callback); } else if (selectedItemDefinition instanceof DomainObject) { render((DomainObject) selectedItemDefinition, callback); } }); } } }
final AbstractCanvasHandler canvasHandler = getSession().getCanvasHandler(); final SelectionControl<AbstractCanvasHandler, Element> selectionControl = getSession().getSelectionControl(); final Collection<String> selectedItems = selectionControl.getSelectedItems(); selectionControl.clearSelection();
@Override protected void enableControls() { zoomControl.init(getCanvas()); selectionControl.init(getHandler()); }
@Override protected void destroyControls() { zoomControl.destroy(); selectionControl.destroy(); zoomControlInstances.destroy(zoomControl); zoomControlInstances.destroyAll(); selectionControlInstances.destroy(selectionControl); selectionControlInstances.destroyAll(); zoomControl = null; selectionControl = null; }
times(1)).init(eq(canvas)); verify(selectionControlInstance, times(1)).init(eq(canvasHandler)); verify(view, times(1)).setWidget(eq(canvasViewWidget));
protected String getSelectedElementUUID(ClientSession clientSession) { if (clientSession instanceof EditorSession) { final SelectionControl selectionControl = ((EditorSession) clientSession).getSelectionControl(); if (null != selectionControl) { final Collection<String> selectedItems = selectionControl.getSelectedItems(); if (null != selectedItems && !selectedItems.isEmpty()) { return selectedItems.iterator().next(); } } } return null; }
@Override @SuppressWarnings("unchecked") public <V> void execute(final Callback<V> callback) { checkNotNull("callback", callback); final SessionCommandManager<AbstractCanvasHandler> scm = getSessionCommandManager(); if (null != scm) { final CommandResult<CanvasViolation> result = getSessionCommandManager().undo((AbstractCanvasHandler) getSession().getCanvasHandler()); checkState(); if (CommandUtils.isError(result)) { callback.onError((V) result); } else { callback.onSuccess(); } getSession().getSelectionControl().clearSelection(); } }
public static String getSelectedElementUUID(ClientSession clientSession) { Optional<Collection<String>> selectedItems = Optional.empty(); if (clientSession instanceof EditorSession) { selectedItems = Optional.ofNullable(((EditorSession) clientSession).getSelectionControl().getSelectedItems()); } else if (clientSession instanceof ViewerSession) { selectedItems = Optional.ofNullable(((ViewerSession) clientSession).getSelectionControl().getSelectedItems()); } return selectedItems.map(strings -> strings.stream().findFirst().orElse(null)).orElse(null); }
@Override @SuppressWarnings("unchecked") public <V> void execute(final Callback<V> callback) { checkNotNull("callback", callback); if (!redoCommandHandler.isEnabled()) { callback.onSuccess(); } final CommandResult<?> result = redoCommandHandler.execute(getSession().getCanvasHandler(), sessionCommandManager); checkState(); if (CommandUtils.isError(result)) { callback.onError((V) result); } else { callback.onSuccess(); } getSession().getSelectionControl().clearSelection(); }
protected String getSelectedElementUUID(ClientSession clientSession) { if (clientSession instanceof EditorSession) { final SelectionControl selectionControl = ((EditorSession) clientSession).getSelectionControl(); if (null != selectionControl) { final Collection<String> selectedItems = selectionControl.getSelectedItems(); if (null != selectedItems && !selectedItems.isEmpty()) { return selectedItems.iterator().next(); } } } return null; }
private Optional<Element> getSelectedParentElement(String nodeUUID) { if (null != getSession().getSelectionControl()) { Collection<String> selectedItems = getSession().getSelectionControl().getSelectedItems(); if (Objects.nonNull(selectedItems) && !selectedItems.isEmpty()) { Optional<String> selectedParent = selectedItems.stream() .filter(Objects::nonNull) .filter(item -> Objects.equals(item, nodeUUID)) .findFirst(); return (selectedParent.isPresent() ? selectedParent : selectedItems.stream().filter(Objects::nonNull).findFirst()) .map(this::getElement); } } return Optional.empty(); }
@SuppressWarnings("unchecked") private Collection<String> getSelectedItems() { return getSession().getSelectionControl().getSelectedItems(); } }
@Override @SuppressWarnings("unchecked") public void execute() { try { boolean found = false; final EditorSession session = (EditorSession) getSession(); final Collection<String> selectedItems = session.getSelectionControl().getSelectedItems(); if (null != selectedItems) { final String uuid = selectedItems.stream().findFirst().orElse(null); if (null != uuid) { execute(selectedItems.stream() .map(this::getViewElement) .collect(Collectors.toList())); found = true; } } if (!found) { LOGGER.log(Level.WARNING, "No items selected."); } } catch (final ClassCastException e) { LOGGER.log(Level.WARNING, "Session is not an instance of ClientFullSession"); } }
@Override public <V> void execute(final Callback<V> callback) { if (null != getSession().getSelectionControl()) { try { //for now just copy Nodes not Edges final SelectionControl<AbstractCanvasHandler, Element> selectionControl = getSession().getSelectionControl(); //for now just copy Nodes not Edges clipboardControl.set(selectionControl.getSelectedItems().stream() .map(this::getElement) .toArray(Element[]::new)); commandExecutedEvent.fire(new CopySelectionSessionCommandExecutedEvent(this, getSession())); callback.onSuccess(); } catch (Exception e) { LOGGER.severe("Error on copy selection." + e.getMessage()); return; } } }