use of org.eclipse.gef.commands.Command in project tdi-studio-se by Talend.
the class TerminalBusinessItemNameEditPart 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 GEFDeleteAction method createDeleteCommand.
@Override
public Command createDeleteCommand(List objects) {
objects = filterSameObject(objectsToDelete);
if (objects.isEmpty()) {
return null;
}
if (!(objects.get(0) instanceof EditPart)) {
return null;
}
EditPart object = (EditPart) objects.get(0);
// for TUP-1015
boolean isConnAttachedJLTriggerComp = false;
ConnectionPart connectionPart = null;
if (object instanceof ConnectionPart) {
connectionPart = (ConnectionPart) object;
} else if (object instanceof ConnLabelEditPart) {
connectionPart = (ConnectionPart) object.getParent();
}
if (connectionPart != null) {
Node srcNode = null;
Object srcModel = connectionPart.getSource().getModel();
if (srcModel instanceof Node) {
srcNode = (Node) srcModel;
}
Node tarNode = null;
Object tarModel = connectionPart.getTarget().getModel();
if (tarModel instanceof Node) {
tarNode = (Node) tarModel;
}
if (srcNode == null || tarNode == null) {
return null;
}
IProcess process = srcNode.getProcess();
if (AbstractProcessProvider.isExtensionProcessForJoblet(process)) {
IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
if (service != null && (service.isTriggerNode(srcNode) || service.isTriggerNode(tarNode))) {
isConnAttachedJLTriggerComp = true;
}
}
}
IPreferenceStore preferenceStore = DesignerPlugin.getDefault().getPreferenceStore();
String preKey = TalendDesignerPrefConstants.NOT_SHOW_WARNING_WHEN_DELETE_LINK_WITH_JOBLETTRIGGERLINKCOMPONENT;
if (isConnAttachedJLTriggerComp && !preferenceStore.getBoolean(preKey)) {
MessageDialogWithToggle jlTriggerConfirmDialog = new MessageDialogWithToggle(null, //$NON-NLS-1$
Messages.getString("GEFDeleteAction.deleteConnectionDialog.title"), // accept the default window icon
null, Messages.getString("GEFDeleteAction.deleteConnectionDialog.msg"), MessageDialog.WARNING, new String[] { //$NON-NLS-1$
IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0, //$NON-NLS-1$
Messages.getString("GEFDeleteAction.deleteConnectionDialog.toggleMsg"), preferenceStore.getDefaultBoolean(preKey));
jlTriggerConfirmDialog.setPrefStore(preferenceStore);
jlTriggerConfirmDialog.setPrefKey(preKey);
if (jlTriggerConfirmDialog.open() != IDialogConstants.YES_ID) {
return null;
}
preferenceStore.setValue(preKey, jlTriggerConfirmDialog.getToggleState());
}
List nodeParts = new ArrayList();
List noteParts = new ArrayList();
List others = new ArrayList(objects);
for (Object o : objects) {
if (o instanceof NodePart) {
others.remove(o);
Node model = (Node) ((NodePart) o).getModel();
if (model.getJobletNode() != null) {
continue;
}
if (model.getJunitNode() != null) {
continue;
}
nodeParts.add(o);
} else if (o instanceof NoteEditPart) {
noteParts.add(o);
others.remove(o);
} else if (o instanceof SubjobContainerPart) {
others.remove(o);
SubjobContainerPart subjob = (SubjobContainerPart) o;
for (Iterator iterator = subjob.getChildren().iterator(); iterator.hasNext(); ) {
NodeContainerPart nodeContainerPart = (NodeContainerPart) iterator.next();
if (nodeContainerPart instanceof JobletContainerPart) {
JobletContainer jobletCon = (JobletContainer) ((JobletContainerPart) nodeContainerPart).getModel();
JobletContainerFigure jobletFigure = (JobletContainerFigure) ((JobletContainerPart) nodeContainerPart).getFigure();
if (!jobletCon.isCollapsed()) {
jobletFigure.doCollapse();
}
}
NodePart nodePart = nodeContainerPart.getNodePart();
if (nodePart != null) {
Node model = (Node) nodePart.getModel();
if (model.getJunitNode() != null) {
continue;
}
nodeParts.add(nodePart);
}
}
}
}
if (others.size() == 0) {
// so notes & nodes only
CompoundCommand cpdCmd = new CompoundCommand();
//$NON-NLS-1$
cpdCmd.setLabel(Messages.getString("GEFDeleteAction.DeleteItems"));
if (nodeParts.size() != 0) {
GroupRequest deleteReq = new GroupRequest(RequestConstants.REQ_DELETE);
deleteReq.setEditParts(nodeParts);
cpdCmd.add(((NodePart) nodeParts.get(0)).getCommand(deleteReq));
}
if (noteParts.size() != 0) {
GroupRequest deleteReq = new GroupRequest(RequestConstants.REQ_DELETE);
deleteReq.setEditParts(noteParts);
cpdCmd.add(((NoteEditPart) noteParts.get(0)).getCommand(deleteReq));
}
return cpdCmd;
} else {
GroupRequest deleteReq = new GroupRequest(RequestConstants.REQ_DELETE);
deleteReq.setEditParts(objects);
Command cmd = object.getCommand(deleteReq);
return cmd;
}
}
use of org.eclipse.gef.commands.Command in project tdi-studio-se by Talend.
the class ParallelExecutionAction method run.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.Action#run()
*/
@Override
public void run() {
boolean hasFlowConnection = false;
for (IConnection connection : node.getOutgoingConnections()) {
if (connection.getLineStyle().hasConnectionCategory(IConnectionCategory.FLOW)) {
hasFlowConnection = true;
break;
}
}
if (hasFlowConnection) {
MessageDialog.openError(getWorkbenchPart().getSite().getShell(), Messages.getString(//$NON-NLS-1$
"ParallelExecutionAction.gotLink"), //$NON-NLS-1$
Messages.getString("ParallelExecutionAction.noOutputLink"));
return;
}
IElementParameter enableParallelizeParameter = node.getElementParameter(EParameterName.PARALLELIZE.getName());
if (enableParallelizeParameter != null) {
parallelEnable = (Boolean) enableParallelizeParameter.getValue();
}
IElementParameter numberParallelizeParameter = node.getElementParameter(EParameterName.PARALLELIZE_NUMBER.getName());
if (numberParallelizeParameter != null) {
numberParallel = (String) numberParallelizeParameter.getValue();
}
Dialog dialog = new ParallelDialog(getWorkbenchPart().getSite().getShell());
if (dialog.open() == Dialog.OK) {
Command command = new PropertyChangeCommand(node, EParameterName.PARALLELIZE.getName(), parallelEnable);
execute(command);
}
}
use of org.eclipse.gef.commands.Command in project tdi-studio-se by Talend.
the class ComponentChooseDialog method getChangeMetadataCommand.
/**
* DOC bqian Comment method "getChangeMetadataCommand".
*
* @param selectedNode
* @param node
* @param list
* @param connectionItem
*/
private void getChangeMetadataCommand(CompoundCommand cc, RepositoryNode selectedNode, Node node, ConnectionItem connectionItem) {
if (selectedNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.METADATA_CON_COLUMN) {
RepositoryNode columnParentNode = selectedNode.getParent().getParent();
if (columnParentNode != null) {
selectedNode = columnParentNode;
}
}
if (selectedNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.METADATA_CON_TABLE || selectedNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.METADATA_SAP_FUNCTION || selectedNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.METADATA_SALESFORCE_MODULE) {
String etlSchema = null;
if (connectionItem.getConnection() instanceof DatabaseConnection) {
DatabaseConnection connection = (DatabaseConnection) connectionItem.getConnection();
if (connection instanceof DatabaseConnection) {
etlSchema = connection.getUiSchema();
}
if (!"".equals(etlSchema)) {
//$NON-NLS-1$
//$NON-NLS-1$
IElementParameter e = node.getElementParameter("ELT_SCHEMA_NAME");
if (e != null) {
if (connection.isContextMode() && ContextParameterUtils.isContainContextParam(etlSchema)) {
e.setValue(etlSchema);
} else {
e.setValue(TalendTextUtils.addQuotes(etlSchema));
}
}
// node.getElementParameter("ELT_SCHEMA_NAME").setValue("\"" + etlSchema + "\"");
}
}
IRepositoryViewObject object = selectedNode.getObject();
MetadataTable table = null;
if (object instanceof MetadataTableRepositoryObject) {
table = ((MetadataTableRepositoryObject) object).getTable();
} else if (object instanceof SalesforceModuleRepositoryObject) {
table = ((SalesforceModuleRepositoryObject) object).getDefaultTable();
IRepositoryViewObject obj = null;
if (selectedNode.getChildren() != null) {
for (IRepositoryNode repositoryNode : selectedNode.getChildren()) {
obj = repositoryNode.getObject();
if (obj instanceof MetadataTableRepositoryObject) {
table = ((MetadataTableRepositoryObject) obj).getTable();
break;
}
}
}
}
// for SAP
if (PluginChecker.isSAPWizardPluginLoaded() && connectionItem instanceof SAPConnectionItem) {
getSAPCommand(cc, object, connectionItem, table, node);
return;
}
if (table != null) {
//$NON-NLS-1$
String value = connectionItem.getProperty().getId() + " - " + table.getLabel();
IElementParameter schemaParam = node.getElementParameterFromField(EParameterFieldType.SCHEMA_TYPE);
if (schemaParam == null) {
schemaParam = node.getElementParameterFromField(EParameterFieldType.SCHEMA_REFERENCE);
}
IElementParameter queryParam = node.getElementParameterFromField(EParameterFieldType.QUERYSTORE_TYPE);
if (queryParam != null) {
queryParam = queryParam.getChildParameters().get(EParameterName.QUERYSTORE_TYPE.getName());
if (queryParam != null) {
queryParam.setValue(EmfComponent.BUILTIN);
}
}
// }
if (PluginChecker.isHL7PluginLoaded() && connectionItem instanceof HL7ConnectionItem) {
Command hl7Cmd = new RepositoryChangeMetadataForHL7Command(node, IEbcdicConstant.TABLE_SCHEMAS, table.getLabel(), ConvertionHelper.convert(table));
cc.add(hl7Cmd);
return;
}
if (schemaParam == null) {
return;
}
if (node.isELTComponent()) {
//$NON-NLS-1$
node.setPropertyValue(EParameterName.LABEL.getName(), "__ELT_TABLE_NAME__");
}
schemaParam.getChildParameters().get(EParameterName.SCHEMA_TYPE.getName()).setValue(EmfComponent.REPOSITORY);
RepositoryChangeMetadataCommand command2 = new RepositoryChangeMetadataCommand(node, //$NON-NLS-1$
schemaParam.getName() + ":" + EParameterName.REPOSITORY_SCHEMA_TYPE.getName(), value, ConvertionHelper.convert(table), null, connectionItem.getConnection());
cc.add(command2);
return;
}
}
}
use of org.eclipse.gef.commands.Command in project tdi-studio-se by Talend.
the class ComponentChooseDialog method handleDrop.
// private void checkRequiredModules() {
// Object newObject = ((CreateRequest) getTargetRequest()).getNewObject();
// if (newObject instanceof Node) {
// IComponent component = ((Node) newObject).getComponent();
// Shell shell = Display.getCurrent().getActiveShell();
// ModulesInstallerUtil.installModules(new Shell(shell), component);
// }
// }
/*
* (non-Javadoc)
*
* @see org.eclipse.gef.dnd.TemplateTransferDropTargetListener#handleDrop()
*/
@Override
protected void handleDrop() {
updateTargetRequest();
updateTargetEditPart();
// checkRequiredModules();
if (fromPalette && getTargetRequest() instanceof CreateRequest) {
if (selectedConnectionPart != null) {
CreateRequest req = ((CreateRequest) getTargetRequest());
Object o = req.getNewObject();
Point location = req.getLocation();
if (o instanceof Node) {
createComponentOnLink((Node) o, location);
}
// checkRequiredModules();
return;
} else if (getTargetEditPart() instanceof ProcessPart) {
// for palette dnd, feature 6457
Object newObject = ((CreateRequest) getTargetRequest()).getNewObject();
if (newObject != null) {
Command command = getCommand();
if (command != null) {
execCommandStack(command);
}
}
// checkRequiredModules();
return;
} else if (getTargetEditPart() instanceof SubjobContainerPart) {
// TDI-24985:for palette dnd.
Object newObject = ((CreateRequest) getTargetRequest()).getNewObject();
if (newObject != null) {
Command command = getCommand();
if (command != null) {
execCommandStack(command);
}
}
return;
} else if (getTargetEditPart() instanceof JobletContainerPart) {
JobletContainerPart jobletPart = (JobletContainerPart) getTargetEditPart();
if (isLock(jobletPart)) {
Shell shell = Display.getCurrent().getActiveShell();
ChooseJobletDialog dialog = new ChooseJobletDialog(new Shell(shell), getDropLocation());
if (dialog.open() == dialog.OK) {
EditPart part = getTargetEditPart();
if (dialog.addToJoblet()) {
AbstractMultiPageTalendEditor openEditor = getJobletPart((JobletContainerPart) part);
part = openEditor.getDesignerEditor().getProcessPart();
// editor = openEditor.getTalendEditor();
setTargetEditPart(part);
Object newObject = ((CreateRequest) getTargetRequest()).getNewObject();
if (newObject != null) {
Command command = getCommand();
if (command != null) {
CommandStack commandStack = (CommandStack) openEditor.getAdapter(CommandStack.class);
if (commandStack != null) {
commandStack.execute(command);
} else {
command.execute();
}
}
}
// checkRequiredModules();
return;
} else {
part = getParentPart(part);
setTargetEditPart(part);
Object newObject = ((CreateRequest) getTargetRequest()).getNewObject();
if (newObject != null) {
Command command = getCommand();
if (command != null) {
execCommandStack(command);
}
}
// checkRequiredModules();
return;
}
}
}
}
}
List<Object> sources = getSelectSource();
if (containsContextSource(sources)) {
createContext(sources);
} else {
if (!(getTargetEditPart() instanceof NodeContainerPart)) {
try {
createNewComponent(getCurrentEvent());
} catch (OperationCanceledException e) {
return;
}
} else {
if (containsSQLPatternSource(sources)) {
createSQLPattern(sources);
} else {
Object obj = getSelection().getFirstElement();
createSchema(obj, getTargetEditPart());
createQuery(obj, getTargetEditPart());
createProperty(obj, getTargetEditPart());
createChildJob(obj, getTargetEditPart());
createValidationRule(obj, getTargetEditPart());
if (obj instanceof IRepositoryNode) {
propaHadoopCfgChanges((IRepositoryNode) obj);
}
for (IExtendedNodeHandler hander : ExtendedNodeManager.getExtendedNodeHandler()) {
boolean updated = hander.updateComponent(obj, getTargetEditPart(), editor.getCommandStack());
if (updated) {
break;
}
}
}
}
}
// in case after drag/drop the editor is dirty but can not get focus
if (editor.isDirty()) {
editor.setFocus();
}
this.eraseTargetFeedback();
}
Aggregations