use of org.eclipse.gef.commands.CommandStack in project tdi-studio-se by Talend.
the class DynamicTabbedPropertySection method getCommandStack.
/**
* Get the command stack of the Gef editor.
*
* @return
*/
protected CommandStack getCommandStack() {
AbstractTalendEditor talendEditor = part.getTalendEditor();
Object adapter = talendEditor.getAdapter(CommandStack.class);
return (CommandStack) adapter;
}
use of org.eclipse.gef.commands.CommandStack in project tdi-studio-se by Talend.
the class StatsAndLogsHelper method changeRepositoryConnection.
static void changeRepositoryConnection(Element process, StatsAndLogsComposite statsComposite) {
String propertyType = (String) ElementParameter2ParameterType.getParameterValue(process, EParameterName.PROPERTY_TYPE.getName());
String id = (String) (ElementParameter2ParameterType.getParameterValue(process, EParameterName.PROPERTY_TYPE.getName()));
Connection repositoryConnection = null;
/* 16969 */
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
Item item = null;
try {
IRepositoryViewObject repobj = factory.getLastVersion(id);
if (repobj != null) {
Property tmpproperty = repobj.getProperty();
if (tmpproperty != null) {
item = tmpproperty.getItem();
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
if (item != null && item instanceof ConnectionItem) {
repositoryConnection = ((ConnectionItem) item).getConnection();
} else {
repositoryConnection = null;
}
ChangeValuesFromRepository cmd1 = new ChangeValuesFromRepository(process, repositoryConnection, ImplicitContextLoadHelper.getExtraParameterName(EParameterName.PROPERTY_TYPE) + ":" + EParameterName.PROPERTY_TYPE.getName(), //$NON-NLS-1$
propertyType);
ChangeValuesFromRepository cmd2 = new ChangeValuesFromRepository(process, repositoryConnection, ImplicitContextLoadHelper.getExtraParameterName(EParameterName.PROPERTY_TYPE) + ":" + EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), //$NON-NLS-1$
id);
AbstractMultiPageTalendEditor part = (AbstractMultiPageTalendEditor) ((IProcess2) process).getEditor();
if (part instanceof AbstractMultiPageTalendEditor) {
Object adapter = (part).getTalendEditor().getAdapter(CommandStack.class);
if (adapter != null) {
CommandStack commandStack = ((CommandStack) adapter);
commandStack.execute(cmd1);
commandStack.execute(cmd2);
}
}
}
use of org.eclipse.gef.commands.CommandStack in project tdi-studio-se by Talend.
the class ProjectSettingManager method changeImplicitContextRepositoryItem.
static void changeImplicitContextRepositoryItem(Element process, ExtraComposite extraComposite) {
// change repository item
String propertyType = (String) ElementParameter2ParameterType.getParameterValue(process, JobSettingsConstants.getExtraParameterName(EParameterName.PROPERTY_TYPE.getName()));
String id = (String) (ElementParameter2ParameterType.getParameterValue(process, EParameterName.PROPERTY_TYPE.getName()));
Connection repositoryConnection = null;
/* 16969 */
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
Item item = null;
try {
IRepositoryViewObject repobj = factory.getLastVersion(id);
if (repobj != null) {
Property tmpproperty = repobj.getProperty();
if (tmpproperty != null) {
item = tmpproperty.getItem();
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
if (item != null && item instanceof ConnectionItem) {
repositoryConnection = ((ConnectionItem) item).getConnection();
} else {
repositoryConnection = null;
}
ChangeValuesFromRepository cmd1 = new ChangeValuesFromRepository(process, repositoryConnection, ImplicitContextLoadHelper.getExtraParameterName(EParameterName.PROPERTY_TYPE) + ":" + EParameterName.PROPERTY_TYPE.getName(), //$NON-NLS-1$
propertyType);
ChangeValuesFromRepository cmd2 = new ChangeValuesFromRepository(process, repositoryConnection, ImplicitContextLoadHelper.getExtraParameterName(EParameterName.PROPERTY_TYPE) + ":" + EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), //$NON-NLS-1$
id);
AbstractMultiPageTalendEditor part = (AbstractMultiPageTalendEditor) ((IProcess2) process).getEditor();
if (part instanceof AbstractMultiPageTalendEditor) {
Object adapter = (part).getTalendEditor().getAdapter(CommandStack.class);
if (adapter != null) {
CommandStack commandStack = ((CommandStack) adapter);
commandStack.execute(cmd1);
commandStack.execute(cmd2);
}
}
}
use of org.eclipse.gef.commands.CommandStack in project tdi-studio-se by Talend.
the class UIManager method closeMapper.
/**
* DOC amaumont Comment method "closeMapperDialog".
*
* @param ok
*/
public void closeMapper(int response) {
boolean save = true;
for (DataMapTableView dataMapTableView : getInputsTablesView()) {
dataMapTableView.notifyFocusLost();
}
for (DataMapTableView dataMapTableView : getOutputsTablesView()) {
dataMapTableView.notifyFocusLost();
}
for (DataMapTableView dataMapTableView : getVarsTablesView()) {
dataMapTableView.notifyFocusLost();
}
if ((response == SWT.OK || response == SWT.APPLICATION_MODAL) && mapperManager.getProblemsManager().checkProblemsForAllEntriesOfAllTables(false)) {
save = MessageDialog.openConfirm(getMapperContainer().getShell(), //$NON-NLS-1$
Messages.getString("UIManager.SaveDespiteErrors.Title"), //$NON-NLS-1$
Messages.getString("UIManager.SaveDespiteErrors.Message"));
}
if (save) {
Composite parent = mapperUI.getMapperUIParent();
prepareClosing(response);
if (parent instanceof Shell) {
if (response == SWT.OK || response == SWT.CANCEL) {
((Shell) parent).close();
} else {
IExternalNode externalNode = mapperManager.getAbstractMapComponent().getExternalNode();
IWorkbenchPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
if (externalNode != null && (part instanceof AbstractMultiPageTalendEditor)) {
INode node = externalNode.getOriginalNode();
if (node != null && node instanceof Node) {
Command cmd = new ExternalNodeChangeCommand((Node) node, externalNode);
CommandStack cmdStack = (CommandStack) part.getAdapter(CommandStack.class);
cmdStack.execute(cmd);
}
}
}
}
}
}
use of org.eclipse.gef.commands.CommandStack in project tdi-studio-se by Talend.
the class ComponentListController method updateComponentList.
protected static void updateComponentList(Collection<INode> nodeList, INode currentNode, IElementParameter param, boolean isSelectDefaultItem) {
final Collection<String> componentDisplayNames = new ArrayList<String>();
final Collection<String> componentUniqueNames = new ArrayList<String>();
for (INode node : nodeList) {
if (node.getJobletNode() != null) {
node = node.getJobletNode();
}
final String uniqueName = node.getUniqueName();
if (uniqueName.equals(currentNode.getUniqueName())) {
continue;
}
//$NON-NLS-1$
String displayName = (String) node.getElementParameter("LABEL").getValue();
if (displayName == null) {
displayName = uniqueName;
}
if (displayName.indexOf("__UNIQUE_NAME__") != -1) {
//$NON-NLS-1$
//$NON-NLS-1$
displayName = displayName.replaceAll("__UNIQUE_NAME__", uniqueName);
}
if (!displayName.equals(uniqueName)) {
//$NON-NLS-1$
displayName = uniqueName + " - " + displayName;
}
componentUniqueNames.add(uniqueName);
componentDisplayNames.add(displayName);
}
param.setListItemsDisplayName(componentDisplayNames.toArray(new String[0]));
final String[] componentValueList = componentUniqueNames.toArray(new String[0]);
param.setListItemsValue(componentValueList);
Object value = param.getValue();
if (!componentUniqueNames.contains(value) && isSelectDefaultItem) {
String newValue = null;
if (!param.isDynamicSettings()) {
if (!componentUniqueNames.isEmpty()) {
if (value == null || value.equals("")) {
//$NON-NLS-1$
currentNode.setPropertyValue(getParameterName(param), componentValueList[0]);
if (currentNode instanceof IGraphicalNode) {
IGraphicalNode node = (IGraphicalNode) currentNode;
node.checkAndRefreshNode();
((IProcess2) node.getProcess()).setProcessModified(true);
} else if (currentNode instanceof IConnection) {
((IProcess2) ((IConnection) currentNode).getSource().getProcess()).setProcessModified(true);
}
} else {
newValue = componentValueList[0];
}
} else {
// removed the old value.
//$NON-NLS-1$
newValue = "";
}
}
if (!("".equals(newValue)) && newValue != null) {
//$NON-NLS-1$
IEditorPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
if (part instanceof AbstractMultiPageTalendEditor) {
AbstractTalendEditor te = ((AbstractMultiPageTalendEditor) part).getTalendEditor();
CommandStack cmdStack = (CommandStack) te.getAdapter(CommandStack.class);
cmdStack.execute(new PropertyChangeCommand(currentNode, getParameterName(param), ""));
}
}
}
}
Aggregations