Search in sources :

Example 16 with IWorkbenchPart

use of org.eclipse.ui.IWorkbenchPart in project tdi-studio-se by Talend.

the class UIManager method closeMapper.

/**
     * DOC amaumont Comment method "closeMapperDialog".
     * 
     * @param ok
     */
public void closeMapper(int response) {
    boolean save = true;
    for (DataMapTableView dataMapTableView : getInputsTablesView()) {
        dataMapTableView.notifyFocusLost();
    }
    for (DataMapTableView dataMapTableView : getOutputsTablesView()) {
        dataMapTableView.notifyFocusLost();
    }
    for (DataMapTableView dataMapTableView : getVarsTablesView()) {
        dataMapTableView.notifyFocusLost();
    }
    if ((response == SWT.OK || response == SWT.APPLICATION_MODAL) && mapperManager.getProblemsManager().checkProblemsForAllEntriesOfAllTables(false)) {
        save = MessageDialog.openConfirm(getMapperContainer().getShell(), //$NON-NLS-1$
        Messages.getString("UIManager.SaveDespiteErrors.Title"), //$NON-NLS-1$
        Messages.getString("UIManager.SaveDespiteErrors.Message"));
    }
    if (save) {
        Composite parent = mapperUI.getMapperUIParent();
        prepareClosing(response);
        if (parent instanceof Shell) {
            if (response == SWT.OK || response == SWT.CANCEL) {
                ((Shell) parent).close();
            } else {
                IExternalNode externalNode = mapperManager.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);
                    }
                }
            }
        }
    }
}
Also used : ExternalNodeChangeCommand(org.talend.designer.core.ui.editor.cmd.ExternalNodeChangeCommand) CommandStack(org.eclipse.gef.commands.CommandStack) Shell(org.eclipse.swt.widgets.Shell) INode(org.talend.core.model.process.INode) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) ExternalNodeChangeCommand(org.talend.designer.core.ui.editor.cmd.ExternalNodeChangeCommand) Command(org.eclipse.gef.commands.Command) DataMapTableViewSelectedCommand(org.talend.designer.mapper.ui.commands.DataMapTableViewSelectedCommand) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) INode(org.talend.core.model.process.INode) Node(org.talend.designer.core.ui.editor.nodes.Node) IExternalNode(org.talend.core.model.process.IExternalNode) InputDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.InputDataMapTableView) OutputDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.OutputDataMapTableView) VarsDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.VarsDataMapTableView) DataMapTableView(org.talend.designer.mapper.ui.visualmap.table.DataMapTableView) IExternalNode(org.talend.core.model.process.IExternalNode)

Example 17 with IWorkbenchPart

use of org.eclipse.ui.IWorkbenchPart in project tdi-studio-se by Talend.

the class FindDialog method getFindTarget.

/**
     * Gets the target for find action.
     * 
     * @return The target for find action
     */
private static IFindTarget getFindTarget() {
    IWorkbenchPart activePart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();
    if (activePart instanceof IFindTarget) {
        return (IFindTarget) activePart;
    }
    PropertySheet part = (PropertySheet) activePart;
    if (part == null) {
        return null;
    }
    IPage page = part.getCurrentPage();
    if (!(page instanceof TabbedPropertySheetPage)) {
        return null;
    }
    TabbedPropertySheetPage propertySheetPage = (TabbedPropertySheetPage) page;
    ISection[] sections = propertySheetPage.getCurrentTab().getSections();
    if (sections.length != 1) {
        return null;
    }
    ISection section = sections[0];
    if (!(section instanceof IFindTarget)) {
        return null;
    }
    return (IFindTarget) section;
}
Also used : ISection(org.eclipse.ui.views.properties.tabbed.ISection) IFindTarget(org.talend.designer.runtime.visualization.internal.ui.properties.cpu.actions.FindAction.IFindTarget) IPage(org.eclipse.ui.part.IPage) PropertySheet(org.eclipse.ui.views.properties.PropertySheet) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) TabbedPropertySheetPage(org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage)

Example 18 with IWorkbenchPart

use of org.eclipse.ui.IWorkbenchPart 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 19 with IWorkbenchPart

use of org.eclipse.ui.IWorkbenchPart in project tdi-studio-se by Talend.

the class AbstractJvmPropertySection method isFocused.

/**
     * Gets the state indicating if property sheet containing this property section is focused.
     * 
     * @return True of property sheet is focused.
     */
private boolean isFocused() {
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window == null) {
        return false;
    }
    IWorkbenchPage page = window.getActivePage();
    if (page == null) {
        return false;
    }
    IWorkbenchPart part = page.getActivePart();
    if (part != null) {
        return part.equals(propertySheet);
    }
    return false;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage)

Example 20 with IWorkbenchPart

use of org.eclipse.ui.IWorkbenchPart in project tesb-studio-se by Talend.

the class ResourceEditorListener method partClosed.

@Override
public void partClosed(IWorkbenchPartReference partRef) {
    IWorkbenchPart part = partRef.getPart(true);
    if (part instanceof IEditorPart) {
        IEditorInput input = ((IEditorPart) part).getEditorInput();
        if (input instanceof RouteResourceInput) {
            Item item = ((RouteResourceInput) input).getItem();
            if (item.getProperty().getId().equals(editorInput.getItem().getProperty().getId())) {
                try {
                    ProxyRepositoryFactory.getInstance().unlock(item);
                    page.getWorkbenchWindow().getPartService().removePartListener(this);
                    IResourceChangeListener l = editorInput.getListener();
                    if (null != l) {
                        ResourcesPlugin.getWorkspace().removeResourceChangeListener(l);
                    }
                } catch (Exception e) {
                    ExceptionHandler.process(e);
                }
            }
        }
    }
}
Also used : RouteResourceInput(org.talend.designer.camel.resource.editors.input.RouteResourceInput) Item(org.talend.core.model.properties.Item) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) IEditorPart(org.eclipse.ui.IEditorPart) IResourceChangeListener(org.eclipse.core.resources.IResourceChangeListener) IEditorInput(org.eclipse.ui.IEditorInput)

Aggregations

IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)50 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)21 IEditorPart (org.eclipse.ui.IEditorPart)17 ISelection (org.eclipse.jface.viewers.ISelection)16 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)12 ArrayList (java.util.ArrayList)11 Shell (org.eclipse.swt.widgets.Shell)11 IFile (org.eclipse.core.resources.IFile)10 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)10 IViewPart (org.eclipse.ui.IViewPart)10 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)10 IEditorInput (org.eclipse.ui.IEditorInput)8 Command (org.eclipse.gef.commands.Command)6 CommandStack (org.eclipse.gef.commands.CommandStack)6 XLIFFEditorImplWithNatTable (net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.XLIFFEditorImplWithNatTable)5 PartInitException (org.eclipse.ui.PartInitException)5 AbstractMultiPageTalendEditor (org.talend.designer.core.ui.AbstractMultiPageTalendEditor)5 DBSObject (org.jkiss.dbeaver.model.struct.DBSObject)4 Iterator (java.util.Iterator)3 IPartListener (org.eclipse.ui.IPartListener)3