List of usage examples for org.eclipse.jface.dialogs ProgressMonitorDialog open
@Override public int open()
From source file:org.elbe.relations.internal.utility.BibtexExporter.java
License:Open Source License
/** * Starts the export job./*from ww w. j a va2 s . c om*/ */ public void export() { final ProgressMonitorDialog lDialog = new ProgressMonitorJobsDialog(shell); lDialog.open(); final ExportJob lJob = new ExportJob(); try { lDialog.run(true, true, lJob); } catch (final InvocationTargetException exc) { log.error(exc, exc.getMessage()); } catch (final InterruptedException exc) { log.error(exc, exc.getMessage()); } }
From source file:org.elbe.relations.internal.wizards.ExportToXML.java
License:Open Source License
@Override public boolean performFinish() { final String lCatalog = dbSettings.getCatalog(); final String lBackupFile = page.getFileName(); statusLine.showStatusLineMessage(String.format(STATUS_MSG, lCatalog, lBackupFile)); final ProgressMonitorDialog lDialog = new ProgressMonitorJobsDialog(shell); lDialog.open(); final ExporterJob lJob = new ExporterJob(page.getFileName()); try {/* w ww . j a v a 2 s. co m*/ lDialog.run(true, true, lJob); } catch (final InvocationTargetException exc) { log.error(exc, exc.getMessage()); } catch (final InterruptedException exc) { log.error(exc, exc.getMessage()); } finally { lDialog.close(); } return true; }
From source file:org.elbe.relations.internal.wizards.ImportFromXML.java
License:Open Source License
private boolean createAndFill(final IDBChange inCreateDB, final String inImportFile) { final XMLImport lImport = inImportFile.endsWith(".zip") ? new ZippedXMLImport(inImportFile) //$NON-NLS-1$ : new XMLImport(inImportFile); final int lWorkItemsCount = 6; // run catalog creation and data import with progress monitor IRunnableWithProgress lJob = new AbstractRunnableWithProgress() { @Override/*from w w w.j a va 2 s. co m*/ protected final Runnable getRunnableInitialize(final IProgressMonitor inMonitor) { return new Runnable() { @Override public void run() { inMonitor.beginTask( String.format(RelationsMessages.getString("ImportFromXML.job.import.start"), //$NON-NLS-1$ inImportFile), lWorkItemsCount); } }; } /** * Create tables in database catalog - Parse XML file and create * table entries */ @Override protected final int process(final IProgressMonitor inMonitor) throws InvocationTargetException, InterruptedException { int outNumberOfImported = 0; sync.syncExec(new Runnable() { @Override public void run() { inCreateDB.execute(); } }); inMonitor.worked(1); if (inMonitor.isCanceled()) { throw new InterruptedException(); } try { outNumberOfImported = lImport.processFile(inMonitor, dbSettings.getDBConnectionConfig().canSetIdentityField()); monitorWorked(inMonitor); } catch (final InterruptedException exc) { throw exc; } catch (final Exception exc) { throw new InvocationTargetException(exc); } return outNumberOfImported; } @Override protected final Runnable getRunnableFeedback(final int inNumberOfProcessed) { final String lFeedback = String.format( RelationsMessages.getString("ImportFromXML.job.import.feedback"), inNumberOfProcessed); //$NON-NLS-1$ return new Runnable() { @Override public void run() { if (dbSettings.getDBConnectionConfig().canSetIdentityField()) { MessageDialog.openInformation(shell, RelationsMessages.getString("ImportFromXML.job.import.success"), lFeedback); //$NON-NLS-1$ } else { statusLine.showStatusLineMessage(lFeedback); } } }; } }; final ProgressMonitorDialog lImportDialog = new ProgressMonitorJobsDialog(shell); lImportDialog.open(); try { lImportDialog.run(true, true, lJob); } catch (final InvocationTargetException exc) { log.error(exc, exc.getMessage()); restorePrevious(inCreateDB); return false; } catch (final InterruptedException exc) { log.debug("Import of data interrupted by user."); //$NON-NLS-1$ restorePrevious(inCreateDB); return false; } finally { lImportDialog.close(); } if (!dbSettings.getDBConnectionConfig().canSetIdentityField()) { // run relation rebind with progress monitor final Collection<RelationReplaceHelper> lRelationsToRebind = lImport.getRelationsToRebind(); lJob = new AbstractRunnableWithProgress() { @Override protected Runnable getRunnableInitialize(final IProgressMonitor inMonitor) { return new Runnable() { @Override public void run() { inMonitor.beginTask(RelationsMessages.getString("ImportFromXML.job.rebind.start"), //$NON-NLS-1$ lRelationsToRebind.size()); } }; } @Override protected int process(final IProgressMonitor inMonitor) throws InvocationTargetException, InterruptedException { return processRebind(lRelationsToRebind, inMonitor); } @Override protected Runnable getRunnableFeedback(final int inNumberOfProcessed) { final String lFeedback = String.format( RelationsMessages.getString("ImportFromXML.job.rebind.feedback"), inNumberOfProcessed); //$NON-NLS-1$ return new Runnable() { @Override public void run() { MessageDialog.openInformation(shell, RelationsMessages.getString("ImportFromXML.job.rebind.success"), lFeedback); //$NON-NLS-1$ } }; } }; final ProgressMonitorDialog lRebindDialog = new ProgressMonitorJobsDialog(shell); lRebindDialog.open(); try { lRebindDialog.run(true, true, lJob); } catch (final InvocationTargetException exc) { log.error(exc, exc.getMessage()); return false; } catch (final InterruptedException exc) { return false; } finally { lRebindDialog.close(); } } return true; }
From source file:org.emftrace.ui.validation.ProjectCleaningHandler.java
License:Open Source License
@Override public Object execute(ExecutionEvent event) throws ExecutionException { ISelection sel = HandlerUtil.getCurrentSelection(event); final ECPProject project = (ECPProject) ((StructuredSelection) sel).getFirstElement(); final Shell shell = HandlerUtil.getActiveWorkbenchWindow(event).getShell(); final ProgressMonitorDialog progressDialog = new ProgressMonitorDialog(shell); progressDialog.open(); progressDialog.getProgressMonitor().beginTask("Cleaning up project...", 10); Callable<Void> call = new Callable<Void>() { @Override//from w w w . ja v a 2 s.c o m public Void call() throws Exception { Activator.getAccessLayer().invalidateCache(project); Activator.getProjectCleaner().cleanUpRuleOrphans(project); progressDialog.getProgressMonitor().worked(1); Activator.getProjectCleaner().cleanUpLinkTypeOrphans(project); progressDialog.getProgressMonitor().worked(1); Activator.getProjectCleaner().cleanUpViolationTypeOrphans(project); progressDialog.getProgressMonitor().worked(1); Activator.getProjectCleaner().cleanUpChangeTypeOrphans(project); progressDialog.getProgressMonitor().worked(1); Activator.getProjectCleaner().updateLinkTypeCatalogs(project); progressDialog.getProgressMonitor().worked(1); Activator.getProjectCleaner().updateViolationTypeCatalogs(project); progressDialog.getProgressMonitor().worked(1); Activator.getProjectCleaner().updateRuleCatalogs(project); progressDialog.getProgressMonitor().worked(1); Activator.getProjectCleaner().updateChangeTypeCatalogs(project); progressDialog.getProgressMonitor().worked(1); Activator.getProjectCleaner().updateLinkContainer(project); progressDialog.getProgressMonitor().worked(1); Activator.getProjectCleaner().updateReportContainer(project); progressDialog.getProgressMonitor().worked(1); return null; } }; RunESCommand.run(call); progressDialog.getProgressMonitor().done(); progressDialog.close(); return null; }
From source file:org.example.progressdemo.handlers.OpenHandler.java
License:Open Source License
private void showSubMonitors(Shell shell) throws InvocationTargetException, InterruptedException { ProgressMonitorDialog progressMonitorDialog = new ProgressMonitorDialog(shell); progressMonitorDialog.open(); progressMonitorDialog.run(true, true, new IRunnableWithProgress() { @Override/*w w w . ja va 2 s . c o m*/ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask("MyTask", 100); for (int i = 0; i < 10; i++) { SubProgressMonitor subProgressMonitor = new SubProgressMonitor(monitor, 10); subProgressMonitor.beginTask("MyTask", 10); subProgressMonitor.subTask("Sub Task: " + i); do10Steps(subProgressMonitor); } } }); }
From source file:org.example.progressdemo.handlers.OpenHandler.java
License:Open Source License
private void showSubTasks(Shell shell) throws InvocationTargetException, InterruptedException { ProgressMonitorDialog progressMonitorDialog = new ProgressMonitorDialog(shell); progressMonitorDialog.open(); progressMonitorDialog.run(true, true, new IRunnableWithProgress() { @Override/*from w ww . ja v a2 s.c o m*/ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask("MyTask", 10); for (int i = 0; i < 10; i++) { if (monitor.isCanceled()) { break; } monitor.subTask("Sub Task: " + i); monitor.worked(1); doSth(300); } } }); }
From source file:org.example.progressdemo.handlers.OpenHandler.java
License:Open Source License
private void showProgressDialog(Shell shell) throws InvocationTargetException, InterruptedException { ProgressMonitorDialog progressMonitorDialog = new ProgressMonitorDialog(shell); progressMonitorDialog.open(); progressMonitorDialog.run(true, true, new IRunnableWithProgress() { @Override/* w w w . j a v a 2s. com*/ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask("MyTask", 10); do10Steps(monitor); } }); }
From source file:org.fusesource.ide.jvmmonitor.internal.ui.actions.OpenDeclarationAction.java
License:Open Source License
/** * Searches the source for the given class name with progress monitor. * /*from w w w . j a v a2 s. com*/ * @return The source * @throws InterruptedException * if operation is canceled */ private IType searchSource() throws InterruptedException { final ProgressMonitorDialog dialog = new ProgressMonitorDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()); dialog.setOpenOnRun(false); // search source corresponding to the class name final IType[] source = new IType[1]; IRunnableWithProgress op = new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { if (!searchEngineInitialized) { monitor.subTask(Messages.searchingSoruceMsg); searchEngineInitialized = true; } // open progress monitor dialog when it takes long time new Timer().schedule(new TimerTask() { @Override public void run() { Display.getDefault().syncExec(new Runnable() { @Override public void run() { dialog.open(); } }); } }, 400); if (className == null) { return; } try { source[0] = doSearchSource(className); } catch (CoreException e) { throw new InvocationTargetException(e); } if (monitor.isCanceled()) { throw new InterruptedException(); } } }; try { dialog.run(true, true, op); } catch (InvocationTargetException e) { Activator.log(IStatus.ERROR, NLS.bind(Messages.searchClassFailedMsg, className), e); } return source[0]; }
From source file:org.jboss.tools.aerogear.hybrid.ui.internal.engine.AvailableCordovaEnginesSection.java
License:Open Source License
private void handleSearch(final Composite parent) { DirectoryDialog directoryDialog = new DirectoryDialog(parent.getShell()); directoryDialog.setMessage("Select the directory in which to search for hybrid mobile engines"); directoryDialog.setText("Search for Hybrid Mobile Engines"); String pathStr = directoryDialog.open(); if (pathStr == null) return;//from www . j a va2 s . c om final IPath path = new Path(pathStr); final ProgressMonitorDialog dialog = new ProgressMonitorDialog(parent.getShell()); dialog.setBlockOnOpen(false); dialog.setCancelable(true); dialog.open(); final EngineSearchListener listener = new EngineSearchListener() { @Override public void libraryFound(PlatformLibrary library) { addPathToPreference(library.getLocation()); getEngineProvider().libraryFound(library); } }; IRunnableWithProgress runnable = new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { List<HybridMobileEngineLocator> locators = HybridCore.getEngineLocators(); for (HybridMobileEngineLocator locator : locators) { locator.searchForRuntimes(path, listener, monitor); } parent.getDisplay().asyncExec(new Runnable() { @Override public void run() { updateAvailableEngines(); } }); } }; try { dialog.run(true, true, runnable); } catch (InvocationTargetException e) { if (e.getTargetException() != null) { if (e.getTargetException() instanceof CoreException) { StatusManager.handle((CoreException) e.getTargetException()); } else { ErrorDialog.openError(parent.getShell(), "Local Engine Search Error", null, new Status(IStatus.ERROR, HybridUI.PLUGIN_ID, "Error when searching for local hybrid mobile engines", e.getTargetException())); } } } catch (InterruptedException e) { HybridUI.log(IStatus.ERROR, "Search for Cordova Engines error", e); } }
From source file:org.jboss.tools.xform.Activator.java
License:Open Source License
/** * @return the session to the ModeShape workspace repository. *///from w w w .j av a 2 s . c om public Session workspaceRepositorySession() { if (modeShape == null) try { final ProgressMonitorDialog dlg = new ProgressMonitorDialog(null); dlg.open(); dlg.getProgressMonitor().setTaskName("Starting workspace repository..."); dlg.run(false, false, new IRunnableWithProgress() { @SuppressWarnings("synthetic-access") @Override public void run(final IProgressMonitor monitor) throws InvocationTargetException { try { modeShape = new ModeShapeEngine(); modeShape.start(); final RepositoryConfiguration config = RepositoryConfiguration .read("workspaceRepository.json"); final Problems problems = config.validate(); if (problems.hasProblems()) for (final Problem problem : problems) { int severity; switch (problem.getStatus()) { case ERROR: severity = IStatus.ERROR; break; case WARNING: severity = IStatus.WARNING; break; default: severity = IStatus.INFO; } log(severity, problem.getThrowable()); } if (problems.hasErrors()) throw new RuntimeException(problems.iterator().next().getThrowable()); Repository repository; try { repository = modeShape.getRepository(config.getName()); } catch (final NoSuchRepositoryException err) { repository = modeShape.deploy(config); } session = repository.login("default"); } catch (final Exception error) { throw new InvocationTargetException(error); } } }); } catch (InvocationTargetException | InterruptedException error) { throw new RuntimeException(error); } return session; }