use of org.eclipse.gef.EditPart in project tdi-studio-se by Talend.
the class NodesPasteCommand method execute.
@SuppressWarnings("unchecked")
@Override
public void execute() {
// create the node container list to paste
createNodeContainerList();
AbstractMultiPageTalendEditor multiPageTalendEditor = (AbstractMultiPageTalendEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
GraphicalViewer viewer = multiPageTalendEditor.getTalendEditor().getViewer();
// save old selection
if (!multipleCommand) {
oldSelection = new ArrayList<EditPart>();
for (EditPart editPart : (List<EditPart>) viewer.getSelectedEditParts()) {
oldSelection.add(editPart);
}
// remove the old selection
viewer.deselectAll();
}
// creates the different nodes
for (NodeContainer nodeContainer : nodeContainerList) {
((Process) process).addNodeContainer(nodeContainer);
}
// check that the created connections exists now, or create them if needed
for (String newConnectionName : createdNames) {
if (process.checkValidConnectionName(newConnectionName, true)) {
process.addUniqueConnectionName(newConnectionName);
}
}
process.checkStartNodes();
process.checkProcess();
// set the new node as the current selection
if (!multipleCommand) {
EditPart processPart = (EditPart) viewer.getRootEditPart().getChildren().get(0);
if (processPart instanceof ProcessPart) {
// can only be
// ProcessPart but still
// test
List<EditPart> sel = new ArrayList<EditPart>();
for (EditPart editPart : (List<EditPart>) processPart.getChildren()) {
if (editPart instanceof SubjobContainerPart) {
for (EditPart subjobChildsPart : (List<EditPart>) editPart.getChildren()) {
if (subjobChildsPart instanceof NodeContainerPart) {
if (nodeContainerList.contains(((NodeContainerPart) subjobChildsPart).getModel())) {
NodePart nodePart = ((NodeContainerPart) subjobChildsPart).getNodePart();
if (jobletNodeToExpand.contains(((Node) nodePart.getModel()).getNodeContainer())) {
PropertyChangeCommand ppc = new PropertyChangeCommand(((Node) nodePart.getModel()).getNodeContainer(), EParameterName.COLLAPSED.getName(), false);
ppc.execute();
for (EditPart jobletChildren : (List<EditPart>) subjobChildsPart.getChildren()) {
if (jobletChildren instanceof NodePart) {
sel.add(jobletChildren);
}
}
} else if (nodePart != null) {
sel.add(nodePart);
}
}
}
}
}
if (editPart instanceof NodePart) {
Node currentNode = (Node) editPart.getModel();
if (nodeContainerList.contains(currentNode.getNodeContainer())) {
sel.add(editPart);
}
}
}
if (!isJunitCreate() && !isJobletRefactor()) {
StructuredSelection s = new StructuredSelection(sel);
viewer.setSelection(s);
}
}
}
}
use of org.eclipse.gef.EditPart in project tdi-studio-se by Talend.
the class MoveNodeCommand method initializeCurrentSelection.
private void initializeCurrentSelection() {
currentSelection = new ArrayList<Node>();
AbstractMultiPageTalendEditor multiPageTalendEditor = (AbstractMultiPageTalendEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
GraphicalViewer viewer = multiPageTalendEditor.getTalendEditor().getViewer();
for (EditPart editPart : (List<EditPart>) viewer.getSelectedEditParts()) {
if (editPart.getModel() instanceof Node) {
currentSelection.add((Node) editPart.getModel());
}
}
}
use of org.eclipse.gef.EditPart in project tdi-studio-se by Talend.
the class MultiplePasteCommand method execute.
/*
* (non-Javadoc)
*
* @see org.eclipse.gef.commands.CompoundCommand#execute()
*/
@Override
public void execute() {
AbstractMultiPageTalendEditor multiPageTalendEditor = (AbstractMultiPageTalendEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
GraphicalViewer viewer = multiPageTalendEditor.getTalendEditor().getViewer();
oldSelection = new ArrayList<EditPart>();
for (EditPart editPart : (List<EditPart>) viewer.getSelectedEditParts()) {
oldSelection.add(editPart);
}
// remove the old selection
viewer.deselectAll();
super.execute();
EditPart processPart = (EditPart) viewer.getRootEditPart().getChildren().get(0);
if (processPart instanceof ProcessPart) {
// can only be ProcessPart but still test
List<EditPart> sel = new ArrayList<EditPart>();
for (EditPart editPart : (List<EditPart>) processPart.getChildren()) {
if (editPart instanceof NodePart) {
Node currentNode = (Node) editPart.getModel();
if (nodeCmd.getNodeContainerList().contains(currentNode.getNodeContainer())) {
sel.add(editPart);
}
} else if (editPart instanceof NoteEditPart) {
Note currentNode = (Note) editPart.getModel();
if (noteCmd.getNoteList().contains(currentNode)) {
sel.add(editPart);
}
} else if (editPart instanceof SubjobContainerPart) {
// add for the bug TDI-7706
for (EditPart subjobChildsPart : (List<EditPart>) editPart.getChildren()) {
if (subjobChildsPart instanceof NodeContainerPart) {
if (nodeCmd.getNodeContainerList().contains(((NodeContainerPart) subjobChildsPart).getModel())) {
NodePart nodePart = ((NodeContainerPart) subjobChildsPart).getNodePart();
if (nodePart != null) {
sel.add(nodePart);
}
}
}
}
}
}
StructuredSelection s = new StructuredSelection(sel);
viewer.setSelection(s);
}
}
use of org.eclipse.gef.EditPart in project tdi-studio-se by Talend.
the class TalendEditorComponentCreationAssist method highlightOveredConnection.
private void highlightOveredConnection(org.eclipse.swt.graphics.Point cursorRelativePosition) {
if (overedConnection != null) {
overedConnection.setLineWidth(1);
overedConnection = null;
}
EditPart findObjectAt = graphicViewer.findObjectAt(new Point(cursorRelativePosition.x, cursorRelativePosition.y));
if (findObjectAt instanceof ConnectionPart) {
overedConnection = (ConnectionFigure) ((ConnectionPart) findObjectAt).getFigure();
} else if (findObjectAt instanceof ConnLabelEditPart) {
overedConnection = (ConnectionFigure) ((ConnectionPart) ((ConnLabelEditPart) findObjectAt).getParent()).getFigure();
}
if (overedConnection != null) {
overedConnection.setLineWidth(2);
}
}
use of org.eclipse.gef.EditPart in project tdi-studio-se by Talend.
the class AbstractTalendEditor method collapsePalette.
/**
* DOC hcw Comment method "collapsePalette".
*
* @param children
*/
private void collapsePalette(List children) {
for (Object object : children) {
if (object instanceof TalendDrawerEditPart) {
TalendDrawerEditPart part = (TalendDrawerEditPart) object;
part.setExpanded(false);
collapsePalette(part.getChildren());
} else if (object instanceof EditPart) {
collapsePalette(((EditPart) object).getChildren());
}
}
}
Aggregations