use of org.eclipse.gef.EditPart in project knime-core by knime.
the class WorkflowSelectionDragEditPartsTracker method getCommand.
/**
* Asks each edit part in the
* {@link org.eclipse.gef.tools.AbstractTool#getOperationSet() operation set}
* to contribute to a {@link CompoundCommand} after first setting the
* request type to either {@link org.eclipse.gef.RequestConstants#REQ_MOVE}
* or {@link org.eclipse.gef.RequestConstants#REQ_ORPHAN}, depending on the
* result of {@link #isMove()}.
*
* Additionally the method creates a command to adapt connections where both
* node container are include in the drag operation.
*
* {@inheritDoc}
*/
@Override
protected Command getCommand() {
CompoundCommand command = new CompoundCommand();
command.setDebugLabel("Drag Object Tracker");
Iterator iter = getOperationSet().iterator();
Request request = getTargetRequest();
if (isCloneActive()) {
request.setType(REQ_CLONE);
} else if (isMove()) {
request.setType(REQ_MOVE);
} else {
request.setType(REQ_ORPHAN);
}
if (!isCloneActive()) {
while (iter.hasNext()) {
EditPart editPart = (EditPart) iter.next();
command.add(editPart.getCommand(request));
}
}
// now add the commands for the node-embraced connections
ConnectionContainerEditPart[] connectionsToAdapt = getEmbracedConnections(getOperationSet());
for (ConnectionContainerEditPart connectionPart : connectionsToAdapt) {
command.add(connectionPart.getBendpointAdaptionCommand(request));
}
if (!isMove() || isCloneActive()) {
if (!isCloneActive()) {
request.setType(REQ_ADD);
}
if (getTargetEditPart() == null) {
command.add(UnexecutableCommand.INSTANCE);
} else {
command.add(getTargetEditPart().getCommand(getTargetRequest()));
}
}
return command;
}
use of org.eclipse.gef.EditPart in project knime-core by knime.
the class WorkflowSelectionDragEditPartsTracker method handleDoubleClick.
/**
* {@inheritDoc}
*/
@Override
protected boolean handleDoubleClick(final int button) {
EditPart part = getSourceEditPart();
if (part instanceof NodeContainerEditPart && getCurrentInput().isModKeyDown(SWT.MOD1)) {
NodeContainerEditPart ncPart = ((NodeContainerEditPart) part);
NodeContainerUI container = (NodeContainerUI) ncPart.getModel();
if (container instanceof SubNodeContainerUI) {
ncPart.openSubWorkflowEditor();
return false;
}
}
return super.handleDoubleClick(button);
}
use of org.eclipse.gef.EditPart in project knime-core by knime.
the class WorkflowMarqueeSelectionTool method calculateConnections.
private void calculateConnections(final Collection<GraphicalEditPart> newSelections, final Collection<GraphicalEditPart> deselections) {
// determine the currently selected nodes minus the ones that are to be
// deselected
Collection<EditPart> currentNodes = new HashSet<EditPart>();
if (getSelectionMode() != DEFAULT_MODE) {
// everything is deselected
// in default mode
Iterator<EditPart> iter = getCurrentViewer().getSelectedEditParts().iterator();
while (iter.hasNext()) {
EditPart selected = iter.next();
if (!(selected instanceof ConnectionEditPart) && !deselections.contains(selected)) {
currentNodes.add(selected);
}
}
}
// add new connections to be selected to newSelections
Collection<ConnectionEditPart> connections = new ArrayList<ConnectionEditPart>();
for (Iterator<GraphicalEditPart> nodes = newSelections.iterator(); nodes.hasNext(); ) {
GraphicalEditPart node = nodes.next();
for (Iterator<ConnectionEditPart> itr = node.getSourceConnections().iterator(); itr.hasNext(); ) {
ConnectionEditPart sourceConn = itr.next();
if (sourceConn.getSelected() == EditPart.SELECTED_NONE && (newSelections.contains(sourceConn.getTarget()) || currentNodes.contains(sourceConn.getTarget()))) {
connections.add(sourceConn);
}
}
for (Iterator<ConnectionEditPart> itr = node.getTargetConnections().iterator(); itr.hasNext(); ) {
ConnectionEditPart targetConn = itr.next();
if (targetConn.getSelected() == EditPart.SELECTED_NONE && (newSelections.contains(targetConn.getSource()) || currentNodes.contains(targetConn.getSource()))) {
connections.add(targetConn);
}
}
}
newSelections.addAll(connections);
// add currently selected connections that are to be deselected to
// deselections
connections = new HashSet<ConnectionEditPart>();
for (Iterator<GraphicalEditPart> nodes = deselections.iterator(); nodes.hasNext(); ) {
GraphicalEditPart node = nodes.next();
for (Iterator<ConnectionEditPart> itr = node.getSourceConnections().iterator(); itr.hasNext(); ) {
ConnectionEditPart sourceConn = itr.next();
if (sourceConn.getSelected() != EditPart.SELECTED_NONE) {
connections.add(sourceConn);
}
}
for (Iterator<ConnectionEditPart> itr = node.getTargetConnections().iterator(); itr.hasNext(); ) {
ConnectionEditPart targetConn = itr.next();
if (targetConn.getSelected() != EditPart.SELECTED_NONE) {
connections.add(targetConn);
}
}
}
deselections.addAll(connections);
}
use of org.eclipse.gef.EditPart in project knime-core by knime.
the class WorkflowMarqueeSelectionTool method showTargetFeedback.
private void showTargetFeedback() {
for (Iterator<GraphicalEditPart> itr = selectedEditParts.iterator(); itr.hasNext(); ) {
EditPart editPart = itr.next();
editPart.showTargetFeedback(getTargetRequest());
}
}
use of org.eclipse.gef.EditPart in project knime-core by knime.
the class CutAction method runInSWT.
/**
* Invokes the copy action followed by the delete command.
* {@inheritDoc}
*/
@Override
public void runInSWT() {
LOGGER.debug("Clipboard cut action invoked...");
// invoke copy action
CopyAction copy = new CopyAction(getEditor());
copy.runInSWT();
NodeContainerEditPart[] nodeParts = copy.getNodeParts();
AnnotationEditPart[] annotationParts = copy.getAnnotationParts();
Collection<EditPart> coll = new ArrayList<EditPart>();
coll.addAll(Arrays.asList(nodeParts));
coll.addAll(Arrays.asList(annotationParts));
DeleteCommand delete = new DeleteCommand(coll, getEditor().getWorkflowManager().get());
// enable undo
getCommandStack().execute(delete);
getEditor().updateActions();
// Give focus to the editor again. Otherwise the actions (selection)
// is not updated correctly.
getWorkbenchPart().getSite().getPage().activate(getWorkbenchPart());
}
Aggregations