org.eclipse.ui.IWorkbenchWindow Java Examples

The following examples show how to use org.eclipse.ui.IWorkbenchWindow. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: YangSyntax.java    From yang-design-studio with Eclipse Public License 1.0 6 votes vote down vote up
public MessageConsoleStream getMessageStream() {
	MessageConsole myConsole = findConsole("Yang Console"); //calls function to find/create the Yang console
	if (myConsole != null) {

		IWorkbench wb = PlatformUI.getWorkbench();
		IWorkbenchWindow win = wb.getActiveWorkbenchWindow();
		IWorkbenchPage page = win.getActivePage();
		String id = IConsoleConstants.ID_CONSOLE_VIEW;
		IConsoleView view;
		try {

			view = (IConsoleView) page.showView(id);
			view.display(myConsole);

			return myConsole.newMessageStream();
		} catch (PartInitException e) {
			e.printStackTrace();
		}
	}
	return null;
}
 
Example #2
Source File: UIHelper.java    From tlaplus with MIT License 6 votes vote down vote up
/**
 * Closes all windows with a perspective
 * 
 * @param perspectiveId
 *            a perspective Id pointing the perspective
 */
public static void closeWindow(String perspectiveId) {
	IWorkbench workbench = Activator.getDefault().getWorkbench();
	// hide intro
	if (InitialPerspective.ID.equals(perspectiveId)) {
		workbench.getIntroManager().closeIntro(workbench.getIntroManager().getIntro());
	}

	IWorkbenchWindow[] windows = workbench.getWorkbenchWindows();

	// closing the perspective opened in a window
	for (int i = 0; i < windows.length; i++) {
		IWorkbenchPage page = windows[i].getActivePage();
		if (page != null && page.getPerspective() != null && perspectiveId.equals(page.getPerspective().getId())) {
			windows[i].close();
		}
	}
}
 
Example #3
Source File: XLIFFEditorSelectionPropertyTester.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
	boolean enabled = false;
	IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
	if (window != null) {
		IWorkbenchPage page = window.getActivePage();
		if (page != null) {
			IEditorPart editor = page.getActiveEditor();
			if (editor != null && editor instanceof XLIFFEditorImplWithNatTable) {
				XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) editor;
				if (xliffEditor != null && xliffEditor.getTable() != null) {
					List<String> selectedRowIds = xliffEditor.getSelectedRowIds();
					enabled = (selectedRowIds != null && selectedRowIds.size() > 0);
				}
			}
		}
	}

	return enabled;
}
 
Example #4
Source File: OpenTypeHierarchyUtil.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private static TypeHierarchyViewPart openInViewPart(IWorkbenchWindow window, IJavaElement[] input) {
	IWorkbenchPage page= window.getActivePage();
	try {
		TypeHierarchyViewPart result= (TypeHierarchyViewPart) page.findView(JavaUI.ID_TYPE_HIERARCHY);
		if (result != null) {
			result.clearNeededRefresh(); // avoid refresh of old hierarchy on 'becomes visible'
		}
		result= (TypeHierarchyViewPart) page.showView(JavaUI.ID_TYPE_HIERARCHY);
		result.setInputElements(input);
		return result;
	} catch (CoreException e) {
		ExceptionHandler.handle(e, window.getShell(),
			JavaUIMessages.OpenTypeHierarchyUtil_error_open_view, e.getMessage());
	}
	return null;
}
 
Example #5
Source File: Navigator.java    From olca-app with Mozilla Public License 2.0 6 votes vote down vote up
/**
 * Returns the instance of the navigation view or NULL if there is# no such
 * instance available.
 */
public static Navigator getInstance() {
	IWorkbench workbench = PlatformUI.getWorkbench();
	if (workbench == null)
		return null;
	IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
	if (window == null)
		return null;
	IWorkbenchPage page = window.getActivePage();
	if (page == null)
		return null;
	IViewPart part = page.findView(ID);
	if (part instanceof Navigator)
		return (Navigator) part;
	return null;
}
 
Example #6
Source File: ShowHidenNonPrintingCharacterHandler.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException {
	isSelected = !isSelected;				
	try {
		IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
		if (window != null) {
			IWorkbenchPage page = window.getActivePage();
			if (page != null) {
				IEditorPart editor = page.getActiveEditor();
				if (editor != null && editor instanceof IXliffEditor) {
					((IXliffEditor) editor).refreshWithNonprinttingCharacter(isSelected);
				}
			}
		}
	} catch (NullPointerException e) {
		e.printStackTrace();
	}
	
	return null;
}
 
Example #7
Source File: ShowPreviousUntranslatedHandler.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException {
	IEditorPart editor = HandlerUtil.getActiveEditor(event);
	if (!(editor instanceof XLIFFEditorImplWithNatTable)) {
		return null;
	}
	XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) editor;
	int[] selectedRows = xliffEditor.getSelectedRows();
	if (selectedRows.length < 1) {
		return null;
	}
	Arrays.sort(selectedRows);
	int firstSelectedRow = selectedRows[0];
	XLFHandler handler = xliffEditor.getXLFHandler();

	int row = handler.getPreviousUntranslatedSegmentIndex(firstSelectedRow);
	if (row != -1) {
		xliffEditor.jumpToRow(row);
	} else {
		IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
		MessageDialog.openWarning(window.getShell(), "", "不存在上一未翻译文本段。");
	}

	return null;
}
 
Example #8
Source File: JavaReconciler.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void uninstall() {

	IWorkbenchPartSite site= fTextEditor.getSite();
	IWorkbenchWindow window= site.getWorkbenchWindow();
	window.getPartService().removePartListener(fPartListener);
	fPartListener= null;

	Shell shell= window.getShell();
	if (shell != null && !shell.isDisposed())
		shell.removeShellListener(fActivationListener);
	fActivationListener= null;

	JavaCore.removeElementChangedListener(fJavaElementChangedListener);
	fJavaElementChangedListener= null;

	IWorkspace workspace= JavaPlugin.getWorkspace();
	workspace.removeResourceChangeListener(fResourceChangeListener);
	fResourceChangeListener= null;

	JavaPlugin.getDefault().getCombinedPreferenceStore().removePropertyChangeListener(fPropertyChangeListener);
	fPropertyChangeListener= null;

	super.uninstall();
}
 
Example #9
Source File: CalcitePane.java    From mat-calcite-plugin with Apache License 2.0 6 votes vote down vote up
private void makeActions() {
	executeQueryAction = new ExecuteQueryAction(this, null, false);
	explainQueryAction = new ExecuteQueryAction(this, null, true);
	commentLineAction = new CommentLineAction(queryString);
	IWorkbenchWindow window = this.getEditorSite().getWorkbenchWindow();
	ActionFactory.IWorkbenchAction globalAction = ActionFactory.COPY.create(window);
	this.copyQueryStringAction = new Action() {
		public void run() {
			CalcitePane.this.queryString.copy();
		}
	};
	this.copyQueryStringAction.setAccelerator(globalAction.getAccelerator());
	this.contentAssistAction = new Action() {
		@Override
		public void run() {
			queryViewer.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
		}
	};
}
 
Example #10
Source File: ShowNextUntranslatableHandler.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException {
	IEditorPart editor = HandlerUtil.getActiveEditor(event);
	if (!(editor instanceof XLIFFEditorImplWithNatTable)) {
		return null;
	}
	XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) editor;
	int[] selectedRows = xliffEditor.getSelectedRows();
	if (selectedRows.length < 1) {
		return null;
	}
	Arrays.sort(selectedRows);
	int lastSelectedRow = selectedRows[selectedRows.length - 1];
	XLFHandler handler = xliffEditor.getXLFHandler();

	int row = handler.getNextUntranslatableSegmentIndex(lastSelectedRow);
	if (row != -1) {
		xliffEditor.jumpToRow(row);
	} else {
		IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
		MessageDialog.openWarning(window.getShell(), "", "不存在下一不可翻译文本段。");
	}

	return null;
}
 
Example #11
Source File: ShowPreviousNoteHandler.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException {
	IEditorPart editor = HandlerUtil.getActiveEditor(event);
	if (!(editor instanceof XLIFFEditorImplWithNatTable)) {
		return null;
	}
	XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) editor;
	int[] selectedRows = xliffEditor.getSelectedRows();
	if (selectedRows.length < 1) {
		return null;
	}
	Arrays.sort(selectedRows);
	int firstSelectedRow = selectedRows[0];
	XLFHandler handler = xliffEditor.getXLFHandler();

	int row = handler.getPreviousNoteSegmentIndex(firstSelectedRow);
	if (row != -1) {
		xliffEditor.jumpToRow(row);
	} else {
		IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
		MessageDialog.openWarning(window.getShell(), "", "不存在上一个带批注的文本段。");
	}

	return null;
}
 
Example #12
Source File: ShowPreviousUntranslatableHandler.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException {
	IEditorPart editor = HandlerUtil.getActiveEditor(event);
	if (!(editor instanceof XLIFFEditorImplWithNatTable)) {
		return null;
	}
	XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) editor;
	int[] selectedRows = xliffEditor.getSelectedRows();
	if (selectedRows.length < 1) {
		return null;
	}
	Arrays.sort(selectedRows);
	int firstSelectedRow = selectedRows[0];
	XLFHandler handler = xliffEditor.getXLFHandler();

	int row = handler.getPreviousUntranslatableSegmentIndex(firstSelectedRow);
	if (row != -1) {
		xliffEditor.jumpToRow(row);
	} else {
		IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
		MessageDialog.openWarning(window.getShell(), "", "不存在上一不可翻译文本段。");
	}

	return null;
}
 
Example #13
Source File: LamiChartViewerTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Reset the current perspective
 */
@After
public void resetPerspective() {
    SWTBotView viewBot = fViewBot;
    if (viewBot != null) {
        viewBot.close();
    }
    /*
     * UI Thread executes the reset perspective action, which opens a shell
     * to confirm the action. The current thread will click on the 'Yes'
     * button
     */
    Runnable runnable = () -> SWTBotUtils.anyButtonOf(fBot, "Yes", "Reset Perspective").click();
    UIThreadRunnable.asyncExec(() -> {
        IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getWorkbenchWindows()[0];
        ActionFactory.RESET_PERSPECTIVE.create(activeWorkbenchWindow).run();
    });
    runnable.run();
}
 
Example #14
Source File: TmfAlignmentSynchronizer.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Get the narrowest view that corresponds to the given alignment information.
 */
private static TmfView getNarrowestView(TmfTimeViewAlignmentInfo alignmentInfo) {
    IWorkbenchWindow workbenchWindow = getWorkbenchWindow(alignmentInfo.getShell());
    if (workbenchWindow == null || workbenchWindow.getActivePage() == null) {
        // Only time aligned views that are part of a workbench window are supported
        return null;
    }
    IWorkbenchPage page = workbenchWindow.getActivePage();

    int narrowestWidth = Integer.MAX_VALUE;
    TmfView narrowestView = null;
    for (IViewReference ref : page.getViewReferences()) {
        IViewPart view = ref.getView(false);
        if (isTimeAlignedView(view)) {
            TmfView tmfView = (TmfView) view;
            if (isCandidateForNarrowestView(tmfView, alignmentInfo, narrowestWidth)) {
                narrowestWidth = ((ITmfTimeAligned) tmfView).getAvailableWidth(getClampedTimeAxisOffset(alignmentInfo));
                narrowestWidth = getClampedTimeAxisWidth(alignmentInfo, narrowestWidth);
                narrowestView = tmfView;
            }
        }
    }

    return narrowestView;
}
 
Example #15
Source File: ParseSpecHandler.java    From tlaplus with MIT License 6 votes vote down vote up
/**
 * @deprecated
 */
protected void saveDirtyEditors()
{
    Display display = UIHelper.getCurrentDisplay(); 
    display.syncExec(new Runnable() {
        public void run()
        {
            IWorkbenchWindow[] windows = Activator.getDefault().getWorkbench().getWorkbenchWindows();
            for (int i = 0; i < windows.length; i++)
            {
                IWorkbenchPage[] pages = windows[i].getPages();
                for (int j = 0; j < pages.length; j++)
                    pages[j].saveAllEditors(false);
            }
        }
    });
}
 
Example #16
Source File: PasteHandler.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public boolean isEnabled() {
    // Check if we are closing down
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window == null) {
        return false;
    }

    // Get the selection
    IWorkbenchPage page = window.getActivePage();
    IWorkbenchPart part = page.getActivePart();
    if (!(part instanceof FilterView)) {
        return false;
    }
    FilterView v = (FilterView) part;
    ITmfFilterTreeNode sel = v.getSelection();
    if (sel == null) {
        sel = v.getFilterRoot();
    }
    ITmfFilterTreeNode objectToPaste = FilterEditUtils.getTransferredTreeNode();
    return (v.isTreeInFocus() && objectToPaste != null &&
            (sel.getValidChildren().contains(objectToPaste.getNodeName())
                    || TmfFilterNode.NODE_NAME.equals(objectToPaste.getNodeName())));
}
 
Example #17
Source File: ViewUtils.java    From saros with GNU General Public License v2.0 6 votes vote down vote up
public static void openSarosView() {
  /*
   * TODO What to do if no WorkbenchWindows are are active?
   */
  final IWorkbench workbench = PlatformUI.getWorkbench();

  if (workbench == null) return;

  final IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();

  if (window == null) return;

  try {
    window.getActivePage().showView(SarosView.ID, null, IWorkbenchPage.VIEW_CREATE);
  } catch (PartInitException e) {
    log.error("could not open Saros view (id: " + SarosView.ID + ")", e); // $NON-NLS-1$
  }
}
 
Example #18
Source File: GamlReferenceSearch.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
public static void install() {
	WorkbenchHelper.runInUI("Install GAML Search", 0, m -> {
		final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
		if (window instanceof WorkbenchWindow) {
			final MTrimBar topTrim = ((WorkbenchWindow) window).getTopTrim();
			for (final MTrimElement element : topTrim.getChildren()) {
				if ("SearchField".equals(element.getElementId())) {
					final Composite parent = ((Control) element.getWidget()).getParent();
					final Control old = (Control) element.getWidget();
					WorkbenchHelper.runInUI("Disposing old search control", 500, m2 -> old.dispose());
					element.setWidget(GamlSearchField.installOn(parent));
					parent.layout(true, true);
					parent.update();
					break;
				}
			}
		}
	});
}
 
Example #19
Source File: PreferenceHandler.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException {
	IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
	if (window != null) {
		PreferenceUtil.openPreferenceDialog(window, null);
	}
	
	return null;
}
 
Example #20
Source File: StackWindowAction.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public void init( IWorkbenchWindow window )
{
	WrapperCommandStack stack = (WrapperCommandStack) getCommandStack( );
	if ( stack != null )
	{
		designHandle = getDesignHandle( );

		stack.setActivityStack( getDesignHandle( ).getCommandStack( ) );
		stack.addCommandStackListener( getCommandStackListener( ) );
	}
}
 
Example #21
Source File: BrowseKillRingHandler.java    From e4macs with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Insert text from kill ring entry into the most recently activated text editor
 * 
 * @param text - the text from the kill ring entry
 */
//	@SuppressWarnings("restriction")	// for cast to internal org.eclipse.ui.internal.WorkbenchWindow
private void insertFromBrowseRing(String text) {
	// insert into most recently active editor
	IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
	RecentEditor recent = getRecentEditor();
	// use widget to avoid unpleasant scrolling side effects of IRewriteTarget		
	Control widget = MarkUtils.getTextWidget(recent.editor);
	if (recent.editor != null) {
		try {
			// cache for ancillary computations
			setThisEditor(recent.editor);
			// reduce the amount of unnecessary work
			if (window instanceof WorkbenchWindow) {
				((WorkbenchWindow) window).largeUpdateStart();
			}
			widget.setRedraw(false);
			recent.page.activate(recent.epart);
			insertText(recent.editor.getDocumentProvider().getDocument(recent.editor.getEditorInput()),
					(ITextSelection)recent.editor.getSelectionProvider().getSelection(), text);
		} catch (Exception e) {
		} finally {
			widget.setRedraw(true);
			setThisEditor(null);
			if (window instanceof WorkbenchWindow) {
				((WorkbenchWindow) window).largeUpdateEnd();
			}
		}
	} else {
		beep();
	}
}
 
Example #22
Source File: UserLibraryPreferencePage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private IPath getWorkbenchWindowSelection() {
	IWorkbenchWindow window= fWorkbench.getActiveWorkbenchWindow();
	if (window != null) {
		ISelection selection= window.getSelectionService().getSelection();
		if (selection instanceof IStructuredSelection) {
			IStructuredSelection structuredSelection= (IStructuredSelection) selection;
			Object element= structuredSelection.getFirstElement();
			if (element != null) {
				Object resource= Platform.getAdapterManager().getAdapter(element, IResource.class);
				if (resource != null) {
					return ((IResource) resource).getFullPath();
				}
				if (structuredSelection instanceof ITreeSelection) {
					TreePath treePath= ((ITreeSelection) structuredSelection).getPaths()[0];
					while ((treePath = treePath.getParentPath()) != null) {
						element= treePath.getLastSegment();
						resource= Platform.getAdapterManager().getAdapter(element, IResource.class);
						if (resource != null) {
							return ((IResource) resource).getFullPath();
						}
					}
				}
			}
			
		}
	}
	return null;
}
 
Example #23
Source File: SelectElementTypeContributionItem.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected IContributionItem[] getContributionItems() {

    /*
     * Fill the selected trace types and verify if selection applies only to
     * either traces or experiments
     */
    Set<String> selectedTraceTypes = new HashSet<>();
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    IWorkbenchPage page = window.getActivePage();
    ISelection selection = page.getSelection();
    boolean forTraces = false, forExperiments = false;
    if (selection instanceof StructuredSelection) {
        for (Object element : ((StructuredSelection) selection).toList()) {
            if (element instanceof TmfTraceElement) {
                TmfTraceElement trace = (TmfTraceElement) element;
                selectedTraceTypes.add(trace.getTraceType());
                forTraces = true;
            } else if (element instanceof TmfExperimentElement) {
                TmfExperimentElement exp = (TmfExperimentElement) element;
                selectedTraceTypes.add(exp.getTraceType());
                forExperiments = true;
            }
        }
    }

    if (forTraces && forExperiments) {
        /* This should never happen anyways */
        throw new RuntimeException("You must select only experiments or only traces to set the element type"); //$NON-NLS-1$
    }

    return getContributionItems(selectedTraceTypes, forExperiments);
}
 
Example #24
Source File: BibtexEntryView.java    From slr-toolkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * While changing the resources (caused by changing project) all open bibtex
 * editors have to be closed without saving their content.
 */
protected void closeEditors() {
	IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
	IWorkbenchPage page = window.getActivePage();
	IEditorReference[] references = page.findEditors(null, editorId, IWorkbenchPage.MATCH_ID);
	page.closeEditors(references, false);
	references = page.findEditors(null, overviewId, IWorkbenchPage.MATCH_ID);
	page.closeEditors(references, false);
}
 
Example #25
Source File: SavePerspectiveHandler.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException {
	IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
	IWorkbenchAction savePerspectiveAction = ActionFactory.SAVE_PERSPECTIVE.create(window);
	savePerspectiveAction.run();
	
	return null;
}
 
Example #26
Source File: TypeScriptUIPlugin.java    From typescript.java with MIT License 5 votes vote down vote up
public static Shell getActiveWorkbenchShell() {
	IWorkbenchWindow window = getActiveWorkbenchWindow();
	if (window != null) {
		return window.getShell();
	}
	return null;
}
 
Example #27
Source File: UIUtils.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
public static Shell getActiveShell() {
    Shell shell = getDisplay().getActiveShell();
    if (shell == null) {
        IWorkbenchWindow window = getActiveWorkbenchWindow();
        if (window != null) {
            shell = window.getShell();
        }
    }
    return shell;
}
 
Example #28
Source File: EditorAPI.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the active workbench window. Needs to be called from UI thread.
 *
 * @return the active workbench window or <code>null</code> if there is no window or method is
 *     called from non-UI thread or the activeWorkbenchWindow is disposed.
 * @see IWorkbench#getActiveWorkbenchWindow()
 */
private static IWorkbenchWindow getActiveWindow() {
  try {
    return PlatformUI.getWorkbench().getActiveWorkbenchWindow();
  } catch (Exception e) {
    log.error("could not get active window", e);
    return null;
  }
}
 
Example #29
Source File: XMLAnalysesManagerPreferencePage.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Get editor references.
 *
 * @return the set of editor references
 */
private static Set<IEditorReference> getEditorReferences() {
    Set<IEditorReference> editorReferences = new HashSet<>();
    IWorkbench wb = PlatformUI.getWorkbench();
    for (IWorkbenchWindow wbWindow : wb.getWorkbenchWindows()) {
        for (IWorkbenchPage wbPage : wbWindow.getPages()) {
            editorReferences.addAll(Arrays.asList(wbPage.getEditorReferences()));
        }
    }
    return editorReferences;
}
 
Example #30
Source File: CreateItemHandler.java    From ice with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Opens an {@link NewItemWizard} in a new {@link WizardDialog}.
 */
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {

	// Get the window and the shell.
	IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
	Shell shell = window.getShell();

	// Create a dialog and open it. The wizard itself handles everything, so
	// we do not need to do anything special with the return value.
	WizardDialog dialog = new WizardDialog(shell, new NewItemWizard());
	dialog.open();

	return null;
}