use of org.eclipse.gef.commands.Command in project tdi-studio-se by Talend.
the class InputBusinessItemNameEditPart method createDefaultEditPolicies.
/**
* @generated
*/
protected void createDefaultEditPolicies() {
super.createDefaultEditPolicies();
installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new NonResizableEditPolicy() {
protected List createSelectionHandles() {
List handles = new ArrayList();
NonResizableHandleKit.addMoveHandle((GraphicalEditPart) getHost(), handles);
return handles;
}
public Command getCommand(Request request) {
return null;
}
public boolean understandsRequest(Request request) {
return false;
}
});
}
use of org.eclipse.gef.commands.Command in project tdi-studio-se by Talend.
the class FilterColumnDialog method okPressed.
@Override
protected void okPressed() {
stack.execute(new Command() {
@Override
public void execute() {
List<Object> checkedElements = Arrays.asList(tabView.getCheckedElements());
if (checkedElements.size() == 0)
conn.setNullColumn = true;
Integer validColumn1 = 0;
Object value = conn.getPropertyValue(EParameterName.TRACES_CONNECTION_FILTER.getName());
conn.traceColumn.clear();
for (TableItem item : tabView.getTable().getItems()) {
Object data = item.getData();
if (data instanceof ConditionBean) {
ConditionBean bean = (ConditionBean) data;
if (checkedElements.contains(bean)) {
conn.setNullColumn = false;
conn.traceColumn.add(validColumn1);
} else {
tabView.setChecked(item, false);
}
TracesConnectionUtils.setTraceColumnValues(conn, bean.getColumnName(), bean.getCondition(), checkedElements.contains(bean));
validColumn1++;
}
}
// fire property change and refresh
conn.setPropertyValue(EParameterName.TRACES_CONNECTION_FILTER.getName(), value);
}
});
super.okPressed();
}
use of org.eclipse.gef.commands.Command in project tdi-studio-se by Talend.
the class TalendConnectionCreationTool method handleConnection.
protected boolean handleConnection() {
setAvoidDeactivation(true);
EditPartViewer viewer = getCurrentViewer();
Command endCommand = getCommand();
if (endCommand == null) {
if (isInState(STATE_TERMINAL)) {
// Fake a drag to cause feedback to be displayed immediately on mouse down.
setState(STATE_CONNECTION_STARTED);
handleDrag();
}
return true;
}
sourcePart.getViewer().getSelectionManager().deselect(sourcePart);
setCurrentCommand(endCommand);
executeCurrentCommand();
selectAddedObject(viewer, getReturnValues(endCommand));
setAvoidDeactivation(false);
getSourceRequest().setType(RequestConstants.REQ_CONNECTION_END);
eraseSourceFeedback();
deactivate();
return true;
}
use of org.eclipse.gef.commands.Command in project tdi-studio-se by Talend.
the class TalendConnectionCreationTool method getReturnValues.
public Collection getReturnValues(Command c) {
if (c instanceof CompoundCommand) {
CompoundCommand cc = (CompoundCommand) c;
List l = new ArrayList(cc.size());
for (Iterator i = cc.getCommands().iterator(); i.hasNext(); ) {
l.addAll(getReturnValues((Command) i.next()));
}
return l;
}
return Collections.EMPTY_LIST;
}
use of org.eclipse.gef.commands.Command in project tdi-studio-se by Talend.
the class DCSchemaController method createButtonCommand.
/*
* (non-Javadoc)
*
* @see
* org.talend.designer.core.ui.editor.properties.controllers.AbstractRepositoryController#createButtonCommand(org
* .eclipse.swt.widgets.Button)
*/
@SuppressWarnings("unchecked")
protected Command createButtonCommand(Button button) {
Button inputButton = button;
Map<INode, Map<IMetadataTable, Boolean>> inputInfos = new HashMap<INode, Map<IMetadataTable, Boolean>>();
Node node;
if (elem instanceof Node) {
node = (Node) elem;
} else {
// else instanceof Connection
node = (Node) ((Connection) elem).getSource();
}
String componentName = node.getComponent().getName();
initConnectionParameters();
IContextManager manager;
if (part == null) {
manager = new EmptyContextManager();
} else {
manager = part.getProcess().getContextManager();
}
IElement oldElement = elem;
if (isUseExistingConnection()) {
this.elem = connectionNode;
initConnectionParametersWithContext(connectionNode, manager.getDefaultContext());
} else {
initConnectionParametersWithContext(elem, manager.getDefaultContext());
}
this.elem = oldElement;
if (!GlobalServiceRegister.getDefault().isServiceRegistered(IDCService.class)) {
return null;
}
IDCService restService = (IDCService) GlobalServiceRegister.getDefault().getService(IDCService.class);
restService.setupRestHelperInstance(connParameters.getHost(), connParameters.getPort(), connParameters.getUserName(), connParameters.getPassword(), connParameters.getDirectory(), connParameters.isHttps());
String entityName = elem.getPropertyValue("ENTITY").toString().replaceAll("\"", "");
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();
}
boolean inputReadOnly = false, outputReadOnly = false, inputReadOnlyNode = false, inputReadOnlyParam = false;
for (Connection connec : (List<Connection>) node.getIncomingConnections()) {
if (connec.isActivate() && (EConnectionType.FLOW_MAIN.equals(connec.getLineStyle()) || EConnectionType.TABLE.equals(connec.getLineStyle()) || EConnectionType.FLOW_MERGE.equals(connec.getLineStyle()) || EConnectionType.FLOW_REF.equals(connec.getLineStyle()))) {
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_TYPE || curParam.getFieldType() == EParameterFieldType.DCSCHEMA) {
if (curParam.isReadOnly()) {
inputReadOnlyParam = true;
}
}
}
}
// check if the inputMetadata is readonly
if (inputMetadata != null) {
for (IMetadataColumn column : inputMetadata.getListColumns()) {
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("SchemaTypeController.inputNotSet"), //$NON-NLS-1$
Messages.getString("SchemaTypeController.connectionNotAvaliable"));
return null;
}
IMetadataTable originaleMetadataTable = getMetadataTableFromXml(node);
// check if the outputMetadata is readonly
IMetadataTable originaleOutputTable = node.getMetadataFromConnector(param.getContext());
IMetadataTable outputMetaCopy = originaleOutputTable.clone();
for (IMetadataColumn column : originaleOutputTable.getListColumns()) {
IMetadataColumn columnCopied = outputMetaCopy.getColumn(column.getLabel());
columnCopied.setCustom(column.isCustom());
columnCopied.setReadOnly(column.isReadOnly());
}
outputMetaCopy.setReadOnly(originaleOutputTable.isReadOnly() || param.isReadOnly(node.getElementParametersWithChildrens()));
outputMetaCopy.sortCustomColumns();
// create the MetadataDialog
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("SchemaController.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) {
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 {
Node inputNode = (Node) (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());
}
/*
* Datacert: Populating data in the edit schema dialog
*
* @author : virtusa
*/
List<IMetadataColumn> columnList = new ArrayList<IMetadataColumn>();
String prefix = "";
if (componentName.equalsIgnoreCase(Messages.getString("DataCertController.tDataCertDenormalize.componentName"))) {
String denorCol = elem.getPropertyValue("DC_COLUMN_DENORMALIZE").toString().replaceAll("\"", "");
;
prefix = denorCol;
IMetadataTable inputTable = null;
if (node.getIncomingConnections() != null && node.getIncomingConnections().size() > 0) {
IConnection inputConn = node.getIncomingConnections().get(0);
if (inputConn != null) {
inputTable = inputConn.getMetadataTable();
}
}
if (inputTable != null) {
for (IMetadataColumn inCol : inputTable.getListColumns()) {
if (!inCol.getLabel().equals(denorCol)) {
columnList.add(inCol);
}
}
}
}
restService.addColumnsToSchema(entityName, componentName, prefix, columnList);
outputMetaCopy.setListColumns(columnList);
outputMetaCopy.setComment("Attribute Metadata");
outputMetaCopy.setLabel("Attribute Metadata");
outputMetaCopy.setTableName(entityName);
if (metaDialog != null) {
//$NON-NLS-1$
metaDialog.setText(Messages.getString("AbstractSchemaController.schema.title", node.getLabel()));
metaDialog.setInputReadOnly(false);
metaDialog.setOutputReadOnly(false);
if (metaDialog.open() == MetadataDialog.OK) {
outputMetaCopy = metaDialog.getOutputMetaData();
boolean modified = false;
if (!outputMetaCopy.sameMetadataAs(originaleOutputTable, IMetadataColumn.OPTIONS_NONE)) {
modified = true;
}
if (modified) {
Node inputNode = null;
if (inputConec != null) {
inputNode = (Node) inputConec.getSource();
}
ChangeMetadataCommand changeMetadataCommand = new ChangeMetadataCommand(node, param, inputNode, inputMetadata, inputMetaCopy, originaleOutputTable, outputMetaCopy);
return changeMetadataCommand;
}
}
}
return null;
}
Aggregations