use of org.talend.designer.core.ui.editor.connections.Connection in project tdi-studio-se by Talend.
the class ConnectionDeleteCommand method execute.
@Override
public void execute() {
connectionDeletedInfosMap = new HashMap<Connection, ConnectionDeleteCommand.ConnectionDeletedInfo>();
Process process = (Process) connectionList.get(0).getSource().getProcess();
for (Connection connection : connectionList) {
boolean re = deleteExpendNode(connection);
if (re) {
return;
}
ConnectionDeletedInfo deletedInfo = new ConnectionDeletedInfo();
connectionDeletedInfosMap.put(connection, deletedInfo);
INode source = connection.getSource();
if (source != null && source instanceof Node && !(((Node) source).isELTMapComponent())) {
deletedInfo.metadataTable = connection.getMetadataTable();
List<IMetadataTable> metaList = source.getMetadataList();
if (metaList != null && deletedInfo.metadataTable != null) {
deletedInfo.metadataTableIndex = metaList.indexOf(deletedInfo.metadataTable);
}
}
connection.disconnect();
final INode target = connection.getTarget();
if (target.getExternalNode() instanceof AbstractNode) {
((AbstractNode) target.getExternalNode()).removeInput(connection);
}
INodeConnector nodeConnectorSource, nodeConnectorTarget;
nodeConnectorSource = connection.getSourceNodeConnector();
if (nodeConnectorSource != null) {
nodeConnectorSource.setCurLinkNbOutput(nodeConnectorSource.getCurLinkNbOutput() - 1);
}
nodeConnectorTarget = connection.getTargetNodeConnector();
nodeConnectorTarget.setCurLinkNbInput(nodeConnectorTarget.getCurLinkNbInput() - 1);
}
process.checkStartNodes();
process.checkProcess();
}
use of org.talend.designer.core.ui.editor.connections.Connection in project tdi-studio-se by Talend.
the class RadioController method createCommand.
private List<Command> createCommand(SelectionEvent event) {
Set<String> elementsName;
Control ctrl = (Control) event.getSource();
elementsName = hashCurControls.keySet();
List<Command> commands = new ArrayList<Command>();
for (String name : elementsName) {
Object o = hashCurControls.get(name);
if (o instanceof Control) {
ctrl = (Control) o;
if (ctrl == null) {
hashCurControls.remove(name);
return null;
}
if (ctrl.equals(event.getSource())) {
if (ctrl instanceof Button) {
// before
if (!elem.getPropertyValue(name).equals(new Boolean(((Button) ctrl).getSelection()))) {
Command cmd = null;
Boolean value = new Boolean(((Button) ctrl).getSelection());
if (name.equals(EParameterName.ACTIVATE.getName())) {
if (elem instanceof Node) {
List<Node> nodeList = new ArrayList<Node>();
nodeList.add((Node) elem);
List<Connection> connList = new ArrayList<Connection>();
cmd = new ChangeActivateStatusElementCommand(value, nodeList, connList);
commands.add(cmd);
}
} else {
IElementParameter param = elem.getElementParameter(name);
if (Boolean.TRUE.equals(value)) {
List<IElementParameter> parameters = DesignerUtilities.findRadioParamInSameGroup(elem.getElementParameters(), param);
for (IElementParameter currentRadioParam : parameters) {
if (Boolean.TRUE.equals(currentRadioParam.getValue())) {
cmd = new PropertyChangeCommand(elem, currentRadioParam.getName(), Boolean.FALSE);
commands.add(cmd);
}
}
}
cmd = new PropertyChangeCommand(elem, name, value);
commands.add(cmd);
String groupName = param.getGroup();
if (groupName != null && elem.getElementParameter(groupName) != null) {
Command cmd2 = new PropertyChangeCommand(elem, groupName, name);
commands.add(cmd2);
}
}
return commands;
}
}
}
}
}
return null;
}
use of org.talend.designer.core.ui.editor.connections.Connection 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.Connection in project tdi-studio-se by Talend.
the class ChangeActivateStatusElementCommand method execute.
@SuppressWarnings("unchecked")
@Override
public void execute() {
if (connectionList != null && connectionList.size() != 0) {
curConn = connectionList.get(0);
listNm = (List<IConnection>) curConn.getSource().getOutgoingConnections(curConn.getLineStyle());
outputs = (List<Connection>) curConn.getSource().getOutgoingConnections();
connIndex = outputs.indexOf(curConn);
deactiveNum = 0;
object = outputs.get(connIndex);
if (listNm.size() > 1) {
for (int i = 0; i < listNm.size(); i++) {
if (!listNm.get(i).isActivate()) {
deactiveNum = deactiveNum + 1;
}
}
outputs.remove(curConn);
if (value) {
outputs.add(outputs.size() - deactiveNum, (Connection) object);
} else {
outputs.add(curConn);
}
curConn.updateAllId();
}
}
if (nodeList != null && nodeList.size() > 0) {
List<Connection> connIn = null;
List<Connection> allConn = null;
connIn = (List<Connection>) nodeList.get(0).getIncomingConnections();
if (nodeList.get(0).getIncomingConnections() != null && nodeList.get(0).getIncomingConnections().size() > 0) {
allConn = (List<Connection>) nodeList.get(0).getIncomingConnections().get(0).getSource().getOutgoingConnections();
if (allConn.containsAll(connIn)) {
if (connIn != null && connIn.size() >= 1) {
for (int i = 0; i < connIn.size(); i++) {
Connection con = connIn.get(i);
allConn.remove(con);
allConn.add(con);
}
}
}
allConn.get(0).updateAllId();
}
}
Process process;
if (nodeList.size() > 0) {
process = (Process) nodeList.get(0).getProcess();
} else {
process = (Process) curConn.getSource().getProcess();
}
process.setActivate(false);
for (Connection connection : connectionList) {
connection.setPropertyValue(EParameterName.ACTIVATE.getName(), value);
}
List uniqueNameList = new ArrayList();
for (Node node : nodeList) {
uniqueNameList.add(node.getUniqueName());
if (isSameSchemaInputOutput(node)) {
node.setPropertyValue(EParameterName.DUMMY.getName(), !value);
}
node.setPropertyValue(EParameterName.ACTIVATE.getName(), value);
}
dummyMiddleElement(false);
process.setActivate(true);
process.checkStartNodes();
process.checkProcess();
refreshPropertyView();
refreshMRStatus();
}
use of org.talend.designer.core.ui.editor.connections.Connection in project tdi-studio-se by Talend.
the class ChangeActivateStatusElementCommand method isSameSchemaInputOutput.
private boolean isSameSchemaInputOutput(Node node) {
boolean hasInput = false;
IMetadataTable inputMetadata = null;
for (Connection connection : (List<Connection>) node.getIncomingConnections()) {
if (connection.getLineStyle().hasConnectionCategory(IConnectionCategory.FLOW)) {
if (hasInput) {
// so don't accept the dummy
return false;
}
hasInput = true;
inputMetadata = connection.getMetadataTable();
}
}
if (!hasInput) {
return false;
}
for (Connection outputConnection : (List<Connection>) node.getOutgoingConnections()) {
if (outputConnection.getLineStyle().hasConnectionCategory(IConnectionCategory.FLOW)) {
IMetadataTable outputMeta = outputConnection.getMetadataTable();
if (!inputMetadata.sameMetadataAs(outputMeta, IMetadataColumn.OPTIONS_IGNORE_KEY | IMetadataColumn.OPTIONS_IGNORE_NULLABLE | IMetadataColumn.OPTIONS_IGNORE_COMMENT | IMetadataColumn.OPTIONS_IGNORE_PATTERN | IMetadataColumn.OPTIONS_IGNORE_DBCOLUMNNAME | IMetadataColumn.OPTIONS_IGNORE_DBTYPE)) {
// input and output schema is different, so don't accept dummy
return false;
}
}
}
return true;
}
Aggregations