@Override public void run(final IStructuredSelection selection) { IWorkspaceRunnable operation= new IWorkspaceRunnable() { @Override public void run(IProgressMonitor monitor) throws CoreException { performRefresh(selection, monitor); } }; new WorkbenchRunnableAdapter(operation).runAsUserJob(ActionMessages.RefreshAction_refresh_operation_label, null); }
@Override public void run(final IStructuredSelection selection) { IWorkspaceRunnable operation= new IWorkspaceRunnable() { @Override public void run(IProgressMonitor monitor) throws CoreException { performRefresh(selection, monitor); } }; new WorkbenchRunnableAdapter(operation).runAsUserJob(ActionMessages.RefreshAction_refresh_operation_label, null); }
protected IStatus run(IProgressMonitor monitor) { try { IWorkspaceRunnable runnable= new IWorkspaceRunnable() { public void run(IProgressMonitor pm) throws CoreException { updateClasspathEntries(oldLocations, pm); IPreferenceStore preferenceStore= PreferenceConstants.getPreferenceStore(); preferenceStore.setValue(PREF_JAVADOCLOCATIONS, ""); //$NON-NLS-1$ preferenceStore.setValue(PREF_JAVADOCLOCATIONS_MIGRATED, true); } }; new WorkbenchRunnableAdapter(runnable).run(monitor); } catch (InvocationTargetException e) { JavaPlugin.log(e); } catch (InterruptedException e) { // should not happen, cannot cancel } return Status.OK_STATUS; } };
@Override protected IStatus run(IProgressMonitor monitor) { try { IWorkspaceRunnable runnable= new IWorkspaceRunnable() { @Override public void run(IProgressMonitor pm) throws CoreException { updateClasspathEntries(oldLocations, pm); IPreferenceStore preferenceStore= PreferenceConstants.getPreferenceStore(); preferenceStore.setValue(PREF_JAVADOCLOCATIONS, ""); //$NON-NLS-1$ preferenceStore.setValue(PREF_JAVADOCLOCATIONS_MIGRATED, true); } }; new WorkbenchRunnableAdapter(runnable).run(monitor); } catch (InvocationTargetException e) { JavaPlugin.log(e); } catch (InterruptedException e) { // should not happen, cannot cancel } return Status.OK_STATUS; } };
private void updateContainerEntry(final IClasspathEntry newEntry, final String[] changedAttributes, final IJavaProject jproject, final IPath containerPath) { try { IWorkspaceRunnable runnable= new IWorkspaceRunnable() { public void run(IProgressMonitor monitor) throws CoreException { BuildPathSupport.modifyClasspathEntry(null, newEntry, changedAttributes, jproject, containerPath, monitor); } }; PlatformUI.getWorkbench().getProgressService().run(true, true, new WorkbenchRunnableAdapter(runnable)); } catch (InvocationTargetException e) { String title= NewWizardMessages.LibrariesWorkbookPage_configurecontainer_error_title; String message= NewWizardMessages.LibrariesWorkbookPage_configurecontainer_error_message; ExceptionHandler.handle(e, getShell(), title, message); } catch (InterruptedException e) { // } }
private void updateContainerEntry(final IClasspathEntry newEntry, final String[] changedAttributes, final IJavaProject jproject, final IPath containerPath) { try { IWorkspaceRunnable runnable= new IWorkspaceRunnable() { @Override public void run(IProgressMonitor monitor) throws CoreException { BuildPathSupport.modifyClasspathEntry(null, newEntry, changedAttributes, jproject, containerPath, false, monitor); } }; PlatformUI.getWorkbench().getProgressService().run(true, true, new WorkbenchRunnableAdapter(runnable)); } catch (InvocationTargetException e) { String title= NewWizardMessages.LibrariesWorkbookPage_configurecontainer_error_title; String message= NewWizardMessages.LibrariesWorkbookPage_configurecontainer_error_message; ExceptionHandler.handle(e, getShell(), title, message); } catch (InterruptedException e) { // } }
private void updateContainerEntry(final IClasspathEntry newEntry, final String[] changedAttributes, final IJavaProject jproject, final IPath containerPath) { try { IWorkspaceRunnable runnable= new IWorkspaceRunnable() { @Override public void run(IProgressMonitor monitor) throws CoreException { BuildPathSupport.modifyClasspathEntry(null, newEntry, changedAttributes, jproject, containerPath, false, monitor); } }; PlatformUI.getWorkbench().getProgressService().run(true, true, new WorkbenchRunnableAdapter(runnable)); } catch (InvocationTargetException e) { String title= NewWizardMessages.LibrariesWorkbookPage_configurecontainer_error_title; String message= NewWizardMessages.LibrariesWorkbookPage_configurecontainer_error_message; ExceptionHandler.handle(e, getShell(), title, message); } catch (InterruptedException e) { // } }
private void configureBuildPath() { Shell shell= getShell(); IWorkspaceRunnable runnable= new IWorkspaceRunnable() { public void run(IProgressMonitor monitor) throws CoreException, OperationCanceledException { fBlock.configureJavaProject(monitor); } }; IRunnableWithProgress op= new WorkbenchRunnableAdapter(runnable); // lock on root try { PlatformUI.getWorkbench().getProgressService().run(true, true, op); } catch (InvocationTargetException e) { String title= PreferencesMessages.BuildPathDialog_error_title; String message= PreferencesMessages.BuildPathDialog_error_message; ExceptionHandler.handle(e, shell, title, message); } catch (InterruptedException e) { // cancelled } } }
public void run(final IStructuredSelection selection) { try { PlatformUI.getWorkbench().getActiveWorkbenchWindow().run(true, true, new WorkbenchRunnableAdapter(new IWorkspaceRunnable() { public void run(IProgressMonitor pm) throws CoreException { try{ IPackageFragmentRoot[] roots= getRootsToRemove(selection); pm.beginTask(ActionMessages.RemoveFromClasspathAction_Removing, roots.length); for (int i= 0; i < roots.length; i++) { int jCoreFlags= IPackageFragmentRoot.NO_RESOURCE_MODIFICATION | IPackageFragmentRoot.ORIGINATING_PROJECT_CLASSPATH; roots[i].delete(IResource.NONE, jCoreFlags, new SubProgressMonitor(pm, 1)); } } finally { pm.done(); } } })); } catch (InvocationTargetException e) { ExceptionHandler.handle(e, getShell(), ActionMessages.RemoveFromClasspathAction_exception_dialog_title, ActionMessages.RemoveFromClasspathAction_Problems_occurred); } catch (InterruptedException e) { // canceled } }
/** * @see org.eclipse.jface.preference.IPreferencePage#performOk() */ @Override public boolean performOk() { if (fIsValidElement && fIgnoreOptionalProblemsField.isSelected() != isIgnoringOptionalProblems()) { String newValue= fIgnoreOptionalProblemsField.isSelected() ? "true" : null; //$NON-NLS-1$ fElement.setAttribute(IClasspathAttribute.IGNORE_OPTIONAL_PROBLEMS, newValue); IWorkspaceRunnable runnable= getRunnable(getShell(), fProject, fElement.getClasspathEntry()); WorkbenchRunnableAdapter op= new WorkbenchRunnableAdapter(runnable); op.runAsUserJob(PreferencesMessages.BuildPathsPropertyPage_job_title, null); } return true; }
/** * @see org.eclipse.jface.preference.IPreferencePage#performOk() */ @Override public boolean performOk() { if (fIsValidElement && fIgnoreOptionalProblemsField.isSelected() != isIgnoringOptionalProblems()) { String newValue= fIgnoreOptionalProblemsField.isSelected() ? "true" : null; //$NON-NLS-1$ fElement.setAttribute(IClasspathAttribute.IGNORE_OPTIONAL_PROBLEMS, newValue); IWorkspaceRunnable runnable= getRunnable(getShell(), fProject, fElement.getClasspathEntry()); WorkbenchRunnableAdapter op= new WorkbenchRunnableAdapter(runnable); op.runAsUserJob(PreferencesMessages.BuildPathsPropertyPage_job_title, null); } return true; }
private IJavaElement[] persistEntry(CPListElement element) throws InterruptedException, InvocationTargetException { // NB: we assume that element is a *new* entry IJavaElement[] selectedJavaElements; IJavaProject javaProject= element.getJavaProject(); IClasspathEntry newEntry= element.getClasspathEntry(); IWorkspaceRunnable runnable= new IWorkspaceRunnable() { @Override public void run(IProgressMonitor monitor) throws CoreException { IClasspathEntry[] oldClasspath= javaProject.getRawClasspath(); int nEntries= oldClasspath.length; IClasspathEntry[] newEntries= Arrays.copyOf(oldClasspath, nEntries+1); newEntries[nEntries]= newEntry; javaProject.setRawClasspath(newEntries, monitor); } }; PlatformUI.getWorkbench().getProgressService().run(true, true, new WorkbenchRunnableAdapter(runnable)); selectedJavaElements= ModuleEncapsulationDetail.getTargetJavaElements(element.getJavaProject(), element.getPath()); return selectedJavaElements; }
/** * @see Dialog#okPressed() */ protected void okPressed() { try { IWorkspaceRunnable runnable= new IWorkspaceRunnable() { public void run(IProgressMonitor monitor) throws CoreException { URL javadocLocation= fJavadocConfigurationBlock.getJavadocLocation(); fElement.setURL(javadocLocation, monitor); } }; PlatformUI.getWorkbench().getProgressService().run(true, true, new WorkbenchRunnableAdapter(runnable)); } catch (InvocationTargetException e) { String title= JavadocExportMessages.JavadocStandardWizardPage_configurecontainer_error_title; String message= JavadocExportMessages.JavadocStandardWizardPage_configurecontainer_error_message; ExceptionHandler.handle(e, getShell(), title, message); } catch (InterruptedException e) { // user cancelled } fListDialogField.refresh(); doValidation(LINK_REFERENCES); super.okPressed(); }
/** * @see Dialog#okPressed() */ protected void okPressed() { try { IWorkspaceRunnable runnable= new IWorkspaceRunnable() { public void run(IProgressMonitor monitor) throws CoreException { URL javadocLocation= fJavadocConfigurationBlock.getJavadocLocation(); fElement.setURL(javadocLocation, monitor); } }; PlatformUI.getWorkbench().getProgressService().run(true, true, new WorkbenchRunnableAdapter(runnable)); } catch (InvocationTargetException e) { String title= JavadocExportMessages.JavadocStandardWizardPage_configurecontainer_error_title; String message= JavadocExportMessages.JavadocStandardWizardPage_configurecontainer_error_message; ExceptionHandler.handle(e, getShell(), title, message); } catch (InterruptedException e) { // user cancelled } fListDialogField.refresh(); doValidation(LINK_REFERENCES); super.okPressed(); }
/** * @see Dialog#okPressed() */ @Override protected void okPressed() { try { IWorkspaceRunnable runnable= new IWorkspaceRunnable() { @Override public void run(IProgressMonitor monitor) throws CoreException { URL javadocLocation= fJavadocConfigurationBlock.getJavadocLocation(); fElement.setURL(javadocLocation, monitor); } }; PlatformUI.getWorkbench().getProgressService().run(true, true, new WorkbenchRunnableAdapter(runnable)); } catch (InvocationTargetException e) { String title= JavadocExportMessages.JavadocStandardWizardPage_configurecontainer_error_title; String message= JavadocExportMessages.JavadocStandardWizardPage_configurecontainer_error_message; ExceptionHandler.handle(e, getShell(), title, message); } catch (InterruptedException e) { // user cancelled } fListDialogField.refresh(); doValidation(LINK_REFERENCES); super.okPressed(); }
private void internalRun(List initialSelection) { ListSelectionDialog dialog= new ListSelectionDialog(getShell(), getClosedProjectsInWorkspace(), new ArrayContentProvider(), new JavaElementLabelProvider(), ActionMessages.OpenProjectAction_dialog_message); dialog.setTitle(ActionMessages.OpenProjectAction_dialog_title); if (initialSelection != null && !initialSelection.isEmpty()) { dialog.setInitialElementSelections(initialSelection); } int result= dialog.open(); if (result != Window.OK) return; final Object[] projects= dialog.getResult(); IWorkspaceRunnable runnable= createRunnable(projects); try { PlatformUI.getWorkbench().getProgressService().run(true, true, new WorkbenchRunnableAdapter(runnable)); } catch (InvocationTargetException e) { ExceptionHandler.handle(e, getShell(), ActionMessages.OpenProjectAction_dialog_title, ActionMessages.OpenProjectAction_error_message); } catch (InterruptedException e) { // user cancelled } }
/** * Note this method is for internal use only. * * @param cu the compilation unit * @param members an array of members */ public void run(ICompilationUnit cu, IMember[] members) { try { AddJavaDocStubOperation op= new AddJavaDocStubOperation(members); PlatformUI.getWorkbench().getProgressService().runInUI( PlatformUI.getWorkbench().getProgressService(), new WorkbenchRunnableAdapter(op, op.getScheduleRule()), op.getScheduleRule()); } catch (InvocationTargetException e) { ExceptionHandler.handle(e, getShell(), getDialogTitle(), ActionMessages.AddJavaDocStubsAction_error_actionFailed); } catch (InterruptedException e) { // operation canceled } }
private void internalRun(List<?> initialSelection) { ListSelectionDialog dialog= new ListSelectionDialog(getShell(), getClosedProjectsInWorkspace(), new ArrayContentProvider(), new JavaElementLabelProvider(), ActionMessages.OpenProjectAction_dialog_message); dialog.setTitle(ActionMessages.OpenProjectAction_dialog_title); if (initialSelection != null && !initialSelection.isEmpty()) { dialog.setInitialElementSelections(initialSelection); } int result= dialog.open(); if (result != Window.OK) return; final Object[] projects= dialog.getResult(); IWorkspaceRunnable runnable= createRunnable(projects); try { PlatformUI.getWorkbench().getProgressService().run(true, true, new WorkbenchRunnableAdapter(runnable)); } catch (InvocationTargetException e) { ExceptionHandler.handle(e, getShell(), ActionMessages.OpenProjectAction_dialog_title, ActionMessages.OpenProjectAction_error_message); } catch (InterruptedException e) { // user cancelled } }
private void internalRun(List<?> initialSelection) { ListSelectionDialog dialog= new ListSelectionDialog(getShell(), getClosedProjectsInWorkspace(), new ArrayContentProvider(), new JavaElementLabelProvider(), ActionMessages.OpenProjectAction_dialog_message); dialog.setTitle(ActionMessages.OpenProjectAction_dialog_title); if (initialSelection != null && !initialSelection.isEmpty()) { dialog.setInitialElementSelections(initialSelection); } int result= dialog.open(); if (result != Window.OK) return; final Object[] projects= dialog.getResult(); IWorkspaceRunnable runnable= createRunnable(projects); try { PlatformUI.getWorkbench().getProgressService().run(true, true, new WorkbenchRunnableAdapter(runnable)); } catch (InvocationTargetException e) { ExceptionHandler.handle(e, getShell(), ActionMessages.OpenProjectAction_dialog_title, ActionMessages.OpenProjectAction_error_message); } catch (InterruptedException e) { // user cancelled } }
@Override public void apply(IDocument document) { IRunnableContext context= JavaPlugin.getActiveWorkbenchWindow(); if (context == null) { context= new BusyIndicatorRunnableContext(); } Shell shell= JavaPlugin.getActiveWorkbenchShell(); if (ClasspathFixSelectionDialog.openClasspathFixSelectionDialog(shell, getCompilationUnit().getJavaProject(), fMissingType, context)) { if (fMissingType.indexOf('.') == -1) { try { IChooseImportQuery query= AddImportOnSelectionAction.newDialogQuery(shell); AddImportsOperation op= new AddImportsOperation(getCompilationUnit(), fOffset, fLength, query, false, false); IProgressService progressService= PlatformUI.getWorkbench().getProgressService(); progressService.runInUI(context, new WorkbenchRunnableAdapter(op, op.getScheduleRule()), op.getScheduleRule()); fResultingEdit= op.getResultingEdit(); super.apply(document); } catch (InvocationTargetException e) { JavaPlugin.log(e); } catch (InterruptedException e) { // ignore } } } }