Search in sources :

Example 1 with AbstractMultiPageTalendEditor

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

the class ToolbarInputZone method addPreviewToolItems.

private void addPreviewToolItems() {
    if (PluginChecker.isTraceDebugPluginLoaded() && getMapperManager().isTracesActive()) {
        final RunProcessContext activeContext = RunProcessPlugin.getDefault().getRunProcessContextManager().getActiveContext();
        if (activeContext == null) {
            return;
        }
        new ToolItem(getToolBarActions(), SWT.SEPARATOR);
        previousRow = new ToolItem(getToolBarActions(), SWT.PUSH);
        previousRow.setEnabled(activeContext.isRunning());
        previousRow.setToolTipText("Previous Row");
        previousRow.setImage(ImageProvider.getImage(EImage.LEFT_ICON));
        currentRowLabel = new ToolItem(getToolBarActions(), SWT.PUSH | SWT.BORDER);
        currentRowLabel.setEnabled(false);
        currentRowLabel.setText(getCurrentRowString());
        currentRowLabel.setToolTipText("Current Row");
        currentRowLabel.setWidth(50);
        nextRow = new ToolItem(getToolBarActions(), SWT.PUSH);
        nextRow.setEnabled(!getMapperManager().componentIsReadOnly());
        nextRow.setToolTipText("Next Row");
        nextRow.setImage(ImageProvider.getImage(EImage.RIGHT_ICON));
        nextBreakpoint = new ToolItem(getToolBarActions(), SWT.PUSH);
        nextBreakpoint.setToolTipText("Next Breakpoint");
        nextBreakpoint.setImage(ImageProvider.getImage(EImage.RIGHTX_ICON));
        Boolean bc = activeContext.checkBreakpoint();
        if (!bc) {
            nextBreakpoint.setEnabled(bc);
        } else {
            nextBreakpoint.setEnabled(activeContext.isRunning());
        }
        killBtn = new ToolItem(getToolBarActions(), SWT.PUSH);
        killBtn.setToolTipText("Kill");
        killBtn.setImage(ImageProvider.getImage(ERunprocessImages.KILL_PROCESS_ACTION));
        killBtn.setEnabled(activeContext.isRunning());
        previousRow.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                activeContext.setPreviousRow(true);
            }
        });
        nextRow.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                if (!activeContext.isRunning()) {
                    for (DataMapTableView dataMapTableView : getMapperManager().getUiManager().getOutputsTablesView()) {
                        dataMapTableView.notifyFocusLost();
                    }
                    if (getMapperManager().isDataChanged()) {
                        boolean closeWindow = MessageDialog.openConfirm(getComposite().getShell(), //$NON-NLS-1$
                        "tMap configuration modified", //$NON-NLS-1$
                        "Do you want to apply the modification of the tMap now ?");
                        // save change and regenerate code
                        if (closeWindow) {
                            IExternalNode externalNode = getMapperManager().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);
                                }
                            }
                        }
                    }
                    activeContext.setLastIsRow(true);
                    IDebugProcessService service = (IDebugProcessService) GlobalServiceRegister.getDefault().getService(IDebugProcessService.class);
                    service.debugProcess();
                } else {
                    activeContext.setNextRow(true);
                }
            }
        });
        nextBreakpoint.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                activeContext.setNextBreakPoint(true);
            }
        });
        killBtn.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                IDebugProcessService service = (IDebugProcessService) GlobalServiceRegister.getDefault().getService(IDebugProcessService.class);
                service.debugKill();
                killBtn.setEnabled(false);
                previousRow.setEnabled(false);
                nextBreakpoint.setEnabled(false);
            }
        });
        propertyListener = new PropertyChangeListener() {

            public void propertyChange(final PropertyChangeEvent evt) {
                final String propName = evt.getPropertyName();
                ProcessManager.getInstance().getProcessShell().getDisplay().syncExec(new Runnable() {

                    public void run() {
                        if (RunProcessContext.PREVIOUS_ROW.equals(propName)) {
                            boolean enabled = ((Boolean) evt.getNewValue()).booleanValue();
                            if (!previousRow.isDisposed() && enabled != previousRow.isEnabled()) {
                                previousRow.setEnabled(enabled);
                            }
                        } else if (RunProcessContext.PROP_RUNNING.equals(propName)) {
                            boolean enabled = ((Boolean) evt.getNewValue()).booleanValue();
                            if (!previousRow.isDisposed() && enabled != previousRow.isEnabled()) {
                                previousRow.setEnabled(enabled);
                            }
                            if (!nextBreakpoint.isDisposed() && enabled != nextBreakpoint.isEnabled()) {
                                Boolean bc = activeContext.checkBreakpoint();
                                if (!bc) {
                                    nextBreakpoint.setEnabled(bc);
                                } else {
                                    nextBreakpoint.setEnabled(enabled);
                                }
                            }
                            if (!killBtn.isDisposed() && enabled != killBtn.isEnabled()) {
                                killBtn.setEnabled(enabled);
                            }
                            if (!nextRow.isDisposed()) {
                                nextRow.setEnabled(true);
                            }
                        } else if (RunProcessContext.NEXTBREAKPOINT.equals(propName)) {
                            boolean running = ((Boolean) evt.getNewValue()).booleanValue();
                            if (!nextBreakpoint.isDisposed()) {
                                nextBreakpoint.setEnabled(running);
                            }
                            if (!nextRow.isDisposed()) {
                                nextRow.setEnabled(true);
                            }
                        } else if (RunProcessContext.BREAKPOINT_BAR.equals(propName)) {
                            boolean enable = ((Boolean) evt.getNewValue()).booleanValue();
                            if (!enable) {
                                if (!previousRow.isDisposed()) {
                                    previousRow.setEnabled(false);
                                }
                                if (!nextRow.isDisposed()) {
                                    nextRow.setEnabled(false);
                                }
                                if (!nextBreakpoint.isDisposed()) {
                                    nextBreakpoint.setEnabled(false);
                                }
                            }
                        }
                    }
                });
            }
        };
        activeContext.addPropertyChangeListener(propertyListener);
    }
}
Also used : CommandStack(org.eclipse.gef.commands.CommandStack) RunProcessContext(org.talend.designer.runprocess.RunProcessContext) INode(org.talend.core.model.process.INode) PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) Node(org.talend.designer.core.ui.editor.nodes.Node) IExternalNode(org.talend.core.model.process.IExternalNode) INode(org.talend.core.model.process.INode) DataMapTableView(org.talend.designer.mapper.ui.visualmap.table.DataMapTableView) ExternalNodeChangeCommand(org.talend.designer.core.ui.editor.cmd.ExternalNodeChangeCommand) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) ExternalNodeChangeCommand(org.talend.designer.core.ui.editor.cmd.ExternalNodeChangeCommand) Command(org.eclipse.gef.commands.Command) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IDebugProcessService(org.talend.core.model.runprocess.IDebugProcessService) ToolItem(org.eclipse.swt.widgets.ToolItem) IExternalNode(org.talend.core.model.process.IExternalNode)

Example 2 with AbstractMultiPageTalendEditor

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

the class JobletContainerFigure method reSelection.

private void reSelection() {
    // select the start node.
    if (jobletContainer.isCollapsed()) {
        IProcess2 process = jobletContainer.getProcess();
        if (process == null) {
            return;
        }
        AbstractMultiPageTalendEditor editor = (AbstractMultiPageTalendEditor) process.getEditor();
        Node startNode = jobletContainer.getJobletStartNode();
        if (startNode != null && editor != null) {
            editor.selectNode(startNode);
        }
    }
}
Also used : AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) Node(org.talend.designer.core.ui.editor.nodes.Node) IProcess2(org.talend.core.model.process.IProcess2)

Example 3 with AbstractMultiPageTalendEditor

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

the class ComponentChooseDialog method getJobletPart.

public AbstractMultiPageTalendEditor getJobletPart(JobletContainerPart part) {
    AbstractMultiPageTalendEditor openEditor = null;
    Node jobletNode = ((JobletContainer) part.getModel()).getNode();
    IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    if (PluginChecker.isJobLetPluginLoaded()) {
        IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
        if (service != null) {
            openEditor = (AbstractMultiPageTalendEditor) service.openJobletEditor(jobletNode, page);
        }
    }
    return openEditor;
}
Also used : IJobletProviderService(org.talend.core.ui.IJobletProviderService) JobletContainer(org.talend.designer.core.ui.editor.jobletcontainer.JobletContainer) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) INode(org.talend.core.model.process.INode) RepositoryNode(org.talend.repository.model.RepositoryNode) HL7FileNode(org.talend.core.model.metadata.builder.connection.HL7FileNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) Node(org.talend.designer.core.ui.editor.nodes.Node) IExternalNode(org.talend.core.model.process.IExternalNode) XMLFileNode(org.talend.core.model.metadata.builder.connection.XMLFileNode) MapperExternalNode(org.talend.core.model.process.node.MapperExternalNode) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage)

Example 4 with AbstractMultiPageTalendEditor

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

the class JobSettingsView method getProcess.

private IProcess getProcess(IRepositoryViewObject viewObject) {
    boolean isOpen = RepositoryManager.isOpenedItemInEditor(viewObject);
    if (isOpen) {
        final IEditorPart activeEditor = getSite().getPage().getActiveEditor();
        if (activeEditor != null && activeEditor instanceof AbstractMultiPageTalendEditor) {
            AbstractTalendEditor talendEditor = ((AbstractMultiPageTalendEditor) activeEditor).getTalendEditor();
            IProcess process = talendEditor.getProcess();
            return process;
        }
    }
    return null;
}
Also used : AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) AbstractTalendEditor(org.talend.designer.core.ui.editor.AbstractTalendEditor) IEditorPart(org.eclipse.ui.IEditorPart) IProcess(org.talend.core.model.process.IProcess)

Example 5 with AbstractMultiPageTalendEditor

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

the class JobSettingsView method refresh.

public void refresh(boolean force, Object obj) {
    if (force) {
        cleanDisplay();
    }
    final IEditorPart activeEditor = getSite().getPage().getActiveEditor();
    if (obj == null) {
        if (activeEditor != null && activeEditor instanceof AbstractMultiPageTalendEditor) {
            AbstractTalendEditor talendEditor = ((AbstractMultiPageTalendEditor) activeEditor).getTalendEditor();
            IProcess process = talendEditor.getProcess();
            if (process != null && process instanceof Element) {
                this.selectedPrimary = true;
                this.cleaned = force;
                this.element = (Element) process;
                // remove "Job" or "Joblet" from title
                String title = activeEditor.getTitle();
                if (title.startsWith(VIEW_NAME_JOBLET)) {
                    title = title.substring(VIEW_NAME_JOBLET.length() + 1);
                } else if (title.startsWith(getViewNameLable())) {
                    title = title.substring(getViewNameLable().length() + 1);
                }
                setElement(element, title, null);
                return;
            }
        } else {
            IDiagramModelService diagramModelService = CorePlugin.getDefault().getDiagramModelService();
            if (diagramModelService != null && diagramModelService.isBusinessDiagramEditor(activeEditor)) {
                this.selectedPrimary = true;
                this.cleaned = force;
                IRepositoryViewObject object = retrieveBusiness(activeEditor);
                if (object != null) {
                    //$NON-NLS-1$
                    String title = object.getLabel() + " " + object.getVersion();
                    Object type = object.getRepositoryObjectType();
                    setElement(activeEditor, type + SEPARATOR + title, null);
                }
                return;
            }
        }
    } else {
        this.selectedPrimary = true;
        this.cleaned = force;
        IRepositoryViewObject object = retrieveBusiness(activeEditor);
        if (object != null) {
            //$NON-NLS-1$
            String title = object.getLabel() + " " + object.getVersion();
            Object type = object.getRepositoryObjectType();
            setElement(obj, type + SEPARATOR + title, null);
        }
        return;
    }
    cleanDisplay();
}
Also used : IDiagramModelService(org.talend.designer.business.diagram.custom.IDiagramModelService) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) AbstractTalendEditor(org.talend.designer.core.ui.editor.AbstractTalendEditor) Element(org.talend.core.model.process.Element) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) EmptyRepositoryObject(org.talend.core.model.repository.EmptyRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IEditorPart(org.eclipse.ui.IEditorPart) IProcess(org.talend.core.model.process.IProcess)

Aggregations

AbstractMultiPageTalendEditor (org.talend.designer.core.ui.AbstractMultiPageTalendEditor)53 IEditorPart (org.eclipse.ui.IEditorPart)26 INode (org.talend.core.model.process.INode)16 Node (org.talend.designer.core.ui.editor.nodes.Node)15 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)14 CommandStack (org.eclipse.gef.commands.CommandStack)13 AbstractTalendEditor (org.talend.designer.core.ui.editor.AbstractTalendEditor)12 GraphicalViewer (org.eclipse.gef.GraphicalViewer)10 IExternalNode (org.talend.core.model.process.IExternalNode)10 IProcess (org.talend.core.model.process.IProcess)10 ArrayList (java.util.ArrayList)9 List (java.util.List)8 EditPart (org.eclipse.gef.EditPart)8 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)8 IEditorReference (org.eclipse.ui.IEditorReference)7 PersistenceException (org.talend.commons.exception.PersistenceException)7 IProcess2 (org.talend.core.model.process.IProcess2)7 Property (org.talend.core.model.properties.Property)7 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)7 Process (org.talend.designer.core.ui.editor.process.Process)7