Search in sources :

Example 1 with IGEFProcess

use of org.talend.core.ui.process.IGEFProcess 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 IGEFProcess

use of org.talend.core.ui.process.IGEFProcess 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 IGEFProcess

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

the class SubjobContainerFigure method initFigure.

/**
     * DOC rdubois Comment method "initFigure".
     */
protected void initFigure() {
    outlineFigure = new RoundedRectangle();
    rectFig = new RoundedRectangle();
    titleFigure = new SimpleHtmlFigure();
    titleFigure.setOpaque(true);
    collapseFigure = new SubjobCollapseFigure();
    collapseFigure.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            IProcess2 process = subjobContainer.getProcess();
            if (!process.isReadOnly()) {
                PropertyChangeCommand ppc = new PropertyChangeCommand(subjobContainer, EParameterName.COLLAPSED.getName(), !subjobContainer.isCollapsed());
                boolean executed = false;
                if (process instanceof IGEFProcess) {
                    IDesignerCoreUIService designerCoreUIService = CoreUIPlugin.getDefault().getDesignerCoreUIService();
                    if (designerCoreUIService != null) {
                        executed = designerCoreUIService.executeCommand((IGEFProcess) process, ppc);
                    }
                }
                if (!executed) {
                    ppc.execute();
                }
                reSelection();
            }
        }
    });
}
Also used : PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) ActionListener(org.eclipse.draw2d.ActionListener) ActionEvent(org.eclipse.draw2d.ActionEvent) IProcess2(org.talend.core.model.process.IProcess2) IDesignerCoreUIService(org.talend.core.ui.services.IDesignerCoreUIService) RoundedRectangle(org.eclipse.draw2d.RoundedRectangle) SimpleHtmlFigure(org.talend.commons.ui.utils.workbench.gef.SimpleHtmlFigure) IGEFProcess(org.talend.core.ui.process.IGEFProcess)

Example 4 with IGEFProcess

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

the class UpdateNodeParameterCommand method execute.

@Override
public void execute() {
    if (result == null) {
        return;
    }
    Object updateObject = result.getUpdateObject();
    if (updateObject == null || (!(updateObject instanceof Node)) || (!(result.getJob() instanceof IProcess))) {
        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;
        }
    }
    IUpdateItemType updateType = result.getUpdateType();
    if (updateType instanceof EUpdateItemType) {
        switch((EUpdateItemType) updateType) {
            case NODE_PROPERTY:
                updateProperty();
                break;
            case NODE_SCHEMA:
                updateSchema();
                break;
            case NODE_QUERY:
                updateQuery();
                break;
            case NODE_SAP_FUNCTION:
                updateSAPParameters();
                break;
            case NODE_SAP_IDOC:
                updateSAPIDocParameters();
                break;
            case NODE_VALIDATION_RULE:
                updateValidationRule();
                break;
            default:
                return;
        }
    }
    // else { // for extension
    Node node = (Node) updateObject;
    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 : INode(org.talend.core.model.process.INode) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) Node(org.talend.designer.core.ui.editor.nodes.Node) IExternalNode(org.talend.core.model.process.IExternalNode) INode(org.talend.core.model.process.INode) IProcess2(org.talend.core.model.process.IProcess2) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IUpdateItemType(org.talend.core.model.update.IUpdateItemType) IDesignerCoreUIService(org.talend.core.ui.services.IDesignerCoreUIService) EUpdateItemType(org.talend.core.model.update.EUpdateItemType) IProcess(org.talend.core.model.process.IProcess) IGEFProcess(org.talend.core.ui.process.IGEFProcess)

Example 5 with IGEFProcess

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

the class UpdateManagerUtils method executeUpdate.

private static void executeUpdate(UpdateResult result, IProgressMonitor monitor, boolean updateAllJobs) {
    if (result.isReadOnlyProcess()) {
        return;
    }
    // update
    Command command = null;
    IUpdateItemType updateType = result.getUpdateType();
    if (updateType instanceof EUpdateItemType) {
        switch((EUpdateItemType) updateType) {
            case NODE_PROPERTY:
            case NODE_SCHEMA:
            case NODE_QUERY:
            case NODE_SAP_IDOC:
            case NODE_SAP_FUNCTION:
            case NODE_VALIDATION_RULE:
                command = new UpdateNodeParameterCommand(result);
                break;
            case JOB_PROPERTY_EXTRA:
            case JOB_PROPERTY_STATS_LOGS:
            case JOB_PROPERTY_HEADERFOOTER:
            case JOB_PROPERTY_STORM:
            case JOB_PROPERTY_MAPREDUCE:
                command = new UpdateMainParameterCommand(result);
                break;
            case CONTEXT:
                command = executeContextUpdates(result);
                break;
            case CONTEXT_GROUP:
                command = executeContextGroupUpdates(result);
                break;
            case JOBLET_RENAMED:
            case JOBLET_SCHEMA:
            case RELOAD:
                command = executeJobletNodesUpdates(result);
                break;
            case JUNIT_RELOAD:
                command = executeJunitNodesUpdates(result);
                break;
            // break;
            case MAP_PATH:
                command = new UpdateNodePathCommand(result);
                break;
            default:
                break;
        }
    }
    if (command != null) {
        SubProgressMonitor subMonitor = new SubProgressMonitor(monitor, 1 * UpdatesConstants.SCALE, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
        subMonitor.beginTask(UpdatesConstants.EMPTY, 1);
        subMonitor.subTask(getResultTaskInfor(result));
        //
        Object job = result.getJob();
        boolean executed = false;
        if (job != null && job instanceof IGEFProcess) {
            IDesignerCoreUIService designerCoreUIService = CoreUIPlugin.getDefault().getDesignerCoreUIService();
            if (designerCoreUIService != null) {
                executed = designerCoreUIService.executeCommand((IGEFProcess) job, command);
            }
        }
        if (!executed) {
            command.execute();
        }
        subMonitor.worked(1);
    }
    // from extension point
    UpdateManagerProviderDetector.INSTANCE.doUpdate(monitor, result);
}
Also used : UpdateNodeParameterCommand(org.talend.designer.core.ui.editor.update.cmd.UpdateNodeParameterCommand) UpdateContextParameterCommand(org.talend.designer.core.ui.editor.update.cmd.UpdateContextParameterCommand) UpdateNodePathCommand(org.talend.designer.core.ui.editor.update.cmd.UpdateNodePathCommand) Command(org.eclipse.gef.commands.Command) UpdateMainParameterCommand(org.talend.designer.core.ui.editor.update.cmd.UpdateMainParameterCommand) UpdateJobletNodeCommand(org.talend.designer.core.ui.editor.update.cmd.UpdateJobletNodeCommand) UpdateNodeParameterCommand(org.talend.designer.core.ui.editor.update.cmd.UpdateNodeParameterCommand) UpdateJunitNodeCommand(org.talend.designer.core.ui.editor.update.cmd.UpdateJunitNodeCommand) UpdateMainParameterCommand(org.talend.designer.core.ui.editor.update.cmd.UpdateMainParameterCommand) IUpdateItemType(org.talend.core.model.update.IUpdateItemType) UpdateNodePathCommand(org.talend.designer.core.ui.editor.update.cmd.UpdateNodePathCommand) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IDesignerCoreUIService(org.talend.core.ui.services.IDesignerCoreUIService) EUpdateItemType(org.talend.core.model.update.EUpdateItemType) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor) 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