Search in sources :

Example 1 with IWorkbenchWindow

use of org.eclipse.ui.IWorkbenchWindow in project flux by eclipse.

the class LiveEditConnector method dispose.

public void dispose() {
    this.liveEditCoordinator.removeLiveEditConnector(liveEditConnector);
    this.repository.removeRepositoryListener(repositoryListener);
    FileBuffers.getTextFileBufferManager().removeFileBufferListener(fileBufferListener);
    ResourcesPlugin.getWorkspace().removeResourceChangeListener(workspaceListener);
    WorkbenchJob jw = new WorkbenchJob("Removing listener") {

        @Override
        public IStatus runInUIThread(IProgressMonitor monitor) {
            IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
            if (window != null) {
                window.getActivePage().removePartListener(partListener);
            }
            return Status.OK_STATUS;
        }
    };
    jw.setSystem(true);
    jw.schedule();
    for (IDocument document : documentMappings.values()) {
        if (document != null) {
            document.removeDocumentListener(documentListener);
        }
    }
    resourceMappings.clear();
    documentMappings.clear();
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) WorkbenchJob(org.eclipse.ui.progress.WorkbenchJob) IDocument(org.eclipse.jface.text.IDocument)

Example 2 with IWorkbenchWindow

use of org.eclipse.ui.IWorkbenchWindow in project gfm_viewer by satyagraha.

the class DIManager method getInjector.

public Injector getInjector(Component.Scope scope) {
    if (scope == null) {
        throw new IllegalArgumentException("null scope");
    }
    switch(scope) {
        case PLUGIN:
            return pluginInjector;
        case PAGE:
            IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
            if (workbenchWindow == null) {
                throw new IllegalStateException("no active workbench window");
            }
            IWorkbenchPage workbenchPage = workbenchWindow.getActivePage();
            if (workbenchPage == null) {
                throw new IllegalStateException("no active workbench page");
            }
            Injector pageInjector = pageInjectorMap.get(workbenchPage);
            if (pageInjector == null) {
                throw new IllegalStateException("unable to locate pageInjector for page: " + workbenchPage);
            }
            return pageInjector;
        default:
            throw new IllegalArgumentException("unexpected scope: " + scope);
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage)

Example 3 with IWorkbenchWindow

use of org.eclipse.ui.IWorkbenchWindow in project dbeaver by serge-rider.

the class NavigatorHandlerProjectCreate method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
    createNewProject(window);
    return null;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow)

Example 4 with IWorkbenchWindow

use of org.eclipse.ui.IWorkbenchWindow in project dbeaver by serge-rider.

the class NavigatorHandlerProjectSelect method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    final DBeaverCore core = DBeaverCore.getInstance();
    final DBNProject projectNode = core.getNavigatorModel().getRoot().getProject(core.getProjectRegistry().getActiveProject());
    if (projectNode != null) {
        final IWorkbenchWindow workbenchWindow = HandlerUtil.getActiveWorkbenchWindow(event);
        try {
            final ProjectNavigatorView projectsView = (ProjectNavigatorView) workbenchWindow.getActivePage().showView(ProjectNavigatorView.VIEW_ID);
            if (projectsView != null) {
                projectsView.showNode(projectNode);
            }
        } catch (PartInitException e) {
            log.error(e);
        }
    }
    return null;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) DBNProject(org.jkiss.dbeaver.model.navigator.DBNProject) DBeaverCore(org.jkiss.dbeaver.core.DBeaverCore) ProjectNavigatorView(org.jkiss.dbeaver.ui.navigator.project.ProjectNavigatorView) PartInitException(org.eclipse.ui.PartInitException)

Example 5 with IWorkbenchWindow

use of org.eclipse.ui.IWorkbenchWindow in project dbeaver by serge-rider.

the class NavigatorHandlerCreateLink method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    final ISelection selection = HandlerUtil.getCurrentSelection(event);
    if (selection instanceof IStructuredSelection) {
        final IStructuredSelection structSelection = (IStructuredSelection) selection;
        Object element = structSelection.getFirstElement();
        if (!(element instanceof DBNResource)) {
            return null;
        }
        final IResource resource = ((DBNResource) element).getResource();
        if (resource instanceof IFolder) {
            final IWorkbenchWindow workbenchWindow = HandlerUtil.getActiveWorkbenchWindow(event);
            DirectoryDialog dialog = new DirectoryDialog(workbenchWindow.getShell(), SWT.NONE);
            String folder = dialog.open();
            if (folder != null) {
                createLink(workbenchWindow, (IFolder) resource, folder);
            }
        }
    }
    return null;
}
Also used : DBNResource(org.jkiss.dbeaver.model.navigator.DBNResource) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IResource(org.eclipse.core.resources.IResource) IFolder(org.eclipse.core.resources.IFolder) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog)

Aggregations

IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)284 IEditorPart (org.eclipse.ui.IEditorPart)114 PartInitException (org.eclipse.ui.PartInitException)70 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)68 QueryEditorPart (com.cubrid.common.ui.query.editor.QueryEditorPart)39 IViewPart (org.eclipse.ui.IViewPart)38 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)35 ArrayList (java.util.ArrayList)34 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)32 IEditorReference (org.eclipse.ui.IEditorReference)30 XLIFFEditorImplWithNatTable (net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.XLIFFEditorImplWithNatTable)27 ISelection (org.eclipse.jface.viewers.ISelection)25 XLFHandler (net.heartsome.cat.ts.core.file.XLFHandler)24 IFile (org.eclipse.core.resources.IFile)23 IWorkbench (org.eclipse.ui.IWorkbench)21 CoreException (org.eclipse.core.runtime.CoreException)20 QueryUnit (com.cubrid.common.ui.query.editor.QueryUnit)19 IProject (org.eclipse.core.resources.IProject)19 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)17 TreeViewer (org.eclipse.jface.viewers.TreeViewer)17