use of org.talend.core.model.process.IConnection in project tdi-studio-se by Talend.
the class DbGenerationManager method getConnectionContextList.
protected List<String> getConnectionContextList(DbMapComponent component) {
List<String> contextList = new ArrayList<String>();
List<IConnection> inputConnections = (List<IConnection>) component.getIncomingConnections();
List<Map<String, String>> itemNameList = null;
for (IConnection iconn : inputConnections) {
String connName = iconn.getName();
if (!ContextParameterUtils.containContextVariables(connName)) {
continue;
}
//$NON-NLS-1$
MapExpressionParser mapParser1 = new MapExpressionParser("\\s*(\\w+)\\s*\\.\\s*(\\w+)\\s*\\.\\s*(\\w+)\\s*");
itemNameList = mapParser1.parseInTableEntryLocations(connName);
if (itemNameList == null) {
return contextList;
}
IMetadataTable metadataTable = iconn.getMetadataTable();
for (Map<String, String> itemNamemap : itemNameList) {
Set<Entry<String, String>> set = itemNamemap.entrySet();
Iterator<Entry<String, String>> ite = set.iterator();
while (ite.hasNext()) {
Entry<String, String> entry = ite.next();
String tableValue = entry.getKey();
String schemaValue = entry.getValue();
if (metadataTable != null && tableValue.equals(metadataTable.getLabel())) {
if (!contextList.contains(schemaValue)) {
contextList.add(schemaValue);
}
}
}
}
}
return contextList;
}
use of org.talend.core.model.process.IConnection in project tdi-studio-se by Talend.
the class DbGenerationManager method getOriginalColumnName.
private String getOriginalColumnName(String entryName, DbMapComponent component, ExternalDbMapTable table) {
List<IConnection> inputConnections = (List<IConnection>) component.getIncomingConnections();
if (inputConnections != null) {
for (IConnection iconn : inputConnections) {
IMetadataTable metadataTable = iconn.getMetadataTable();
String tName = iconn.getName();
String tableValue = table.getTableName();
if (tableValue != null && tableValue.equals(tName) && metadataTable != null) {
List<IMetadataColumn> lColumn = metadataTable.getListColumns();
for (IMetadataColumn colu : lColumn) {
if (colu.getLabel().equals(entryName)) {
String tempName = colu.getOriginalDbColumnName();
if (tempName != null && tempName.length() > 0) {
entryName = tempName;
return entryName;
}
}
}
}
}
}
return entryName;
}
use of org.talend.core.model.process.IConnection in project tdi-studio-se by Talend.
the class DbMapComponent method sortOutputsConnectionsLikeVisualOrder.
/**
* Sort outgoingConnections for code generation as visible output zone of tMap.
*/
@SuppressWarnings("unchecked")
private void sortOutputsConnectionsLikeVisualOrder() {
if (!MapperMain.isStandAloneMode()) {
List<IConnection> outgoingConnections = (List<IConnection>) getOutgoingConnections();
Map<String, IConnection> connectionNameToOutgoingConnection = new HashMap<String, IConnection>();
for (IConnection connection : outgoingConnections) {
connectionNameToOutgoingConnection.put(connection.getUniqueName(), connection);
}
List<ExternalDbMapTable> outputTables = externalData.getOutputTables();
List<IConnection> tmpList = new ArrayList<IConnection>(outgoingConnections);
outgoingConnections.clear();
int lstSize = outputTables.size();
for (int i = 0; i < lstSize; i++) {
ExternalDbMapTable table = outputTables.get(i);
String tableName = table.getName();
IConnection connection = connectionNameToOutgoingConnection.get(tableName);
if (connection != null) {
outgoingConnections.add(connection);
}
}
// add connections without metadata
for (IConnection connection : tmpList) {
if (!outgoingConnections.contains(connection)) {
outgoingConnections.add(connection);
}
}
}
}
use of org.talend.core.model.process.IConnection in project tdi-studio-se by Talend.
the class SchemaReferenceController method createButtonCommand.
@Override
protected Command createButtonCommand(Button button) {
if (checkForRepositoryShema(button)) {
return null;
}
Button inputButton = button;
IElementParameter switchParam = elem.getElementParameter(EParameterName.REPOSITORY_ALLOW_AUTO_SWITCH.getName());
if (inputButton.getData(NAME).equals(SCHEMA)) {
// this map wil hold the all input connection for the tUnite component
Map<INode, Map<IMetadataTable, Boolean>> inputInfos = new HashMap<INode, Map<IMetadataTable, Boolean>>();
INode node;
if (elem instanceof Node) {
node = (INode) elem;
} else {
// else instanceof Connection
node = ((IConnection) elem).getSource();
}
IMetadataTable inputMetadata = null, inputMetaCopy = null;
Connection inputConec = null;
String propertyName = (String) inputButton.getData(PARAMETER_NAME);
IElementParameter param = node.getElementParameter(propertyName);
IElementParameter connectionParam = param.getChildParameters().get(EParameterName.CONNECTION.getName());
String connectionName = null;
if (connectionParam != null) {
connectionName = (String) connectionParam.getValue();
}
Object obj = button.getData(FORCE_READ_ONLY);
boolean forceReadOnly = false;
if (obj != null) {
forceReadOnly = (Boolean) obj;
}
boolean inputReadOnly = false, outputReadOnly = false, inputReadOnlyNode = false, inputReadOnlyParam = false;
for (Connection connec : (List<Connection>) node.getIncomingConnections()) {
if (connec.isActivate() && (connec.getLineStyle().equals(EConnectionType.FLOW_MAIN) || connec.getLineStyle().equals(EConnectionType.TABLE) || connec.getLineStyle().equals(EConnectionType.FLOW_MERGE) || connec.getLineStyle() == EConnectionType.FLOW_REF)) {
if (connectionName != null && !connec.getName().equals(connectionName)) {
continue;
}
inputMetadata = connec.getMetadataTable();
inputMetaCopy = inputMetadata.clone();
inputConec = connec;
if (connec.getSource().isReadOnly()) {
inputReadOnlyNode = true;
} else {
for (IElementParameter curParam : connec.getSource().getElementParameters()) {
if (curParam.getFieldType() == EParameterFieldType.SCHEMA_REFERENCE) {
if (curParam.isReadOnly()) {
inputReadOnlyParam = true;
}
}
}
}
// check if the inputMetadata is readonly
if (inputMetadata != null) {
for (IMetadataColumn column : inputMetadata.getListColumns(true)) {
IMetadataColumn columnCopied = inputMetaCopy.getColumn(column.getLabel());
columnCopied.setCustom(column.isCustom());
columnCopied.setReadOnly(column.isReadOnly());
}
inputMetaCopy.setReadOnly(inputMetadata.isReadOnly());
inputReadOnly = prepareReadOnlyTable(inputMetaCopy, inputReadOnlyParam, inputReadOnlyNode);
}
// store the value for Dialog
Map<IMetadataTable, Boolean> oneInput = new HashMap<IMetadataTable, Boolean>();
oneInput.put(inputMetaCopy, inputReadOnly);
inputInfos.put(connec.getSource(), oneInput);
}
}
if (connectionParam != null && inputMetadata == null) {
//$NON-NLS-1$
MessageDialog.openError(//$NON-NLS-1$
button.getShell(), //$NON-NLS-1$
Messages.getString("SchemaReferenceController.inputNotSet"), //$NON-NLS-1$
Messages.getString("SchemaReferenceController.connectionNotAvaliable"));
return null;
}
IMetadataTable originaleMetadataTable = getMetadataTableFromXml(node);
// check if the outputMetadata is readonly
IMetadataTable originaleOutputTable = node.getMetadataFromConnector(param.getContext());
// when several schema_type button ,need get the right one which is opening
//$NON-NLS-1$
IElementParameter schemaParam = param.getChildParameters().get("SCHEMA_TYPE");
// need setRepository here
if (!param.getContext().equals(schemaParam.getContext())) {
//$NON-NLS-1$
schemaParam = param.getChildParameters().get("SCHEMA_TYPE");
}
if (schemaParam != null && EmfComponent.REPOSITORY.equals(schemaParam.getValue())) {
if (originaleOutputTable != null && originaleOutputTable instanceof MetadataTable) {
((MetadataTable) originaleOutputTable).setRepository(true);
}
} else if (schemaParam != null && EmfComponent.BUILTIN.equals(schemaParam.getValue())) {
if (originaleOutputTable != null && originaleOutputTable instanceof MetadataTable) {
((MetadataTable) originaleOutputTable).setRepository(false);
}
}
IMetadataTable outputMetaCopy = originaleOutputTable.clone(true);
for (IMetadataColumn column : originaleOutputTable.getListColumns(true)) {
IMetadataColumn columnCopied = outputMetaCopy.getColumn(column.getLabel());
columnCopied.setCustom(column.isCustom());
columnCopied.setReadOnly(column.isReadOnly());
}
outputMetaCopy.setReadOnly(originaleOutputTable.isReadOnly() || param.isReadOnly(node.getElementParametersWithChildrens()));
//$NON-NLS-1$
IElementParameter schemaTypeParam = param.getChildParameters().get("SCHEMA_TYPE");
List<IElementParameterDefaultValue> defaultValues = schemaTypeParam.getDefaultValues();
for (IElementParameterDefaultValue elementParameterDefaultValue : defaultValues) {
if (elementParameterDefaultValue.getDefaultValue() instanceof MetadataTable) {
MetadataTable table = (MetadataTable) elementParameterDefaultValue.getDefaultValue();
outputMetaCopy.setReadOnlyColumnPosition(table.getReadOnlyColumnPosition());
break;
}
}
outputMetaCopy.sortCustomColumns();
if (!forceReadOnly) {
outputReadOnly = prepareReadOnlyTable(outputMetaCopy, param.isReadOnly(), node.isReadOnly());
} else {
outputReadOnly = true;
}
MetadataDialog metaDialog = null;
if (inputMetadata != null) {
if (inputInfos != null && inputInfos.size() > 1 && connectionName == null) {
MetadataDialogForMerge metaDialogForMerge = new MetadataDialogForMerge(composite.getShell(), inputInfos, outputMetaCopy, node, getCommandStack());
//$NON-NLS-1$
metaDialogForMerge.setText(Messages.getString("SchemaReferenceController.schemaOf") + node.getLabel());
metaDialogForMerge.setInputReadOnly(inputReadOnly);
metaDialogForMerge.setOutputReadOnly(outputReadOnly);
if (metaDialogForMerge.open() == MetadataDialogForMerge.OK) {
outputMetaCopy = metaDialogForMerge.getOutputMetaData();
// check if the metadata is modified
boolean modified = false;
if (!outputMetaCopy.sameMetadataAs(originaleOutputTable, IMetadataColumn.OPTIONS_NONE)) {
modified = true;
} else {
if (inputMetadata != null) {
// Notice: the Map inputInfos maybe is modified by the dialog.
Set<INode> inputNodes = inputInfos.keySet();
for (INode inputNode : inputNodes) {
Map<IMetadataTable, Boolean> oneInput = inputInfos.get(inputNode);
inputMetaCopy = (IMetadataTable) oneInput.keySet().toArray()[0];
if (!inputMetaCopy.sameMetadataAs(inputNode.getMetadataList().get(0), IMetadataColumn.OPTIONS_NONE)) {
modified = true;
}
}
}
}
// create the changeMetadataCommand
if (modified) {
if (switchParam != null) {
switchParam.setValue(Boolean.FALSE);
}
Command changeMetadataCommand = null;
// only output, no input
if (inputInfos.isEmpty()) {
changeMetadataCommand = new ChangeMetadataCommand(node, param, null, null, null, originaleOutputTable, outputMetaCopy);
} else {
Set<INode> inputNodes = inputInfos.keySet();
int count = 0;
for (INode inputNode : inputNodes) {
Map<IMetadataTable, Boolean> oneInput = inputInfos.get(inputNode);
inputMetaCopy = (IMetadataTable) oneInput.keySet().toArray()[0];
if (count == 0) {
changeMetadataCommand = new ChangeMetadataCommand(node, param, inputNode, inputNode.getMetadataList().get(0), inputMetaCopy, originaleOutputTable, outputMetaCopy);
} else {
changeMetadataCommand = changeMetadataCommand.chain(new ChangeMetadataCommand(node, param, inputNode, inputNode.getMetadataList().get(0), inputMetaCopy, originaleOutputTable, outputMetaCopy));
}
count++;
}
}
return changeMetadataCommand;
}
}
} else {
INode inputNode = (inputConec.getSource());
if (inputMetaCopy.getAttachedConnector() == null) {
INodeConnector mainConnector;
if (inputNode.isELTComponent()) {
mainConnector = inputNode.getConnectorFromType(EConnectionType.TABLE);
} else {
mainConnector = inputNode.getConnectorFromType(EConnectionType.FLOW_MAIN);
}
inputMetaCopy.setAttachedConnector(mainConnector.getName());
}
metaDialog = new MetadataDialog(composite.getShell(), inputMetaCopy, inputNode, outputMetaCopy, node, getCommandStack());
}
} else {
metaDialog = new MetadataDialog(composite.getShell(), outputMetaCopy, node, getCommandStack());
}
if (metaDialog != null) {
//$NON-NLS-1$
metaDialog.setText(Messages.getString("SchemaReferenceController.schema.title", node.getLabel()));
metaDialog.setInputReadOnly(inputReadOnly);
metaDialog.setOutputReadOnly(outputReadOnly);
if (metaDialog.open() == MetadataDialog.OK) {
inputMetaCopy = metaDialog.getInputMetaData();
outputMetaCopy = metaDialog.getOutputMetaData();
boolean modified = false;
if (!outputMetaCopy.sameMetadataAs(originaleOutputTable, IMetadataColumn.OPTIONS_NONE)) {
modified = true;
} else {
if (inputMetadata != null) {
if (!inputMetaCopy.sameMetadataAs(inputMetadata, IMetadataColumn.OPTIONS_NONE)) {
modified = true;
}
}
}
if (modified) {
if (switchParam != null) {
switchParam.setValue(Boolean.FALSE);
}
INode inputNode = null;
if (inputConec != null) {
inputNode = inputConec.getSource();
}
// update the component schema
if (param instanceof GenericElementParameter) {
GenericElementParameter genericElementParameter = (GenericElementParameter) param;
String paramName = genericElementParameter.getName();
ComponentProperties componentProperties = node.getComponentProperties();
if (componentProperties != null) {
org.talend.daikon.properties.property.Property schemaProperty = componentProperties.getValuedProperty(paramName);
if (schemaProperty != null) {
SchemaUtils.updateComponentSchema(node, outputMetaCopy, null);
}
}
}
if (node.getComponent().isSchemaAutoPropagated()) {
ChangeMetadataCommand changeMetadataCommand = new ChangeMetadataCommand(node, param, inputNode, inputMetadata, inputMetaCopy, originaleOutputTable, outputMetaCopy);
return changeMetadataCommand;
} else {
ChangeMetadataCommand changeMetadataCommand = new ChangeMetadataCommand(node, param, inputNode, inputMetadata, inputMetaCopy, originaleOutputTable, outputMetaCopy);
changeMetadataCommand.setPropagate(Boolean.FALSE);
return changeMetadataCommand;
}
}
}
}
} else if (inputButton.getData(NAME).equals(RETRIEVE_SCHEMA)) {
Node node = (Node) elem;
// String propertyName = (String) inputButton.getData(PARAMETER_NAME);
final Command cmd = RetrieveSchemaHelper.retrieveSchemasCommand(node);
if (switchParam != null) {
switchParam.setValue(Boolean.FALSE);
}
return cmd;
} else if (inputButton.getData(NAME).equals(RESET_COLUMNS)) {
Node node = (Node) elem;
String propertyName = (String) inputButton.getData(PARAMETER_NAME);
IElementParameter param = node.getElementParameter(propertyName);
final Command cmd = SynchronizeSchemaHelper.createCommand(node, param);
if (switchParam != null) {
switchParam.setValue(Boolean.FALSE);
}
return cmd;
} else if (button.getData(NAME).equals(REPOSITORY_CHOICE)) {
String paramName = (String) button.getData(PARAMETER_NAME);
IElementParameter schemaParam = elem.getElementParameter(paramName);
ERepositoryObjectType type = ERepositoryObjectType.METADATA_CON_TABLE;
String filter = schemaParam.getFilter();
RepositoryReviewDialog dialog = new RepositoryReviewDialog(button.getShell(), type, filter);
if (dialog.open() == RepositoryReviewDialog.OK) {
RepositoryNode node = dialog.getResult();
while (node.getObject().getProperty().getItem() == null || (!(node.getObject().getProperty().getItem() instanceof ConnectionItem))) {
node = node.getParent();
}
IRepositoryViewObject object = dialog.getResult().getObject();
Property property = object.getProperty();
String id = property.getId();
// The name is Table Name.
String name = object.getLabel();
if (name != null) {
if (elem instanceof Node) {
//$NON-NLS-1$
String value = id + " - " + name;
//$NON-NLS-1$
paramName = paramName + ":" + EParameterName.REPOSITORY_SCHEMA_TYPE.getName();
Command selectorCommand = new PropertyChangeCommand(elem, paramName, TalendTextUtils.addQuotes(value));
executeCommand(selectorCommand);
}
}
//$NON-NLS-1$
String value = id + " - " + name;
//$NON-NLS-1$
String fullParamName = paramName + ":" + getRepositoryChoiceParamName();
org.talend.core.model.metadata.builder.connection.Connection connection = null;
if (elem instanceof Node) {
IMetadataTable repositoryMetadata = MetadataToolHelper.getMetadataFromRepository(value);
connection = MetadataToolHelper.getConnectionFromRepository(value);
// For validation rule.
boolean isValRulesLost = false;
IRepositoryViewObject currentValRuleObj = ValidationRulesUtil.getCurrentValidationRuleObjs(elem);
if (currentValRuleObj != null) {
List<IRepositoryViewObject> valRuleObjs = ValidationRulesUtil.getRelatedValidationRuleObjs(value);
if (!ValidationRulesUtil.isCurrentValRuleObjInList(valRuleObjs, currentValRuleObj)) {
if (!MessageDialog.openConfirm(button.getShell(), //$NON-NLS-1$
Messages.getString("SchemaReferenceController.validationrule.title.confirm"), Messages.getString("SchemaReferenceController.validationrule.selectMetadataMsg"))) {
//$NON-NLS-1$
return null;
} else {
isValRulesLost = true;
}
}
}
if (repositoryMetadata == null) {
repositoryMetadata = new MetadataTable();
}
if (switchParam != null) {
switchParam.setValue(Boolean.FALSE);
}
CompoundCommand cc = new CompoundCommand();
RepositoryChangeMetadataCommand changeMetadataCommand = new RepositoryChangeMetadataCommand((Node) elem, fullParamName, value, repositoryMetadata, null, null);
changeMetadataCommand.setConnection(connection);
cc.add(changeMetadataCommand);
if (isValRulesLost) {
ValidationRulesUtil.appendRemoveValidationRuleCommands(cc, elem);
}
return cc;
}
}
} else if (button.getData(NAME).equals(COPY_CHILD_COLUMNS)) {
String paramName = (String) button.getData(PARAMETER_NAME);
IElementParameter param = elem.getElementParameter(paramName);
IElementParameter processParam = elem.getElementParameterFromField(EParameterFieldType.PROCESS_TYPE);
IElementParameter processIdParam = processParam.getChildParameters().get(EParameterName.PROCESS_TYPE_PROCESS.getName());
String id = (String) processIdParam.getValue();
Item item = ItemCacheManager.getProcessItem(id);
Node node = (Node) elem;
copySchemaFromChildJob(node, item);
// pop up the schema dialog
MetadataDialog metaDialog = new MetadataDialog(composite.getShell(), node.getMetadataList().get(0), node, getCommandStack());
//$NON-NLS-1$
metaDialog.setText(Messages.getString("SchemaReferenceController.schemaOf") + node.getLabel());
if (metaDialog.open() == MetadataDialog.OK) {
IMetadataTable outputMetaData = metaDialog.getOutputMetaData();
return new ChangeMetadataCommand(node, param, null, outputMetaData);
}
}
return null;
}
use of org.talend.core.model.process.IConnection in project tdi-studio-se by Talend.
the class TalendEditorContextMenuProvider method buildContextMenu.
/**
* Called when the context menu is about to show. Actions, whose state is enabled, will appear in the context menu.
*
* @see org.eclipse.gef.ContextMenuProvider#buildContextMenu(org.eclipse.jface.action.IMenuManager)
*/
@Override
public void buildContextMenu(final IMenuManager menu) {
if (!isEnableContextMenu()) {
return;
}
// Add standard action groups to the menu
menu.add(new Separator(GROUP_CONNECTIONS));
menu.add(new Separator(GEFActionConstants.GROUP_UNDO));
menu.add(new Separator(GEFActionConstants.GROUP_COPY));
menu.add(new Separator(GEFActionConstants.GROUP_EDIT));
menu.add(new Separator(GEFActionConstants.GROUP_REST));
menu.add(new Separator(GROUP_OTHER));
menu.add(new Separator(GEFActionConstants.GROUP_VIEW));
menu.add(new Separator(GROUP_BREAKPOINT));
IAction action;
// target group id
menu.appendToGroup(// target group id
GEFActionConstants.GROUP_UNDO, // action to add
getAction(ActionFactory.UNDO.getId()));
menu.appendToGroup(GEFActionConstants.GROUP_UNDO, getAction(ActionFactory.REDO.getId()));
if (part != null) {
// new GEFCopyAction(part);
action = getAction(ActionFactory.COPY.getId());
if (action instanceof GEFCopyAction) {
((GEFCopyAction) action).update();
}
menu.appendToGroup(GEFActionConstants.GROUP_EDIT, action);
// new GEFPasteAction(part);
action = getAction(ActionFactory.PASTE.getId());
GEFPasteAction pasteAction = (GEFPasteAction) action;
Point p = Display.getCurrent().getCursorLocation();
p = this.getViewer().getControl().toControl(p);
// gcui see bug 7812:Copy/Paste component in Job designer.
LayerManager layerManager = (LayerManager) this.getViewer().getEditPartRegistry().get(LayerManager.ID);
IFigure contentLayer = layerManager.getLayer(LayerConstants.PRINTABLE_LAYERS);
// System.out.println("X:" + contentLayer.getSize().width + " Y:" + contentLayer.getSize().height);
org.eclipse.draw2d.geometry.Point p1 = new org.eclipse.draw2d.geometry.Point(p.x, p.y);
contentLayer.translateToAbsolute(p1);
// System.out.println("relative:" + p);
p.x = 2 * (p.x) - p1.x;
p.y = 2 * (p.y) - p1.y;
// System.out.println("absolute:" + p);
pasteAction.setCursorLocation(p);
menu.appendToGroup(GEFActionConstants.GROUP_EDIT, action);
menu.appendToGroup(GEFActionConstants.GROUP_EDIT, getAction(ActionFactory.DELETE.getId()));
menu.appendToGroup(GEFActionConstants.GROUP_EDIT, getAction(ActionFactory.SELECT_ALL.getId()));
action = new ActivateElementAction(part);
((ActivateElementAction) action).update();
if (action.isEnabled()) {
menu.appendToGroup(GEFActionConstants.GROUP_REST, action);
}
action = new ActivateSubjobAction(part);
((ActivateSubjobAction) action).update();
if (action.isEnabled()) {
menu.appendToGroup(GEFActionConstants.GROUP_REST, action);
}
action = new ActivateSubjobOneComponentAction(part);
((ActivateSubjobOneComponentAction) action).update();
if (action.isEnabled()) {
menu.appendToGroup(GEFActionConstants.GROUP_REST, action);
}
action = getAction(ConnectionSetAsMainRef.ID);
if (action.isEnabled()) {
menu.appendToGroup(GEFActionConstants.GROUP_REST, action);
}
action = getAction(ModifyMergeOrderAction.ID);
if (action.isEnabled()) {
menu.appendToGroup(GEFActionConstants.GROUP_REST, action);
}
action = getAction(ModifyOutputOrderAction.ID);
if (action.isEnabled()) {
menu.appendToGroup(GEFActionConstants.GROUP_REST, action);
}
List<String> orderActionIDs = ModifyConnectionOrderAction.getOrderActionIDs();
for (String id : orderActionIDs) {
action = getAction(id);
if (action != null && action.isEnabled()) {
menu.appendToGroup(GEFActionConstants.GROUP_REST, action);
}
}
//$NON-NLS-1$
MenuManager subMenu = new MenuManager(Messages.getString("TalendEditorContextMenuProvider.Row"));
menu.appendToGroup(GROUP_CONNECTIONS, subMenu);
action = new ConnectionCreateAction(part, EConnectionType.FLOW_MAIN);
((ConnectionCreateAction) action).update();
List<INodeConnector> connectors = ((ConnectionCreateAction) action).getConnectors();
if (connectors.size() > 1) {
for (INodeConnector connector : connectors) {
if (connector.isMultiSchema()) {
action = new ConnectionCreateAction(part, connector);
((ConnectionCreateAction) action).update();
if (action.isEnabled() && connector.isShow()) {
List<String> menuList = ((ConnectionCreateAction) action).getMenuList();
for (int i = 0; i < menuList.size(); i++) {
action = new ConnectionCreateAction(part, connector);
((ConnectionCreateAction) action).update();
((ConnectionCreateAction) action).setText(menuList.get(i));
subMenu.add(action);
}
}
} else {
action = new ConnectionCreateAction(part, connector);
((ConnectionCreateAction) action).update();
if (action.isEnabled() && connector.isShow()) {
((ConnectionCreateAction) action).setText(connector.getMenuName());
subMenu.add(action);
}
}
}
} else {
if (connectors.size() == 1) {
action = new ConnectionCreateAction(part, connectors.get(0));
((ConnectionCreateAction) action).update();
if (action.isEnabled() && connectors.get(0).isShow()) {
List<String> menuList = ((ConnectionCreateAction) action).getMenuList();
for (int i = 0; i < menuList.size(); i++) {
action = new ConnectionCreateAction(part, connectors.get(0));
((ConnectionCreateAction) action).update();
((ConnectionCreateAction) action).setText(menuList.get(i));
subMenu.add(action);
}
}
}
}
retrieveConnectors(subMenu, EConnectionType.ITERATE);
retrieveConnectors(subMenu, EConnectionType.ROUTE);
retrieveConnectors(subMenu, EConnectionType.ROUTE_TRY);
retrieveConnectors(subMenu, EConnectionType.ROUTE_CATCH);
retrieveConnectors(subMenu, EConnectionType.ROUTE_FINALLY);
retrieveConnectors(subMenu, EConnectionType.ROUTE_ENDBLOCK);
//$NON-NLS-1$
subMenu = new MenuManager("Link");
menu.appendToGroup(GROUP_CONNECTIONS, subMenu);
action = new ConnectionCreateAction(part, EConnectionType.TABLE);
((ConnectionCreateAction) action).update();
if (action.isEnabled()) {
List<String> menuList = ((ConnectionCreateAction) action).getMenuList();
for (int i = 0; i < menuList.size(); i++) {
action = new ConnectionCreateAction(part, EConnectionType.TABLE);
((ConnectionCreateAction) action).update();
((ConnectionCreateAction) action).setText(menuList.get(i));
subMenu.add(action);
}
}
//$NON-NLS-1$
subMenu = new MenuManager("Move to joblet");
menu.appendToGroup(GROUP_OTHER, subMenu);
action = getMoveToJobletAction(part, null, null);
if (action != null) {
((AddToJobletAction) action).update();
List<Node> nodeList = ((AddToJobletAction) action).getJobletNodeList();
Map<INode, IConnection> nodeMap = ((AddToJobletAction) action).getJobletNodeMap();
if (nodeList != null) {
for (Node jobletNode : nodeList) {
action = getMoveToJobletAction(part, jobletNode, nodeMap);
if (action != null) {
((AddToJobletAction) action).update();
action.setText(jobletNode.getLabel());
subMenu.add(action);
}
}
}
}
action = getMoveToJobAction(part);
if (action != null) {
((SelectionAction) action).update();
if (action.isEnabled()) {
menu.appendToGroup(GROUP_OTHER, action);
}
}
//$NON-NLS-1$
subMenu = new MenuManager(Messages.getString("TalendEditorContextMenuProvider.Trigger"));
menu.appendToGroup(GROUP_CONNECTIONS, subMenu);
/*
* action = new ConnectionCreateAction(part, EConnectionType.RUN_BEFORE); ((ConnectionCreateAction)
* action).update(); if (action.isEnabled()) { subMenu.add(action); }
*/
retrieveConnectors(subMenu, EConnectionType.ON_SUBJOB_OK);
retrieveConnectors(subMenu, EConnectionType.ON_SUBJOB_ERROR);
subMenu.add(new Separator());
retrieveConnectors(subMenu, EConnectionType.SYNCHRONIZE);
retrieveConnectors(subMenu, EConnectionType.PARALLELIZE);
subMenu.add(new Separator());
retrieveConnectors(subMenu, EConnectionType.RUN_IF);
retrieveConnectors(subMenu, EConnectionType.ROUTE_WHEN);
retrieveConnectors(subMenu, EConnectionType.ROUTE_OTHER);
retrieveConnectors(subMenu, EConnectionType.ON_COMPONENT_OK);
retrieveConnectors(subMenu, EConnectionType.ON_COMPONENT_ERROR);
retrieveConnectors(subMenu, EConnectionType.STARTS);
action = new NodeBreakpointAction(part);
((NodeBreakpointAction) action).update();
if (action.isEnabled()) {
menu.appendToGroup(GEFActionConstants.GROUP_REST, action);
}
action = new ShowComponentSettingViewerAction(part);
((ShowComponentSettingViewerAction) action).update();
if (action.isEnabled()) {
menu.appendToGroup(GROUP_OTHER, action);
}
action = new DisplaySubjobAction(part);
((SelectionAction) action).update();
if (action.isEnabled()) {
menu.appendToGroup(GROUP_OTHER, action);
}
if (PluginChecker.isAutoParalelPluginLoaded()) {
action = new SetParallelizationAction(part);
((SelectionAction) action).update();
if (action.isEnabled()) {
menu.appendToGroup(GROUP_OTHER, action);
}
action = new DisableParallelizationAction(part);
((SelectionAction) action).update();
if (action.isEnabled()) {
menu.appendToGroup(GROUP_OTHER, action);
}
}
// see feature 5027
action = new ParallelExecutionAction(part);
((SelectionAction) action).update();
if (PluginChecker.isTeamEdition() && action.isEnabled()) {
menu.appendToGroup(GROUP_OTHER, action);
}
action = new SearchComponentAction(part);
((SelectionAction) action).update();
if (action.isEnabled()) {
menu.appendToGroup(GROUP_OTHER, action);
}
action = new TraceEnableAction(part);
((SelectionAction) action).update();
if (action.isEnabled()) {
menu.appendToGroup(GROUP_BREAKPOINT, action);
}
action = new TraceDisableAction(part);
((SelectionAction) action).update();
if (action.isEnabled()) {
menu.appendToGroup(GROUP_BREAKPOINT, action);
}
action = new FilterTraceColumnAction(part);
((SelectionAction) action).update();
if (action.isEnabled()) {
menu.appendToGroup(GROUP_BREAKPOINT, action);
}
action = new ShowBreakpointAction(part);
((SelectionAction) action).update();
if (action.isEnabled()) {
menu.appendToGroup(GROUP_BREAKPOINT, action);
}
action = new OpenJobHierarchyAction(part);
((SelectionAction) action).update();
if (action.isEnabled()) {
menu.appendToGroup(GROUP_OTHER, action);
}
action = new OpentRunJobComponentAction(part);
((SelectionAction) action).update();
if (action.isEnabled()) {
menu.appendToGroup(GEFActionConstants.GROUP_VIEW, action);
}
action = new BringForwardAction(part);
((SelectionAction) action).update();
if (action.isEnabled()) {
menu.appendToGroup(GEFActionConstants.GROUP_VIEW, action);
}
action = new BringToFrontAction(part);
((SelectionAction) action).update();
if (action.isEnabled()) {
menu.appendToGroup(GEFActionConstants.GROUP_VIEW, action);
}
action = new SendBackwardAction(part);
((SelectionAction) action).update();
if (action.isEnabled()) {
menu.appendToGroup(GEFActionConstants.GROUP_VIEW, action);
}
action = new SendToBackAction(part);
((SelectionAction) action).update();
if (action.isEnabled()) {
menu.appendToGroup(GEFActionConstants.GROUP_VIEW, action);
}
List<SelectionAction> instances = CustomExternalActions.getInstances(part);
for (SelectionAction selectionAction : instances) {
selectionAction.update();
if (selectionAction.isEnabled()) {
menu.appendToGroup(GEFActionConstants.GROUP_VIEW, selectionAction);
}
}
}
}
Aggregations