use of org.talend.designer.core.ui.editor.connections.ConnectionPerformanceEditPart in project tdi-studio-se by Talend.
the class TalendSelectionManager method appendSelection.
/*
* (non-Javadoc)
*
* @see org.eclipse.gef.SelectionManager#appendSelection(org.eclipse.gef.EditPart)
*/
@Override
public void appendSelection(EditPart arg0) {
// judge whether the refresh operation is executed.
// see bug 3315.
boolean needRefresh = false;
if (getSelection() instanceof StructuredSelection) {
StructuredSelection selection = (StructuredSelection) getSelection();
Object selected = null;
for (Object element : selection.toArray()) {
selected = element;
}
if (getSelection().isEmpty() || (selected instanceof ProcessPart)) {
this.selectionType = ETalendSelectionType.SINGLE;
needRefresh = true;
}
if (!(arg0 instanceof NodeLabelEditPart) && !(arg0 instanceof ConnLabelEditPart) && !(arg0 instanceof ConnectionPart)) {
// removes old selections of labels by calling setSelection
for (Object element : selection.toArray()) {
if (element instanceof NodeLabelEditPart) {
this.deselect(((AbstractGraphicalEditPart) element));
} else if (element instanceof ConnLabelEditPart) {
this.deselect(((AbstractGraphicalEditPart) element));
} else if (element instanceof ConnectionPart) {
this.deselect(((AbstractConnectionEditPart) element));
}
}
needRefresh = true;
}
if (arg0 instanceof ConnectionPerformanceEditPart && getSelectPoint() != null) {
if (needRefresh) {
EditPart transferPart = transferFocus((ConnectionPerformanceEditPart) arg0);
if (transferPart == null) {
needRefresh = false;
setSelectPoint(null);
return;
}
super.appendSelection(transferPart);
needRefresh = false;
return;
}
}
if (needRefresh) {
super.appendSelection(arg0);
needRefresh = false;
setSelectPoint(null);
}
}
}
use of org.talend.designer.core.ui.editor.connections.ConnectionPerformanceEditPart in project tdi-studio-se by Talend.
the class PartFactory method createEditPart.
/*
* (non-Javadoc)
*
* @see org.eclipse.gef.EditPartFactory#createEditPart(org.eclipse.gef.EditPart, java.lang.Object)
*/
@Override
public EditPart createEditPart(EditPart context, Object model) {
EditPart part = null;
if (model instanceof SubjobContainer) {
part = new SubjobContainerPart();
} else if (model instanceof Process) {
part = new ProcessPart();
} else if (model instanceof Node) {
part = new NodePart();
} else if (model instanceof Connection) {
part = new ConnectionPart();
} else if (model instanceof ConnectionLabel) {
part = new ConnLabelEditPart();
} else if (model instanceof MonitorConnectionLabel) {
part = new MonitorConnectionLabelPart();
} else if (model instanceof ConnectionPerformance) {
part = new ConnectionPerformanceEditPart();
} else if (model instanceof ConnectionTrace) {
part = new ConnectionTraceEditPart();
} else if (model instanceof ConnectionResuming) {
part = new ConnectionResumingEditPart();
} else if (model instanceof NodeLabel) {
part = new NodeLabelEditPart();
} else if (model instanceof NodeContainer) {
if (GlobalServiceRegister.getDefault().isServiceRegistered(ITestContainerGEFService.class)) {
ITestContainerGEFService testContainerService = (ITestContainerGEFService) GlobalServiceRegister.getDefault().getService(ITestContainerGEFService.class);
if (testContainerService != null) {
part = testContainerService.createEditorPart(model);
if (part != null) {
part.setModel(model);
return part;
}
}
}
if (((NodeContainer) model).getNode().isSparkJoblet()) {
if (GlobalServiceRegister.getDefault().isServiceRegistered(ISparkJobletProviderService.class)) {
ISparkJobletProviderService sparkService = (ISparkJobletProviderService) GlobalServiceRegister.getDefault().getService(ISparkJobletProviderService.class);
if (sparkService != null) {
part = (EditPart) sparkService.createEditorPart(model);
if (part != null) {
part.setModel(model);
return part;
}
}
}
} else if (((NodeContainer) model).getNode().isSparkStreamingJoblet()) {
if (GlobalServiceRegister.getDefault().isServiceRegistered(ISparkStreamingJobletProviderService.class)) {
ISparkStreamingJobletProviderService sparkService = (ISparkStreamingJobletProviderService) GlobalServiceRegister.getDefault().getService(ISparkStreamingJobletProviderService.class);
if (sparkService != null) {
part = (EditPart) sparkService.createEditorPart(model);
if (part != null) {
part.setModel(model);
return part;
}
}
}
} else if (((NodeContainer) model).getNode().isStandardJoblet()) {
part = new JobletContainerPart();
} else if (((NodeContainer) model).getNode().isMapReduce()) {
part = new JobletContainerPart();
} else {
part = new NodeContainerPart();
}
} else if (model instanceof Note) {
part = new NoteEditPart();
} else if (model instanceof NodeError) {
part = new NodeErrorEditPart();
} else if (model instanceof NodeProgressBar) {
part = new NodeProgressBarPart();
} else {
return null;
}
// tell the newly created part about the model object
part.setModel(model);
return part;
}
use of org.talend.designer.core.ui.editor.connections.ConnectionPerformanceEditPart in project tdi-studio-se by Talend.
the class TalendSelectionManager method transferFocus.
/*
* (non-Javadoc) for bug 10072
*
* @when the selected element is ConnectionPerformanceEditPart,transfer Focus to nodepart
*/
private EditPart transferFocus(ConnectionPerformanceEditPart arg0) {
ConnectionPart connPart = (ConnectionPart) arg0.getParent();
EditPart targetPart = connPart.getTarget();
if (targetPart instanceof NodePart) {
NodeFigure targetFigure = (NodeFigure) ((NodePart) targetPart).getFigure();
if (targetFigure.containsPoint(getSelectPoint())) {
setSelectPoint(null);
return targetPart;
}
}
EditPart sourcePart = connPart.getSource();
if (sourcePart instanceof NodePart) {
NodeFigure sourceFigure = (NodeFigure) ((NodePart) sourcePart).getFigure();
if (sourceFigure.containsPoint(getSelectPoint())) {
setSelectPoint(null);
return sourcePart;
}
}
if (connPart.getParent() instanceof TalendScalableFreeformRootEditPart) {
TalendScalableFreeformRootEditPart parentPart = (TalendScalableFreeformRootEditPart) connPart.getParent();
if (parentPart.getContents() instanceof ProcessPart) {
ProcessPart processPart = (ProcessPart) parentPart.getContents();
List children = processPart.getChildren();
for (int i = 0; i < children.size(); i++) {
if (children.get(i) instanceof SubjobContainerPart) {
List nodeList = ((SubjobContainerPart) children.get(i)).getChildren();
nodeList.remove(sourcePart.getParent());
nodeList.remove(targetPart.getParent());
for (int j = 0; j < nodeList.size(); j++) {
if (nodeList.get(j) instanceof NodeContainerPart) {
NodePart nodePart = ((NodeContainerPart) nodeList.get(j)).getNodePart();
NodeFigure figure = (NodeFigure) nodePart.getFigure();
if (figure.containsPoint(getSelectPoint())) {
setSelectPoint(null);
return nodePart;
}
}
}
}
}
}
}
return null;
}
Aggregations