Search in sources :

Example 1 with IDesignerCoreUIService

use of org.talend.core.ui.services.IDesignerCoreUIService in project tdi-studio-se by Talend.

the class MultiSchemasManager method executeCommand.

public void executeCommand(Command cmd) {
    IProcess process = this.getMultiSchemasComponent().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)

Example 2 with IDesignerCoreUIService

use of org.talend.core.ui.services.IDesignerCoreUIService in project tdi-studio-se by Talend.

the class MavenVersionManagementProjectSettingPage method updateItemsVersion.

protected void updateItemsVersion() {
    List<ItemVersionObject> JobsOpenedInEditor = new ArrayList<ItemVersionObject>();
    List<ItemVersionObject> closedJobs = new ArrayList<ItemVersionObject>();
    boolean hasJobOpenedInEditor = false;
    StringBuilder builder = new StringBuilder();
    for (ItemVersionObject object : checkedObjects) {
        if (RepositoryManager.isOpenedItemInEditor(object.getRepositoryNode().getObject())) {
            hasJobOpenedInEditor = true;
            JobsOpenedInEditor.add(object);
            //$NON-NLS-1$
            builder.append(object.getRepositoryNode().getObject().getLabel() + ", ");
        } else {
            closedJobs.add(object);
        }
    }
    if (builder.length() > 0) {
        builder.delete(builder.length() - 2, builder.length());
    }
    if (hasJobOpenedInEditor) {
        MessageDialog.openWarning(Display.getCurrent().getActiveShell(), //$NON-NLS-1$
        Messages.getString("VersionManagementDialog.WarningTitle2"), //$NON-NLS-1$
        Messages.getString("VersionManagementDialog.openedInEditorMessage", builder.toString()));
        IWorkbenchWindow workBench = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
        if (workBench != null) {
            IWorkbenchPage page = workBench.getActivePage();
            IEditorReference[] editorRefs = page.getEditorReferences();
            if (GlobalServiceRegister.getDefault().isServiceRegistered(IDesignerCoreUIService.class)) {
                IDesignerCoreUIService service = (IDesignerCoreUIService) GlobalServiceRegister.getDefault().getService(IDesignerCoreUIService.class);
                if (service != null) {
                    for (IEditorReference editorRef : editorRefs) {
                        IEditorPart editor = editorRef.getEditor(false);
                        if (editor instanceof IMultiPageTalendEditor) {
                            IProcess2 process = ((IMultiPageTalendEditor) editor).getProcess();
                            String version = null;
                            for (ItemVersionObject object : JobsOpenedInEditor) {
                                if (object.getItem().getProperty().getId().equals(process.getId())) {
                                    version = object.getNewVersion();
                                    break;
                                }
                            }
                            if (version != null) {
                                String jobDefaultVersion = MavenVersionUtils.getDefaultVersion(process.getProperty().getVersion());
                                if (version.equals(jobDefaultVersion)) {
                                    // if default, set null to remove key from property.
                                    version = null;
                                }
                                Command command = service.crateMavenDeploymentValueChangeCommand(process, MavenConstants.NAME_USER_VERSION, version);
                                if (process instanceof IGEFProcess) {
                                    service.executeCommand((IGEFProcess) process, command);
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    final IWorkspaceRunnable runnable = new IWorkspaceRunnable() {

        @Override
        public void run(final IProgressMonitor monitor) throws CoreException {
            RepositoryWorkUnit<Object> rwu = new //$NON-NLS-1$
            RepositoryWorkUnit<Object>(//$NON-NLS-1$
            project, //$NON-NLS-1$
            "Update items Maven version") {

                @Override
                protected void run() throws LoginException, PersistenceException {
                    //$NON-NLS-1$
                    monitor.beginTask("Update items Maven version", closedJobs.size());
                    for (ItemVersionObject object : closedJobs) {
                        final Item item = object.getItem();
                        Property itemProperty = item.getProperty();
                        MavenVersionUtils.setItemMavenVersion(itemProperty, object.getNewVersion());
                        monitor.subTask(itemProperty.getLabel());
                        FACTORY.save(project, itemProperty);
                        monitor.worked(1);
                    }
                    try {
                        FACTORY.saveProject(project);
                    } catch (PersistenceException e) {
                        ExceptionHandler.process(e);
                    }
                }
            };
            rwu.setAvoidUnloadResources(true);
            rwu.executeRun();
            monitor.done();
        }
    };
    IRunnableWithProgress iRunnableWithProgress = new IRunnableWithProgress() {

        @Override
        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            IWorkspace workspace = ResourcesPlugin.getWorkspace();
            try {
                ISchedulingRule schedulingRule = workspace.getRoot();
                // the update the project files need to be done in the workspace runnable to avoid all notification
                // of changes before the end of the modifications.
                workspace.run(runnable, schedulingRule, IWorkspace.AVOID_UPDATE, monitor);
            } catch (CoreException e) {
                ExceptionHandler.process(e);
            }
        }
    };
    final ProgressMonitorDialog dialog = new ProgressMonitorDialog(null);
    try {
        dialog.run(false, false, iRunnableWithProgress);
    } catch (InvocationTargetException | InterruptedException e) {
        ExceptionHandler.process(e);
    }
}
Also used : ArrayList(java.util.ArrayList) RepositoryWorkUnit(org.talend.repository.RepositoryWorkUnit) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IMultiPageTalendEditor(org.talend.designer.core.IMultiPageTalendEditor) Item(org.talend.core.model.properties.Item) TableItem(org.eclipse.swt.widgets.TableItem) IEditorReference(org.eclipse.ui.IEditorReference) Property(org.talend.core.model.properties.Property) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IWorkspaceRunnable(org.eclipse.core.resources.IWorkspaceRunnable) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) IDesignerCoreUIService(org.talend.core.ui.services.IDesignerCoreUIService) IEditorPart(org.eclipse.ui.IEditorPart) InvocationTargetException(java.lang.reflect.InvocationTargetException) IGEFProcess(org.talend.core.ui.process.IGEFProcess) ISchedulingRule(org.eclipse.core.runtime.jobs.ISchedulingRule) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) Command(org.eclipse.gef.commands.Command) IWorkspace(org.eclipse.core.resources.IWorkspace) IProcess2(org.talend.core.model.process.IProcess2) PersistenceException(org.talend.commons.exception.PersistenceException) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) ItemVersionObject(org.talend.repository.model.ItemVersionObject) ItemVersionObject(org.talend.repository.model.ItemVersionObject)

Example 3 with IDesignerCoreUIService

use of org.talend.core.ui.services.IDesignerCoreUIService 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 4 with IDesignerCoreUIService

use of org.talend.core.ui.services.IDesignerCoreUIService in project tdi-studio-se by Talend.

the class JobJavaScriptsManager method getExportResources.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.talend.repository.ui.wizards.exportjob.JobScriptsManager#getExportResources(org.talend.core.model.properties
     * .ProcessItem[], boolean, boolean, boolean, boolean, boolean, boolean, boolean, java.lang.String)
     */
@Override
public List<ExportFileResource> getExportResources(ExportFileResource[] process, String... codeOptions) throws ProcessorException {
    exportFileResource = process;
    for (int i = 0; i < process.length; i++) {
        ProcessItem processItem = (ProcessItem) process[i].getItem();
        String selectedJobVersion = processItem.getProperty().getVersion();
        selectedJobVersion = preExportResource(process, i, selectedJobVersion);
        IProcess jobProcess = null;
        // code is just kept like this to avoid too big changes right now.
        if (!isOptionChoosed(ExportChoice.doNotCompileCode)) {
            if (contextName != null) {
                jobProcess = generateJobFiles(processItem, contextName, selectedJobVersion, statisticPort != IProcessor.NO_STATISTICS || isOptionChoosed(ExportChoice.addStatistics), tracePort != IProcessor.NO_TRACES, isOptionChoosed(ExportChoice.applyToChildren), progressMonitor);
            }
            analysisModules(processItem.getProperty().getId(), selectedJobVersion);
        } else {
            LastGenerationInfo.getInstance().setModulesNeededWithSubjobPerJob(processItem.getProperty().getId(), processItem.getProperty().getVersion(), Collections.<ModuleNeeded>emptySet());
            LastGenerationInfo.getInstance().setLastMainJob(null);
        }
        List<URL> resources = new ArrayList<URL>();
        List<URL> childrenList = new ArrayList<URL>();
        if (CommonsPlugin.isHeadless()) {
            childrenList = posExportResource(process, exportChoice, contextName, launcher, statisticPort, tracePort, i, jobProcess, processItem, selectedJobVersion, resources, codeOptions);
        } else {
            String log4jOption = getLog4jLevel() != null ? TalendProcessArgumentConstant.CMD_ARG_LOG4J_LEVEL + getLog4jLevel().toLowerCase() : null;
            String[] newCodeOptions = codeOptions;
            if (!ArrayUtils.contains(codeOptions, log4jOption)) {
                newCodeOptions = (String[]) ArrayUtils.add(codeOptions, log4jOption);
            }
            childrenList = posExportResource(process, exportChoice, contextName, launcher, statisticPort, tracePort, i, jobProcess, processItem, selectedJobVersion, resources, newCodeOptions);
        }
        resources.addAll(childrenList);
        process[i].addResources(resources);
    // Gets job designer resouce
    // List<URL> srcList = getSource(processItem, exportChoice.get(ExportChoice.needSource));
    // process[i].addResources(JOB_SOURCE_FOLDER_NAME, srcList);
    }
    // Exports the system libs
    List<ExportFileResource> list = new ArrayList<ExportFileResource>(Arrays.asList(process));
    // Add the java system libraries
    ExportFileResource libResource = getCompiledLibExportFileResource(process);
    list.add(libResource);
    // Gets jobInfo.properties
    // only addClasspathJar not check in preferences ,then export the jobInfo.properties
    boolean addClasspathJar = false;
    IDesignerCoreUIService designerCoreUIService = CoreUIPlugin.getDefault().getDesignerCoreUIService();
    if (designerCoreUIService != null) {
        addClasspathJar = designerCoreUIService.getPreferenceStore().getBoolean(IRepositoryPrefConstants.ADD_CLASSPATH_JAR);
    }
    if (!addClasspathJar) {
        if (!(process.length > 1)) {
            for (ExportFileResource pro : process) {
                ExportFileResource jobInfoResource = new ExportFileResource(null, PATH_SEPARATOR);
                if (CommonsPlugin.isHeadless()) {
                    jobInfoResource = new ExportFileResource();
                }
                list.add(jobInfoResource);
                List<URL> jobInfoList = getJobInfoFile(pro, contextName);
                jobInfoResource.addResources(jobInfoList);
            }
        }
    }
    if (PluginChecker.isRulesPluginLoaded()) {
        // hywang add for 6484,add final drl files or xls files to exported job script
        //$NON-NLS-1$
        ExportFileResource ruleFileResource = new ExportFileResource(null, "Rules/rules/final");
        list.add(ruleFileResource);
        try {
            Map<String, List<URL>> map = initUrlForRulesFiles(process);
            Object[] keys = map.keySet().toArray();
            for (Object key : keys) {
                List<URL> talendDrlFiles = map.get(key.toString());
                ruleFileResource.addResources(key.toString(), talendDrlFiles);
            }
        } catch (CoreException e) {
            ExceptionHandler.process(e);
        } catch (MalformedURLException e) {
            ExceptionHandler.process(e);
        } catch (PersistenceException e) {
            ExceptionHandler.process(e);
        }
    }
    return list;
}
Also used : MalformedURLException(java.net.MalformedURLException) ArrayList(java.util.ArrayList) IDesignerCoreUIService(org.talend.core.ui.services.IDesignerCoreUIService) URL(java.net.URL) ProcessItem(org.talend.core.model.properties.ProcessItem) CoreException(org.eclipse.core.runtime.CoreException) ExportFileResource(org.talend.repository.documentation.ExportFileResource) PersistenceException(org.talend.commons.exception.PersistenceException) ArrayList(java.util.ArrayList) List(java.util.List) EList(org.eclipse.emf.common.util.EList) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IProcess(org.talend.core.model.process.IProcess)

Example 5 with IDesignerCoreUIService

use of org.talend.core.ui.services.IDesignerCoreUIService 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)

Aggregations

IDesignerCoreUIService (org.talend.core.ui.services.IDesignerCoreUIService)17 IGEFProcess (org.talend.core.ui.process.IGEFProcess)9 ArrayList (java.util.ArrayList)5 IProcess (org.talend.core.model.process.IProcess)5 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)5 PersistenceException (org.talend.commons.exception.PersistenceException)4 IProcess2 (org.talend.core.model.process.IProcess2)4 PropertyChangeCommand (org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand)4 List (java.util.List)3 CoreException (org.eclipse.core.runtime.CoreException)3 EList (org.eclipse.emf.common.util.EList)3 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)3 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)3 EUpdateItemType (org.talend.core.model.update.EUpdateItemType)3 Command (org.eclipse.gef.commands.Command)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 ProcessItem (org.talend.core.model.properties.ProcessItem)2 Property (org.talend.core.model.properties.Property)2