List of usage examples for org.eclipse.jface.dialogs ProgressMonitorDialog run
@Override public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException
IRunnableWithProgress
using the progress monitor for this progress dialog and blocks until the runnable has been run, regardless of the value of fork
. From source file:de.blizzy.backup.Updater.java
License:Open Source License
public boolean update(Shell shell) throws Throwable { final boolean[] restartNecessary = new boolean[1]; if (needsCheck()) { final ProgressMonitorDialog pmd = new ProgressMonitorDialog(shell); IRunnableWithProgress runnable = new IRunnableWithProgress() { @Override/*from w w w . j av a2s . c om*/ @SuppressWarnings("synthetic-access") public void run(IProgressMonitor monitor) { SubMonitor progress = SubMonitor.convert(monitor); restartNecessary[0] = updateInJob(progress, pmd.getShell()); monitor.done(); } }; try { pmd.run(true, true, runnable); } catch (InvocationTargetException e) { throw e.getCause(); } } if (restartNecessary[0]) { IDialogSettings settings = Utils.getSection("versionCheck"); //$NON-NLS-1$ settings.put("cleanupOldFeatures", true); //$NON-NLS-1$ } return restartNecessary[0]; }
From source file:de.fu_berlin.inf.dpp.project.SharedResourcesManager.java
License:Open Source License
protected void handleVCSActivity(VCSActivity activity) { final VCSActivity.Type activityType = activity.getType(); SPath path = activity.getPath();/*from ww w. j ava2 s . c o m*/ final IResource resource = ((EclipseResourceImpl) path.getResource()).getDelegate(); final IProject project = ((EclipseProjectImpl) path.getProject()).getDelegate(); final String url = activity.getURL(); final String directory = activity.getDirectory(); final String revision = activity.getParam1(); // Connect is special since the project doesn't have a VCSAdapter // yet. final VCSAdapter vcs = activityType == VCSActivity.Type.CONNECT ? VCSAdapter.getAdapter(revision) : VCSAdapter.getAdapter(project); if (vcs == null) { log.warn("Could not execute VCS activity. Do you have the Subclipse plug-in installed?"); if (activity.containedActivity.size() > 0) { log.trace("contained activities: " + activity.containedActivity.toString()); } for (IResourceActivity a : activity.containedActivity) { consumer.exec(a); } return; } try { // TODO Should these operations run in an IWorkspaceRunnable? Shell shell = SWTUtils.getShell(); ProgressMonitorDialog progressMonitorDialog = new ProgressMonitorDialog(shell); progressMonitorDialog.open(); Shell pmdShell = progressMonitorDialog.getShell(); pmdShell.setText("Saros running VCS operation"); log.trace("about to call progressMonitorDialog.run"); progressMonitorDialog.run(true, false, new IRunnableWithProgress() { @Override public void run(IProgressMonitor progress) throws InvocationTargetException, InterruptedException { log.trace("progressMonitorDialog.run started"); if (!SWTUtils.isSWT()) log.trace("not in SWT thread"); if (activityType == VCSActivity.Type.CONNECT) { vcs.connect(project, url, directory, progress); } else if (activityType == VCSActivity.Type.DISCONNECT) { vcs.disconnect(project, revision != null, progress); } else if (activityType == VCSActivity.Type.SWITCH) { vcs.switch_(resource, url, revision, progress); } else if (activityType == VCSActivity.Type.UPDATE) { vcs.update(resource, revision, progress); } else { log.error("VCS activity type not implemented yet."); } log.trace("progressMonitorDialog.run done"); } }); pmdShell.dispose(); } catch (InvocationTargetException e) { // TODO We can't get here, right? throw new IllegalStateException(e); } catch (InterruptedException e) { log.error("Code not designed to be interrupted!"); } }
From source file:de.fu_berlin.inf.dpp.ui.SarosUI.java
License:Open Source License
/** * @swt//from www .j a v a 2 s .co m */ public void performPermissionChange(final User user, final Permission newPermission) { ProgressMonitorDialog dialog = new ProgressMonitorDialog(EditorAPI.getAWorkbenchWindow().getShell()); try { dialog.run(true, true, new IRunnableWithProgress() { public void run(final IProgressMonitor monitor) { final SubMonitor progress = SubMonitor.convert(monitor); try { progress.beginTask("Performing permission change", IProgressMonitor.UNKNOWN); sessionManager.getSarosSession().initiatePermissionChange(user, newPermission, progress); } catch (CancellationException e) { log.warn("Permission change failed because buddy" + " canceled the permission change"); Utils.runSafeSWTSync(log, new Runnable() { public void run() { MessageDialog.openInformation(EditorAPI.getAWorkbenchWindow().getShell(), "Permission Change Canceled", "The permission change was canceled."); } }); } catch (InterruptedException e) { log.error("Code not designed to be interruptable", e); } finally { progress.done(); } } }); } catch (InvocationTargetException e) { log.error("Internal Error: ", e); MessageDialog.openError(EditorAPI.getAWorkbenchWindow().getShell(), "Permission Change Failed", "Permission change failed because of an internal error.\n\n" + " Please try again."); } catch (InterruptedException e) { log.error("Code not designed to be interruptable", e); } }
From source file:de.hoesel.dav.buv.twitter.baustelle.BaustelleTwitternDialogOeffnenHandler.java
License:Open Source License
@SuppressWarnings("rawtypes") @Override/*from w w w. jav a 2 s . c om*/ public Object execute(ExecutionEvent event) throws ExecutionException { final Shell activeShell = HandlerUtil.getActiveShell(event); ISelection menuSelection = HandlerUtil.getActiveMenuSelection(event); if (menuSelection instanceof IStructuredSelection) { Iterator iterator = ((IStructuredSelection) menuSelection).iterator(); while (iterator.hasNext()) { Object obj = iterator.next(); final SystemObjekt objekt = (SystemObjekt) Platform.getAdapterManager().getAdapter(obj, SystemObjekt.class); if (objekt instanceof Baustelle) { final Baustelle baustelle = (Baustelle) objekt; final CacheService cacheService = RahmenwerkService.getService().getCacheService(); final NetzCacheExtended netzCache = cacheService .getNetzCacheExtended(cacheService.getDefaultNetzPid()); if (!netzCache.isInitialisiert()) { ProgressMonitorDialog progress = new ProgressMonitorDialog(activeShell); try { progress.run(true, true, new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask("Warte auf Caches ...", IProgressMonitor.UNKNOWN); while (!netzCache.isInitialisiert()) { Thread.sleep(100); } monitor.done(); final BaustelleTwitternDialog dialog = new BaustelleTwitternDialog(activeShell, baustelle); activeShell.getDisplay().asyncExec(new Runnable() { @Override public void run() { dialog.open(); } }); } }); } catch (InvocationTargetException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } // progress.open(); } else { final BaustelleTwitternDialog dialog = new BaustelleTwitternDialog(activeShell, baustelle); dialog.open(); } } } } return null; }
From source file:de.jcup.egradle.eclipse.ide.ui.RootProjectConfigUIDelegate.java
License:Apache License
private void createValidationGroup(Composite parent) { if (!mode.isValidationGroupNeeded()) { return;/*from w w w. ja v a 2 s . co m*/ } /* ------------------------------------ */ /* - Check output - */ /* ------------------------------------ */ GridData groupLayoutData = new GridData(); groupLayoutData.horizontalAlignment = GridData.FILL; groupLayoutData.verticalAlignment = GridData.FILL; groupLayoutData.grabExcessHorizontalSpace = true; groupLayoutData.grabExcessVerticalSpace = true; groupLayoutData.verticalSpan = 2; groupLayoutData.horizontalSpan = 3; Group validationGroup = SWTFactory.createGroup(parent, "Validate preferences correct", 1, 10, SWT.FILL); validationGroup.setLayoutData(groupLayoutData); GridData labelGridData = new GridData(); labelGridData.horizontalAlignment = GridData.FILL; labelGridData.verticalAlignment = GridData.BEGINNING; labelGridData.grabExcessHorizontalSpace = false; labelGridData.grabExcessVerticalSpace = false; GridData gridDataLastColumn = new GridData(); gridDataLastColumn.horizontalAlignment = GridData.FILL; gridDataLastColumn.verticalAlignment = GridData.FILL; gridDataLastColumn.grabExcessHorizontalSpace = true; gridDataLastColumn.grabExcessVerticalSpace = true; gridDataLastColumn.verticalSpan = 2; gridDataLastColumn.horizontalSpan = 2; gridDataLastColumn.minimumHeight = 50; gridDataLastColumn.heightHint = 100; validationOutputField = new Text(validationGroup, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.READ_ONLY); validationOutputField.setLayoutData(gridDataLastColumn); validationButton = new Button(validationGroup, SWT.NONE); validationButton.setText("Start validation"); validationButton.setImage(getValidationButtonImage()); validationButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (validationRunning == true) { return; } setValid(false); handleValidationRunning(true); validationOutputField.setText("Start validation...\n"); OutputHandler validationOutputHandler = new OutputHandler() { @Override public void output(String line) { EclipseUtil.safeAsyncExec(new Runnable() { @Override public void run() { validationOutputField.append(line + "\n"); } }); } }; MutableGradleConfiguration configuration = new MutableGradleConfiguration(); configuration.setGradleCommand(getGradleCommand()); configuration.setGradleBinDirectory(getGradleBinDirectory()); configuration.setShellCommand(getShellCommand()); configuration.setWorkingDirectory(getWorkingDirectory()); configuration.setJavaHome(getGlobalJavaHomePath()); startValidation(validationOutputHandler, configuration); } private void startValidation(OutputHandler validationOutputHandler, MutableGradleConfiguration configuration) { try { RootProjectConfigUIDelegate observer = RootProjectConfigUIDelegate.this; ProgressMonitorDialog progressMonitorDialog = new ProgressMonitorDialog( EclipseUtil.getActiveWorkbenchShell()); RootProjectValidationProgressRunnable runnable = new RootProjectValidationProgressRunnable( new CancelStateProvider() { @Override public boolean isCanceled() { return progressMonitorDialog.getProgressMonitor().isCanceled(); } }, configuration, observer, validationOutputHandler); /* * use own progress monitor dialog here - progress service * did not work well because this is in model state */ progressMonitorDialog.run(true, true, runnable); } catch (InvocationTargetException | InterruptedException e1) { IDEUtil.logError("Was not able to execute validation", e1); } } }); }
From source file:de.jcup.egradle.eclipse.ui.RootProjectConfigUIDelegate.java
License:Apache License
private void createValidationGroup(Composite parent) { /* ------------------------------------ */ /* - Check output - */ /* ------------------------------------ */ GridData groupLayoutData = new GridData(); groupLayoutData.horizontalAlignment = GridData.FILL; groupLayoutData.verticalAlignment = GridData.FILL; groupLayoutData.grabExcessHorizontalSpace = true; groupLayoutData.grabExcessVerticalSpace = true; groupLayoutData.verticalSpan = 2;/*from w w w. java 2 s . c o m*/ groupLayoutData.horizontalSpan = 3; Group validationGroup = SWTFactory.createGroup(parent, "Validate preferences correct", 1, 10, SWT.FILL); validationGroup.setLayoutData(groupLayoutData); GridData labelGridData = new GridData(); labelGridData.horizontalAlignment = GridData.FILL; labelGridData.verticalAlignment = GridData.BEGINNING; labelGridData.grabExcessHorizontalSpace = false; labelGridData.grabExcessVerticalSpace = false; GridData gridDataLastColumn = new GridData(); gridDataLastColumn.horizontalAlignment = GridData.FILL; gridDataLastColumn.verticalAlignment = GridData.FILL; gridDataLastColumn.grabExcessHorizontalSpace = true; gridDataLastColumn.grabExcessVerticalSpace = true; gridDataLastColumn.verticalSpan = 2; gridDataLastColumn.horizontalSpan = 2; gridDataLastColumn.minimumHeight = 50; gridDataLastColumn.heightHint = 100; validationOutputField = new Text(validationGroup, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.READ_ONLY); validationOutputField.setLayoutData(gridDataLastColumn); validationButton = new Button(validationGroup, SWT.NONE); validationButton.setText("Start validation"); validationButton.setImage(getValidationButtonImage()); validationButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (validationRunning == true) { return; } setValid(false); handleValidationRunning(true); validationOutputField.setText("Start validation...\n"); OutputHandler validationOutputHandler = new OutputHandler() { @Override public void output(String line) { EGradleUtil.safeAsyncExec(new Runnable() { @Override public void run() { validationOutputField.append(line + "\n"); } }); } }; MutableGradleConfiguration configuration = new MutableGradleConfiguration(); configuration.setGradleCommand(getGradleCommand()); configuration.setGradleBinDirectory(getGradleBinDirectory()); configuration.setShellCommand(getShellCommand()); configuration.setWorkingDirectory(getWorkingDirectory()); configuration.setJavaHome(getGlobalJavaHomePath()); startValidation(validationOutputHandler, configuration); } private void startValidation(OutputHandler validationOutputHandler, MutableGradleConfiguration configuration) { try { RootProjectConfigUIDelegate observer = RootProjectConfigUIDelegate.this; ProgressMonitorDialog progressMonitorDialog = new ProgressMonitorDialog( EGradleUtil.getActiveWorkbenchShell()); RootProjectValidationProgressRunnable runnable = new RootProjectValidationProgressRunnable( new CancelStateProvider() { @Override public boolean isCanceled() { return progressMonitorDialog.getProgressMonitor().isCanceled(); } }, configuration, observer, validationOutputHandler); /* use own progress monitor dialog here - progress service did not work well because this is in model state */ progressMonitorDialog.run(true, true, runnable); } catch (InvocationTargetException | InterruptedException e1) { EGradleUtil.log(e1); } } }); }
From source file:de.loskutov.eclipse.jdepend.preferences.JDependPreferencePage.java
License:Open Source License
/** * Utility method to create and return a selection dialog that allows * selection of a specific Java package. Empty packages are not returned. * If Java Projects are provided, only packages found within those projects * are included. If no Java projects are provided, all Java projects in the * workspace are considered.//from w w w . j a va2 s . c o m */ public static ElementListSelectionDialog createAllPackagesDialog(Shell shell, IJavaProject[] originals, final boolean includeDefaultPackage) throws JavaModelException { final List<IPackageFragment> packageList = new ArrayList<IPackageFragment>(); if (originals == null) { IWorkspaceRoot wsroot = ResourcesPlugin.getWorkspace().getRoot(); IJavaModel model = JavaCore.create(wsroot); originals = model.getJavaProjects(); } final IJavaProject[] projects = originals; final JavaModelException[] exception = new JavaModelException[1]; ProgressMonitorDialog monitor = new ProgressMonitorDialog(shell); IRunnableWithProgress r = new IRunnableWithProgress() { @Override public void run(IProgressMonitor myMonitor) { try { Set<String> packageNameSet = new HashSet<String>(); myMonitor.beginTask(JDepend4EclipsePlugin.getResourceString("JDependPreferencePage.Searching"), //$NON-NLS-1$ projects.length); for (int i = 0; i < projects.length; i++) { IPackageFragment[] pkgs = projects[i].getPackageFragments(); for (int j = 0; j < pkgs.length; j++) { IPackageFragment pkg = pkgs[j]; if (!pkg.hasChildren() && (pkg.getNonJavaResources().length > 0)) { continue; } String pkgName = pkg.getElementName(); if (!includeDefaultPackage && pkgName.length() == 0) { continue; } if (packageNameSet.add(pkgName)) { packageList.add(pkg); } } myMonitor.worked(1); } myMonitor.done(); } catch (JavaModelException jme) { exception[0] = jme; } } }; try { monitor.run(false, false, r); } catch (InvocationTargetException e) { JDepend4EclipsePlugin.logError(e, "ooo"); //$NON-NLS-1$ } catch (InterruptedException e) { JDepend4EclipsePlugin.logError(e, "ooo"); //$NON-NLS-1$ } if (exception[0] != null) { throw exception[0]; } int flags = JavaElementLabelProvider.SHOW_DEFAULT; ElementListSelectionDialog dialog = new ElementListSelectionDialog(shell, new JavaElementLabelProvider(flags)); dialog.setIgnoreCase(false); dialog.setElements(packageList.toArray()); // XXX inefficient return dialog; }
From source file:de.plugins.eclipse.depclipse.preferences.JDependPreferencePage.java
License:Open Source License
/** * Utility method to create and return a selection dialog that allows * selection of a specific Java package. Empty packages are not returned. * If Java Projects are provided, only packages found within those projects * are included. If no Java projects are provided, all Java projects in the * workspace are considered./* w w w. j a v a 2 s . c om*/ */ public static ElementListSelectionDialog createAllPackagesDialog(Shell shell, IJavaProject[] originals, final boolean includeDefaultPackage) throws JavaModelException { final List<IPackageFragment> packageList = new ArrayList<IPackageFragment>(); if (originals == null) { IWorkspaceRoot wsroot = ResourcesPlugin.getWorkspace().getRoot(); IJavaModel model = JavaCore.create(wsroot); originals = model.getJavaProjects(); } final IJavaProject[] projects = originals; final JavaModelException[] exception = new JavaModelException[1]; ProgressMonitorDialog monitor = new ProgressMonitorDialog(shell); IRunnableWithProgress r = new IRunnableWithProgress() { public void run(IProgressMonitor myMonitor) { try { Set<String> packageNameSet = new HashSet<String>(); myMonitor.beginTask(Messages.JDependPreferencePage_Searching_Progress_Monitor, projects.length); for (int i = 0; i < projects.length; i++) { IPackageFragment[] pkgs = projects[i].getPackageFragments(); for (int j = 0; j < pkgs.length; j++) { IPackageFragment pkg = pkgs[j]; if (!pkg.hasChildren() && (pkg.getNonJavaResources().length > 0)) { continue; } String pkgName = pkg.getElementName(); if (!includeDefaultPackage && pkgName.length() == 0) { continue; } if (packageNameSet.add(pkgName)) { packageList.add(pkg); } } myMonitor.worked(1); } myMonitor.done(); } catch (JavaModelException jme) { exception[0] = jme; } } }; try { monitor.run(false, false, r); } catch (InvocationTargetException e) { DepclipsePlugin.logError(e, "ooo"); //$NON-NLS-1$ } catch (InterruptedException e) { DepclipsePlugin.logError(e, "ooo"); //$NON-NLS-1$ } if (exception[0] != null) { throw exception[0]; } int flags = JavaElementLabelProvider.SHOW_DEFAULT; ElementListSelectionDialog dialog = new ElementListSelectionDialog(shell, new JavaElementLabelProvider(flags)); dialog.setIgnoreCase(false); dialog.setElements(packageList.toArray()); // XXX inefficient return dialog; }
From source file:de.quamoco.qm.application.QmEditorAdvisor.java
License:Apache License
/** * {@inheritDoc}/*from w ww . ja va 2 s. co m*/ */ @Override public void postShutdown() { // save the workspace IRunnableWithProgress runnable = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) { try { ResourcesPlugin.getWorkspace().save(true, monitor); } catch (CoreException e) { QmEditorPlugin.INSTANCE.log(e); } } }; ProgressMonitorDialog dialog = new ProgressMonitorDialog(Display.getDefault().getActiveShell()); try { dialog.run(true, true, runnable); } catch (InvocationTargetException e) { QmEditorPlugin.INSTANCE.log(e); } catch (InterruptedException e) { QmEditorPlugin.INSTANCE.log(e); } }
From source file:de.quamoco.qm.editor.action.EvaluateAction.java
License:Apache License
/** {@inheritDoc} */ @Override/*from ww w.ja va 2s. co m*/ public void run(IAction action) { EvaluateWizardPageBase page = "Java".equals(model.getName()) ? new JavaEvaluateWizardPage(model, editor) : new CSharpEvaluationWizardPage(model, editor); Wizard wizard = new SinglePageWizard(page); WizardDialog dialog = new WizardDialog(Display.getDefault().getActiveShell(), wizard); if (dialog.open() == IDialogConstants.OK_ID) { ProgressMonitorDialog progressDialog = new ProgressMonitorDialog(Display.getDefault().getActiveShell()); try { progressDialog.run(true, true, page.getRunnable()); } catch (InvocationTargetException e) { reportError(e, "Quality evaluation could not be started"); } catch (InterruptedException e) { reportError(e, "Quality evaluation has been interrupted"); } } }