use of org.talend.core.ui.IJobletProviderService in project tdi-studio-se by Talend.
the class ConnectionCreateAction method canPerformAction.
/**
* Test if the selected item is a node.
*
* @return true/false
*/
@SuppressWarnings("unchecked")
private boolean canPerformAction() {
if (getSelectedObjects().isEmpty()) {
return false;
}
List parts = getSelectedObjects();
if (parts.size() == 1) {
Object o = parts.get(0);
if (!(o instanceof NodePart)) {
return false;
}
nodePart = (NodePart) o;
if (!(nodePart.getModel() instanceof Node)) {
return false;
}
Node node = (Node) nodePart.getModel();
if (!node.isActivate()) {
return false;
}
if (node.getJobletNode() != null) {
return false;
}
if (curNodeConnector != null && "VALIDATION_REJECT".equals(curNodeConnector.getName())) {
if (node.getProcess() != null && !ComponentCategory.CATEGORY_4_DI.getName().equals(node.getProcess().getComponentsType())) {
return false;
}
}
if (connecType.hasConnectionCategory(IConnectionCategory.EXECUTION_ORDER)) {
if (!(Boolean) node.getPropertyValue(EParameterName.STARTABLE.getName()) || (!node.getProcessStartNode(false).equals(node))) {
if (!node.isELTMapComponent()) {
boolean jobletOk = false;
if (PluginChecker.isJobLetPluginLoaded()) {
IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
if (service != null && service.isJobletComponent(node)) {
jobletOk = true;
}
}
if (!jobletOk) {
return false;
}
}
}
}
menuList = new ArrayList<String>();
if (curNodeConnector == null) {
curNodeConnector = node.getConnectorFromType(connecType);
if (curNodeConnector == null) {
return false;
}
}
if (curNodeConnector.getMaxLinkOutput() != -1) {
if (curNodeConnector.getCurLinkNbOutput() >= curNodeConnector.getMaxLinkOutput()) {
return false;
}
}
if (curNodeConnector.getMaxLinkOutput() == 0) {
return false;
}
/**
* judge whether to show the table link menu in ELTMap components
*/
if (curNodeConnector.getName().equals(EConnectionType.TABLE.getName())) {
List<? extends IConnection> tableRefs = node.getOutgoingConnections(EConnectionType.TABLE_REF);
if (tableRefs != null && 0 < tableRefs.size()) {
return false;
}
}
if (!curNodeConnector.isMultiSchema()) {
// setText(curNodeConnector.getMenuName());
}
if (curNodeConnector.isMultiSchema()) {
for (int i = 0; i < node.getMetadataList().size(); i++) {
IMetadataTable table = (node.getMetadataList().get(i));
String value = table.getAdditionalProperties().get(ISINPUT);
if (value != null && value.equals(TRUE)) {
continue;
}
String name = table.getTableName();
if (name.equals(node.getUniqueName())) {
continue;
}
if (table.getAttachedConnector() == null || table.getAttachedConnector().equals(curNodeConnector.getName())) {
if (connecType == EConnectionType.TABLE) {
//$NON-NLS-1$ //$NON-NLS-2$
name = table.getLabel() + " (" + name + ")";
}
boolean nameUsed = false;
for (Connection connec : (List<Connection>) node.getOutgoingConnections()) {
if (connec.getLineStyle().hasConnectionCategory(IConnectionCategory.FLOW)) {
if (connec.getMetadataTable().getTableName().equals(table.getTableName())) {
nameUsed = true;
}
}
}
// if the name is not already in the process adds to the list
if (!nameUsed) {
menuList.add(name);
}
}
}
if ((curNodeConnector.getMaxLinkOutput() == -1 || node.getMetadataList().size() < curNodeConnector.getMaxLinkOutput()) && curNodeConnector.isBuiltIn()) {
menuList.add(getNewOutputMenuName());
}
} else {
String menuName;
boolean addDefaultName = false;
// get linked metadata to connector
IMetadataTable table = null;
for (int i = 0; i < node.getMetadataList().size(); i++) {
table = (node.getMetadataList().get(i));
if (table.getTableName().equals(node.getUniqueName())) {
break;
}
}
// if EBCDIC + single schema mode, only have one output maximum
if (node.getComponent().getName().contains("EBCDIC") && node.checkSchemaForEBCDIC(table) && curNodeConnector.getCurLinkNbOutput() > 0) {
return false;
}
if (connecType == EConnectionType.TABLE) {
addDefaultName = addDefaultName();
menuName = getNewOutputMenuName();
} else {
menuName = curNodeConnector.getMenuName();
}
if (!addDefaultName) {
setText(menuName);
menuList.add(menuName);
}
}
return true;
}
return false;
}
use of org.talend.core.ui.IJobletProviderService in project tdi-studio-se by Talend.
the class JobletContainer method refreshJobletNodes.
public void refreshJobletNodes(boolean update, boolean coll) {
if (this.node.isJoblet()) {
if (!coll || update) {
boolean componentUpdated = false;
IComponent oldComponent = node.getComponent();
if (GlobalServiceRegister.getDefault().isServiceRegistered(IJobletProviderService.class)) {
IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
IComponent newComponent = service.getUpdatedJobletComponent(oldComponent);
if (oldComponent != newComponent) {
node.setComponent(newComponent);
componentUpdated = true;
}
}
JobletUtil util = new JobletUtil();
IProcess jobletProcess = this.getNode().getComponent().getProcess();
Set<IConnection> conns = new HashSet<IConnection>();
List<? extends INode> jobletNodes = jobletProcess.getGraphicalNodes();
boolean lockByOther = false;
if (jobletProcess instanceof IProcess2) {
lockByOther = util.lockByOthers(((IProcess2) jobletProcess).getProperty().getItem());
}
Map<String, List<? extends IElementParameter>> paraMap = new HashMap<String, List<? extends IElementParameter>>();
// List<NodeContainer> temList = new ArrayList<NodeContainer>(nodeContainers);
if (!componentUpdated) {
for (NodeContainer nc : nodeContainers) {
if (this.node.getProcess() instanceof IProcess2) {
if (!update) {
paraMap.put(nc.getNode().getJoblet_unique_name(), nc.getNode().getElementParameters());
}
((IProcess2) this.node.getProcess()).removeUniqueNodeName(nc.getNode().getUniqueName());
}
}
}
nodeContainers.clear();
jobletElements.clear();
// boolean canRemove = false;
for (INode inode : jobletNodes) {
// canAdd = util.canAdd(temList, inode);
if ((inode instanceof Node)) {
Node temNode = (Node) inode;
// if (canAdd) {
conns.addAll(temNode.getIncomingConnections());
conns.addAll(temNode.getOutgoingConnections());
Node jnode = util.cloneNode(temNode, this.node.getProcess(), paraMap, lockByOther);
if (!this.node.isActivate()) {
jnode.setActivate(this.node.isActivate());
}
NodeContainer nodeContainer = util.cloneNodeContainer(temNode.getNodeContainer(), jnode);
jnode.setJobletnode(this.node);
jnode.setJoblet_unique_name(temNode.getUniqueName());
this.nodeContainers.add(nodeContainer);
this.jobletElements.add(jnode);
this.jobletElements.add(jnode.getNodeLabel());
this.jobletElements.add(jnode.getNodeError());
this.jobletElements.add(jnode.getNodeProgressBar());
// } else if (update) {
// for (NodeContainer nodeC : nodeContainers) {
// if (nodeC.getNode().getJoblet_unique_name().equals(temNode.getUniqueName())) {
// util.updateNode(nodeC.getNode(), temNode);
// break;
// }
// }
// }
}
}
// }
for (IConnection con : conns) {
String sourceName = con.getSource().getUniqueName();
String targetName = con.getTarget().getUniqueName();
Node sourceNode = null;
Node targetNode = null;
for (NodeContainer nodeC : nodeContainers) {
Node connNode = nodeC.getNode();
if (connNode.getJoblet_unique_name().equals(sourceName)) {
sourceNode = connNode;
}
if (connNode.getJoblet_unique_name().equals(targetName)) {
targetNode = connNode;
}
if (sourceNode != null && targetNode != null) {
util.cloneConnection(con, sourceNode, targetNode);
break;
}
}
}
}
} else if (this.node.isMapReduceStart()) {
Integer mrGroupId = node.getMrGroupId();
List<? extends INode> mapReduceNodes = this.node.getProcess().getGraphicalNodes();
List<Node> nodeList = new ArrayList<Node>();
if (node.getNodeContainer().getSubjobContainer() != null && node.getNodeContainer().getSubjobContainer().isCollapsed()) {
nodeList.add(node);
} else {
for (INode inode : mapReduceNodes) {
if ((inode instanceof Node)) {
Node temNode = (Node) inode;
if (temNode.getMrGroupId() != null && mrGroupId != null && temNode.getMrGroupId().equals(mrGroupId)) {
nodeList.add(temNode);
}
}
}
}
nodeContainers.clear();
jobletElements.clear();
for (Node inode : nodeList) {
if (!inode.isActivate()) {
continue;
}
NodeContainer nodeContainer = inode.getNodeContainer();
// inode.setJoblet_unique_name(inode.getUniqueName());
if (nodeContainer instanceof JobletContainer) {
((JobletContainer) nodeContainer).setMrStartContainer(this);
}
this.nodeContainers.add(nodeContainer);
this.jobletElements.add(inode);
this.jobletElements.add(inode.getNodeLabel());
this.jobletElements.add(inode.getNodeError());
this.jobletElements.add(inode.getNodeProgressBar());
}
}
}
use of org.talend.core.ui.IJobletProviderService in project tdi-studio-se by Talend.
the class JobletContainer method canCollapse.
public boolean canCollapse() {
List<String> connList = new ArrayList<String>();
List<String> triConnList = new ArrayList<String>();
List<String> metaList = new ArrayList<String>();
if (node.getIncomingConnections().size() > 1) {
for (IConnection conn : node.getIncomingConnections()) {
if (conn.getConnectorName().startsWith("TRIGGER")) {
metaList.add(conn.getMetaName());
}
}
for (NodeContainer nodeContainer : this.nodeContainers) {
Node connNode = nodeContainer.getNode();
IElementParameter elePa = this.node.getElementParameter(connNode.getJoblet_unique_name());
if (elePa != null) {
boolean isTri = false;
IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
if (service != null) {
isTri = service.isTriggerNode(connNode);
}
if (isTri) {
IElementParameter elechild = elePa.getChildParameters().get("COMPONENT_LIST");
if (elechild != null) {
if (elechild.getValue() == null || ((String) elechild.getValue()).length() <= 0) {
return false;
} else {
if (triConnList.contains(elechild.getValue())) {
return false;
} else {
triConnList.add((String) elechild.getValue());
}
}
if (elechild.getValue() != null && (elechild.getValue() instanceof String)) {
metaList.remove(elechild.getValue());
}
}
} else {
IElementParameter elechild = elePa.getChildParameters().get("CONNECTION");
if (elechild != null) {
if ((elechild.getValue() == null || "".equals(elechild.getValue()))) {
return false;
} else {
if (elechild.getValue() instanceof String) {
if (connList.contains(elechild.getValue())) {
return false;
} else {
connList.add((String) elechild.getValue());
}
}
}
}
}
}
}
if (metaList.size() > 0) {
return false;
}
}
return true;
}
use of org.talend.core.ui.IJobletProviderService in project tdi-studio-se by Talend.
the class ComponentChooseDialog method getJobletPart.
public AbstractMultiPageTalendEditor getJobletPart(JobletContainerPart part) {
AbstractMultiPageTalendEditor openEditor = null;
Node jobletNode = ((JobletContainer) part.getModel()).getNode();
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
if (PluginChecker.isJobLetPluginLoaded()) {
IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
if (service != null) {
openEditor = (AbstractMultiPageTalendEditor) service.openJobletEditor(jobletNode, page);
}
}
return openEditor;
}
use of org.talend.core.ui.IJobletProviderService in project tdi-studio-se by Talend.
the class NodesMoveCommond method createNodeContainerList.
@SuppressWarnings("unchecked")
private void createNodeContainerList() {
int firstIndex = 0;
int index = 0;
nodeContainerList = new ArrayList<NodeContainer>();
connections = new ArrayList<IConnection>();
createdNames = new ArrayList<String>();
Map<String, String> oldNameTonewNameMap = new HashMap<String, String>();
Map<String, String> oldMetaToNewMeta = new HashMap<String, String>();
// see bug 0004882: Subjob title is not copied when copying/pasting subjobs from one job to another
Map<INode, SubjobContainer> mapping = new HashMap<INode, SubjobContainer>();
IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
// create the nodes
for (INode copiedNode : nodes) {
// IGraphicalNode copiedNode = (IGraphicalNode) copiedNodePart.getModel();
if (!containNodeInProcess(copiedNode)) {
continue;
}
IComponent component = ComponentsFactoryProvider.getInstance().get(copiedNode.getComponent().getName(), copiedNode.getProcess().getComponentsType());
if (component == null) {
component = copiedNode.getComponent();
}
IGraphicalNode pastedNode = new Node(component, process);
if (isJobletRefactor()) {
// keep original for joblet refactor.
process.removeUniqueNodeName(pastedNode.getUniqueName());
pastedNode.setPropertyValue(EParameterName.UNIQUE_NAME.getName(), copiedNode.getUniqueName());
process.addUniqueNodeName(copiedNode.getUniqueName());
}
if (service != null) {
if (service.isJobletInOutComponent(pastedNode)) {
process.removeUniqueNodeName(pastedNode.getUniqueName());
pastedNode.setPropertyValue(EParameterName.UNIQUE_NAME.getName(), copiedNode.getUniqueName());
process.addUniqueNodeName(copiedNode.getUniqueName());
}
}
// for bug 0004882: Subjob title is not copied when copying/pasting subjobs from one job to another
makeCopyNodeAndSubjobMapping(copiedNode, pastedNode, mapping);
Point location = null;
if (getCursorLocation() == null) {
location = (Point) ((Node) copiedNode).getLocation();
} else {
location = getCursorLocation();
index = nodes.indexOf(copiedNode);
}
if (process.isGridEnabled()) {
// replace the component to set it on the grid if it's enabled
int tempVar = location.x / TalendEditor.GRID_SIZE;
location.x = tempVar * TalendEditor.GRID_SIZE;
tempVar = location.y / TalendEditor.GRID_SIZE;
location.y = tempVar * TalendEditor.GRID_SIZE;
}
pastedNode.setLocation(findLocationForNode(location, (Dimension) ((Node) copiedNode).getSize(), index, firstIndex, ((Node) copiedNode)));
pastedNode.setSize(((Node) copiedNode).getSize());
INodeConnector mainConnector;
if (pastedNode.isELTComponent()) {
mainConnector = pastedNode.getConnectorFromType(EConnectionType.TABLE);
} else {
mainConnector = pastedNode.getConnectorFromType(EConnectionType.FLOW_MAIN);
}
if (!mainConnector.isMultiSchema()) {
if (copiedNode.getMetadataList().size() != 0) {
pastedNode.getMetadataList().clear();
for (IMetadataTable metaTable : copiedNode.getMetadataList()) {
IMetadataTable newMetaTable = metaTable.clone();
if (metaTable.getTableName().equals(copiedNode.getUniqueName())) {
newMetaTable.setTableName(pastedNode.getUniqueName());
}
for (IMetadataColumn column : metaTable.getListColumns()) {
if (column.isCustom()) {
IMetadataColumn newColumn = newMetaTable.getColumn(column.getLabel());
newColumn.setReadOnly(column.isReadOnly());
newColumn.setCustom(column.isCustom());
}
}
pastedNode.getMetadataList().add(newMetaTable);
}
}
} else {
List<IMetadataTable> copyOfMetadataList = new ArrayList<IMetadataTable>();
for (IMetadataTable metaTable : copiedNode.getMetadataList()) {
IMetadataTable newTable = metaTable.clone();
if (copiedNode.isELTComponent()) {
newTable.setTableName(createNewConnectionName(metaTable.getTableName(), IProcess.DEFAULT_TABLE_CONNECTION_NAME));
} else {
newTable.setTableName(createNewConnectionName(metaTable.getTableName(), null));
}
//$NON-NLS-1$
oldMetaToNewMeta.put(pastedNode.getUniqueName() + ":" + metaTable.getTableName(), newTable.getTableName());
for (IMetadataColumn column : metaTable.getListColumns()) {
if (column.isCustom()) {
IMetadataColumn newColumn = newTable.getColumn(column.getLabel());
newColumn.setReadOnly(column.isReadOnly());
newColumn.setCustom(column.isCustom());
}
}
newTable.sortCustomColumns();
copyOfMetadataList.add(newTable);
}
pastedNode.setMetadataList(copyOfMetadataList);
IExternalNode externalNode = pastedNode.getExternalNode();
if (externalNode != null) {
if (copiedNode.getExternalData() != null) {
try {
externalNode.setExternalData(copiedNode.getExternalData().clone());
} catch (CloneNotSupportedException e) {
ExceptionHandler.process(e);
}
((Node) pastedNode).setExternalData(externalNode.getExternalData());
}
for (IMetadataTable metaTable : copiedNode.getMetadataList()) {
String oldName = metaTable.getTableName();
//$NON-NLS-1$
String newName = oldMetaToNewMeta.get(pastedNode.getUniqueName() + ":" + metaTable.getTableName());
externalNode.renameOutputConnection(oldName, newName);
CorePlugin.getDefault().getMapperService().renameJoinTable(process, externalNode.getExternalData(), createdNames);
}
// when copy a external node, should also copy screeshot
if (copiedNode.getExternalNode() != null) {
ImageDescriptor screenshot = copiedNode.getExternalNode().getScreenshot();
if (screenshot != null) {
externalNode.setScreenshot(screenshot);
}
}
}
}
((Node) pastedNode).getNodeLabel().setOffset(new Point(((Node) copiedNode).getNodeLabel().getOffset()));
oldNameTonewNameMap.put(copiedNode.getUniqueName(), pastedNode.getUniqueName());
if (copiedNode.getElementParametersWithChildrens() != null) {
for (ElementParameter param : (List<ElementParameter>) copiedNode.getElementParametersWithChildrens()) {
if (!EParameterName.UNIQUE_NAME.getName().equals(param.getName())) {
IElementParameter elementParameter = pastedNode.getElementParameter(param.getName());
if (param.getFieldType() == EParameterFieldType.TABLE) {
List<Map<String, Object>> tableValues = (List<Map<String, Object>>) param.getValue();
ArrayList newValues = new ArrayList();
for (Map<String, Object> map : tableValues) {
Map<String, Object> newMap = new HashMap<String, Object>();
newMap.putAll(map);
// rename schemas
if (EParameterName.SCHEMAS.name().equals(param.getName()) && !oldMetaToNewMeta.isEmpty()) {
String newSchemaName = oldMetaToNewMeta.get(pastedNode.getUniqueName() + ":" + map.get(EParameterName.SCHEMA.getName()));
if (newSchemaName != null) {
newMap.put(EParameterName.SCHEMA.getName(), newSchemaName);
}
}
newValues.add(newMap);
}
elementParameter.setValue(newValues);
} else {
if (param.getParentParameter() != null) {
String parentName = param.getParentParameter().getName();
//$NON-NLS-1$
pastedNode.setPropertyValue(parentName + ":" + param.getName(), param.getValue());
} else {
pastedNode.setPropertyValue(param.getName(), param.getValue());
// See Bug 0005722: the pasted component don't keep the same read-only mode and didn;t
// hide
// the password.
elementParameter.setReadOnly(param.getOriginalityReadOnly());
elementParameter.setRepositoryValueUsed(param.isRepositoryValueUsed());
}
}
}
}
}
NodeContainer nc = ((Process) pastedNode.getProcess()).loadNodeContainer((Node) pastedNode, false);
;
nodeContainerList.add(nc);
}
((Process) process).setCopyPasteSubjobMappings(mapping);
Map<String, String> oldToNewConnVarMap = new HashMap<String, String>();
// add the connections
for (INode copiedNode : nodes) {
// INode copiedNode = (INode) copiedNodePart.getModel();
for (IConnection connection : (List<IConnection>) copiedNode.getOutgoingConnections()) {
INode pastedTargetNode = null, pastedSourceNode = null;
String nodeSource = oldNameTonewNameMap.get(copiedNode.getUniqueName());
for (NodeContainer nodeContainer : nodeContainerList) {
INode node = nodeContainer.getNode();
if (node.getUniqueName().equals(nodeSource)) {
pastedSourceNode = node;
}
}
INode targetNode = connection.getTarget();
// test if the target is in the nodes to paste to add the
// connection
// if the targeted node is not in the nodes to paste, then the
// string will be null
String nodeToConnect = oldNameTonewNameMap.get(targetNode.getUniqueName());
if (nodeToConnect != null) {
for (NodeContainer nodeContainer : nodeContainerList) {
INode node = nodeContainer.getNode();
if (node.getUniqueName().equals(nodeToConnect)) {
pastedTargetNode = node;
}
}
}
if ((pastedSourceNode != null) && (pastedTargetNode != null)) {
String newConnectionName;
String metaTableName;
if (connection.getLineStyle().hasConnectionCategory(IConnectionCategory.UNIQUE_NAME) && connection.getLineStyle().hasConnectionCategory(IConnectionCategory.FLOW)) {
String newNameBuiltIn = oldMetaToNewMeta.get(//$NON-NLS-1$
pastedSourceNode.getUniqueName() + ":" + connection.getMetaName());
if (newNameBuiltIn == null) {
IElementParameter formatParam = pastedSourceNode.getElementParameter(EParameterName.CONNECTION_FORMAT.getName());
String baseName = IProcess.DEFAULT_ROW_CONNECTION_NAME;
if (formatParam != null) {
String value = (String) formatParam.getValue();
if (value != null && !"".equals(value)) {
//$NON-NLS-1$
baseName = value;
}
}
if (process.checkValidConnectionName(connection.getName(), true)) {
// keep the name, bug 5086
baseName = null;
}
newConnectionName = createNewConnectionName(connection.getName(), baseName);
} else {
newConnectionName = newNameBuiltIn;
}
} else {
newConnectionName = connection.getName();
}
//$NON-NLS-1$
String meta = oldMetaToNewMeta.get(pastedSourceNode.getUniqueName() + ":" + connection.getMetaName());
if (meta != null) {
if (pastedSourceNode.getConnectorFromType(connection.getLineStyle()).isMultiSchema() && !connection.getLineStyle().equals(EConnectionType.TABLE)) {
newConnectionName = meta;
}
metaTableName = meta;
} else {
if (pastedSourceNode.getConnectorFromType(connection.getLineStyle()).isMultiSchema()) {
metaTableName = pastedSourceNode.getMetadataList().get(0).getTableName();
} else {
// connection.getMetaName();
metaTableName = pastedSourceNode.getUniqueName();
}
}
IConnection pastedConnection;
if (!pastedTargetNode.isELTComponent()) {
pastedConnection = new Connection(pastedSourceNode, pastedTargetNode, connection.getLineStyle(), connection.getConnectorName(), metaTableName, newConnectionName, connection.isMonitorConnection());
} else {
pastedConnection = new Connection(pastedSourceNode, pastedTargetNode, connection.getLineStyle(), connection.getConnectorName(), metaTableName, newConnectionName, metaTableName, connection.isMonitorConnection());
}
connections.add(pastedConnection);
oldNameTonewNameMap.put(connection.getUniqueName(), pastedConnection.getUniqueName());
// pastedConnection.setActivate(pastedSourceNode.isActivate());
for (ElementParameter param : (List<ElementParameter>) connection.getElementParameters()) {
// pastedConnection.getElementParameter(param.getName())
// .setValue(param.getValue());
pastedConnection.setPropertyValue(param.getName(), param.getValue());
}
// reset unique name param
IElementParameter uniqueNameParam = pastedConnection.getElementParameter(EParameterName.UNIQUE_NAME.getName());
String newName = oldNameTonewNameMap.get(connection.getUniqueName());
if (uniqueNameParam != null && newName != null) {
if (!newName.equals(uniqueNameParam.getValue())) {
pastedConnection.setPropertyValue(EParameterName.UNIQUE_NAME.getName(), newName);
}
}
// // keep the label (bug 3778)
// if (pastedConnection != null) {
// if (pastedConnection.getSourceNodeConnector().isBuiltIn()
// && pastedConnection.getLineStyle().hasConnectionCategory(EConnectionType.FLOW)) {
// pastedConnection.setPropertyValue(EParameterName.LABEL.getName(), connection.getName());
// } else {
// pastedConnection.setPropertyValue(EParameterName.LABEL.getName(), newConnectionName);
// }
// }
((Connection) pastedConnection).getConnectionLabel().setOffset(new Point(((Connection) connection).getConnectionLabel().getOffset()));
INodeConnector connector = pastedConnection.getSourceNodeConnector();
connector.setCurLinkNbOutput(connector.getCurLinkNbOutput() + 1);
connector = pastedConnection.getTargetNodeConnector();
connector.setCurLinkNbInput(connector.getCurLinkNbInput() + 1);
IExternalNode externalNode = pastedTargetNode.getExternalNode();
if (externalNode != null) {
externalNode.renameInputConnection(connection.getName(), newConnectionName);
}
// (feature 2962)
if (pastedConnection.getMetadataTable() == null) {
continue;
}
for (IMetadataColumn column : pastedConnection.getMetadataTable().getListColumns()) {
//$NON-NLS-1$
String oldConnVar = connection.getName() + "." + column.getLabel();
//$NON-NLS-1$
String newConnVar = newConnectionName + "." + column.getLabel();
// String newConnVar = newConnectionName;
if (!oldToNewConnVarMap.containsKey(oldConnVar)) {
oldToNewConnVarMap.put(oldConnVar, newConnVar);
}
}
}
}
}
// rename the connection data for node parameters. (feature 2962)
for (NodeContainer nodeContainer : nodeContainerList) {
Node node = nodeContainer.getNode();
for (String oldConnVar : oldToNewConnVarMap.keySet()) {
String newConnVar = oldToNewConnVarMap.get(oldConnVar);
if (newConnVar != null) {
node.renameData(oldConnVar, newConnVar);
}
}
}
// check if the new components use the old components name.
Map<String, Set<String>> usedDataMap = new HashMap<String, Set<String>>();
for (NodeContainer nodeContainer : nodeContainerList) {
Node currentNode = nodeContainer.getNode();
String uniqueName = currentNode.getUniqueName();
for (String oldName : oldNameTonewNameMap.keySet()) {
if (!oldName.equals(oldNameTonewNameMap.get(oldName)) && currentNode.useData(oldName)) {
Set<String> oldNameSet = usedDataMap.get(uniqueName);
if (oldNameSet == null) {
oldNameSet = new HashSet<String>();
usedDataMap.put(uniqueName, oldNameSet);
}
oldNameSet.add(oldName);
}
}
}
// check if the new connections use the old components name.
Map<String, Set<String>> usedDataMapForConnections = new HashMap<String, Set<String>>();
for (IConnection connection : connections) {
String uniqueName = connection.getUniqueName();
for (String oldName : oldNameTonewNameMap.keySet()) {
if (oldName != null && !oldName.equals(oldNameTonewNameMap.get(oldName)) && UpgradeElementHelper.isUseData(connection, oldName)) {
Set<String> oldNameSet = usedDataMapForConnections.get(uniqueName);
if (oldNameSet == null) {
oldNameSet = new HashSet<String>();
usedDataMapForConnections.put(uniqueName, oldNameSet);
}
oldNameSet.add(oldName);
}
}
}
if (!usedDataMap.isEmpty() || !usedDataMapForConnections.isEmpty()) {
MessageBox msgBox = new MessageBox(PlatformUI.getWorkbench().getDisplay().getActiveShell(), SWT.YES | SWT.NO | SWT.ICON_WARNING);
//$NON-NLS-1$
msgBox.setMessage(Messages.getString("NodesPasteCommand.renameMessages"));
if (msgBox.open() == SWT.YES) {
for (NodeContainer nodeContainer : nodeContainerList) {
Node currentNode = nodeContainer.getNode();
Set<String> oldNameSet = usedDataMap.get(currentNode.getUniqueName());
if (oldNameSet != null && !oldNameSet.isEmpty()) {
for (String oldName : oldNameSet) {
currentNode.renameData(oldName, oldNameTonewNameMap.get(oldName));
}
}
}
// Rename connections
for (IConnection connection : connections) {
Set<String> oldNameSet = usedDataMapForConnections.get(connection.getUniqueName());
if (oldNameSet != null && !oldNameSet.isEmpty()) {
for (String oldName : oldNameSet) {
UpgradeElementHelper.renameData(connection, oldName, oldNameTonewNameMap.get(oldName));
}
}
}
}
}
}
Aggregations