List of usage examples for org.eclipse.jface.dialogs ProgressMonitorDialog ProgressMonitorDialog
public ProgressMonitorDialog(Shell parent)
From source file:com.gigaspaces.azure.runnable.NewHostedServiceWithProgressWindow.java
License:Open Source License
@Override public void run() { ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell); try {/*ww w. ja v a2 s .c o m*/ dialog.run(true, true, this); dialog.close(); } catch (InvocationTargetException e) { MessageUtil.displayErrorDialog(shell, com.gigaspaces.azure.wizards.Messages.createHostedServiceFailedMsg, e.getMessage()); Activator.getDefault().log(Messages.error, e); } catch (InterruptedException e) { MessageDialog.openWarning(shell, Messages.interrupt, Messages.newServiceInterrupted); Activator.getDefault().log(Messages.error, e); } }
From source file:com.gigaspaces.azure.runnable.NewStorageAccountWithProgressWindow.java
License:Open Source License
@Override public void run() { ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell); try {/*from w ww. j a va 2 s. c o m*/ dialog.run(true, true, this); dialog.close(); } catch (InvocationTargetException e) { MessageUtil.displayErrorDialog(shell, com.gigaspaces.azure.wizards.Messages.createStorageAccountFailedTitle, e.getMessage()); Activator.getDefault().log(Messages.error, e); } catch (InterruptedException e) { MessageDialog.openWarning(shell, Messages.interrupt, Messages.newStorageInterrupted); Activator.getDefault().log(Messages.error, e); } }
From source file:com.google.cloud.tools.eclipse.appengine.login.ui.LoginServiceUi.java
License:Apache License
private String showProgressDialogAndWaitForCode(final String message, final LocalServerReceiver codeReceiver, final String redirectUrl) throws IOException { try {// w w w. j a v a 2s . co m final Semaphore wait = new Semaphore(0 /* initially zero permit */); final ProgressMonitorDialog dialog = new ProgressMonitorDialog(shellProvider.getShell()) { @Override protected void configureShell(Shell shell) { super.configureShell(shell); shell.setText(Messages.LOGIN_PROGRESS_DIALOG_TITLE); } @Override protected void cancelPressed() { wait.release(); // Allow termination of the attached task. stopCodeWaitingJob(redirectUrl); AnalyticsPingManager.getInstance().sendPing(AnalyticsEvents.LOGIN_CANCELED, null, null, getParentShell()); } }; final String[] codeHolder = new String[1]; final IOException[] exceptionHolder = new IOException[1]; dialog.run(true /* fork */, true /* cancelable */, new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { AnalyticsPingManager.getInstance().sendPing(AnalyticsEvents.LOGIN_START, null, null, dialog.getShell()); monitor.beginTask(message != null ? message : Messages.LOGIN_PROGRESS_DIALOG_MESSAGE, IProgressMonitor.UNKNOWN); // Fork another sub-job to circumvent the limitation of LocalServerReceiver. // (See the comments of scheduleCodeWaitingJob().) scheduleCodeWaitingJob(new LocalServerReceiverWrapper(codeReceiver), wait, codeHolder, exceptionHolder); wait.acquireUninterruptibly(); // Block until signaled. } }); if (exceptionHolder[0] != null) { throw exceptionHolder[0]; } return codeHolder[0]; } catch (InvocationTargetException | InterruptedException ex) { // Never thrown from the attached task. return null; } }
From source file:com.google.cloud.tools.eclipse.login.ui.LoginServiceUi.java
License:Apache License
private String showProgressDialogAndWaitForCode(final String message, final LocalServerReceiver codeReceiver, final String redirectUrl) throws IOException { try {/*from www .j av a 2 s .c o m*/ final Semaphore wait = new Semaphore(0 /* initially zero permit */); final ProgressMonitorDialog dialog = new ProgressMonitorDialog(shellProvider.getShell()) { @Override protected void configureShell(Shell shell) { super.configureShell(shell); shell.setText(Messages.getString("LOGIN_PROGRESS_DIALOG_TITLE")); } @Override protected void cancelPressed() { wait.release(); // Allow termination of the attached task. stopCodeWaitingJob(redirectUrl); AnalyticsPingManager.getInstance().sendPing(AnalyticsEvents.LOGIN_CANCELED, null, null, getParentShell()); } }; final String[] codeHolder = new String[1]; final IOException[] exceptionHolder = new IOException[1]; dialog.run(true /* fork */, true /* cancelable */, new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { AnalyticsPingManager.getInstance().sendPing(AnalyticsEvents.LOGIN_START, null, null, dialog.getShell()); monitor.beginTask( message != null ? message : Messages.getString("LOGIN_PROGRESS_DIALOG_MESSAGE"), IProgressMonitor.UNKNOWN); // Fork another sub-job to circumvent the limitation of LocalServerReceiver. // (See the comments of scheduleCodeWaitingJob().) scheduleCodeWaitingJob(new LocalServerReceiverWrapper(codeReceiver), wait, codeHolder, exceptionHolder); wait.acquireUninterruptibly(); // Block until signaled. } }); if (exceptionHolder[0] != null) { throw exceptionHolder[0]; } return codeHolder[0]; } catch (InvocationTargetException | InterruptedException ex) { // Never thrown from the attached task. return null; } }
From source file:com.google.dart.tools.designer.editor.XmlDesignPage.java
License:Open Source License
private void internal_refreshGEF_withProgress() throws Exception { final Display display = Display.getCurrent(); IRunnableWithProgress runnable = new IRunnableWithProgress() { @Override/*from w ww .j a v a 2s .c o m*/ public void run(final IProgressMonitor monitor) { monitor.beginTask("Opening Design page.", 6); // try { DesignPageSite.setProgressMonitor(monitor); display.syncExec(new Runnable() { @Override public void run() { try { internal_refreshGEF(monitor); } catch (Throwable e) { ReflectionUtils.propagate(e); } } }); } catch (Throwable e) { ReflectionUtils.propagate(e); } finally { DesignPageSite.setProgressMonitor(null); } // done progress monitor monitor.subTask(null); ExecutionUtils.waitEventLoop(100); monitor.done(); } }; try { new ProgressMonitorDialog(DesignerPlugin.getShell()).run(false, false, runnable); } catch (InvocationTargetException e) { ReflectionUtils.propagate(e.getCause()); } catch (Throwable e) { ReflectionUtils.propagate(e); } }
From source file:com.google.dart.tools.internal.corext.refactoring.RefactoringExecutionStarter.java
License:Open Source License
public static void startCleanupRefactoring(CompilationUnit[] cus, ICleanUp[] cleanUps, boolean useOptionsFromProfile, Shell shell, boolean showWizard, String actionName) throws InvocationTargetException { final CleanUpRefactoring refactoring = new CleanUpRefactoring(actionName); for (int i = 0; i < cus.length; i++) { refactoring.addCompilationUnit(cus[i]); }//w w w .java 2s . c o m if (!showWizard) { refactoring.setUseOptionsFromProfile(useOptionsFromProfile); for (int i = 0; i < cleanUps.length; i++) { refactoring.addCleanUp(cleanUps[i]); } IRunnableContext context; if (refactoring.getCleanUpTargetsSize() > 1) { context = new ProgressMonitorDialog(shell); } else { context = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); } RefactoringExecutionHelper helper = new RefactoringExecutionHelper(refactoring, IStatus.INFO, RefactoringSaveHelper.SAVE_ALL, shell, context); try { helper.perform(true, true, true); } catch (InterruptedException e) { } } else { CleanUpRefactoringWizard refactoringWizard = new CleanUpRefactoringWizard(refactoring, RefactoringWizard.WIZARD_BASED_USER_INTERFACE); RefactoringStarter starter = new RefactoringStarter(); starter.activate(refactoringWizard, shell, actionName, RefactoringSaveHelper.SAVE_ALL); } }
From source file:com.google.dart.tools.search.internal.ui.util.ExtendedDialogWindow.java
License:Open Source License
@Override public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException { // The operation can only be canceled if it is executed in a separate thread. // Otherwise the UI is blocked anyway. Object state = null;//from w w w. j a va2 s .c om try { fActiveRunningOperations++; state = aboutToStart(fork && cancelable); if (fUseEmbeddedProgressMonitorPart) { ModalContext.run(runnable, fork, fProgressMonitorPart, getShell().getDisplay()); } else { new ProgressMonitorDialog(getShell()).run(fork, cancelable, runnable); } } finally { if (state != null) { stopped(state); } fActiveRunningOperations--; } }
From source file:com.google.dart.tools.search2.internal.ui.InternalSearchUI.java
License:Open Source License
public IStatus runSearchInForeground(IRunnableContext context, final ISearchQuery query, ISearchResultViewPart view) {//www . j a v a 2 s.com if (isQueryRunning(query)) { return Status.CANCEL_STATUS; } // prepare view if (view == null) { getSearchViewManager().activateSearchView(true); } else { getSearchViewManager().activateSearchView(view); } addQuery(query); SearchJobRecord sjr = new SearchJobRecord(query); fSearchJobs.put(query, sjr); if (context == null) { context = new ProgressMonitorDialog(null); } return doRunSearchInForeground(sjr, context); }
From source file:com.google.dart.tools.search2.internal.ui.SearchAgainAction.java
License:Open Source License
public void run() { final ISearchResult search = fView.getCurrentSearchResult(); if (search != null) { ISearchQuery query = search.getQuery(); NewSearchUI.cancelQuery(query);//from w w w . ja va 2 s. c o m if (query.canRerun()) { if (query.canRunInBackground()) NewSearchUI.runQueryInBackground(query, fView); else { Shell shell = fView.getSite().getShell(); ProgressMonitorDialog pmd = new ProgressMonitorDialog(shell); IStatus status = NewSearchUI.runQueryInForeground(pmd, query, fView); if (!status.isOK() && status.getSeverity() != IStatus.CANCEL) { ErrorDialog.openError(shell, SearchMessages.SearchAgainAction_Error_title, SearchMessages.SearchAgainAction_Error_message, status); } } } } }
From source file:com.google.dart.tools.update.core.internal.jobs.InstallUpdateAction.java
License:Open Source License
private void applyUpdate() throws InvocationTargetException, InterruptedException { new ProgressMonitorDialog(getShell()) { @Override//from w ww . java2 s . c o m protected void configureShell(Shell shell) { shell.setText(UpdateJobMessages.InstallUpdateAction_progress_mon_title); } }.run(true, false, new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { doApplyUpdate(monitor); } catch (IOException e) { throw new InvocationTargetException(e); } } }); }