use of org.talend.designer.core.ui.editor.connections.Connection in project tdi-studio-se by Talend.
the class JobletUtil method cloneConnection.
public Connection cloneConnection(IConnection conn, INode source, INode target) {
Connection cloneConn = new Connection(source, target, conn.getLineStyle(), conn.getConnectorName(), conn.getMetaName(), conn.getName(), conn.isMonitorConnection());
if (!source.isActivate() || !target.isActivate()) {
cloneConn.setActivate(false);
}
List<? extends IElementParameter> elementParas = conn.getElementParameters();
for (IElementParameter elementPara : elementParas) {
if (elementPara.getName() != null && !elementPara.getName().equals("UNIQUE_NAME")) {
IElementParameter cloneElement = cloneConn.getElementParameter(elementPara.getName());
Object paValue = elementPara.getValue();
if (paValue instanceof List) {
List list = new ArrayList();
list.addAll((List) paValue);
cloneElement.setValue(list);
} else {
cloneElement.setContextMode(elementPara.isContextMode());
cloneElement.setValue(elementPara.getValue());
}
}
}
return cloneConn;
}
use of org.talend.designer.core.ui.editor.connections.Connection in project tdi-studio-se by Talend.
the class DummyNodeAnchor method getLocation.
/*
* (non-Javadoc)
*
* @see org.eclipse.draw2d.ChopboxAnchor#getLocation(org.eclipse.draw2d.geometry.Point)
*/
@Override
public Point getLocation(Point reference) {
int nb = 0;
int connectionId = 0;
for (Connection connection : (List<Connection>) source.getOutgoingConnections()) {
if (connection.getTarget().equals(target)) {
nb++;
if (connection.equals(this.connection)) {
connectionId = nb;
}
}
}
if (nb <= 1) {
return getSourceAnchorLocation(reference);
} else {
return getLocationForMultipleConnections(connectionId);
}
}
use of org.talend.designer.core.ui.editor.connections.Connection in project tdi-studio-se by Talend.
the class SubjobContainer method refreshOutputConnections.
/**
* DOC nrousseau Comment method "refreshOutputConnections".
*/
private void refreshOutputConnections() {
boolean collapsed = isCollapsed();
// reinitialize all output connections.
Node subjobStartNode = this.getSubjobStartNode();
List<Connection> connectionsToUpdate = new ArrayList<Connection>(outputs);
outputs = new ArrayList<Connection>();
if (!collapsed) {
fireStructureChange(UPDATE_SUBJOB_CONNECTIONS, this);
for (NodeContainer nodeContainer : this.nodeContainers) {
Node currentNode = nodeContainer.getNode();
// force connections draw update
currentNode.forceConnectionsUpdate();
for (Connection connection : outputs) {
if (connection.getLineStyle().hasConnectionCategory(IConnectionCategory.DEPENDENCY)) {
connection.setSubjobConnection(false);
}
}
}
return;
}
for (NodeContainer nodeContainer : this.nodeContainers) {
Node currentNode = nodeContainer.getNode();
if (currentNode.equals(subjobStartNode)) {
// avoid subjobStartNode as it's not needed
continue;
}
for (Connection connection : (List<Connection>) currentNode.getOutgoingConnections()) {
if (connection.getLineStyle().hasConnectionCategory(IConnectionCategory.DEPENDENCY) && !subjobStartNode.equals(connection.getTarget().getDesignSubjobStartNode())) {
connection.setSubjobConnection(true);
outputs.add(connection);
}
}
fireStructureChange(UPDATE_SUBJOB_CONNECTIONS, this);
}
}
use of org.talend.designer.core.ui.editor.connections.Connection in project tdi-studio-se by Talend.
the class ProcessComposite method addTrace.
private void addTrace(int itemId) {
Boolean trace = false;
processContext.setMonitorTrace(trace);
processManager.setBooleanTrace(trace);
org.talend.core.model.process.IProcess process = processContext.getProcess();
List<INode> nodeList = (List<INode>) process.getGraphicalNodes();
for (INode node : nodeList) {
for (Connection connection : (List<Connection>) node.getOutgoingConnections()) {
ConnectionTrace traceNode = connection.getConnectionTrace();
if (traceNode == null) {
continue;
}
traceNode.setPropertyValue(EParameterName.TRACES_SHOW_ENABLE.getName(), trace);
if (connection != null && connection.checkTraceShowEnable()) {
connection.setPropertyValue(EParameterName.TRACES_SHOW_ENABLE.getName(), trace);
}
}
}
}
use of org.talend.designer.core.ui.editor.connections.Connection in project tdi-studio-se by Talend.
the class GEFDeleteAction method calculateEnabled.
@Override
protected boolean calculateEnabled() {
objectsToDelete = new ArrayList();
List objects = getSelectedObjects();
objectsToDelete.addAll(objects);
if (objects.isEmpty() || (objects.size() == 1 && objects.get(0) instanceof ProcessPart)) {
return false;
}
if (!(objects.get(0) instanceof EditPart)) {
return false;
}
AbstractTalendEditor editor = (AbstractTalendEditor) this.getWorkbenchPart();
AbstractProcessProvider pProvider = AbstractProcessProvider.findProcessProviderFromPID(IComponent.JOBLET_PID);
if (pProvider != null) {
Map<JobletContainerPart, List<NodePart>> jobletMap = new HashMap<JobletContainerPart, List<NodePart>>();
boolean nodeInJoblet = false;
boolean allJunitnode = true;
boolean hasNode = false;
int i = 0;
for (Object o : objects) {
if (o instanceof NodePart) {
hasNode = true;
NodePart nodePart = (NodePart) o;
Node no = (Node) ((NodePart) o).getModel();
if (no.getProcess().isReadOnly()) {
return false;
}
if (no.isReadOnly()) {
i++;
}
if (no.getJunitNode() == null) {
allJunitnode = false;
}
if (!pProvider.canDeleteNode(no)) {
return false;
}
boolean isCollapsedNode = false;
if (editor.getProcess().getGraphicalNodes().contains(nodePart.getModel())) {
isCollapsedNode = true;
}
if (!isCollapsedNode && nodePart.getParent() instanceof JobletContainerPart) {
JobletContainerPart jobletContainer = (JobletContainerPart) nodePart.getParent();
List<NodePart> jobletNodeParts = jobletMap.get(jobletContainer);
if (jobletNodeParts == null) {
jobletNodeParts = new ArrayList<NodePart>();
jobletMap.put(jobletContainer, jobletNodeParts);
}
jobletNodeParts.add(nodePart);
}
} else if (o instanceof ConnectionPart) {
Connection conn = (Connection) ((ConnectionPart) o).getModel();
if (conn.getSource().getProcess().isReadOnly()) {
return false;
}
if (conn.isReadOnly()) {
i++;
}
} else if (o instanceof ConnLabelEditPart) {
ConnectionLabel connLabel = (ConnectionLabel) ((ConnLabelEditPart) o).getModel();
if (connLabel.getConnection().getSource().getProcess().isReadOnly()) {
return false;
}
if (connLabel.getConnection().isReadOnly()) {
i++;
}
} else if (o instanceof NoteEditPart) {
allJunitnode = false;
Note note = (Note) ((NoteEditPart) o).getModel();
if (note.isReadOnly()) {
i++;
}
} else if (o instanceof SubjobContainerPart) {
SubjobContainer subjob = (SubjobContainer) ((SubjobContainerPart) o).getModel();
if (subjob.getProcess().isReadOnly()) {
return false;
}
if (subjob.isReadOnly()) {
i++;
continue;
}
boolean isAllReadonly = true;
boolean subjobAllJunit = true;
for (NodeContainer nc : subjob.getNodeContainers()) {
Node node = nc.getNode();
if (!node.isReadOnly()) {
isAllReadonly = false;
}
if (node.getJunitNode() == null) {
subjobAllJunit = false;
}
}
if (isAllReadonly || subjobAllJunit) {
i++;
}
}
}
for (JobletContainerPart jobletContainer : jobletMap.keySet()) {
boolean copyJobletNode = true;
List<NodePart> list = jobletMap.get(jobletContainer);
for (Object obj : jobletContainer.getChildren()) {
if (obj instanceof NodePart) {
if (!list.contains(obj)) {
copyJobletNode = false;
break;
}
}
}
if (copyJobletNode) {
objectsToDelete.removeAll(list);
PartFactory factory = new PartFactory();
NodePart createEditPart = (NodePart) factory.createEditPart(jobletContainer, ((NodeContainer) jobletContainer.getModel()).getNode());
createEditPart.setParent(jobletContainer);
createEditPart.installEditPolicy(EditPolicy.COMPONENT_ROLE, new NodeEditPolicy());
objectsToDelete.add(createEditPart);
} else {
nodeInJoblet = true;
}
}
if (((nodeInJoblet || allJunitnode) && hasNode) || i == objects.size()) {
return false;
}
}
return true;
}
Aggregations