/** * Shows a dialog for resolving an ambiguous java element. * Utility method that can be called by subclasses. */ public static IJavaElement selectJavaElement(IJavaElement[] elements, Shell shell, String title, String message) { int nResults= elements.length; if (nResults == 0) return null; if (nResults == 1) return elements[0]; int flags= JavaElementLabelProvider.SHOW_DEFAULT | JavaElementLabelProvider.SHOW_QUALIFIED | JavaElementLabelProvider.SHOW_ROOT; ElementListSelectionDialog dialog= new ElementListSelectionDialog(shell, new JavaElementLabelProvider(flags)); dialog.setTitle(title); dialog.setMessage(message); dialog.setElements(elements); if (dialog.open() == Window.OK) { return (IJavaElement) dialog.getFirstResult(); } return null; } }
/** * Shows a selection dialog. Returns chosen element(s) or null if dialog was * cancelled. */ public Object[] selectionDialog(Object[] elements, String title, String message, boolean multi) { // TODO re-think: implement DebugModelPresentation extension for // ILaunchTarget? ILabelProvider labelProvider = DebugUITools.newDebugModelPresentation(); try { ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), labelProvider); dialog.setTitle(title); dialog.setMessage(message); dialog.setElements(elements); dialog.setMultipleSelection(multi); dialog.open(); return dialog.getResult(); } finally { labelProvider.dispose(); } }
@Override public String selectArgument(IStringVariable variable, Shell shell) { ElementListSelectionDialog dialog = new ElementListSelectionDialog(shell, new LabelProvider()); dialog.setElements(System.getProperties().keySet().toArray()); dialog.setTitle(StringSubstitutionMessages.SystemPropertyArgumentSelector_0); dialog.setMessage(StringSubstitutionMessages.SystemPropertyArgumentSelector_1); if (dialog.open() == Window.OK) { return (String) dialog.getResult()[0]; } return null; }
private void handleAdd() { ElementListSelectionDialog dialog = new ElementListSelectionDialog(PDEPlugin.getActiveWorkbenchShell(), new EELabelProvider()); dialog.setElements(getEnvironments()); dialog.setAllowDuplicates(false); dialog.setMultipleSelection(true); dialog.setTitle(PDEUIMessages.RequiredExecutionEnvironmentSection_dialog_title); dialog.setMessage(PDEUIMessages.RequiredExecutionEnvironmentSection_dialogMessage); dialog.create(); PlatformUI.getWorkbench().getHelpSystem().setHelp(dialog.getShell(), IHelpContextIds.EXECUTION_ENVIRONMENT_SELECTION); if (dialog.open() == Window.OK) { addExecutionEnvironments(dialog.getResult()); } }
String currentSelectedPrototypeString = fPrototypeText.getText(); DecoratingLabelProvider labelProvider = new DecoratingLabelProvider(DebugUITools.newDebugModelPresentation(), PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator()); ElementListSelectionDialog selectPrototypeDialog = new ElementListSelectionDialog(getShell(), labelProvider); try { ILaunchConfigurationType type = fSelectedLaunchConfiguration.getType(); ILaunchConfiguration[] prototypes = type.getPrototypes(); selectPrototypeDialog.setElements(prototypes); selectPrototypeDialog.setMultipleSelection(false); selectPrototypeDialog.setTitle(LaunchConfigurationsMessages.PrototypeTab_Select_Message_5); selectPrototypeDialog.setEmptySelectionMessage(LaunchConfigurationsMessages.PrototypeTab_Select_Empty_Message_6); selectPrototypeDialog.setInitialSelections(getPrototype(prototypes, currentSelectedPrototypeString)); int open = selectPrototypeDialog.open(); if (open == Window.OK) { Object selectedPrototype = selectPrototypeDialog.getFirstResult(); if (selectedPrototype instanceof ILaunchConfiguration) { fAppliedPrototype = (ILaunchConfiguration) selectedPrototype;
/** * add a new package to the list of all available package filters */ private void addPackage() { try { ElementListSelectionDialog dialog = JDIDebugUIPlugin.createAllPackagesDialog(getShell(), null, false); dialog.setTitle(DebugUIMessages.JavaStepFilterPreferencePage_Add_package_to_step_filters_24); dialog.setMessage(DebugUIMessages.JavaStepFilterPreferencePage_Select_a_package_to_filter_when_stepping_27); dialog.setMultipleSelection(true); if (dialog.open() == IDialogConstants.OK_ID) { Object[] packages = dialog.getResult(); if (packages != null) { IJavaElement pkg = null; for (int i = 0; i < packages.length; i++) { pkg = (IJavaElement)packages[i]; String filter = pkg.getElementName() + ".*"; //$NON-NLS-1$ addFilter(filter, true); } } } } catch (JavaModelException jme) { ExceptionHandler.handle(jme, DebugUIMessages.JavaStepFilterPreferencePage_Add_package_to_step_filters_24, DebugUIMessages.JavaStepFilterPreferencePage_Could_not_open_package_selection_dialog_for_step_filters_25); } }
public int open() { MainMethodSearchEngine engine= new MainMethodSearchEngine(); IType[] types; try { types= engine.searchMainMethods(fRunnableContext, fScope, fStyle); } catch (InterruptedException e) { return CANCEL; } catch (InvocationTargetException e) { //XX: to do ExceptionHandler.handle(e, JavaUIMessages.MultiMainTypeSelectionDialog_errorTitle, e.getMessage()); return CANCEL; } setElements(types); return super.open(); }
@Override public void setElements(Object[] elements) { super.setElements(elements); fElements = elements; }
protected void handleAdd() { ElementListSelectionDialog dialog = new ElementListSelectionDialog(PDEPlugin.getActiveWorkbenchShell(), new StyledBundleLabelProvider(false, false)); dialog.setTitle(PDEUIMessages.PluginSelectionDialog_title); dialog.setMessage(PDEUIMessages.PluginSelectionDialog_message); dialog.setMultipleSelection(true); try { dialog.setElements(getValidBundles()); } catch (CoreException e) { dialog.setMessage(e.getMessage()); } dialog.create(); PlatformUI.getWorkbench().getHelpSystem().setHelp(dialog.getShell(), IHelpContextIds.IMPLICIT_DEPENDENCIES_SELECTION_DIALOG); if (dialog.open() == Window.OK) { Object[] models = dialog.getResult(); ArrayList<NameVersionDescriptor> pluginsToAdd = new ArrayList<>(); for (Object model : models) { BundleInfo selected = ((BundleInfo) model); pluginsToAdd.add(new NameVersionDescriptor(selected.getSymbolicName(), null)); } Set<NameVersionDescriptor> allDependencies = new HashSet<>(); allDependencies.addAll(pluginsToAdd); NameVersionDescriptor[] currentBundles = getTarget().getImplicitDependencies(); if (currentBundles != null) { allDependencies.addAll(Arrays.asList(currentBundles)); } getTarget().setImplicitDependencies(allDependencies.toArray(new NameVersionDescriptor[allDependencies.size()])); markDirty(); refresh(); } }
ElementListSelectionDialog selectPrototypeDialog = new ElementListSelectionDialog(getShell(), labelProvider); selectPrototypeDialog.setElements(prototypes); selectPrototypeDialog.setInitialSelections(firstLaunchConfiguration.getPrototype()); selectPrototypeDialog.setMultipleSelection(false); selectPrototypeDialog.setEmptySelectionMessage("You have to select a prototype."); //$NON-NLS-1$ selectPrototypeDialog.setTitle("Please select a prototype"); //$NON-NLS-1$ int open = selectPrototypeDialog.open(); if (open == Window.OK) { Object selectedPrototype = selectPrototypeDialog.getFirstResult(); for (Object launchConfiguration : getStructuredSelection().toList()) { if (launchConfiguration instanceof ILaunchConfiguration) {
return; dialog.setTitle(PropertyPageMessages.ExceptionFilterEditor_15); dialog.setMessage(PropertyPageMessages.ExceptionFilterEditor_18); dialog.setMultipleSelection(true); if (dialog.open() == IDialogConstants.CANCEL_ID) { return; Object[] packages = dialog.getResult(); if (packages != null) { for (int i = 0; i < packages.length; i++) {
@Override public int open() { MainMethodSearchEngine engine= new MainMethodSearchEngine(); IType[] types; try { types= engine.searchMainMethods(fRunnableContext, fScope, fStyle); } catch (InterruptedException e) { return CANCEL; } catch (InvocationTargetException e) { //XX: to do ExceptionHandler.handle(e, JavaUIMessages.MultiMainTypeSelectionDialog_errorTitle, e.getMessage()); return CANCEL; } setElements(types); return super.open(); }
@Override protected void browse() { ElementListSelectionDialog dialog = new ElementListSelectionDialog(PDEPlugin.getActiveWorkbenchShell(), new IdAttributeLabelProvider()); dialog.setTitle(PDEUIMessages.IdAttributeRow_title); dialog.setMessage(PDEUIMessages.IdAttributeRow_message); dialog.setEmptyListMessage(PDEUIMessages.IdAttributeRow_emptyMessage); Map<String, IConfigurationElement> attributeMap = PDESchemaHelper.getValidAttributes(getAttribute()); dialog.setElements(attributeMap.entrySet().toArray()); dialog.setFilter("*"); //$NON-NLS-1$ if (dialog.open() == Window.OK) { Map.Entry<?, ?> entry = (Entry<?, ?>) dialog.getFirstResult(); text.setText(entry.getKey().toString()); } }
return; dialog.setTitle(SnippetMessages.getString("SelectImportsDialog.Add_package_as_import_7")); //$NON-NLS-1$ dialog.setMessage(SnippetMessages.getString("SelectImportsDialog.&Select_a_package_to_add_as_an_Import_10")); //$NON-NLS-1$ dialog.setMultipleSelection(true); if (dialog.open() == IDialogConstants.CANCEL_ID) { return; Object[] packages= dialog.getResult(); if (packages != null) { for (int i = 0; i < packages.length; i++) {
@Override public int open() { MainMethodSearchEngine engine= new MainMethodSearchEngine(); IType[] types; try { types= engine.searchMainMethods(fRunnableContext, fScope, fStyle); } catch (InterruptedException e) { return CANCEL; } catch (InvocationTargetException e) { //XX: to do ExceptionHandler.handle(e, JavaUIMessages.MultiMainTypeSelectionDialog_errorTitle, e.getMessage()); return CANCEL; } setElements(types); return super.open(); }
private ILaunchConfiguration chooseConfiguration(ILaunchConfiguration[] configs) { IDebugModelPresentation labelProvider = DebugUITools.newDebugModelPresentation(); ElementListSelectionDialog dialog = new ElementListSelectionDialog(PDEPlugin.getActiveWorkbenchShell(), labelProvider); dialog.setElements(configs); dialog.setTitle(PDEUIMessages.RuntimeWorkbenchShortcut_title); if (fMode.equals(ILaunchManager.DEBUG_MODE)) { dialog.setMessage(PDEUIMessages.RuntimeWorkbenchShortcut_select_debug); } else { dialog.setMessage(PDEUIMessages.RuntimeWorkbenchShortcut_select_run); } dialog.setMultipleSelection(false); int result = dialog.open(); labelProvider.dispose(); if (result == Window.OK) { return (ILaunchConfiguration) dialog.getFirstResult(); } return null; }
public void run() { ElementListSelectionDialog dialog = new ElementListSelectionDialog(Display.getCurrent().getActiveShell(), new LaunchConfigurationLabelProvider()); dialog.setElements(existingLaunchConfigurations); dialog.setTitle("Choose Launch Configuration"); dialog.setMessage("Multiple launch configuration apply to your selection.\nPlease choose one:"); dialog.setMultipleSelection(false); if (dialog.open() != Window.OK) { return; } result.setResult((ILaunchConfiguration) dialog.getResult()[0]); } });
return super.open();
private void browseForPropertyFile() { ElementListSelectionDialog dialog= new ElementListSelectionDialog(getShell(), new JavaElementLabelProvider()); dialog.setIgnoreCase(false); dialog.setTitle(NLSUIMessages.NLSAccessorConfigurationDialog_Property_File_Selection); dialog.setMessage(NLSUIMessages.NLSAccessorConfigurationDialog_Choose_the_property_file); dialog.setElements(createFileListInput()); dialog.setFilter('*' + NLSRefactoring.PROPERTY_FILE_EXT); if (dialog.open() == Window.OK) { IFile selectedFile= (IFile) dialog.getFirstResult(); if (selectedFile != null) fResourceBundleFile.setText(selectedFile.getName()); } }
| JavaElementLabelProvider.SHOW_ROOT; ElementListSelectionDialog dialog= new ElementListSelectionDialog(shell, new JavaElementLabelProvider(flags)); dialog.setTitle(title); dialog.setMessage(message); dialog.setElements(elements.toArray()); if (dialog.open() == Window.OK) { Object[] selection= dialog.getResult(); if (selection != null && selection.length > 0) { nResults= selection.length;