List of usage examples for org.eclipse.jface.dialogs ProgressMonitorDialog setCancelable
public void setCancelable(boolean cancelable)
From source file:org.emftrace.ui.dependencygraph.DependencyGraphNode.java
License:Open Source License
/** * Starts a distance-based impact analysis with this node as the source of change */// w w w . j a va 2 s .c o m private void performDistanceBasedImpactAnalysis() { DependencyGraph graph = (DependencyGraph) getGraphModel(); Shell shell = graph.getShell(); Activator.getAccessLayer().invalidateCache(graph.getProject()); DistanceBasedImpactAnalysisWizard wizard = new DistanceBasedImpactAnalysisWizard(); WizardDialog dialog = new WizardDialog(shell, wizard); dialog.open(); List<EObject> startingImpactSet = new ArrayList<EObject>(); startingImpactSet.add(model); if (wizard.finishedSuccessfully) { ImpactAnalysisOperation op = new ImpactAnalysisOperation(graph.getProject(), startingImpactSet, null, false, true, false); ProgressMonitorDialog progressDialog = new ProgressMonitorDialog(shell); progressDialog.setCancelable(false); try { progressDialog.run(true, true, op); MessageDialog.openInformation(shell, "Impact Analysis completed", op.getSizeOfImpactSet() + " impacted elements found"); } catch (InvocationTargetException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } graph.adjustEdgesAfterImpactAnalysis(); } }
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;/*w ww . j ava 2s.c o m*/ 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.python.pydev.utils.ProgressOperation.java
License:Open Source License
/** * @param shell//from w ww .ja v a 2s . c o m * */ public static void startAction(Shell shell, ProgressAction action, boolean cancelable) { ProgressMonitorDialog monitorDialog = new AsynchronousProgressMonitorDialog(shell); monitorDialog.setCancelable(cancelable); monitorDialog.setBlockOnOpen(false); try { IRunnableWithProgress operation = new ProgressOperation(action); monitorDialog.run(false, false, operation); // Perform the action } catch (InvocationTargetException e) { Log.log(e); } catch (InterruptedException e) { Log.log(e); } }
From source file:org.rcpbook.hyperbola.ui.Application.java
License:Open Source License
private void connectWithProgress(final Session session) { ProgressMonitorDialog progress = new ProgressMonitorDialog(null); progress.setCancelable(true); try {//from w ww . j a v a 2 s . c om progress.run(true, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { session.connectAndLogin(monitor); } catch (XMPPException e) { throw new InvocationTargetException(e); } } }); } catch (InvocationTargetException e) { // TODO: handle exception } catch (InterruptedException e) { // TODO: handle exception } }
From source file:org.rssowl.ui.internal.dialogs.NewsFiltersListDialog.java
License:Open Source License
private void applyFilter(final List<SearchHit<NewsReference>> news, final ISearchFilter filter) { IRunnableWithProgress runnable = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) { List<List<SearchHit<NewsReference>>> chunks = CoreUtils.toChunks(news, FILTER_CHUNK_SIZE); monitor.beginTask(NLS.bind(Messages.NewsFiltersListDialog_WAIT_FILTER_APPLIED, filter.getName()), chunks.size());/* w w w . j ava2s. c o m*/ if (monitor.isCanceled()) return; int counter = 0; for (List<SearchHit<NewsReference>> chunk : chunks) { if (monitor.isCanceled()) return; monitor.subTask(NLS.bind(Messages.NewsFiltersListDialog_FILTERED_N_OF_M_NEWS, (counter * FILTER_CHUNK_SIZE), news.size())); List<INews> newsItemsToFilter = new ArrayList<INews>(FILTER_CHUNK_SIZE); for (SearchHit<NewsReference> chunkItem : chunk) { INews newsItemToFilter = chunkItem.getResult().resolve(); if (newsItemToFilter != null && newsItemToFilter.isVisible()) newsItemsToFilter.add(newsItemToFilter); else CoreUtils.reportIndexIssue(); } applyFilterOnChunks(newsItemsToFilter, filter); monitor.worked(1); counter++; } monitor.done(); } }; /* Show progress and allow for cancellation */ ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell()); dialog.setBlockOnOpen(false); dialog.setCancelable(true); dialog.setOpenOnRun(true); try { dialog.run(true, true, runnable); } catch (InvocationTargetException e) { Activator.getDefault().logError(e.getMessage(), e); } catch (InterruptedException e) { Activator.getDefault().logError(e.getMessage(), e); } }
From source file:org.vast.stt.commands.OpenProject.java
License:Mozilla Public License
public void execute() { Shell shell = Display.getDefault().getActiveShell(); // Two Progress Monitor Dialogs now used... // ...First loads ProjectReader.project object from Project File ProgressMonitorDialog pmd = new ProgressMonitorDialog(shell); pmd.setCancelable(true); ProjectReader reader = new ProjectReader(); LoadProjectRunnable lpr = new LoadProjectRunnable(reader, url); try {/*w w w . ja v a2 s . c om*/ pmd.run(true, true, lpr); } catch (InvocationTargetException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (InterruptedException e1) { // TODO Auto-generated catch block MessageDialog.openInformation(shell, "Information", "User cancelled Project Loading"); return; } Project project = reader.getProject(); if (project == null) { MessageDialog.openError(shell, "Error", "Unknown error reading project"); return; } // ...Second unloads project object into scene tree (populate tree, load enabled data items, etc) pmd = new ProgressMonitorDialog(shell); pmd.setCancelable(true); OpenPageRunnable opr = new OpenPageRunnable(project); try { pmd.run(true, true, opr); } catch (InvocationTargetException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (InterruptedException e1) { // TODO Auto-generated catch block MessageDialog.openInformation(shell, "Information", "User cancelled Project Loading"); return; } System.gc(); // Check me... }
From source file:org.vast.stt.gui.widgets.catalog.CatalogWidget.java
License:Mozilla Public License
protected void searchCatalog(WRSQuery query) { ProgressMonitorDialog pmd = new ProgressMonitorDialog( PlatformUI.getWorkbench().getDisplay().getActiveShell()); pmd.setCancelable(true); SearchCatalogRunnable runnable = new SearchCatalogRunnable(query); // Load Bbox, keywords... try {/*w ww . j a va2s. co m*/ pmd.run(true, true, runnable); } catch (InvocationTargetException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } List<OWSLayerCapabilities> caps = runnable.getLayerCaps(); if (caps == null) MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "STT Error", "Error reading Catalog from " + query.getPostServer()); else if (caps.isEmpty()) MessageDialog.openInformation(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "STT Information", "Catalog Query returned no results"); else layerTree.setInput(caps); }
From source file:org.xtuml.bp.integrity.generator.Generator.java
License:Open Source License
private static void checkReferentialIntegrity() { IPath path;/* w w w .j a v a 2s. co m*/ destPath = ""; List<String> modelsDir = new ArrayList<String>(); final IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects(); // Build an array of string paths to model folders. for (IProject project : projects) { String projPath = project.getLocation().toOSString(); IPath modelspath = new Path(projPath + File.separator + "models"); if (modelspath.toFile().exists()) { modelsDir.add("-i"); modelsDir.add(modelspath.toOSString()); if ("" == destPath) { // only set these up on the first project found path = new Path(projPath + File.separator + DOC_DIR + File.separator); if (!path.toFile().exists()) { path.toFile().mkdirs(); } destPath = path.toOSString(); firstProject = project; } } } if ("" != destPath) { ProgressMonitorDialog pmd = new ProgressMonitorDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()); pmd.setCancelable(true); pmd.create(); IProgressMonitor monitor = pmd.getProgressMonitor(); try { // Proceed with actually running integrity on the model IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); String id = IConsoleConstants.ID_CONSOLE_VIEW; IConsoleView view = (IConsoleView) page.showView(id); view.display(myConsole); pmd.run(true, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { int steps = 3; int curStep = 1; monitor.beginTask("Check Referential Integrity", steps); while (curStep <= steps) { if (monitor.isCanceled()) { InterruptedException ie = new InterruptedException("User cancelled the operation"); throw ie; } try { switch (curStep) { case 1: monitor.subTask("Accumulating model data for workspace"); monitor.worked(1); break; case 2: monitor.subTask("Processing model data for all projects"); runIntegrity(firstProject, destPath, modelsDir); monitor.worked(1); break; case 3: monitor.subTask("Refreshing"); firstProject.refreshLocal(IResource.DEPTH_INFINITE, null); monitor.worked(1); break; } } catch (Throwable e) { RuntimeException err = new RuntimeException(e.getMessage()); throw err; } curStep++; } } }); // This opens the text file in an editor. openOutput(firstProject); } catch (Throwable e) { String errMsg = e.getMessage(); if ((errMsg == null) || errMsg.isEmpty()) { Throwable cause = e.getCause(); if (cause != null) { errMsg = cause.getMessage(); } if ((cause == null) || (errMsg == null)) { errMsg = ""; } } logMsg(app + args + "\nError. Check Referential Integrity failed: " + errMsg); } finally { logMsg(app + args + "\nCheck Referential Integrity finished successfully."); monitor.done(); } } }
From source file:org.xwiki.eclipse.ui.utils.UIUtils.java
License:Open Source License
public static void runWithProgress(IRunnableWithProgress operation, Shell shell, boolean cancelable) throws InvocationTargetException, InterruptedException { ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell); dialog.setCancelable(cancelable); dialog.run(true, cancelable, operation); }
From source file:ummisco.gama.ui.views.SyntaxErrorsView.java
static void build() { final ProgressMonitorDialog dialog = new ProgressMonitorDialog(WorkbenchHelper.getShell()); dialog.setBlockOnOpen(false);// w ww.java 2s . com dialog.setCancelable(false); dialog.setOpenOnRun(true); try { dialog.run(true, false, monitor -> doBuild(monitor)); } catch (InvocationTargetException | InterruptedException e1) { e1.printStackTrace(); } }