Search in sources :

Example 1 with LoadProjectSettingsCommand

use of org.talend.designer.core.ui.editor.cmd.LoadProjectSettingsCommand in project tdi-studio-se by Talend.

the class ExtraComposite method onReloadPreference.

@Override
protected void onReloadPreference() {
    // ExtraComposite.this);
    if (elem instanceof Process) {
        Process process = (Process) elem;
        LoadProjectSettingsCommand command = new LoadProjectSettingsCommand(process, EParameterName.IMPLICITCONTEXT_USE_PROJECT_SETTINGS.getName(), Boolean.TRUE);
        boolean executed = false;
        IDesignerCoreUIService designerCoreUIService = CoreUIPlugin.getDefault().getDesignerCoreUIService();
        if (designerCoreUIService != null) {
            executed = designerCoreUIService.executeCommand(process, command);
        }
        if (!executed) {
            command.execute();
        }
    }
}
Also used : LoadProjectSettingsCommand(org.talend.designer.core.ui.editor.cmd.LoadProjectSettingsCommand) Process(org.talend.designer.core.ui.editor.process.Process) IDesignerCoreUIService(org.talend.core.ui.services.IDesignerCoreUIService)

Example 2 with LoadProjectSettingsCommand

use of org.talend.designer.core.ui.editor.cmd.LoadProjectSettingsCommand in project tdi-studio-se by Talend.

the class StatsAndLogsComposite method onReloadPreference.

@Override
protected void onReloadPreference() {
    // StatsAndLogsComposite.this);
    if (elem instanceof Process) {
        Process process = (Process) elem;
        LoadProjectSettingsCommand command = new LoadProjectSettingsCommand(process, EParameterName.STATANDLOG_USE_PROJECT_SETTINGS.getName(), Boolean.TRUE);
        boolean executed = false;
        IDesignerCoreUIService designerCoreUIService = CoreUIPlugin.getDefault().getDesignerCoreUIService();
        if (designerCoreUIService != null) {
            executed = designerCoreUIService.executeCommand(process, command);
        }
        if (!executed) {
            command.execute();
        }
    }
}
Also used : LoadProjectSettingsCommand(org.talend.designer.core.ui.editor.cmd.LoadProjectSettingsCommand) Process(org.talend.designer.core.ui.editor.process.Process) IDesignerCoreUIService(org.talend.core.ui.services.IDesignerCoreUIService)

Example 3 with LoadProjectSettingsCommand

use of org.talend.designer.core.ui.editor.cmd.LoadProjectSettingsCommand in project tdi-studio-se by Talend.

the class AbstractJobSettingsPage method saveProcess.

protected void saveProcess(IRepositoryViewObject object, boolean addContextModel, Map<String, Set<String>> contextVars, IProgressMonitor monitor) {
    Property property = object.getProperty();
    ProcessItem pItem = (ProcessItem) property.getItem();
    if (isOpenProcess(object)) {
        Process process = getProcess(openedProcessList, object);
        LoadProjectSettingsCommand command = new LoadProjectSettingsCommand(process, getParameterName().getName(), Boolean.TRUE);
        exeCommand(process, command);
        //
        IElementParameter ptParam = elem.getElementParameterFromField(EParameterFieldType.PROPERTY_TYPE);
        if (ptParam != null) {
            IElementParameter propertyElem = ptParam.getChildParameters().get(EParameterName.PROPERTY_TYPE.getName());
            Object proValue = propertyElem.getValue();
            if (proValue instanceof String && ((String) proValue).equalsIgnoreCase(EmfComponent.REPOSITORY)) {
                IElementParameter repositoryElem = ptParam.getChildParameters().get(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
                String value = (String) repositoryElem.getValue();
                ConnectionItem connectionItem = UpdateRepositoryUtils.getConnectionItemByItemId(value);
                if (connectionItem != null) {
                    Connection connection = connectionItem.getConnection();
                    ChangeValuesFromRepository cmd = new ChangeValuesFromRepository(process, connection, addContextModel ? getRepositoryPropertyName() : getPropertyTypeName(), value);
                    cmd.ignoreContextMode(true);
                    exeCommand(process, cmd);
                }
            }
        }
        monitor.worked(100);
    } else {
        try {
            reloadFromProjectSetings(pItem, addContextModel, contextVars);
            factory.save(pItem);
            monitor.worked(100);
        } catch (PersistenceException e) {
            ExceptionHandler.process(e);
        }
    }
}
Also used : ProcessItem(org.talend.core.model.properties.ProcessItem) LoadProjectSettingsCommand(org.talend.designer.core.ui.editor.cmd.LoadProjectSettingsCommand) ChangeValuesFromRepository(org.talend.designer.core.ui.editor.cmd.ChangeValuesFromRepository) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) PersistenceException(org.talend.commons.exception.PersistenceException) IElementParameter(org.talend.core.model.process.IElementParameter) Process(org.talend.designer.core.ui.editor.process.Process) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) Property(org.talend.core.model.properties.Property) RepositoryToComponentProperty(org.talend.core.model.metadata.designerproperties.RepositoryToComponentProperty)

Example 4 with LoadProjectSettingsCommand

use of org.talend.designer.core.ui.editor.cmd.LoadProjectSettingsCommand in project tdi-studio-se by Talend.

the class StatLogsAndImplicitcontextTreeViewPage method saveProcess.

private void saveProcess(RepositoryNode node, String paramName, Boolean isUseProjectSettings, boolean addContextModel, Map<String, Set<String>> contextVars, IProgressMonitor monitor) {
    Property property = node.getObject().getProperty();
    ProcessItem pItem = (ProcessItem) property.getItem();
    ParametersType pType = pItem.getProcess().getParameters();
    if (isOpenProcess(node)) {
        Process process = getProcess(opendProcess, node);
        LoadProjectSettingsCommand command = new LoadProjectSettingsCommand(process, paramName, isUseProjectSettings);
        exeCommand(process, command);
        Element elem = null;
        String propertyName = "";
        String propertyTypeName = "";
        if (EParameterName.IMPLICITCONTEXT_USE_PROJECT_SETTINGS.getName().equals(paramName)) {
            elem = (Element) pro.getInitialContextLoad();
            propertyName = JobSettingsConstants.getExtraParameterName(EParameterName.PROPERTY_TYPE.getName()) + ':' + EParameterName.REPOSITORY_PROPERTY_TYPE.getName();
            propertyTypeName = JobSettingsConstants.getExtraParameterName(EParameterName.PROPERTY_TYPE.getName()) + ':' + EParameterName.PROPERTY_TYPE.getName();
        } else if (EParameterName.STATANDLOG_USE_PROJECT_SETTINGS.getName().equals(paramName)) {
            elem = (Element) pro.getStatsAndLog();
            propertyName = EParameterName.PROPERTY_TYPE.getName() + ':' + EParameterName.REPOSITORY_PROPERTY_TYPE.getName();
            propertyTypeName = EParameterName.PROPERTY_TYPE.getName() + ':' + EParameterName.PROPERTY_TYPE.getName();
        }
        IElementParameter ptParam = elem.getElementParameterFromField(EParameterFieldType.PROPERTY_TYPE);
        if (ptParam != null) {
            IElementParameter propertyElem = ptParam.getChildParameters().get(EParameterName.PROPERTY_TYPE.getName());
            Object proValue = propertyElem.getValue();
            if (proValue instanceof String && ((String) proValue).equalsIgnoreCase(EmfComponent.REPOSITORY)) {
                IElementParameter repositoryElem = ptParam.getChildParameters().get(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
                String value = (String) repositoryElem.getValue();
                ConnectionItem connectionItem = UpdateRepositoryUtils.getConnectionItemByItemId(value);
                if (connectionItem != null) {
                    Connection connection = connectionItem.getConnection();
                    ChangeValuesFromRepository cmd = new ChangeValuesFromRepository(process, connection, addContextModel ? propertyName : propertyTypeName, value);
                    cmd.ignoreContextMode(true);
                    exeCommand(process, cmd);
                }
            }
        }
        monitor.worked(100);
    } else {
        ElementParameter2ParameterType.setParameterValue(pType, paramName, isUseProjectSettings);
        if (isUseProjectSettings) {
            if (EParameterName.IMPLICITCONTEXT_USE_PROJECT_SETTINGS.getName().equals(paramName)) {
                ProjectSettingManager.reloadImplicitValuesFromProjectSettings(pType, ProjectManager.getInstance().getCurrentProject());
            } else if (EParameterName.STATANDLOG_USE_PROJECT_SETTINGS.getName().equals(paramName)) {
                ProjectSettingManager.reloadStatsAndLogFromProjectSettings(pType, ProjectManager.getInstance().getCurrentProject());
            }
        }
        if (addContextModel && contextVars != null && !contextVars.isEmpty() && ContextUtils.getAllContextItem() != null) {
            ContextUtils.addInContextModelForProcessItem(pItem, contextVars, ContextUtils.getAllContextItem());
        }
        try {
            factory.save(pItem);
            monitor.worked(100);
        } catch (PersistenceException e) {
            ExceptionHandler.process(e);
        }
    }
}
Also used : LoadProjectSettingsCommand(org.talend.designer.core.ui.editor.cmd.LoadProjectSettingsCommand) ChangeValuesFromRepository(org.talend.designer.core.ui.editor.cmd.ChangeValuesFromRepository) ConnectionItem(org.talend.core.model.properties.ConnectionItem) Element(org.talend.core.model.process.Element) Connection(org.talend.core.model.metadata.builder.connection.Connection) IProcess(org.talend.core.model.process.IProcess) Process(org.talend.designer.core.ui.editor.process.Process) ProcessItem(org.talend.core.model.properties.ProcessItem) PersistenceException(org.talend.commons.exception.PersistenceException) IElementParameter(org.talend.core.model.process.IElementParameter) ParametersType(org.talend.designer.core.model.utils.emf.talendfile.ParametersType) Property(org.talend.core.model.properties.Property)

Aggregations

LoadProjectSettingsCommand (org.talend.designer.core.ui.editor.cmd.LoadProjectSettingsCommand)4 Process (org.talend.designer.core.ui.editor.process.Process)4 PersistenceException (org.talend.commons.exception.PersistenceException)2 Connection (org.talend.core.model.metadata.builder.connection.Connection)2 IElementParameter (org.talend.core.model.process.IElementParameter)2 ConnectionItem (org.talend.core.model.properties.ConnectionItem)2 ProcessItem (org.talend.core.model.properties.ProcessItem)2 Property (org.talend.core.model.properties.Property)2 IDesignerCoreUIService (org.talend.core.ui.services.IDesignerCoreUIService)2 ChangeValuesFromRepository (org.talend.designer.core.ui.editor.cmd.ChangeValuesFromRepository)2 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)1 RepositoryToComponentProperty (org.talend.core.model.metadata.designerproperties.RepositoryToComponentProperty)1 Element (org.talend.core.model.process.Element)1 IProcess (org.talend.core.model.process.IProcess)1 DatabaseConnectionItem (org.talend.core.model.properties.DatabaseConnectionItem)1 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)1 ParametersType (org.talend.designer.core.model.utils.emf.talendfile.ParametersType)1