use of org.talend.core.model.process.INodeConnector in project tdi-studio-se by Talend.
the class JobletUtil method createConnectors.
public List<INodeConnector> createConnectors(INode node, IProcess2 process) {
List<INodeConnector> listConnector = new ArrayList<INodeConnector>();
if (process == null) {
return listConnector;
}
if (process.getProperty().getItem() instanceof JobletProcessItem) {
JobletProcess jobletProcess = ((JobletProcessItem) process.getProperty().getItem()).getJobletProcess();
EList<JobletNode> jobletLinks = jobletProcess.getJobletNodes();
INodeConnector nodeConnector;
int nbInput = 0;
int nbOutput = 0;
int jobletNbInput = 0;
for (JobletNode jNode : jobletLinks) {
if (jNode.isInput()) {
jobletNbInput++;
}
}
boolean multipleInput = jobletNbInput > 1;
for (JobletNode jNode : jobletLinks) {
String name = ComponentUtilities.getNodeUniqueName(jNode);
if (jNode.isTrigger()) {
// createTriggerConnector(listConnector, node);
} else {
if (jNode.isInput()) {
if (multipleInput) {
nodeConnector = new NodeConnector(node);
nodeConnector.setName(name);
nodeConnector.setBaseSchema(EConnectionType.FLOW_MAIN.getName());
nodeConnector.setDefaultConnectionType(EConnectionType.FLOW_MAIN);
nodeConnector.setMaxLinkInput(1);
nodeConnector.setMinLinkInput(0);
nodeConnector.setMaxLinkOutput(0);
nodeConnector.setMinLinkOutput(0);
listConnector.add(nodeConnector);
}
nbInput++;
} else {
nodeConnector = new NodeConnector(node);
nodeConnector.setName(name);
nodeConnector.setBaseSchema(EConnectionType.FLOW_MAIN.getName());
nodeConnector.setBuiltIn(true);
nodeConnector.setMaxLinkOutput(1);
nodeConnector.setMinLinkOutput(1);
// achen modify to fix bug 6205
String displayName = getDisplayName(jNode);
nodeConnector.setLinkName("Joblet " + name);
nodeConnector.setMenuName(displayName);
nodeConnector.setDefaultConnectionType(EConnectionType.FLOW_MAIN);
nodeConnector.addConnectionProperty(EConnectionType.FLOW_MAIN, EConnectionType.FLOW_MAIN.getRGB(), EConnectionType.FLOW_MAIN.getDefaultLineStyle());
nodeConnector.addConnectionProperty(EConnectionType.FLOW_REF, EConnectionType.FLOW_REF.getRGB(), EConnectionType.FLOW_REF.getDefaultLineStyle());
nodeConnector.addConnectionProperty(EConnectionType.FLOW_MERGE, EConnectionType.FLOW_MERGE.getRGB(), EConnectionType.FLOW_MERGE.getDefaultLineStyle());
listConnector.add(nodeConnector);
nbOutput++;
}
}
}
}
createTriggerConnector(listConnector, node);
return listConnector;
}
use of org.talend.core.model.process.INodeConnector in project tdi-studio-se by Talend.
the class NodeFigure method setBounds.
@Override
public void setBounds(final Rectangle rect) {
super.setBounds(rect);
Point location = (new Point(rect.getCenter())).translate(new Point(-fig.getSize().width / 2, -(fig.getSize().height / 2)));
Rectangle figBounds = new Rectangle(location, fig.getSize());
this.fig.setBounds(figBounds);
if (dummy) {
if (sourceDummyMap != null) {
if (targetConnection != null && sourceDummyMap.keySet().size() != 0) {
for (final ConnectionFigure curConn : newSourceConnections) {
AnchorListener sourceListener = new AnchorListener() {
@Override
public void anchorMoved(ConnectionAnchor anchor) {
if (curConn != null) {
updateSource(curConn);
}
}
};
if (curConn.getTargetAnchor() != null && curConn.getTargetAnchor().getOwner() != null) {
sourceListeners.put(curConn, sourceListener);
curConn.getTargetAnchor().addAnchorListener(sourceListener);
}
}
newSourceConnections.clear();
updateTarget();
List<ConnectionFigure> toRemove = new ArrayList<ConnectionFigure>();
for (ConnectionFigure curConn : sourceDummyMap.keySet()) {
ConnectionFigure connToRemove = updateSource(curConn);
if (connToRemove != null) {
toRemove.add(connToRemove);
}
}
sourceDummyMap.keySet().removeAll(toRemove);
} else {
INodeConnector mainNodeConnector = node.getConnectorFromType(EConnectionType.FLOW_MAIN);
ConnectionFigure connection = new ConnectionFigure(mainNodeConnector.getConnectionProperty(EConnectionType.FLOW_MAIN), node);
connection.setTargetDecoration(null);
connection.setStart(new Point(figBounds.x, figBounds.y + figBounds.height / 2));
connection.setEnd(new Point(figBounds.x + figBounds.width, figBounds.y + figBounds.height / 2));
}
}
}
if (!rect.getSize().equals(fig.getSize())) {
lineBorder.setUseRectangle(true);
} else {
lineBorder.setUseRectangle(false);
}
}
use of org.talend.core.model.process.INodeConnector in project tdi-studio-se by Talend.
the class ConnectionCreateAction method getConnectors.
public List<INodeConnector> getConnectors() {
List<INodeConnector> list = new ArrayList<INodeConnector>();
if (getSelectedObjects().isEmpty()) {
return list;
}
List parts = getSelectedObjects();
if (parts.size() == 1) {
Object o = parts.get(0);
if (!(o instanceof NodePart)) {
return list;
}
nodePart = (NodePart) o;
if (!(nodePart.getModel() instanceof Node)) {
return list;
}
Node node = (Node) nodePart.getModel();
if (!node.isActivate()) {
return list;
}
List<INodeConnector> nodeConnectorList = new ArrayList<INodeConnector>(node.getConnectorsFromType(connecType));
List<INodeConnector> toRemove = new ArrayList<INodeConnector>();
for (INodeConnector connector : nodeConnectorList) {
if ((connector.getMaxLinkOutput() != -1) && (connector.getCurLinkNbOutput() >= connector.getMaxLinkOutput())) {
toRemove.add(connector);
} else {
if (PluginChecker.isJobLetPluginLoaded()) {
IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
if (service != null) {
if (service.isJobletComponent(node) && !service.isBuiltTriggerConnector(node, connector)) {
toRemove.add(connector);
}
// for bug 10973
List<? extends IConnection> outgoingConnections = node.getOutgoingConnections();
if (service.isTriggerInputNode(node) && outgoingConnections != null && outgoingConnections.size() >= 1) {
toRemove.add(connector);
}
}
}
}
}
nodeConnectorList.removeAll(toRemove);
return nodeConnectorList;
}
return list;
}
use of org.talend.core.model.process.INodeConnector in project tdi-studio-se by Talend.
the class ComponentChooseDialog method createComponentOnLink.
private boolean createComponentOnLink(Node node, Point originalPoint) {
boolean executed = false;
RootEditPart rep = editor.getViewer().getRootEditPart().getRoot();
Point viewOriginalPosition = new Point();
if (rep instanceof ScalableFreeformRootEditPart) {
ScalableFreeformRootEditPart root = (ScalableFreeformRootEditPart) rep;
Viewport viewport = (Viewport) root.getFigure();
viewOriginalPosition = viewport.getViewLocation();
}
Point point = new Point(originalPoint.x + viewOriginalPosition.x, originalPoint.y + viewOriginalPosition.y);
point.x = (int) (point.x / AnimatableZoomManager.currentZoom);
point.y = (int) (point.y / AnimatableZoomManager.currentZoom);
org.talend.designer.core.ui.editor.connections.Connection targetConnection = null;
if (selectedConnectionPart != null) {
targetConnection = (org.talend.designer.core.ui.editor.connections.Connection) selectedConnectionPart.getModel();
}
if (targetConnection != null) {
IProcess2 p = editor.getProcess();
NodeContainer nodeContainer = ((Process) node.getProcess()).loadNodeContainer(node, false);
// TDI-21099
if (p instanceof Process) {
CreateNodeContainerCommand createCmd = new CreateNodeContainerCommand((Process) p, nodeContainer, point);
execCommandStack(createCmd);
// reconnect the node
Node originalTarget = (Node) targetConnection.getTarget();
EConnectionType connectionType = EConnectionType.FLOW_MAIN;
if (GlobalServiceRegister.getDefault().isServiceRegistered(ICamelDesignerCoreService.class)) {
ICamelDesignerCoreService camelService = (ICamelDesignerCoreService) GlobalServiceRegister.getDefault().getService(ICamelDesignerCoreService.class);
if (camelService.isRouteBuilderNode(node)) {
connectionType = camelService.getTargetConnectionType(node);
}
}
INodeConnector targetConnector = node.getConnectorFromType(connectionType);
for (INodeConnector connector : node.getConnectorsFromType(connectionType)) {
if (connector.getMaxLinkOutput() != 0) {
targetConnector = connector;
break;
}
}
ConnectionCreateCommand.setCreatingConnection(true);
// bug 21411
if (PluginChecker.isJobLetPluginLoaded()) {
IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
if (service != null && service.isJobletComponent(targetConnection.getTarget())) {
if (targetConnection.getTarget() instanceof Node) {
NodeContainer jobletContainer = ((Node) targetConnection.getTarget()).getNodeContainer();
// remove the old connection in the container
jobletContainer.getInputs().remove(targetConnection);
}
}
}
ConnectionReconnectCommand cmd2 = new ConnectionReconnectCommand(targetConnection);
cmd2.setNewTarget(node);
execCommandStack(cmd2);
List<Object> nodeArgs = CreateComponentOnLinkHelper.getTargetArgs(targetConnection, node);
ConnectionCreateCommand nodeCmd = new ConnectionCreateCommand(node, targetConnector.getName(), nodeArgs, false);
nodeCmd.setTarget(originalTarget);
execCommandStack(nodeCmd);
// Setting,such as the target is TMap
if (node.getOutgoingConnections().size() > 0) {
if (node.getExternalNode() instanceof MapperExternalNode) {
CreateComponentOnLinkHelper.setupTMap(node);
}
if (originalTarget.getExternalNode() instanceof MapperExternalNode) {
CreateComponentOnLinkHelper.updateTMap(originalTarget, targetConnection, node.getOutgoingConnections().get(0));
}
originalTarget.renameData(targetConnection.getName(), node.getOutgoingConnections().get(0).getName());
}
if (!ConnectionCreateCommand.isCreatingConnection()) {
return true;
}
executed = true;
}
}
return executed;
}
use of org.talend.core.model.process.INodeConnector in project tesb-studio-se by Talend.
the class CamelDesignerCoreService method canCreateNodeOnLink.
@Override
public boolean canCreateNodeOnLink(IConnection connection, INode node) {
INodeConnector connector = node.getConnectorFromType(EConnectionType.ROUTE);
if (connector.getMaxLinkOutput() > 0) {
return true;
}
connector = node.getConnectorFromType(EConnectionType.ROUTE_ENDBLOCK);
if (connector.getMaxLinkOutput() > 0) {
return true;
}
return false;
}
Aggregations