Search in sources :

Example 6 with IGEFProcess

use of org.talend.core.ui.process.IGEFProcess in project tdi-studio-se by Talend.

the class UpdateNodePathCommand method execute.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.commands.Command#execute()
     */
@Override
public void execute() {
    IUpdateItemType updateType = result.getUpdateType();
    if (result == null || updateType == null) {
        return;
    }
    Object updateObject = result.getUpdateObject();
    if (updateObject == null || (!(updateObject instanceof Node))) {
        return;
    }
    // instance of node before might not be good (loaded while check updates needed)
    // so get the instance of the node of the current job in this object.
    IProcess process = (IProcess) result.getJob();
    for (INode node : process.getGraphicalNodes()) {
        if (node.getUniqueName().equals(((Node) updateObject).getUniqueName())) {
            updateObject = node;
            result.setUpdateObject(updateObject);
            break;
        }
    }
    Node node = (Node) updateObject;
    if (updateType instanceof EUpdateItemType) {
        switch((EUpdateItemType) updateType) {
            case MAP_PATH:
                Object parameter = result.getParameter();
                if (!(parameter instanceof List)) {
                    return;
                }
                List<Object> params = (List<Object>) parameter;
                if (params.size() != 3) {
                    return;
                }
                IElementParameter param = (IElementParameter) params.get(0);
                if (param == null) {
                    return;
                }
                String oldPath = (String) params.get(1);
                String newPath = (String) params.get(2);
                String relativeNewPath = new Path(newPath).removeFirstSegments(2).removeFileExtension().toPortableString();
                String fullOldPath = new Path(oldPath).removeFileExtension().toPortableString();
                String relativeOldPath = new Path(oldPath).removeFirstSegments(2).removeFileExtension().toPortableString();
                Object value = TalendTextUtils.removeQuotes(String.valueOf(param.getValue()));
                if (!fullOldPath.equals(value) && !relativeOldPath.equals(value)) {
                    return;
                }
                if (fullOldPath.equals(value)) {
                    String newValue = TalendTextUtils.addQuotes(new Path(newPath).removeFileExtension().toPortableString());
                    param.setValue(newValue);
                } else if (relativeOldPath.equals(value)) {
                    param.setValue(TalendTextUtils.addQuotes(relativeNewPath));
                }
                break;
            default:
        }
    }
    if (node.getProcess() instanceof IProcess2) {
        PropertyChangeCommand pcc = new PropertyChangeCommand(node, EParameterName.UPDATE_COMPONENTS.getName(), Boolean.TRUE);
        boolean executed = false;
        if (process instanceof IGEFProcess) {
            IDesignerCoreUIService designerCoreUIService = CoreUIPlugin.getDefault().getDesignerCoreUIService();
            if (designerCoreUIService != null) {
                executed = designerCoreUIService.executeCommand((IGEFProcess) process, pcc);
            }
        }
        if (!executed) {
            pcc.execute();
        }
    }
}
Also used : Path(org.eclipse.core.runtime.Path) INode(org.talend.core.model.process.INode) INode(org.talend.core.model.process.INode) Node(org.talend.designer.core.ui.editor.nodes.Node) IDesignerCoreUIService(org.talend.core.ui.services.IDesignerCoreUIService) EUpdateItemType(org.talend.core.model.update.EUpdateItemType) IGEFProcess(org.talend.core.ui.process.IGEFProcess) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) IProcess2(org.talend.core.model.process.IProcess2) IElementParameter(org.talend.core.model.process.IElementParameter) IUpdateItemType(org.talend.core.model.update.IUpdateItemType) List(java.util.List) IProcess(org.talend.core.model.process.IProcess)

Example 7 with IGEFProcess

use of org.talend.core.ui.process.IGEFProcess in project tdi-studio-se by Talend.

the class StatsAndLogsViewHelper method applySettings.

/**
     * yzhang Comment method "applySettings".
     * 
     * @param element
     * @param dynamicProperty
     */
public static void applySettings(IElement element, IElement applyTo, IDynamicProperty dynamicProperty) {
    List<? extends IElementParameter> elementParameters = applyTo.getElementParameters();
    for (IElementParameter elementParameterType : elementParameters) {
        String parameterName = elementParameterType.getName();
        if (parameterName.equals(EParameterName.ON_STATCATCHER_FLAG.getName())) {
            elementParameterType.setValue(element.getElementParameter(EParameterName.ON_STATCATCHER_FLAG.getName()).getValue());
            continue;
        }
        if (parameterName.equals(EParameterName.ON_LOGCATCHER_FLAG.getName())) {
            elementParameterType.setValue(element.getElementParameter(EParameterName.ON_LOGCATCHER_FLAG.getName()).getValue());
            continue;
        }
        if (parameterName.equals(EParameterName.ON_METERCATCHER_FLAG.getName())) {
            elementParameterType.setValue(element.getElementParameter(EParameterName.ON_METERCATCHER_FLAG.getName()).getValue());
            continue;
        }
        if (parameterName.equals(EParameterName.ON_FILES_FLAG.getName())) {
            elementParameterType.setValue(element.getElementParameter(EParameterName.ON_FILES_FLAG.getName()).getValue());
            continue;
        }
        if (parameterName.equals(EParameterName.FILE_PATH.getName())) {
            elementParameterType.setValue(element.getElementParameter(EParameterName.FILE_PATH.getName()).getValue());
            continue;
        }
        if (parameterName.equals(EParameterName.FILENAME_STATS.getName())) {
            elementParameterType.setValue(element.getElementParameter(EParameterName.FILENAME_STATS.getName()).getValue());
            continue;
        }
        if (parameterName.equals(EParameterName.FILENAME_LOGS.getName())) {
            elementParameterType.setValue(element.getElementParameter(EParameterName.FILENAME_LOGS.getName()).getValue());
            continue;
        }
        if (parameterName.equals(EParameterName.FILENAME_METTER.getName())) {
            elementParameterType.setValue(element.getElementParameter(EParameterName.FILENAME_METTER.getName()).getValue());
            continue;
        }
        if (parameterName.equals(EParameterName.ON_DATABASE_FLAG.getName())) {
            elementParameterType.setValue(element.getElementParameter(EParameterName.ON_DATABASE_FLAG.getName()).getValue());
            continue;
        }
        if (parameterName.equals(EParameterName.PROPERTY_TYPE.getName())) {
            String id = (String) element.getElementParameter(//$NON-NLS-1$
            EParameterName.PROPERTY_TYPE.getName() + ":" + EParameterName.REPOSITORY_PROPERTY_TYPE.getName()).getValue();
            String propertyType = (String) element.getElementParameter(EParameterName.PROPERTY_TYPE.getName() + ":" + EParameterName.PROPERTY_TYPE.getName()).getValue();
            /* 16969 */
            Connection repositoryConnection = null;
            // Map<String, ConnectionItem> repositoryConnectionItemMap =
            // dynamicProperty.getRepositoryConnectionItemMap();
            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;
            }
            // if (repositoryConnectionItemMap.containsKey(id)) {
            // repositoryConnection = repositoryConnectionItemMap.get(id).getConnection();
            // } else {
            // repositoryConnection = null;
            // }
            ChangeValuesFromRepository cmd1 = new ChangeValuesFromRepository(applyTo, repositoryConnection, EParameterName.PROPERTY_TYPE.getName() + ":" + EParameterName.PROPERTY_TYPE.getName(), //$NON-NLS-1$
            propertyType);
            ChangeValuesFromRepository cmd2 = new ChangeValuesFromRepository(applyTo, repositoryConnection, EParameterName.PROPERTY_TYPE.getName() + ":" + EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), //$NON-NLS-1$
            id);
            CompoundCommand cc = new CompoundCommand();
            cc.add(cmd1);
            cc.add(cmd2);
            boolean executed = false;
            if (applyTo instanceof IGEFProcess) {
                IDesignerCoreUIService designerCoreUIService = CoreUIPlugin.getDefault().getDesignerCoreUIService();
                if (designerCoreUIService != null) {
                    executed = designerCoreUIService.executeCommand((IGEFProcess) applyTo, cc);
                }
            }
            if (!executed) {
                cc.execute();
            }
            continue;
        }
        if (PREFERENCE_STORE.getString(LANGUAGE_PREFIX + EParameterName.PROPERTY_TYPE.getName()).equals(EmfComponent.BUILTIN)) {
            if (parameterName.equals(EParameterName.DB_TYPE.getName())) {
                elementParameterType.setValue(element.getElementParameter(EParameterName.DB_TYPE.getName()).getValue());
                continue;
            }
            if (parameterName.equals(EParameterName.HOST.getName())) {
                elementParameterType.setValue(element.getElementParameter(EParameterName.HOST.getName()).getValue());
                continue;
            }
            if (parameterName.equals(EParameterName.PORT.getName())) {
                elementParameterType.setValue(element.getElementParameter(EParameterName.PORT.getName()).getValue());
                continue;
            }
            if (parameterName.equals(EParameterName.DBNAME.getName())) {
                elementParameterType.setValue(element.getElementParameter(EParameterName.DBNAME.getName()).getValue());
                continue;
            }
            if (parameterName.equals(EParameterName.PROPERTIES.getName())) {
                elementParameterType.setValue(element.getElementParameter(EParameterName.PROPERTIES.getName()).getValue());
                continue;
            }
            if (parameterName.equals(EParameterName.DBFILE.getName())) {
                elementParameterType.setValue(element.getElementParameter(EParameterName.DBFILE.getName()).getValue());
                continue;
            }
            if (parameterName.equals(EParameterName.SCHEMA_DB.getName())) {
                elementParameterType.setValue(element.getElementParameter(EParameterName.SCHEMA_DB.getName()).getValue());
                continue;
            }
            if (parameterName.equals(EParameterName.USER.getName())) {
                elementParameterType.setValue(element.getElementParameter(EParameterName.USER.getName()).getValue());
                continue;
            }
            if (parameterName.equals(EParameterName.PASS.getName())) {
                elementParameterType.setValue(element.getElementParameter(EParameterName.PASS.getName()).getValue());
                continue;
            }
            if (parameterName.equals(EParameterName.TABLE_STATS.getName())) {
                elementParameterType.setValue(element.getElementParameter(EParameterName.TABLE_STATS.getName()).getValue());
                continue;
            }
            if (parameterName.equals(EParameterName.TABLE_LOGS.getName())) {
                elementParameterType.setValue(element.getElementParameter(EParameterName.TABLE_LOGS.getName()).getValue());
                continue;
            }
            if (parameterName.equals(EParameterName.TABLE_METER.getName())) {
                elementParameterType.setValue(element.getElementParameter(EParameterName.TABLE_METER.getName()).getValue());
                continue;
            }
            if (parameterName.equals(EParameterName.CATCH_RUNTIME_ERRORS.getName())) {
                elementParameterType.setValue(element.getElementParameter(EParameterName.CATCH_RUNTIME_ERRORS.getName()).getValue());
                continue;
            }
            if (parameterName.equals(EParameterName.CATCH_USER_ERRORS.getName())) {
                elementParameterType.setValue(element.getElementParameter(EParameterName.CATCH_USER_ERRORS.getName()).getValue());
                continue;
            }
            if (parameterName.equals(EParameterName.CATCH_USER_WARNING.getName())) {
                elementParameterType.setValue(element.getElementParameter(EParameterName.CATCH_USER_WARNING.getName()).getValue());
                continue;
            }
            if (parameterName.equals(EParameterName.CATCH_REALTIME_STATS.getName())) {
                elementParameterType.setValue(element.getElementParameter(EParameterName.CATCH_REALTIME_STATS.getName()).getValue());
                continue;
            }
        }
    }
}
Also used : ChangeValuesFromRepository(org.talend.designer.core.ui.editor.cmd.ChangeValuesFromRepository) ConnectionItem(org.talend.core.model.properties.ConnectionItem) Connection(org.talend.core.model.metadata.builder.connection.Connection) IDesignerCoreUIService(org.talend.core.ui.services.IDesignerCoreUIService) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) IGEFProcess(org.talend.core.ui.process.IGEFProcess) ConnectionItem(org.talend.core.model.properties.ConnectionItem) Item(org.talend.core.model.properties.Item) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) IElementParameter(org.talend.core.model.process.IElementParameter) IDynamicProperty(org.talend.core.ui.properties.tab.IDynamicProperty) Property(org.talend.core.model.properties.Property) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 8 with IGEFProcess

use of org.talend.core.ui.process.IGEFProcess in project tdi-studio-se by Talend.

the class ContextParameterExtractor method saveContext.

/**
     * qzhang Comment method "saveContext".
     * 
     * @param parameterName
     * @param elem
     * @param replaceCode
     */
public static void saveContext(final String parameterName, final IElement elem, String replaceCode, IProcess2 process) {
    PropertyChangeCommand cmd = new PropertyChangeCommand(elem, parameterName, replaceCode);
    boolean executed = false;
    if (process != null && process instanceof IGEFProcess) {
        IDesignerCoreUIService designerCoreUIService = CoreUIPlugin.getDefault().getDesignerCoreUIService();
        if (designerCoreUIService != null) {
            executed = designerCoreUIService.executeCommand((IGEFProcess) process, cmd);
        }
    }
    if (!executed) {
        cmd.execute();
    }
// note that no undo will be available
}
Also used : PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) IDesignerCoreUIService(org.talend.core.ui.services.IDesignerCoreUIService) IGEFProcess(org.talend.core.ui.process.IGEFProcess)

Example 9 with IGEFProcess

use of org.talend.core.ui.process.IGEFProcess in project tdi-studio-se by Talend.

the class WebServiceManager method executeCommand.

public void executeCommand(Command cmd) {
    IProcess process = this.getWebServiceComponent().getProcess();
    boolean executed = false;
    if (process != null && process instanceof IGEFProcess) {
        IDesignerCoreUIService designerCoreUIService = CoreUIPlugin.getDefault().getDesignerCoreUIService();
        if (designerCoreUIService != null) {
            executed = designerCoreUIService.executeCommand((IGEFProcess) process, cmd);
        }
    }
    if (!executed) {
        cmd.execute();
    }
}
Also used : IDesignerCoreUIService(org.talend.core.ui.services.IDesignerCoreUIService) IProcess(org.talend.core.model.process.IProcess) IGEFProcess(org.talend.core.ui.process.IGEFProcess)

Aggregations

IGEFProcess (org.talend.core.ui.process.IGEFProcess)9 IDesignerCoreUIService (org.talend.core.ui.services.IDesignerCoreUIService)9 IProcess (org.talend.core.model.process.IProcess)4 IProcess2 (org.talend.core.model.process.IProcess2)4 PropertyChangeCommand (org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand)4 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)3 EUpdateItemType (org.talend.core.model.update.EUpdateItemType)3 IUpdateItemType (org.talend.core.model.update.IUpdateItemType)3 Command (org.eclipse.gef.commands.Command)2 PersistenceException (org.talend.commons.exception.PersistenceException)2 IElementParameter (org.talend.core.model.process.IElementParameter)2 INode (org.talend.core.model.process.INode)2 Item (org.talend.core.model.properties.Item)2 Property (org.talend.core.model.properties.Property)2 Node (org.talend.designer.core.ui.editor.nodes.Node)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 IWorkspace (org.eclipse.core.resources.IWorkspace)1 IWorkspaceRunnable (org.eclipse.core.resources.IWorkspaceRunnable)1