@Override public <V> void execute(Callback<V> callback) { copySelectionSessionCommand.execute(new Callback<V>() { @Override public void onSuccess() { deleteSelectionSessionCommand.execute(callback); //get the executed command by deleteSelectionSessionCommand Command<AbstractCanvasHandler, CanvasViolation> command = sessionCommandManager.getRegistry().peek(); clipboardControl.setRollbackCommand(command); commandExecutedEvent.fire(new CutSelectionSessionCommandExecutedEvent(CutSelectionSessionCommand.this, CutSelectionSessionCommand.this.getSession())); } @Override public void onError(V error) { LOGGER.severe("Error on cut selection." + String.valueOf(error)); callback.onError(error); } }); }
@Override protected void handleCanvasSelectionEvent(final CanvasSelectionEvent event) { if (event.getIdentifiers().isEmpty() || onlyCanvasRootSelected(event)) { enable(false); } else { enable(true); } }
protected void onKeyDownEvent(final Key... keys) { if (isEnabled()) { handleCtrlC(keys); } }
@Override public void bind(final EditorSession session) { super.bind(session); session.getKeyboardControl().addKeyShortcutCallback(this::onKeyDownEvent); this.clipboardControl = session.getClipboardControl(); this.copySelectionSessionCommand.bind(session); }
@Override protected void handleCanvasElementsClearEvent(final CanvasElementsClearEvent event) { enable(false); } }
@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; } } }
@Override public void bind(final EditorSession session) { super.bind(session); copySelectionSessionCommand.bind(session); deleteSelectionSessionCommand.bind(session); session.getKeyboardControl().addKeyShortcutCallback(this::onKeyDownEvent); this.clipboardControl = session.getClipboardControl(); }
@Override protected void handleCanvasClearSelectionEvent(final CanvasClearSelectionEvent event) { enable(false); }
private void handleCtrlC(final Key[] keys) { if (doKeysMatch(keys, Key.CONTROL, Key.C)) { this.execute(); } }
private void menu_copy() { sessionCommands.getCopySelectionSessionCommand().execute(); }
copySelectionSessionCommand.execute();