Search in sources :

Example 11 with CommandStack

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;
}
Also used : CommandStack(org.eclipse.gef.commands.CommandStack) AbstractTalendEditor(org.talend.designer.core.ui.editor.AbstractTalendEditor) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject)

Example 12 with CommandStack

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);
        }
    }
}
Also used : ConnectionItem(org.talend.core.model.properties.ConnectionItem) Item(org.talend.core.model.properties.Item) CommandStack(org.eclipse.gef.commands.CommandStack) ChangeValuesFromRepository(org.talend.designer.core.ui.editor.cmd.ChangeValuesFromRepository) ConnectionItem(org.talend.core.model.properties.ConnectionItem) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) Connection(org.talend.core.model.metadata.builder.connection.Connection) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) Property(org.talend.core.model.properties.Property) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 13 with CommandStack

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);
        }
    }
}
Also used : Item(org.talend.core.model.properties.Item) ConnectionItem(org.talend.core.model.properties.ConnectionItem) CommandStack(org.eclipse.gef.commands.CommandStack) ChangeValuesFromRepository(org.talend.designer.core.ui.editor.cmd.ChangeValuesFromRepository) ConnectionItem(org.talend.core.model.properties.ConnectionItem) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) Connection(org.talend.core.model.metadata.builder.connection.Connection) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) Property(org.talend.core.model.properties.Property) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 14 with CommandStack

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);
                    }
                }
            }
        }
    }
}
Also used : ExternalNodeChangeCommand(org.talend.designer.core.ui.editor.cmd.ExternalNodeChangeCommand) CommandStack(org.eclipse.gef.commands.CommandStack) Shell(org.eclipse.swt.widgets.Shell) INode(org.talend.core.model.process.INode) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) ExternalNodeChangeCommand(org.talend.designer.core.ui.editor.cmd.ExternalNodeChangeCommand) Command(org.eclipse.gef.commands.Command) DataMapTableViewSelectedCommand(org.talend.designer.mapper.ui.commands.DataMapTableViewSelectedCommand) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) INode(org.talend.core.model.process.INode) Node(org.talend.designer.core.ui.editor.nodes.Node) IExternalNode(org.talend.core.model.process.IExternalNode) InputDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.InputDataMapTableView) OutputDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.OutputDataMapTableView) VarsDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.VarsDataMapTableView) DataMapTableView(org.talend.designer.mapper.ui.visualmap.table.DataMapTableView) IExternalNode(org.talend.core.model.process.IExternalNode)

Example 15 with CommandStack

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), ""));
            }
        }
    }
}
Also used : CommandStack(org.eclipse.gef.commands.CommandStack) INode(org.talend.core.model.process.INode) IGraphicalNode(org.talend.core.ui.process.IGraphicalNode) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) ArrayList(java.util.ArrayList) IConnection(org.talend.core.model.process.IConnection) IEditorPart(org.eclipse.ui.IEditorPart) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) AbstractTalendEditor(org.talend.designer.core.ui.editor.AbstractTalendEditor) IProcess2(org.talend.core.model.process.IProcess2)

Aggregations

CommandStack (org.eclipse.gef.commands.CommandStack)34 Command (org.eclipse.gef.commands.Command)15 AbstractMultiPageTalendEditor (org.talend.designer.core.ui.AbstractMultiPageTalendEditor)13 INode (org.talend.core.model.process.INode)10 EditPart (org.eclipse.gef.EditPart)9 Node (org.talend.designer.core.ui.editor.nodes.Node)9 PersistenceException (org.talend.commons.exception.PersistenceException)8 ArrayList (java.util.ArrayList)6 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)6 Item (org.talend.core.model.properties.Item)6 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)6 IEditorPart (org.eclipse.ui.IEditorPart)5 IExternalNode (org.talend.core.model.process.IExternalNode)5 Property (org.talend.core.model.properties.Property)5 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)5 List (java.util.List)4 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)4 Connection (org.talend.core.model.metadata.builder.connection.Connection)4 IProcess (org.talend.core.model.process.IProcess)4 IProcess2 (org.talend.core.model.process.IProcess2)4