use of org.eclipse.gef.EditPart in project tdi-studio-se by Talend.
the class AbstractMultiPageTalendEditor method selectNode.
/**
* DOC bqian Comment method "selectNode".
*
* @param node
*/
@SuppressWarnings("unchecked")
public void selectNode(Node node) {
GraphicalViewer viewer = designerEditor.getViewer();
Object object = viewer.getRootEditPart().getChildren().get(0);
if (object instanceof ProcessPart) {
// ProcessPart < SubjobContainerPart < NodeContainerPart < NodePart
for (EditPart editPart : (List<EditPart>) ((ProcessPart) object).getChildren()) {
if (editPart instanceof SubjobContainerPart) {
SubjobContainerPart subjobPart = (SubjobContainerPart) editPart;
for (EditPart part : (List<EditPart>) subjobPart.getChildren()) {
if (part instanceof NodeContainerPart) {
EditPart nodePart = (EditPart) part.getChildren().get(0);
if (nodePart instanceof NodePart) {
if (((NodePart) nodePart).getModel().equals(node)) {
viewer.select(nodePart);
return;
}
}
}
}
}
}
}
}
use of org.eclipse.gef.EditPart in project tdi-studio-se by Talend.
the class NodePartKeyHander method getNavigationSiblings.
@Override
protected List getNavigationSiblings() {
EditPart focusPart = getFocusEditPart();
boolean displayVa = true;
if (focusPart.getParent() != null) {
if (focusPart instanceof SubjobContainerPart) {
// return getNodePart((SubjobContainerPart) focusPart);
SubjobContainerPart subConPart = (SubjobContainerPart) focusPart;
List subList = focusPart.getParent().getChildren();
for (int j = 0; j < subList.size(); j++) {
if (subList.get(j) instanceof SubjobContainerPart) {
subConPart = (SubjobContainerPart) subList.get(j);
SubjobContainer subContainer = (SubjobContainer) subConPart.getModel();
if (subContainer.isDisplayed() == false) {
displayVa = false;
}
} else if (subList.get(j) instanceof NoteEditPart) {
NoteEditPart notePart = (NoteEditPart) subList.get(j);
return getNodePart((ProcessPart) notePart.getParent());
} else if (subList.get(j) instanceof NodePart) {
NodePart node = (NodePart) subList.get(j);
return getNodePart((ProcessPart) node.getParent().getParent().getParent());
}
}
if (displayVa == false) {
return getNodePart((ProcessPart) focusPart.getParent());
}
} else if (focusPart instanceof NodePart) {
// get all node part for a job.
return getNodePart((ProcessPart) focusPart.getParent().getParent().getParent());
// return getNodePart((SubjobContainerPart) focusPart.getParent().getParent());
} else if (focusPart instanceof NoteEditPart) {
return getNodePart((ProcessPart) focusPart.getParent());
}
return focusPart.getParent().getChildren();
}
List list = new ArrayList();
list.add(focusPart);
return list;
}
use of org.eclipse.gef.EditPart in project tdi-studio-se by Talend.
the class ConnectionPart method getModelChildren.
/*
* (non-Javadoc)
*
* @see org.eclipse.gef.editparts.AbstractEditPart#getModelChildren()
*/
@Override
protected List getModelChildren() {
List<Element> elements;
elements = new ArrayList<Element>();
elements.add(((Connection) getModel()).getConnectionLabel());
elements.add(((Connection) getModel()).getPerformance());
if (((Connection) getModel()).getResuming() != null) {
elements.add(((Connection) getModel()).getResuming());
}
boolean monitorSupport = true;
if (getParent() != null && getRoot() != null) {
EditPart contents = getRoot().getContents();
if (contents.getModel() instanceof IProcess) {
IProcess currentProcess = (IProcess) contents.getModel();
if (ComponentCategory.CATEGORY_4_MAPREDUCE.getName().endsWith(currentProcess.getComponentsType())) {
monitorSupport = false;
}
}
} else {
IProcess currentProcess = ((Connection) getModel()).getSource().getProcess();
if (ComponentCategory.CATEGORY_4_MAPREDUCE.getName().endsWith(currentProcess.getComponentsType())) {
monitorSupport = false;
}
}
if (monitorSupport) {
if (((Connection) getModel()).getConnectionTrace() != null) {
elements.add(((Connection) getModel()).getConnectionTrace());
}
// Add monitor label
if (((Connection) getModel()).isMonitorConnection()) {
elements.add(((Connection) getModel()).getMonitorLabel());
}
}
return elements;
}
use of org.eclipse.gef.EditPart in project tdi-studio-se by Talend.
the class DragAndDropEditPolicy method getCommand.
@Override
public Command getCommand(Request request) {
if (request instanceof CreateNodeConnectionRequest) {
CreateNodeConnectionRequest rq = (CreateNodeConnectionRequest) request;
EditPart targetEditPart = rq.getTargetEditPart();
Command command = null;
if (targetEditPart != null && TemplateTransfer.getInstance().getObject() instanceof TransferedObject) {
TransferedObject toDrop = (TransferedObject) TemplateTransfer.getInstance().getObject();
MapperManager manager = ((XmlMapGraphicViewer) targetEditPart.getViewer()).getMapperManager();
if (manager != null && manager.getExternalData() != null) {
DropType dropType = rq.getNewObjectType();
if (dropType != null) {
switch(dropType) {
case DROP_FILTER:
if (targetEditPart instanceof MapperTablePart) {
command = new UpdateFilterExpressionCommand(toDrop, (MapperTablePart) targetEditPart, manager.getExternalData());
}
break;
case DROP_EXPRESSION:
if (targetEditPart instanceof TableEntityPart) {
command = new UpdateExpressionCommand(toDrop, (TableEntityPart) targetEditPart, manager);
}
break;
case DROP_OUTPUT_DOC_CHILD:
if (targetEditPart instanceof OutputTreeNodeEditPart && rq.getNewObject() instanceof OutputTreeNode) {
command = new CreateDocChildrenCommand(toDrop, (OutputTreeNodeEditPart) targetEditPart, rq, manager);
}
break;
case DROP_INSERT_OUTPUT:
case DROP_INSERT_VAR:
case DROP_INSERT_INPUT:
command = new InsertNewColumnCommand(toDrop, targetEditPart, rq, manager, dropType);
default:
break;
}
}
}
}
if (command != null) {
return command;
}
// drop expression
// boolean update = rq.getDropType() == CreateNodeConnectionRequest.DROP_EXPRESSION ? true : false;
// return new CreateNodeAndConnectionCommand(rq.getNewObject(), rq.getTargetEditPart(), update);
}
return super.getCommand(request);
}
use of org.eclipse.gef.EditPart in project tdi-studio-se by Talend.
the class NodesMoveCommond 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 (nodePart != null) {
sel.add(nodePart);
}
}
}
}
}
if (editPart instanceof NodePart) {
Node currentNode = (Node) editPart.getModel();
if (nodeContainerList.contains(currentNode.getNodeContainer())) {
sel.add(editPart);
}
}
}
StructuredSelection s = new StructuredSelection(sel);
viewer.setSelection(s);
}
}
}
Aggregations