Java Code Examples for org.eclipse.ui.IWorkbenchWindow#getShell()
The following examples show how to use
org.eclipse.ui.IWorkbenchWindow#getShell() .
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: RenameElementHandler.java From statecharts with Eclipse Public License 1.0 | 6 votes |
@Override public Object execute(ExecutionEvent event) throws ExecutionException { NamedElement element = refactoring.getContextObject(); if (element != null) { IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); List<Issue> issues = validator.validate(element.eResource(), CheckMode.NORMAL_AND_FAST, CancelIndicator.NullImpl); Stream<Issue> errors = issues.stream().filter(issue -> issue.getSeverity() == Severity.ERROR); RenameDialog dialog = new RenameDialog(window.getShell(), "Rename..", "Please enter new name: ", element.getName(), new NameUniquenessValidator(element), errors.count() > 0); if (dialog.open() == Window.OK) { String newName = dialog.getNewName(); if (newName != null) { ((RenameRefactoring) refactoring).setNewName(newName); refactoring.execute(); } } } return null; }
Example 2
Source File: AnalyticsPingManager.java From google-cloud-eclipse with Apache License 2.0 | 6 votes |
/** * May return null. (However, dialogs can have null as a parent shell.) */ private static Shell findShell(Shell parentShell) { Preconditions.checkNotNull(Display.getCurrent()); if (parentShell != null && !parentShell.isDisposed()) { return parentShell; } try { Shell activeShell = Display.getCurrent().getActiveShell(); if (activeShell != null) { return activeShell; } IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); if (window != null) { return window.getShell(); } return null; } catch (IllegalStateException ise) { // getWorkbench() might throw this. return null; } }
Example 3
Source File: AVDStatusHandler.java From thym with Eclipse Public License 1.0 | 5 votes |
private Shell getShell(){ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); if (window != null) { return window.getShell(); } IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows(); if (windows.length > 0) { return windows[0].getShell(); } return null; }
Example 4
Source File: ImportItemWizardHandler.java From ice with Eclipse Public License 1.0 | 5 votes |
/** * Opens an {@link ImportItemWizard} 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(); // Get the selected IProject instance if we can IProject project = null; ISelection selection = HandlerUtil.getCurrentSelection(event); if (selection instanceof IStructuredSelection) { Object element = ((IStructuredSelection) selection).getFirstElement(); if (element instanceof IResource) { project = ((IResource) element).getProject(); } } // Create a dialog and open it. The wizard itself handles everything, so // we do not need to do anything special with the return value. ImportItemWizard wizard = new ImportItemWizard(); wizard.setProject(project); WizardDialog dialog = new WizardDialog(shell, wizard); dialog.open(); return null; }
Example 5
Source File: ImportBirtRuntimeAction.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * Execute Action * * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) */ public void run( IAction action ) { try { // initialize webapp settings from Extension BirtWizardUtil.initWebapp( this.properties ); IModelProvider modelProvider = ModelProviderManager .getModelProvider(project); final IBirtFacetUtil util = BirtFacetUtilFactory.getInstance(modelProvider.getModelObject()); // initialize webapp settings from existed web.xml util.initializeWebapp( this.properties, project ); IWorkbenchWindow window = PlatformUI.getWorkbench( ) .getWorkbenchWindows( )[0]; BirtConfigurationDialog dialog = new BirtConfigurationDialog( window.getShell( ), (Map) properties .get( EXT_CONTEXT_PARAM ) ); dialog.open( ); if ( dialog.getReturnCode( ) == Window.CANCEL ) return; // import birt runtime component doImport( window, dialog.isClear( ) ); } catch ( Exception e ) { Logger.logException( e ); } }
Example 6
Source File: NewSpecHandler.java From tlaplus with MIT License | 5 votes |
/** * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) */ public Object execute(ExecutionEvent event) throws ExecutionException { IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); // Create the wizard NewSpecWizard wizard = new NewSpecWizard(event.getParameter(PARAM_PATH)); // we pass null for structured selection, cause we just not using it wizard.init(window.getWorkbench(), null); Shell parentShell = window.getShell(); // Create the wizard dialog WizardDialog dialog = new WizardDialog(parentShell, wizard); dialog.setHelpAvailable(true); // Open the wizard dialog if (Window.OK == dialog.open() && wizard.getRootFilename() != null) { // read UI values from the wizard page final boolean importExisting = wizard.isImportExisting(); final String specName = wizard.getSpecName(); final String rootFilename = wizard.getRootFilename(); // the moment the user clicks finish on the wizard page does // not correspond with the availability of the spec object // it first has to be created/parsed fully before it can be shown in // the editor. Thus, delay opening the editor until parsing is done. createModuleAndSpecInNonUIThread(rootFilename, importExisting, specName); } return null; }
Example 7
Source File: All.java From EasyShell with Eclipse Public License 2.0 | 5 votes |
@Override public Object execute(ExecutionEvent event) throws ExecutionException { // get resource type IWorkbenchPart activePart = HandlerUtil.getActivePart(event); ActionDelegate action = EditorPropertyTester.getActionExactResourceType(activePart, ResourceType.resourceTypeFileOrDirectory); if (action != null) { // load the preferences list = getMenuDataList(action.getCommonResourceType()); if (list.size() > 0) { IWorkbenchWindow workbenchWindow = activePart.getSite().getWorkbenchWindow(); if (list.size() == 1) { Utils.executeCommand(workbenchWindow.getWorkbench(), list.get(0), false); } else { // create and open a new dialog // close the old dialog if (dialog != null) { dialog.close(); dialog = null; } if (usePopup) { dialog = new ExecuteCommandPopup(workbenchWindow.getShell(), workbenchWindow.getWorkbench(), list, getTitle()); } else { dialog = new ExecuteCommandDialog(workbenchWindow.getShell(), workbenchWindow.getWorkbench(), list, getTitle()); } dialog.open(); } } } return null; }
Example 8
Source File: ProcidHandler.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
/** * the command has been executed, so extract extract the needed information * from the application context. */ public Object execute(ExecutionEvent event) throws ExecutionException { IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); ProcidDialog d = new ProcidDialog(window.getShell(), getProcessId()); d.open(); return null; }
Example 9
Source File: WakaTime.java From eclipse-wakatime with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static void promptForApiKey(IWorkbenchWindow window) { String apiKey = ConfigFile.get("settings", "api_key"); InputDialog dialog = new InputDialog(window.getShell(), "WakaTime API Key", "Please enter your api key from http://wakatime.com/settings#apikey", apiKey, null); if (dialog.open() == IStatus.OK) { apiKey = dialog.getValue(); ConfigFile.set("settings", "api_key", apiKey); } }
Example 10
Source File: LinkGhidraCommand.java From ghidra with Apache License 2.0 | 5 votes |
@Override public Object execute(ExecutionEvent event) throws ExecutionException { IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event); ISelection selection = window.getSelectionService().getSelection(); WizardDialog dialog = new WizardDialog(window.getShell(), new LinkGhidraWizard(selection)); dialog.open(); return null; }
Example 11
Source File: DropWorkbenchChangeListener.java From statecharts with Eclipse Public License 1.0 | 5 votes |
protected void windowChanged(IWorkbenchWindow window) { if (window == null) { return; } Shell shell = window.getShell(); runUpdate(shell); }
Example 12
Source File: ImportTmxHandler.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
/** * (non-Javadoc) * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) */ public Object execute(ExecutionEvent event) throws ExecutionException { SystemResourceUtil.load(); IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event); TmDbManagerImportWizard wizard = new TmDbManagerImportWizard(); ImportTmxWizardDialog dlg = new ImportTmxWizardDialog(window.getShell(), wizard); dlg.open(); return null; }
Example 13
Source File: JarImportWizardAction.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * {@inheritDoc} */ public void run(final IAction action) { if (fWorkbenchPart == null || fSelection == null) return; final IImportWizard wizard= new JarImportWizard(false); final IWorkbenchWindow window= fWorkbenchPart.getSite().getWorkbenchWindow(); wizard.init(window.getWorkbench(), fSelection); final WizardDialog dialog= new WizardDialog(window.getShell(), wizard); dialog.create(); dialog.getShell().setSize(Math.max(SIZING_WIZARD_WIDTH, dialog.getShell().getSize().x), SIZING_WIZARD_HEIGHT); PlatformUI.getWorkbench().getHelpSystem().setHelp(dialog.getShell(), IJavaHelpContextIds.JARIMPORT_WIZARD_PAGE); dialog.open(); }
Example 14
Source File: DeveloperStudioAboutPageHandler.java From devstudio-tooling-ei with Apache License 2.0 | 5 votes |
public Object execute(ExecutionEvent event) throws ExecutionException { IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); Shell shell = window.getShell(); shell.setText("Developer Studio"); AboutDialog aboutDialog = new AboutDialog(shell); aboutDialog.open(); return null; }
Example 15
Source File: N4JSGracefulActivator.java From n4js with Eclipse Public License 1.0 | 5 votes |
/** * Returns the active workbench shell or <code>null</code> if none * * @return the active workbench shell or <code>null</code> if none */ public static Shell getActiveWorkbenchShell() { IWorkbenchWindow window = getInstance().getWorkbench().getActiveWorkbenchWindow(); if (window != null) { return window.getShell(); } return null; }
Example 16
Source File: WorkbenchUtils.java From xds-ide with Eclipse Public License 1.0 | 4 votes |
public static Shell getWorkbenchWindowShell() { IWorkbenchWindow activeWindow = getActiveWorkbenchWindow(); return activeWindow != null ? activeWindow.getShell() : null; }
Example 17
Source File: NextSplitPointHandler.java From translationstudio8 with GNU General Public License v2.0 | 4 votes |
public Object execute(ExecutionEvent event) throws ExecutionException { final String XLIFF_EDITOR_ID = "net.heartsome.cat.ts.ui.xliffeditor.nattable.editor"; IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); final Shell shell = window.getShell(); XLIFFEditorImplWithNatTable xliffEditor = null; IWorkbenchPart activePart = HandlerUtil.getActivePart(event); if (activePart instanceof IEditorPart) { if (XLIFF_EDITOR_ID.equals(activePart.getSite().getId())) { xliffEditor = (XLIFFEditorImplWithNatTable) activePart; List<String> splitPointList = xliffEditor.getSplitXliffPoints(); if (splitPointList.size() <= 0) { MessageDialog.openInformation(shell, Messages.getString("all.dialog.info"), Messages.getString("NextSplitPointHandler.msg.nullSplitPoint")); return null; } final XLFHandler xlfHander = xliffEditor.getXLFHandler(); // 先对 splitPointList 进行排序 Collections.sort(splitPointList, new Comparator<String>() { public int compare(String rowId1, String rowId2) { int rowIndex1 = xlfHander.getRowIndex(rowId1); int rowIndex2 = xlfHander.getRowIndex(rowId2); return rowIndex1 > rowIndex2 ? 1 : -1; } }); List<String> selectionRowIdList = xliffEditor.getSelectedRowIds(); if (selectionRowIdList != null && selectionRowIdList.size() > 0) { curSelectionRowId = selectionRowIdList.get(0); } // 开始定位,定位之前让 nattable 恢复默认布局 xliffEditor.resetOrder(); if (curSelectionRowId == null) { curSelectionRowId = splitPointList.get(0); }else { int curSelectionRowIndex = xlfHander.getRowIndex(curSelectionRowId); for (String curRowId : splitPointList) { int pointRowIndex = xlfHander.getRowIndex(curRowId); if (pointRowIndex > curSelectionRowIndex) { curSelectionRowId = curRowId; xliffEditor.jumpToRow(curSelectionRowId); break; } } } } } return null; }
Example 18
Source File: NewTypeDropDownAction.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public void init(IWorkbenchWindow window) { fWizardShell= window.getShell(); }
Example 19
Source File: SWTUtils.java From saros with GNU General Public License v2.0 | 4 votes |
/** * Tries to get a {@linkplain Shell shell} that is centered on the shells of the current Eclipse * application. * * <p>Should be used instead of {@link Display#getActiveShell()}. * * @return a shell centered on top of the current application or <code>null</code> if no such * shell exists or the default display is disposed */ public static Shell getShell() { final Display display = getDisplay(); if (display.isDisposed()) return null; final IWorkbench workbench = PlatformUI.getWorkbench(); final IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow(); if (activeWorkbenchWindow != null && !activeWorkbenchWindow.getShell().isDisposed()) return activeWorkbenchWindow.getShell(); final IWorkbenchWindow[] workbenchWindows = workbench.getWorkbenchWindows(); if (workbenchWindows.length > 0 && !workbenchWindows[0].getShell().isDisposed()) return workbenchWindows[0].getShell(); return display.getActiveShell(); }
Example 20
Source File: WizardAction.java From CogniCrypt with Eclipse Public License 2.0 | 2 votes |
/** * We will cache window object in order to be able to provide parent shell for the message dialog. * * @see IWorkbenchWindowActionDelegate#init */ @Override public void init(final IWorkbenchWindow window) { this.shell = window.getShell(); }