Java Code Examples for org.eclipse.ui.dialogs.SelectionDialog#getResult()
The following examples show how to use
org.eclipse.ui.dialogs.SelectionDialog#getResult() .
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: GotoTypeAction.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override public void run() { Shell shell= JavaPlugin.getActiveWorkbenchShell(); SelectionDialog dialog= null; try { dialog= JavaUI.createTypeDialog(shell, new ProgressMonitorDialog(shell), SearchEngine.createWorkspaceScope(), IJavaElementSearchConstants.CONSIDER_ALL_TYPES, false); } catch (JavaModelException e) { String title= getDialogTitle(); String message= PackagesMessages.GotoType_error_message; ExceptionHandler.handle(e, title, message); return; } dialog.setTitle(getDialogTitle()); dialog.setMessage(PackagesMessages.GotoType_dialog_message); if (dialog.open() == IDialogConstants.CANCEL_ID) { return; } Object[] types= dialog.getResult(); if (types != null && types.length > 0) { gotoType((IType) types[0]); } }
Example 2
Source File: ExpandWithConstructorsConfigurationBlock.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * Creates the type hierarchy for type selection. */ private void doBrowseTypes() { IRunnableContext context= new BusyIndicatorRunnableContext(); IJavaSearchScope scope= SearchEngine.createWorkspaceScope(); int style= IJavaElementSearchConstants.CONSIDER_ALL_TYPES; try { SelectionDialog dialog= JavaUI.createTypeDialog(getShell(), context, scope, style, false, fNameDialogField.getText()); dialog.setTitle(CallHierarchyMessages.CallHierarchyTypesOrMembersDialog_ChooseTypeDialog_title); dialog.setMessage(CallHierarchyMessages.CallHierarchyTypesOrMembersDialog_ChooseTypeDialog_description); if (dialog.open() == Window.OK) { IType res= (IType)dialog.getResult()[0]; fNameDialogField.setText(res.getFullyQualifiedName('.')); } } catch (JavaModelException e) { ExceptionHandler.handle(e, getShell(), CallHierarchyMessages.CallHierarchyTypesOrMembersDialog_ChooseTypeDialog_title, CallHierarchyMessages.CallHierarchyTypesOrMembersDialog_ChooseTypeDialog_error_message); } }
Example 3
Source File: GenerateToStringDialog.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void browseForBuilderClass() { try { IJavaSearchScope scope= SearchEngine.createJavaSearchScope(new IJavaElement[] { getType().getJavaProject() }); SelectionDialog dialog= JavaUI.createTypeDialog(getShell(), PlatformUI.getWorkbench().getProgressService(), scope, IJavaElementSearchConstants.CONSIDER_CLASSES, false, "*ToString", fExtension); //$NON-NLS-1$ dialog.setTitle(JavaUIMessages.GenerateToStringDialog_customBuilderConfig_classSelection_windowTitle); dialog.setMessage(JavaUIMessages.GenerateToStringDialog_customBuilderConfig_classSelection_message); dialog.open(); if (dialog.getReturnCode() == OK) { IType type= (IType)dialog.getResult()[0]; fBuilderClassName.setText(type.getFullyQualifiedParameterizedName()); List<String> suggestions= fValidator.getAppendMethodSuggestions(type); if (!suggestions.contains(fAppendMethodName.getText())) fAppendMethodName.setText(suggestions.get(0)); suggestions= fValidator.getResultMethodSuggestions(type); if (!suggestions.contains(fResultMethodName.getText())) fResultMethodName.setText(suggestions.get(0)); } } catch (JavaModelException e) { JavaPlugin.log(e); } }
Example 4
Source File: CodeAssistFavoritesConfigurationBlock.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void doBrowseTypes() { IRunnableContext context= new BusyIndicatorRunnableContext(); IJavaSearchScope scope= SearchEngine.createWorkspaceScope(); int style= IJavaElementSearchConstants.CONSIDER_ALL_TYPES; try { SelectionDialog dialog= JavaUI.createTypeDialog(getShell(), context, scope, style, false, fNameDialogField.getText()); dialog.setTitle(PreferencesMessages.FavoriteStaticMemberInputDialog_ChooseTypeDialog_title); dialog.setMessage(PreferencesMessages.FavoriteStaticMemberInputDialog_ChooseTypeDialog_description); if (dialog.open() == Window.OK) { IType res= (IType) dialog.getResult()[0]; fNameDialogField.setText(res.getFullyQualifiedName('.')); } } catch (JavaModelException e) { ExceptionHandler.handle(e, getShell(), PreferencesMessages.FavoriteStaticMemberInputDialog_ChooseTypeDialog_title, PreferencesMessages.FavoriteStaticMemberInputDialog_ChooseTypeDialog_error_message); } }
Example 5
Source File: ProblemSeveritiesConfigurationBlock.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void doBrowseTypes(StringButtonDialogField dialogField) { IRunnableContext context= new BusyIndicatorRunnableContext(); IJavaSearchScope scope= SearchEngine.createWorkspaceScope(); int style= IJavaElementSearchConstants.CONSIDER_ANNOTATION_TYPES; try { SelectionDialog dialog= JavaUI.createTypeDialog(getShell(), context, scope, style, false, dialogField.getText()); dialog.setTitle(PreferencesMessages.NullAnnotationsConfigurationDialog_browse_title); dialog.setMessage(PreferencesMessages.NullAnnotationsConfigurationDialog_choose_annotation); if (dialog.open() == Window.OK) { IType res= (IType) dialog.getResult()[0]; dialogField.setText(res.getFullyQualifiedName('.')); } } catch (JavaModelException e) { ExceptionHandler.handle(e, getShell(), PreferencesMessages.NullAnnotationsConfigurationDialog_error_title, PreferencesMessages.NullAnnotationsConfigurationDialog_error_message); } }
Example 6
Source File: ImportOrganizeInputDialog.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void doBrowseTypes() { IRunnableContext context= new BusyIndicatorRunnableContext(); IJavaSearchScope scope= SearchEngine.createWorkspaceScope(); int style= IJavaElementSearchConstants.CONSIDER_ALL_TYPES; try { SelectionDialog dialog= JavaUI.createTypeDialog(getShell(), context, scope, style, false, fNameDialogField.getText()); dialog.setTitle(PreferencesMessages.ImportOrganizeInputDialog_ChooseTypeDialog_title); dialog.setMessage(PreferencesMessages.ImportOrganizeInputDialog_ChooseTypeDialog_description); if (dialog.open() == Window.OK) { IType res= (IType) dialog.getResult()[0]; fNameDialogField.setText(res.getFullyQualifiedName('.')); } } catch (JavaModelException e) { ExceptionHandler.handle(e, getShell(), PreferencesMessages.ImportOrganizeInputDialog_ChooseTypeDialog_title, PreferencesMessages.ImportOrganizeInputDialog_ChooseTypeDialog_error_message); } }
Example 7
Source File: OpenOppositeFileHandler.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
protected List<FileOpener> selectOpeners(IWorkbenchPage page, Collection<FileOpener> openers) { Shell shell = page.getWorkbenchWindow().getShell(); SelectionDialog dialog = new FileOpenerSelector(shell, openers); if (dialog.open() == Window.OK) { List<FileOpener> result = Lists.newArrayList(); for (Object item : dialog.getResult()) if (item instanceof FileOpener) result.add((FileOpener) item); return result; } return Collections.emptyList(); }
Example 8
Source File: DialogUtils.java From typescript.java with MIT License | 5 votes |
public static IProject openProjectDialog(String initialProject, Shell shell) { SelectionDialog dialog = createFolderDialog(initialProject, null, true, false, shell); if (dialog.open() != Window.OK) { return null; } Object[] results = dialog.getResult(); if (results != null && results.length > 0) { return (IProject) results[0]; } return null; }
Example 9
Source File: DialogUtils.java From typescript.java with MIT License | 5 votes |
public static IResource openFolderDialog(String initialFolder, IProject project, boolean showAllProjects, Shell shell) { SelectionDialog dialog = createFolderDialog(initialFolder, project, showAllProjects, true, shell); if (dialog.open() != Window.OK) { return null; } Object[] results = dialog.getResult(); if (results != null && results.length > 0) { return (IResource) results[0]; } return null; }
Example 10
Source File: GotoPackageAction.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public void run() { Shell shell= JavaPlugin.getActiveWorkbenchShell(); SelectionDialog dialog= createAllPackagesDialog(shell); dialog.setTitle(getDialogTitle()); dialog.setMessage(PackagesMessages.GotoPackage_dialog_message); dialog.open(); Object[] res= dialog.getResult(); if (res != null && res.length == 1) gotoPackage((IPackageFragment)res[0]); }
Example 11
Source File: AbstractInterpreterEditor.java From Pydev with Eclipse Public License 1.0 | 4 votes |
public void restoreInterpreterInfos(boolean editorChanged, Shell shell, IInterpreterManager iInterpreterManager) { final Set<String> interpreterNamesToRestore = this.getInterpreterExeOrJarToRestoreAndClear(); final IInterpreterInfo[] exesList = this.getExesList(); if (!editorChanged && interpreterNamesToRestore.size() == 0) { IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); SelectionDialog listDialog = AbstractInterpreterPreferencesPage.createChooseIntepreterInfoDialog( workbenchWindow, exesList, "Select interpreters to be restored", true); int open = listDialog.open(); if (open != ListDialog.OK) { return; } Object[] result = listDialog.getResult(); if (result == null || result.length == 0) { return; } for (Object o : result) { interpreterNamesToRestore.add(((IInterpreterInfo) o).getExecutableOrJar()); } } //this is the default interpreter ProgressMonitorDialog monitorDialog = new AsynchronousProgressMonitorDialog(shell); monitorDialog.setBlockOnOpen(false); try { IRunnableWithProgress operation = new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask("Restoring PYTHONPATH", IProgressMonitor.UNKNOWN); try { pushExpectedSetInfos(); //clear all but the ones that appear iInterpreterManager.setInfos(exesList, interpreterNamesToRestore, monitor); } finally { popExpectedSetInfos(); monitor.done(); } } }; monitorDialog.run(true, true, operation); } catch (Exception e) { Log.log(e); } }
Example 12
Source File: PySelectInterpreter.java From Pydev with Eclipse Public License 1.0 | 4 votes |
@Override public void run(IAction action) { try { PyEdit editor = getPyEdit(); IPythonNature nature = editor.getPythonNature(); if (nature != null) { IInterpreterManager interpreterManager = nature.getRelatedInterpreterManager(); final IInterpreterInfo[] interpreterInfos = interpreterManager.getInterpreterInfos(); if (interpreterInfos == null || interpreterInfos.length == 0) { PyDialogHelpers.openWarning("No interpreters available", "Unable to change default interpreter because no interpreters are available (add more interpreters in the related preferences page)."); return; } if (interpreterInfos.length == 1) { PyDialogHelpers.openWarning("Only 1 interpreters available", "Unable to change default interpreter because only 1 interpreter is configured (add more interpreters in the related preferences page)."); return; } // Ok, more than 1 found. IWorkbenchWindow workbenchWindow = EditorUtils.getActiveWorkbenchWindow(); Assert.isNotNull(workbenchWindow); SelectionDialog listDialog = AbstractInterpreterPreferencesPage.createChooseIntepreterInfoDialog( workbenchWindow, interpreterInfos, "Select interpreter to be made the default.", false); int open = listDialog.open(); if (open != ListDialog.OK || listDialog.getResult().length != 1) { return; } Object[] result = listDialog.getResult(); if (result == null || result.length == 0) { return; } final IInterpreterInfo selectedInterpreter = ((IInterpreterInfo) result[0]); if (selectedInterpreter != interpreterInfos[0]) { // Ok, some interpreter (which wasn't already the default) was selected. Arrays.sort(interpreterInfos, (a, b) -> { if (a == selectedInterpreter) { return -1; } if (b == selectedInterpreter) { return 1; } return 0; // Don't change order for the others. }); Shell shell = EditorUtils.getShell(); setInterpreterInfosWithProgressDialog(interpreterManager, interpreterInfos, shell); } } } catch (Exception e) { Log.log(e); } }
Example 13
Source File: PrimitiveSection.java From uima-uimaj with Apache License 2.0 | 4 votes |
@Override public void handleEvent(Event event) { valueChanged = false; OperationalProperties ops = getOperationalProperties(); if (event.widget == findButton) { String className = null; try { String implKind = editor.getAeDescription().getFrameworkImplementation(); if (Constants.CPP_FRAMEWORK_NAME.equals(implKind)) { FileDialog dialog = new FileDialog(getSection().getShell(), SWT.NONE); String[] extensions = { "*.dll" }; dialog.setFilterExtensions(extensions); String sStartDir = Platform.getLocation().toString(); dialog.setFilterPath(sStartDir); className = dialog.open(); } else { SelectionDialog typeDialog = JavaUI.createTypeDialog(getSection().getShell(), editor .getEditorSite().getWorkbenchWindow(), editor.getSearchScopeForDescriptorType(), IJavaElementSearchConstants.CONSIDER_CLASSES, false, "*"); typeDialog.setTitle(MessageFormat.format("Choose the {0} implementation class", new Object[] { editor.descriptorTypeString() })); typeDialog.setMessage("Filter/mask:"); if (typeDialog.open() == Window.CANCEL) return; Object[] result = typeDialog.getResult(); if (result != null && result.length > 0) className = ((IType) result[0]).getFullyQualifiedName(); } if (className == null || className.equals("")) //$NON-NLS-1$ return; implName.setText(className); editor.getAeDescription().setAnnotatorImplementationName(className); valueChanged = true; } catch (JavaModelException e) { throw new InternalErrorCDE("unexpected Exception", e); } } else if (event.widget == modifiesCas) { ops.setModifiesCas(setValueChangedBoolean(modifiesCas.getSelection(), ops.getModifiesCas())); } else if (event.widget == multipleDeploymentAllowed) { ops.setMultipleDeploymentAllowed(setValueChangedBoolean(multipleDeploymentAllowed .getSelection(), ops.isMultipleDeploymentAllowed())); } else if (event.widget == outputsNewCASes) { ops.setOutputsNewCASes(setValueChangedBoolean(outputsNewCASes.getSelection(), ops .getOutputsNewCASes())); } else if (event.widget == implName) { editor.getAeDescription().setAnnotatorImplementationName( setValueChanged(implName.getText(), editor.getAeDescription() .getAnnotatorImplementationName())); } if (valueChanged) editor.setFileDirty(); }
Example 14
Source File: JarManifestWizardPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 3 votes |
/** * Converts selection dialog results into an array of IPackageFragments. * An empty array is returned in case of errors. * @param dialog the dialog * @return the selected IPackageFragments * @throws ClassCastException if results are not IPackageFragments */ protected IPackageFragment[] getPackagesFromDialog(SelectionDialog dialog) { if (dialog.getReturnCode() == Window.OK && dialog.getResult().length > 0) return Arrays.asList(dialog.getResult()).toArray(new IPackageFragment[dialog.getResult().length]); else return new IPackageFragment[0]; }