List of usage examples for org.eclipse.jface.dialogs ProgressMonitorDialog setCancelable
public void setCancelable(boolean cancelable)
From source file:webx.studio.projectcreation.ui.project.ProjectHelper.java
License:Open Source License
public static void changeWebXVersion(final File topDir, final String settingsFile, final String webxVersion) throws Exception { if (topDir == null || topDir.isFile()) return;//from w w w. j av a 2s. com final File totalPomFile = new File(topDir, "pom.xml"); if (!totalPomFile.exists() || !totalPomFile.isFile()) return; if (StringUtils.isBlank(webxVersion)) return; final Model model = MavenHelper.getModel(totalPomFile); final String origWebXVersion = model.getProperties().getProperty("webx3-version"); if (StringUtils.isBlank(origWebXVersion) || StringUtils.equals(origWebXVersion, webxVersion)) { return; } // Job job = new WorkspaceJob("Change the WebX project version ,from "+origWebXVersion+" to "+webxVersion+", Please wait!") { // // @Override // public IStatus runInWorkspace(IProgressMonitor monitor) // throws CoreException { // // try { // model.getProperties().setProperty("webx3-version", // webxVersion); // FileWriter sw = new FileWriter(totalPomFile); // new MavenXpp3Writer().write(sw, model); // MavenHelper.generateEclipse(topDir.getCanonicalPath(), // settingsFile, ProgressUtil.getMonitorFor(null)); // ResourcesPlugin // .getWorkspace() // .getRoot() // .refreshLocal(IResource.DEPTH_INFINITE, // ProgressUtil.getMonitorFor(null)); // return Status.OK_STATUS; // } catch (Exception e) { // throw new CoreException(new Status(IStatus.ERROR, // ProjectCreationPlugin.PLUGIN_ID, -1, // e.getMessage(), e)); // } // } // // }; // job.schedule(); final ProgressMonitorDialog dialog = new ProgressMonitorDialog( ProjectCreationPlugin.getActiveWorkbenchShell()); dialog.setBlockOnOpen(false); dialog.setCancelable(true); IRunnableWithProgress runnable = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) { try { monitor.beginTask("Change the WebX project version ,from " + origWebXVersion + " to " + webxVersion + ", Please wait!", 100); model.getProperties().setProperty("webx3-version", webxVersion); FileWriter sw = new FileWriter(totalPomFile); new MavenXpp3Writer().write(sw, model); monitor.worked(20); MavenHelper.generateEclipse(topDir.getCanonicalPath(), settingsFile, ProgressUtil.getMonitorFor(null)); monitor.worked(80); ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE, ProgressUtil.getMonitorFor(null)); monitor.done(); } catch (Exception e) { e.printStackTrace(); } } }; dialog.run(true, true, runnable); }