org.eclipse.ui.dialogs.ListDialog Java Examples
The following examples show how to use
org.eclipse.ui.dialogs.ListDialog.
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: OpenXtextElementHandler.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Override public Object execute(ExecutionEvent event) throws ExecutionException { Shell activeShell = HandlerUtil.getActiveShell(event); ListDialog searchDialog = createSearchDialog(event, activeShell, searchEngine); int result = searchDialog.open(); if (result == Window.OK) { try { Object[] selections = searchDialog.getResult(); if (selections != null && selections.length > 0) { Object selection = selections[0]; if (selection instanceof IEObjectDescription) { IEObjectDescription selectedObjectDescription = (IEObjectDescription) selection; uriEditorOpener.open(selectedObjectDescription.getEObjectURI(), true); } } } catch (Exception e) { LOG.error("Error opening editor", e); throw new ExecutionException("Error opening editor", e); } } return null; }
Example #2
Source File: ReorgQueries.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private Runnable createQueryRunnable(final String question, final Object[] elements, final int[] result) { return new Runnable() { public void run() { ListDialog dialog= new YesNoListDialog(fShell, true); dialog.setAddCancelButton(false); dialog.setBlockOnOpen(true); dialog.setContentProvider(new ArrayContentProvider()); dialog.setLabelProvider(new JavaElementLabelProvider()); dialog.setTitle(fDialogTitle); dialog.setMessage(question); dialog.setInput(elements); dialog.open(); result[0]= dialog.getReturnCode(); } }; }
Example #3
Source File: ReorgQueries.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private Runnable createQueryRunnable(final String question, final Object[] elements, final int[] result) { return new Runnable() { public void run() { ListDialog dialog= new YesNoListDialog(fShell, false); dialog.setAddCancelButton(false); dialog.setBlockOnOpen(true); dialog.setContentProvider(new ArrayContentProvider()); dialog.setLabelProvider(new JavaElementLabelProvider()); dialog.setTitle(fDialogTitle); dialog.setMessage(question); dialog.setInput(elements); dialog.open(); result[0]= dialog.getReturnCode(); } }; }
Example #4
Source File: ResourceCloseManagement.java From birt with Eclipse Public License 1.0 | 6 votes |
private static boolean showSaveDirtyFileDialog( List<IEditorPart> dirtyEditors ) { AdaptableList input = new AdaptableList( dirtyEditors ); ListDialog dlg = new ListDialog( PlatformUI.getWorkbench( ) .getActiveWorkbenchWindow( ) .getShell( ) ); dlg.setContentProvider( new BaseWorkbenchContentProvider( ) ); dlg.setLabelProvider( new WorkbenchPartLabelProvider( ) ); dlg.setInput( input ); dlg.setMessage( Messages.getString( "renameChecker.saveResourcesMessage" ) ); //$NON-NLS-1$ dlg.setTitle( Messages.getString( "renameChecker.saveResourcesTitle" ) ); //$NON-NLS-1$ // Just return false to prevent the operation continuing return dlg.open( ) == IDialogConstants.OK_ID; }
Example #5
Source File: ConfigureProjectFromBluePrintAction.java From eclipse-cs with GNU Lesser General Public License v2.1 | 5 votes |
/** * {@inheritDoc} */ @Override public void run(IAction action) { IProject[] projects = CheckstyleUIPlugin.getWorkspace().getRoot().getProjects(); List<IProject> filteredProjects = new ArrayList<>(); for (int i = 0; i < projects.length; i++) { filteredProjects.add(projects[i]); } filteredProjects.removeAll(mSelectedProjects); ListDialog dialog = new ListDialog(mPart.getSite().getShell()); dialog.setInput(filteredProjects); dialog.setContentProvider(new ArrayContentProvider()); dialog.setLabelProvider(new WorkbenchLabelProvider()); dialog.setMessage(Messages.ConfigureProjectFromBluePrintAction_msgSelectBlueprintProject); dialog.setTitle(Messages.ConfigureProjectFromBluePrintAction_titleSelectBlueprintProject); if (Window.OK == dialog.open()) { Object[] result = dialog.getResult(); if (result.length > 0) { BulkConfigureJob job = new BulkConfigureJob((IProject) result[0], mSelectedProjects); job.schedule(); } } }
Example #6
Source File: RefactoringSaveHelper.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private boolean askSaveAllDirtyEditors(Shell shell, IEditorPart[] dirtyEditors) { final boolean canSaveAutomatically= fSaveMode != SAVE_ALL_ALWAYS_ASK; if (canSaveAutomatically && RefactoringSavePreferences.getSaveAllEditors()) //must save everything return true; ListDialog dialog= new ListDialog(shell) { { setShellStyle(getShellStyle() | SWT.APPLICATION_MODAL); } @Override protected Control createDialogArea(Composite parent) { Composite result= (Composite) super.createDialogArea(parent); if (canSaveAutomatically) { final Button check= new Button(result, SWT.CHECK); check.setText(RefactoringMessages.RefactoringStarter_always_save); check.setSelection(RefactoringSavePreferences.getSaveAllEditors()); check.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { RefactoringSavePreferences.setSaveAllEditors(check.getSelection()); } }); applyDialogFont(result); } return result; } }; dialog.setTitle(RefactoringMessages.RefactoringStarter_save_all_resources); dialog.setAddCancelButton(true); dialog.setLabelProvider(createDialogLabelProvider()); dialog.setMessage(RefactoringMessages.RefactoringStarter_must_save); dialog.setContentProvider(new ArrayContentProvider()); dialog.setInput(Arrays.asList(dirtyEditors)); return dialog.open() == Window.OK; }
Example #7
Source File: RefactoringSaveHelper.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private boolean askSaveAllDirtyEditors(Shell shell, IEditorPart[] dirtyEditors) { final boolean canSaveAutomatically= fSaveMode != SAVE_ALL_ALWAYS_ASK; if (canSaveAutomatically && RefactoringSavePreferences.getSaveAllEditors()) //must save everything return true; ListDialog dialog= new ListDialog(shell) { { setShellStyle(getShellStyle() | SWT.APPLICATION_MODAL); } @Override protected Control createDialogArea(Composite parent) { Composite result= (Composite) super.createDialogArea(parent); if (canSaveAutomatically) { final Button check= new Button(result, SWT.CHECK); check.setText(RefactoringMessages.RefactoringStarter_always_save); check.setSelection(RefactoringSavePreferences.getSaveAllEditors()); check.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { RefactoringSavePreferences.setSaveAllEditors(check.getSelection()); } }); applyDialogFont(result); } return result; } }; dialog.setTitle(RefactoringMessages.RefactoringStarter_save_all_resources); dialog.setLabelProvider(createDialogLabelProvider()); dialog.setMessage(RefactoringMessages.RefactoringStarter_must_save); dialog.setContentProvider(new ArrayContentProvider()); dialog.setInput(Arrays.asList(dirtyEditors)); return dialog.open() == Window.OK; }
Example #8
Source File: OpenXtextElementHandler.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
protected ListDialog createSearchDialog(ExecutionEvent event, Shell activeShell, IXtextEObjectSearch searchEngine) { return new XtextEObjectSearchDialog(activeShell, searchEngine, globalDescriptionLabelProvider, isEnableStyledLabels()); }
Example #9
Source File: NewMergeFileAssociationWizardPage.java From APICloud-Studio with GNU General Public License v3.0 | 4 votes |
private void addVariables(Text target, Map bindings) { final List variables = new ArrayList(bindings.size()); ILabelProvider labelProvider = new LabelProvider() { public String getText(Object element) { return ((StringPair) element).s1 + " - " + ((StringPair) element).s2; //$NON-NLS-1$ } }; IStructuredContentProvider contentsProvider = new IStructuredContentProvider() { public Object[] getElements(Object inputElement) { return variables.toArray(new StringPair[variables.size()]); } public void dispose() { } public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } }; for (Iterator it = bindings.keySet().iterator(); it.hasNext();) { StringPair variable = new StringPair(); variable.s1 = (String) it.next(); // variable variable.s2 = (String) bindings.get(variable.s1); // description variables.add(variable); } ListDialog dialog = new ListDialog(this.getShell()); dialog.setContentProvider(contentsProvider); dialog.setAddCancelButton(true); dialog.setLabelProvider(labelProvider); dialog.setInput(variables); dialog.setTitle(Policy .bind("DiffMergePreferencePage.addVariableDialogTitle")); //$NON-NLS-1$ if (dialog.open() != ListDialog.OK) return; Object[] result = dialog.getResult(); for (int i = 0; i < result.length; i++) { target.insert("${" + ((StringPair) result[i]).s1 + "}"); //$NON-NLS-1$ //$NON-NLS-2$ } }
Example #10
Source File: DiffMergePreferencePage.java From APICloud-Studio with GNU General Public License v3.0 | 4 votes |
/** * Add another variable to the given target. The variable is inserted at * current position A ListSelectionDialog is shown and the choose the * variables to add */ private void addVariables(Text target, Map bindings) { final List variables = new ArrayList(bindings.size()); ILabelProvider labelProvider = new LabelProvider() { public String getText(Object element) { return ((StringPair) element).s1 + " - " + ((StringPair) element).s2; //$NON-NLS-1$ } }; IStructuredContentProvider contentsProvider = new IStructuredContentProvider() { public Object[] getElements(Object inputElement) { return variables.toArray(new StringPair[variables.size()]); } public void dispose() { } public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } }; for (Iterator it = bindings.keySet().iterator(); it.hasNext();) { StringPair variable = new StringPair(); variable.s1 = (String) it.next(); // variable variable.s2 = (String) bindings.get(variable.s1); // description variables.add(variable); } ListDialog dialog = new ListDialog(this.getShell()); dialog.setContentProvider(contentsProvider); dialog.setAddCancelButton(true); dialog.setLabelProvider(labelProvider); dialog.setInput(variables); dialog.setTitle(Policy .bind("DiffMergePreferencePage.addVariableDialogTitle")); //$NON-NLS-1$ if (dialog.open() != ListDialog.OK) return; Object[] result = dialog.getResult(); for (int i = 0; i < result.length; i++) { target.insert("${" + ((StringPair) result[i]).s1 + "}"); //$NON-NLS-1$ //$NON-NLS-2$ } }
Example #11
Source File: MergeFileAssociationPreferencePage.java From APICloud-Studio with GNU General Public License v3.0 | 4 votes |
private void addVariables(Text target, Map bindings) { final List variables = new ArrayList(bindings.size()); ILabelProvider labelProvider = new LabelProvider() { public String getText(Object element) { return ((StringPair) element).s1 + " - " + ((StringPair) element).s2; //$NON-NLS-1$ } }; IStructuredContentProvider contentsProvider = new IStructuredContentProvider() { public Object[] getElements(Object inputElement) { return variables.toArray(new StringPair[variables.size()]); } public void dispose() { } public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } }; for (Iterator it = bindings.keySet().iterator(); it.hasNext();) { StringPair variable = new StringPair(); variable.s1 = (String) it.next(); // variable variable.s2 = (String) bindings.get(variable.s1); // description variables.add(variable); } ListDialog dialog = new ListDialog(this.getShell()); dialog.setContentProvider(contentsProvider); dialog.setAddCancelButton(true); dialog.setLabelProvider(labelProvider); dialog.setInput(variables); dialog.setTitle(Policy .bind("DiffMergePreferencePage.addVariableDialogTitle")); //$NON-NLS-1$ if (dialog.open() != ListDialog.OK) return; Object[] result = dialog.getResult(); for (int i = 0; i < result.length; i++) { target.insert("${" + ((StringPair) result[i]).s1 + "}"); //$NON-NLS-1$ //$NON-NLS-2$ } }
Example #12
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 #13
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); } }