Search in sources :

Example 46 with IWorkbenchWindow

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

the class RefreshView method refreshAll.

public static void refreshAll() {
    IWorkbenchWindow workBenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (workBenchWindow == null) {
        return;
    }
    IWorkbenchPage workBenchPage = workBenchWindow.getActivePage();
    if (workBenchPage == null) {
        return;
    }
    for (IViewDescriptor desc : PlatformUI.getWorkbench().getViewRegistry().getViews()) {
        IViewPart viewPart = workBenchPage.findView(desc.getId());
        // show the view again in order to see the change
        if (viewPart != null) {
            workBenchPage.hideView(viewPart);
        }
    }
    workBenchPage.resetPerspective();
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IViewDescriptor(org.eclipse.ui.views.IViewDescriptor) IViewPart(org.eclipse.ui.IViewPart) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage)

Example 47 with IWorkbenchWindow

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

the class RefactorRenameHandler method isEnabled.

public boolean isEnabled() {
    if (!handler.isEnabled()) {
        return false;
    }
    // disable the command when editor is readonly.
    IWorkbench workbench = PlatformUI.getWorkbench();
    if (workbench == null) {
        return false;
    }
    IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
    if (window == null) {
        return false;
    }
    IWorkbenchPage activePage = window.getActivePage();
    if (activePage == null) {
        return false;
    }
    IEditorPart activeEditor = activePage.getActiveEditor();
    if (activeEditor != null && activeEditor instanceof LocalWSDLEditor) {
        LocalWSDLEditor wsdlEditor = (LocalWSDLEditor) activeEditor;
        return !wsdlEditor.isEditorInputReadOnly();
    }
    return false;
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorPart(org.eclipse.ui.IEditorPart)

Example 48 with IWorkbenchWindow

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

the class ESBService method refreshComponentView.

/**
     * When services connection is renamed, refresh the connection label in the component view of job.
     * 
     * @param item
     */
@Override
public void refreshComponentView(Item item) {
    try {
        IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
        IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
        IEditorReference[] editors = activePage.getEditorReferences();
        for (IEditorReference er : editors) {
            IEditorPart part = er.getEditor(false);
            if (part instanceof AbstractMultiPageTalendEditor) {
                AbstractMultiPageTalendEditor editor = (AbstractMultiPageTalendEditor) part;
                CommandStack stack = (CommandStack) editor.getTalendEditor().getAdapter(CommandStack.class);
                if (stack != null) {
                    IProcess process = editor.getProcess();
                    for (final INode processNode : process.getGraphicalNodes()) {
                        if (processNode instanceof Node) {
                            checkRepository((Node) processNode, item, stack);
                        }
                    }
                }
            }
        }
    } catch (Exception e) {
        ExceptionHandler.process(e);
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) CommandStack(org.eclipse.gef.commands.CommandStack) INode(org.talend.core.model.process.INode) IEditorReference(org.eclipse.ui.IEditorReference) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) ProjectRepositoryNode(org.talend.core.repository.model.ProjectRepositoryNode) Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorPart(org.eclipse.ui.IEditorPart) IProcess(org.talend.core.model.process.IProcess) CoreException(org.eclipse.core.runtime.CoreException) BusinessException(org.talend.commons.exception.BusinessException) IOException(java.io.IOException) PersistenceException(org.talend.commons.exception.PersistenceException)

Example 49 with IWorkbenchWindow

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

the class AbstractProcessAction method checkUnLoadedNodeForProcess.

public void checkUnLoadedNodeForProcess(JobEditorInput fileEditorInput) {
    if (fileEditorInput == null || fileEditorInput.getLoadedProcess() == null) {
        return;
    }
    IProcess2 loadedProcess = fileEditorInput.getLoadedProcess();
    List<NodeType> unloadedNode = loadedProcess.getUnloadedNode();
    if (unloadedNode != null && !unloadedNode.isEmpty()) {
        String message = "Some Component are not loaded:\n";
        for (int i = 0; i < unloadedNode.size(); i++) {
            message = message + unloadedNode.get(i).getComponentName() + "\n";
        }
        if (!CommonsPlugin.isHeadless() && PlatformUI.isWorkbenchRunning()) {
            Display display = Display.getCurrent();
            if (display == null) {
                display = Display.getDefault();
            }
            if (display != null) {
                final Display tmpDis = display;
                final String tmpMess = message;
                display.syncExec(new Runnable() {

                    public void run() {
                        Shell shell = null;
                        final IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
                        if (activeWorkbenchWindow != null) {
                            shell = activeWorkbenchWindow.getShell();
                        } else {
                            if (tmpDis != null) {
                                shell = tmpDis.getActiveShell();
                            } else {
                                shell = new Shell();
                            }
                        }
                        MessageDialog.openWarning(shell, "Warning", tmpMess);
                    }
                });
            }
        }
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) Shell(org.eclipse.swt.widgets.Shell) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) IProcess2(org.talend.core.model.process.IProcess2) Display(org.eclipse.swt.widgets.Display)

Example 50 with IWorkbenchWindow

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

the class ExportJobScriptAction method checkDirtyPart.

/**
     * DOC Administrator Comment method "checkDirtyPart".
     * 
     * @param workbench
     */
@SuppressWarnings("restriction")
private boolean checkDirtyPart(IWorkbench workbench) {
    ISaveablePart[] parts = null;
    IWorkbenchWindow[] windows = workbench.getWorkbenchWindows();
    for (IWorkbenchWindow window : windows) {
        IWorkbenchPage[] pages = window.getPages();
        for (IWorkbenchPage page : pages) {
            parts = page.getDirtyEditors();
        }
    }
    if (parts != null && parts.length > 0) {
        return true;
    }
    return false;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) ISaveablePart(org.eclipse.ui.ISaveablePart)

Aggregations

IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)363 IEditorPart (org.eclipse.ui.IEditorPart)136 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)102 PartInitException (org.eclipse.ui.PartInitException)81 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)41 QueryEditorPart (com.cubrid.common.ui.query.editor.QueryEditorPart)39 IViewPart (org.eclipse.ui.IViewPart)39 ArrayList (java.util.ArrayList)37 IEditorReference (org.eclipse.ui.IEditorReference)35 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)32 IWorkbench (org.eclipse.ui.IWorkbench)32 IFile (org.eclipse.core.resources.IFile)30 ISelection (org.eclipse.jface.viewers.ISelection)29 XLIFFEditorImplWithNatTable (net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.XLIFFEditorImplWithNatTable)27 Shell (org.eclipse.swt.widgets.Shell)26 XLFHandler (net.heartsome.cat.ts.core.file.XLFHandler)24 CoreException (org.eclipse.core.runtime.CoreException)23 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)21 IProject (org.eclipse.core.resources.IProject)20 QueryUnit (com.cubrid.common.ui.query.editor.QueryUnit)19