List of usage examples for org.eclipse.jface.dialogs ProgressMonitorDialog close
@Override public boolean close()
ProgressMonitorDialog
implementation of this method only closes the dialog if there are no currently running runnables. 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();/*from w ww . ja v a2 s . c om*/ progressDialog.getProgressMonitor().beginTask("Cleaning up project...", 10); Callable<Void> call = new Callable<Void>() { @Override 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.lejos.tools.eclipse.plugin.util.AbstractJavaTestProject.java
License:Open Source License
public void buildProject() throws CoreException { if (!hasBeenBuild()) { Shell shell = new Shell(); ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell); dialog.open();/*from w w w .jav a 2 s . co m*/ IProgressMonitor monitor = dialog.getProgressMonitor(); try { monitor.beginTask("Building project", 100); this.project.build(IncrementalProjectBuilder.FULL_BUILD, monitor); } finally { monitor.done(); } dialog.close(); } }
From source file:org.openhealthtools.mdht.uml.hl7.ui.actions.ExportMIFAction.java
License:Open Source License
/** * @see IActionDelegate#run(IAction)/*w w w . j av a 2 s. c o m*/ */ public void run(IAction action) { ProgressMonitorDialog progressDialog = new ProgressMonitorDialog(activePart.getSite().getShell()); IRunnableWithProgress runnableWithProgress = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { // Get list of all elements of the model to be exported List<PackageableElement> umlElements = getPackageElements(); // Begin Monitor Task monitor.beginTask("MIF2 Export ", umlElements.size()); // Create new Exporter to export uml MIFExporter exporter = new MIFExporter(); // Loop over the packaged uml elements - each package will result in separate export mif model file. for (Element umlElement : umlElements) { // Updated progress String packageName = ((PackageableElement) umlElement).getName(); monitor.setTaskName("Exporting " + packageName); exporter.createMIFModel(umlElement); // Iterator over UML and process to create MIF for (TreeIterator<Object> iterator = EcoreUtil.getAllContents(Collections .singletonList(umlElement)); iterator.hasNext();) { EObject child = (EObject) iterator.next(); exporter.processUML(child); } monitor.worked(1); if (monitor.isCanceled()) { monitor.done(); return; } } // In order to properly support generalizations within mif we must complete a second pass over all the elements for (Element umlElement : umlElements) { // Iterator over Generalizations and process to create MIF for (TreeIterator<Object> iterator = EcoreUtil.getAllContents(Collections .singletonList(umlElement)); iterator.hasNext();) { EObject child = (EObject) iterator.next(); exporter.processGeneralizations(child); } } exporter.saveMIFModel(); monitor.done(); } }; try { progressDialog.run(false, true, runnableWithProgress); MessageDialog.openInformation(activePart.getSite().getShell(), "MIF2 Export", "Completed MIF2 Export"); } catch (InvocationTargetException invocationTargetException) { MessageDialog.openError(activePart.getSite().getShell(), "MIF2 Export", "Error Procssing Export " + invocationTargetException.getMessage()); Logger.logException("MIF2 Export Error", invocationTargetException); } catch (InterruptedException interruptedException) { MessageDialog.openError(activePart.getSite().getShell(), "MIF2 Export", "Error Procssing Export " + interruptedException.getMessage()); Logger.logException("MIF2 Export Error", interruptedException); } finally { progressDialog.close(); } }
From source file:org.openhealthtools.mdht.uml.hl7.ui.actions.ImportMIFAction.java
License:Open Source License
/** * @see IActionDelegate#run(IAction)//from w w w.j a va 2 s . c om */ public void run(IAction action) { ProgressMonitorDialog progressDialog = new ProgressMonitorDialog(activePart.getSite().getShell()); progressDialog.open(); try { Model umlModel = UMLFactory.eINSTANCE.createModel(); umlModel.setName("MIF_Import"); // Must create UML model resource before importing // so that MIF datatypes can be added to same resource set. List<ModelElement> mifElements = getModelElements(); if (mifElements.isEmpty()) { return; } Resource mifResource = (mifElements.get(0)).eResource(); URI umlURI = mifResource.getURI().trimFileExtension(); umlURI = umlURI.appendFileExtension(getUMLFileExtension()); /* * Special case for rim.coremif * Create a model named "RIM", import content directly into top-level Model. */ if (mifElements.size() == 1 && "rim.coremif".equals(mifResource.getURI().lastSegment())) { umlModel.setName("RIM"); umlURI.trimSegments(1); umlURI = umlURI.appendSegment("RIM"); umlURI = umlURI.appendFileExtension(getUMLFileExtension()); } // save to current IProject IProject project = getCurrentProject(); IFile umlFile = null; if (project != null) { umlFile = project.getFile(umlURI.lastSegment()); umlURI = URI.createPlatformResourceURI(umlFile.getFullPath().toString(), false); } Resource umlResource = mifResource.getResourceSet().createResource(umlURI); umlResource.getContents().add(umlModel); MIFImporter importer = new MIFImporter(); importer.setUMLModel(umlModel); /* * Special case for rim.coremif * Create a model named "RIM", import content directly into top-level Model. */ if (mifElements.size() == 1 && "rim.coremif".equals(mifResource.getURI().lastSegment()) && mifElements.get(0) instanceof StaticModelBase) { ((XMLResource) umlResource).setID(umlModel, "RIM-model"); importer.processMIF(mifElements.get(0)); } else { for (ModelElement element : mifElements) { importer.processMIF(element); } } umlResource.save(new HashMap<Object, Object>()); // unload the model umlModel.eResource().unload(); resourceSet = null; // refresh the Eclipse workspace to show this new file IFile[] files = null; if (umlFile != null) { files = new IFile[1]; files[0] = umlFile; project.refreshLocal(1, null); } else { files = ResourcesPlugin.getWorkspace().getRoot() .findFilesForLocation(new Path(umlURI.toFileString())); } if (files.length == 1) { // files[0].getProject().refreshLocal(IResource.DEPTH_INFINITE, null); files[0].getParent().refreshLocal(IResource.DEPTH_ONE, null); String editorID = "org.eclipse.uml2.uml.editor.presentation.UMLEditorID"; Bundle rsmBundle = Platform.getBundle("com.ibm.xtools.modeler.ui"); if (rsmBundle != null && "emx".equals(files[0].getFullPath().getFileExtension())) { editorID = "com.ibm.xtools.modeler.ui.editors.internal.ModelEditor"; } else if (activePart instanceof CommonNavigator) { // without this, the model file is in wrong sort position in navigator CommonViewer viewer = ((CommonNavigator) activePart).getCommonViewer(); viewer.refresh(); ((CommonNavigator) activePart).selectReveal(new StructuredSelection(files[0])); } // else if (activePart instanceof ISetSelectionTarget) { // ((ISetSelectionTarget)activePart).selectReveal(new StructuredSelection(files[0])); // } IEditorInput editorInput = new FileEditorInput(files[0]); try { IWorkbenchPage activePage = activePart.getSite().getPage(); activePage.openEditor(editorInput, editorID); } catch (PartInitException e) { } // display these last so that the error console will display after Rational console ConsoleUtil.logToConsole(importer.getDiagnostics()); } } catch (Exception e) { e.printStackTrace(); ConsoleUtil.showConsole(ConsoleUtil.DEFAULT_CONSOLE_NAME); ConsoleUtil.printError(ConsoleUtil.DEFAULT_CONSOLE_NAME, e.toString()); } finally { progressDialog.close(); } }
From source file:org.openhealthtools.mdht.uml.hl7.xhl72uml.popup.actions.XHl72UMLAction.java
License:Open Source License
/** * @see IActionDelegate#run(IAction)/*from w w w. j av a 2s .c o m*/ */ public void run(IAction action) { ProgressMonitorDialog progressDialog = new ProgressMonitorDialog(shell); ObjectPluginAction opa = (ObjectPluginAction) action; final TreeSelection selection = (TreeSelection) opa.getSelection(); final String ActionTitle = "xHL7 to UML"; IRunnableWithProgress runnableWithProgress = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask("Model Driven Health Tools ", 5); monitor.setTaskName(ActionTitle); monitor.subTask("Open UML File"); monitor.worked(1); IWorkspaceRoot myWorkspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); File f = (File) selection.getFirstElement(); String hl7Path = myWorkspaceRoot.getLocation().toOSString() + f.getFullPath().toOSString(); String umlPath = hl7Path + ".uml"; monitor.worked(2); monitor.subTask("Execute QVT Transformation"); xhl72uml(hl7Path, umlPath); monitor.subTask("Refresh Workspace"); monitor.worked(2); try { myWorkspaceRoot.refreshLocal(IResource.DEPTH_INFINITE, null); } catch (CoreException e) { // Ignore Exception } if (monitor.isCanceled()) { monitor.done(); return; } monitor.done(); } }; try { progressDialog.run(false, true, runnableWithProgress); UMLModelMetricsDialog dlg = new UMLModelMetricsDialog(shell); dlg.create(); dlg.open(); } catch (InvocationTargetException invocationTargetException) { MessageDialog.openError(shell, ActionTitle, "Error Processing Export " + invocationTargetException.getMessage()); } catch (InterruptedException interruptedException) { MessageDialog.openError(shell, ActionTitle, "Error Processing Export " + interruptedException.getMessage()); } finally { progressDialog.close(); } }
From source file:org.pentaho.di.core.market.Market.java
License:Apache License
/** * Installs the passed MarketEntry into the folder built by buildPluginsFolderPath(marketEntry). * /*w w w . j a v a 2s . c o m*/ * A warning dialog box is displayed if the plugin folder already exists. If the user chooses to install then the * plugin folder is deleted and then recreated. * * @param marketEntry * @throws KettleException */ public static void install(final MarketEntry marketEntry, ProgressMonitorDialog monitorDialog) throws KettleException { String parentFolderName = buildPluginsFolderPath(marketEntry); // Until plugin dependencies are implemented, check that the pentaho-big-data-plugin directory exists // before installing anything of type HadoopShim if (marketEntry.getType().equals(MarketEntryType.HadoopShim)) { File bdPluginFolder = new File(parentFolderName).getParentFile(); if (bdPluginFolder == null || !bdPluginFolder.exists()) { throw new KettleException(BaseMessages.getString(PKG, "Marketplaces.Dialog.PluginNotInstalled.message", "Pentaho Big Data Plugin") + ". You must install the Pentaho Big Data plugin before you can install a Hadoop Shim"); } } File pluginFolder = new File(parentFolderName + File.separator + marketEntry.getId()); LogChannel.GENERAL.logBasic("Installing plugin in folder: " + pluginFolder.getAbsolutePath()); if (pluginFolder.exists()) { monitorDialog.close(); MessageBox mb = new MessageBox(Spoon.getInstance().getShell(), SWT.NO | SWT.YES | SWT.ICON_WARNING); mb.setMessage(BaseMessages.getString(PKG, "Marketplace.Dialog.PromptOverwritePlugin.Message", pluginFolder.getAbsolutePath())); mb.setText(BaseMessages.getString(PKG, "Marketplace.Dialog.PromptOverwritePlugin.Title")); int answer = SWT.NO; answer = mb.open(); if (answer == SWT.YES) { monitorDialog.open(); ClassLoader cl = PluginRegistry.getInstance().getClassLoader(getPluginObject(marketEntry.getId())); if (cl instanceof KettleURLClassLoader) { ((KettleURLClassLoader) cl).closeClassLoader(); } deleteDirectory(pluginFolder); unzipMarketEntry(parentFolderName, marketEntry.getPackageUrl()); if (Market.discoverInstalledVersion(marketEntry).equalsIgnoreCase("unknown")) { createVersionXML(marketEntry); } refreshSpoon(monitorDialog); } } else { unzipMarketEntry(parentFolderName, marketEntry.getPackageUrl()); if (Market.discoverInstalledVersion(marketEntry).equalsIgnoreCase("unknown")) { createVersionXML(marketEntry); } refreshSpoon(monitorDialog); } }
From source file:org.pentaho.di.core.market.Market.java
License:Apache License
/** * Refreshes Spoons plugin registry, core objects and some UI things. * /* w w w.ja v a2 s . c om*/ * @throws KettleException */ private static void refreshSpoon(ProgressMonitorDialog monitorDialog) throws KettleException { if (monitorDialog != null) { monitorDialog.close(); } MessageBox box = new MessageBox(Spoon.getInstance().getShell(), SWT.ICON_QUESTION | SWT.OK); box.setText(BaseMessages.getString(PKG, "MarketplacesDialog.RestartUpdate.Title")); box.setMessage(BaseMessages.getString(PKG, "MarketplacesDialog.RestartUpdate.Message")); box.open(); DatabaseMeta.clearDatabaseInterfacesMap(); PluginRegistry.init(); Spoon spoon = Spoon.getInstance(); // Close all Execution Results panes to avoid SWT disposal issues during refresh int numTabs = spoon.delegates.tabs.getTabs().size(); TabSet tabSet = spoon.getTabSet(); int selectedIndex = tabSet.getSelectedIndex(); for (int i = numTabs - 1; i >= 0; i--) { if (i != selectedIndex) { tabSet.setSelected(i); if (spoon.isExecutionResultsPaneVisible()) { spoon.showExecutionResults(); } } } tabSet.setSelected(selectedIndex); if (spoon.isExecutionResultsPaneVisible()) { spoon.showExecutionResults(); } // Refresh Spoon objects and UI components spoon.refreshCoreObjects(); spoon.refreshTree(); spoon.refreshGraph(); spoon.enableMenus(); GUIResource.getInstance().reload(); spoon.selectionFilter.setText(spoon.selectionFilter.getText()); }
From source file:org.schwiebert.cloudio.application.actions.LoadFileAction.java
License:Open Source License
@Override public void run(IAction action) { FileDialog dialog = new FileDialog(getShell(), SWT.OPEN); dialog.setText("Select text file..."); String sourceFile = dialog.open(); if (sourceFile == null) return;// w ww .j a v a 2 s. com ProgressMonitorDialog pd = new ProgressMonitorDialog(getShell()); try { List<Type> types = TypeCollector.getData(new File(sourceFile), "UTF-8"); pd.setBlockOnOpen(false); pd.open(); pd.getProgressMonitor().beginTask("Generating cloud...", 200); TagCloudViewer viewer = getViewer(); viewer.setInput(types, pd.getProgressMonitor()); long start = System.currentTimeMillis(); viewer.getCloud().layoutCloud(pd.getProgressMonitor(), false); long end = System.currentTimeMillis(); System.out.println("Layouted: " + (end - start)); } catch (IOException e) { e.printStackTrace(); } finally { pd.close(); } }
From source file:org.xmind.ui.internal.sharing.SharingUtils.java
License:Open Source License
public static void run(final IRunnableWithProgress runnable, Display display) { final Throwable[] exception = new Throwable[] { null }; if (display != null && !display.isDisposed()) { display.syncExec(new Runnable() { public void run() { final ProgressMonitorDialog dialog = new ProgressMonitorDialog(null); dialog.setOpenOnRun(false); final boolean[] completed = new boolean[] { false }; Display.getCurrent().timerExec(240, new Runnable() { public void run() { if (!completed[0]) dialog.open(); }/*from w ww .j a v a2 s. c om*/ }); try { dialog.run(true, false, runnable); } catch (InterruptedException e) { // ignore } catch (InvocationTargetException e) { exception[0] = e.getCause(); } catch (Throwable e) { exception[0] = e; } finally { completed[0] = true; dialog.close(); Shell shell = dialog.getShell(); if (shell != null) { shell.dispose(); } } } }); } else { try { runnable.run(new NullProgressMonitor()); } catch (InterruptedException e) { // ignore } catch (InvocationTargetException e) { exception[0] = e.getCause(); } catch (Throwable e) { exception[0] = e; } } if (exception[0] != null) { LocalNetworkSharingUI.log("Failed to disconnect from local network sharing service:", //$NON-NLS-1$ exception[0]); } }
From source file:org.yafra.rcp.commands.ConnectHandler.java
License:Apache License
@SuppressWarnings("static-access") @Override/*from w w w . j a va 2 s. c o m*/ public Object execute(ExecutionEvent event) throws ExecutionException { glob = GlobalSettings.getSingletonObject(); glob.setDebugmessage(" - start command connect and login"); preferredWindow = HandlerUtil.getActiveWorkbenchWindow(event); if (glob.isYafraSessionConnected()) { MessageDialog.openInformation(preferredWindow.getShell(), "Info", "You are already logged in - logoff first"); return null; } login = new LoginDialog(preferredWindow.getShell()); login.open(); if (login.getReturnCode() == (int) login.OK) { ProgressMonitorDialog progressDialog = new ProgressMonitorDialog(preferredWindow.getShell()); IRunnableWithProgress runnable = new IRunnableWithProgress() { public void run(IProgressMonitor progressMonitor) throws InterruptedException { progressMonitor.beginTask(Lloginstartmon, IProgressMonitor.UNKNOWN); try { // for the provider URL see as examples http://openejb.apache.org/clients.html // openejb in tomee http://127.0.0.1:8080/tomee/ejb // openejb standalone ejbd ejbd://localhost:4201 String ServerURL = new String(String.format("http://%s:8080/tomee/ejb", login.getServer())); Properties prop = new Properties(); prop.put(glob.getEjbcontext().INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.RemoteInitialContextFactory"); prop.put("java.naming.provider.url", ServerURL); glob.setEjbcontext(new InitialContext(prop)); progressMonitor.worked(1); glob.setDebugmessage(" - got context"); glob.setYafrases((YafraSessionRemote) glob.getEjbcontext().lookup("YafraSessionRemote")); glob.setDebugmessage(" - got remote session class"); glob.getYafrases().init(); progressMonitor.worked(2); glob.setDebugmessage(" - got remote init"); if (glob.getYafrases().Login(login.getUserid(), login.getPwd())) { glob.setYafraSessionConnected(true); glob.getStatusline().setMessage(null, "Ready - logged in"); glob.setDebugmessage(" - login OK"); GlobalSettings glob = GlobalSettings.getSingletonObject(); glob.setServer(login.getServer()); glob.setUser(login.getUserid()); MHIYafraUserRemote mhiuser = (MHIYafraUserRemote) glob.getEjbcontext() .lookup("MHIYafraUserRemote"); glob.setUserModel(mhiuser.selectUser(login.getUserid())); glob.setUserRoles(mhiuser.getRoles(login.getUserid())); } else { glob.setDebugmessage(" - login NOT OK - EXIT NOW"); glob.getStatusline().setMessage(null, "Ready - not logged in - ERROR with login - try again"); glob.setYafraSessionConnected(false); return; } glob.setDebugmessage(" - version got from server: " + glob.getYafrases().getVersion()); // TODO check why not returning progressMonitor.done(); } catch (Exception e) { glob.setYafraSessionConnected(false); progressMonitor.done(); Status status = new Status(IStatus.ERROR, "My Plug-in ID", 0, "EJB3 connection error", e); ErrorDialog.openError(Display.getCurrent().getActiveShell(), "EJB3 connection error", e.toString(), status); e.printStackTrace(); } }; }; try { progressDialog.open(); runnable.run(progressDialog.getProgressMonitor()); } catch (InvocationTargetException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } progressDialog.close(); try { IViewReference ref = preferredWindow.getActivePage().findViewReference("org.yafra.rcp.LoginView"); preferredWindow.getActivePage().hideView(ref); preferredWindow.getActivePage().showView("org.yafra.rcp.LoginView"); } catch (PartInitException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return null; }