use of org.eclipse.gef.commands.CommandStack in project tdi-studio-se by Talend.
the class NoteEditPart method performRequest.
@Override
public void performRequest(Request request) {
Note note = (Note) getModel();
if (note.isReadOnly()) {
return;
}
if (request.getType() == RequestConstants.REQ_OPEN) {
IWorkbenchPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
if (part instanceof AbstractMultiPageTalendEditor) {
CommandStack commandStack = (CommandStack) part.getAdapter(CommandStack.class);
Command command = new ChangeNoteOpacityCommand(note, !note.isOpaque());
commandStack.execute(command);
}
}
if (request.getType() == RequestConstants.REQ_DIRECT_EDIT) {
if (directEditManager == null) {
NoteFigure noteFigure = (NoteFigure) getFigure();
directEditManager = new NoteDirectEditManager(this, TextCellEditor.class, new NoteCellEditorLocator(noteFigure));
}
directEditManager.show();
}
}
use of org.eclipse.gef.commands.CommandStack in project tdi-studio-se by Talend.
the class GenericElementParameter method updateSchema.
private void updateSchema() {
IElement element = this.getElement();
if (element instanceof Node) {
Node node = (Node) element;
List<INodeConnector> connectors = node.getConnectorsFromType(EConnectionType.FLOW_MAIN);
for (INodeConnector connector : connectors) {
if (connector instanceof GenericNodeConnector) {
Connector componentConnector = ((GenericNodeConnector) connector).getComponentConnector();
Schema schema = null;
schema = getRootProperties().getSchema(componentConnector, ((GenericNodeConnector) connector).isOutput());
IMetadataTable mainTable = node.getMetadataFromConnector(connector.getName());
if (schema != null && mainTable != null) {
MetadataTable metadataTable = MetadataToolAvroHelper.convertFromAvro(schema);
IMetadataTable newTable = MetadataToolHelper.convert(metadataTable);
if (!mainTable.sameMetadataAs(newTable) || !newTable.sameMetadataAs(mainTable)) {
mainTable.setListColumns(newTable.getListColumns());
List<IElementParameter> schemaParameters = node.getElementParametersFromField(EParameterFieldType.SCHEMA_REFERENCE);
updateSchemaParameters(schemaParameters, connector.getName(), schema);
if (this.askPropagate == null && node.getOutgoingConnections().size() != 0) {
boolean hasPropagation = false;
for (IConnection connection : node.getOutgoingConnections()) {
if (connector.getName().equals(connection.getConnectorName())) {
if (isSchemaPropagated(connection.getTarget())) {
hasPropagation = true;
break;
}
}
}
if (hasPropagation) {
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
askPropagate = ChangeMetadataCommand.askPropagate();
}
});
}
}
if (this.askPropagate != null && this.askPropagate) {
for (IConnection connection : node.getOutgoingConnections()) {
if (connector.getName().equals(connection.getConnectorName())) {
INode target = connection.getTarget();
if (!isSchemaPropagated(target)) {
continue;
}
ChangeMetadataCommand cmd = new ChangeMetadataCommand(target, null, null, newTable, null);
cmd.setPropagate(true);
IProcess process = node.getProcess();
if (process instanceof org.talend.designer.core.ui.editor.process.Process) {
CommandStack commandStack = ((org.talend.designer.core.ui.editor.process.Process) process).getCommandStack();
commandStack.execute(cmd);
}
}
}
}
}
}
}
}
this.askPropagate = null;
}
}
use of org.eclipse.gef.commands.CommandStack in project tdi-studio-se by Talend.
the class ProcessLayoutEditPolicy method getConnectionAndEndCommands.
protected Command getConnectionAndEndCommands(CreateConnectionRequest request) {
CompoundCommand cc = new CompoundCommand("CreateNodeCommand");
ProcessPart processPart = (ProcessPart) this.getHost();
final GraphicalViewer graphicalViewer = (GraphicalViewer) processPart.getViewer();
final CommandStack commandStack = processPart.getViewer().getEditDomain().getCommandStack();
final String categoryName = ComponentsFactoryProvider.getInstance().getComponentsHandler().extractComponentsCategory().getName();
final IProcess2 process = (IProcess2) processPart.getModel();
TalendEditorConnectionTargetAssist assist = new TalendEditorConnectionTargetAssist(categoryName, graphicalViewer, commandStack, process);
char start = '*';
assist.showComponentCreationAssist(start);
ConnectionCreateCommand cmd = (ConnectionCreateCommand) request.getStartCommand();
if (assist.getComponentName() == null) {
assist.releaseText();
return cmd;
}
IComponent component = TalendEditorComponentCreationUtil.getComponentsInCategory(categoryName).get(assist.getComponentName());
if (component == null) {
assist.releaseText();
return cmd;
}
assist.releaseText();
Node newNode = new Node(component);
NodeContainer nodeContainer = ((Process) newNode.getProcess()).loadNodeContainer(newNode, false);
CreateNodeContainerCommand command = new CreateNodeContainerCommand((org.talend.designer.core.ui.editor.process.Process) newNode.getProcess(), nodeContainer, request.getLocation());
cc.add(command);
cmd.setTarget(newNode);
cc.add(cmd);
return cc;
}
use of org.eclipse.gef.commands.CommandStack 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();
}
use of org.eclipse.gef.commands.CommandStack in project tdi-studio-se by Talend.
the class ProjectSettingMultipleThreadDynamicComposite method getCommandStack.
@Override
public CommandStack getCommandStack() {
if (cs == null) {
// fixed bug 12476
cs = new CommandStack();
cs.addCommandStackEventListener(new CommandStackEventListener() {
public void stackChanged(CommandStackEvent event) {
if (event.getDetail() == CommandStack.POST_EXECUTE) {
isCommandExcute = true;
// when show connection param ,update it if needed
updateConnectionFromRepository();
}
}
});
}
return cs;
}
Aggregations