List of usage examples for org.eclipse.jface.dialogs ProgressMonitorDialog run
@Override public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException
IRunnableWithProgress
using the progress monitor for this progress dialog and blocks until the runnable has been run, regardless of the value of fork
. From source file:com.aptana.editor.js.preferences.NodePreferencePage.java
License:Open Source License
private void downloadNodeJS() { final ProgressMonitorDialog downloadProgressMonitor = new ProgressMonitorDialog(UIUtils.getActiveShell()); try {//from w w w .java 2s . c o m downloadProgressMonitor.run(true, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { final INodeJS node = getDetectedPath(); IStatus status = node.downloadSource(monitor); if (status.isOK()) { // Set the path in the editor field Control control = NodePreferencePage.this.getControl(); if (control != null && !control.isDisposed()) { UIUtils.runInUIThread(new Runnable() { public void run() { sourceEditor.setStringValue(node.getSourcePath().toOSString()); } }); } } } catch (Exception e) { IdeLog.logError(JSPlugin.getDefault(), "Error while downloading NodeJS sources", e); //$NON-NLS-1$ } } }); } catch (Exception e) { IdeLog.logError(JSPlugin.getDefault(), e); } // setStringValue(value) }
From source file:com.aptana.ide.ui.io.properties.FileInfoPropertyPage.java
License:Open Source License
@Override protected Control createContents(Composite parent) { // first try to adapt to IFileStore directly final IFileStore fileStore = Utils.getFileStore(getElement()); if (fileStore == null) { Label label = new Label(parent, SWT.NONE); label.setText(IDEWorkbenchMessages.ResourceInfoPage_noResource); return label; }//from w w w. j a va2s .c o m try { if (getElement().getAdapter(File.class) != null) { fFileInfo = fileStore.fetchInfo(EFS.NONE, new NullProgressMonitor()); } else { final IFileInfo[] result = new IFileInfo[1]; ProgressMonitorDialog dlg = new ProgressMonitorDialog(parent.getShell()); try { dlg.run(true, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { result[0] = fileStore.fetchInfo(IExtendedFileStore.DETAILED, monitor); } catch (CoreException e) { throw new InvocationTargetException(e, e.getLocalizedMessage()); } finally { monitor.done(); } } }); } catch (InvocationTargetException e) { throw (CoreException) e.getTargetException(); } catch (InterruptedException e) { e.getCause(); } fFileInfo = result[0]; } } catch (CoreException e) { UIUtils.showErrorMessage(Messages.FileInfoPropertyPage_FailedToFetchInfo, e); } if (fFileInfo == null) { Label label = new Label(parent, SWT.NONE); label.setText(IDEWorkbenchMessages.ResourceInfoPage_noResource); return label; } Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(GridLayoutFactory.swtDefaults().margins(0, 0).create()); composite.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); Composite basicInfo = createBasicInfoGroup(composite, fileStore, fFileInfo); basicInfo.setLayoutData(GridDataFactory.fillDefaults().create()); Label separator = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL); separator.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); Composite state = createStateGroup(composite, fileStore, fFileInfo); state.setLayoutData(GridDataFactory.fillDefaults().create()); if (fFileInfo instanceof IExtendedFileInfo) { IExtendedFileInfo extendedInfo = (IExtendedFileInfo) fFileInfo; Composite owner = createOwnerGroup(composite, extendedInfo); owner.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).indent(0, 10).create()); Composite permissions = createPermissionsGroup(composite, extendedInfo); permissions.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).indent(0, 5).create()); } /* * TODO new Label(composite, SWT.NONE); // a vertical spacer encodingEditor = new EncodingFieldEditor("", * fileInfo.isDirectory() ? IDEWorkbenchMessages.ResourceInfo_fileEncodingTitle : * IDEWorkbenchMessages.WorkbenchPreference_encoding, composite); encodingEditor.setPreferenceStore(null); * encodingEditor.setPage(this); encodingEditor.load(); encodingEditor.setPropertyChangeListener(new * IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if * (event.getProperty().equals(FieldEditor.IS_VALID)) { setValid(encodingEditor.isValid()); } } }); if * (fileInfo.isDirectory()) { lineDelimiterEditor = new LineDelimiterEditor(composite, resource.getProject()); * lineDelimiterEditor.doLoad(); } */ Dialog.applyDialogFont(composite); return composite; }
From source file:com.aptana.php.debug.ui.phpini.PHPIniValidator.java
License:Open Source License
/** * Validate the php.ini directives./*from w ww.jav a 2 s . c o m*/ */ public void validate() { synchronized (lock) { if (isRunning) { return; } isRunning = true; } List<PHPIniEntry> extensions = new ArrayList<PHPIniEntry>(); extensions.addAll(mappedEntries.values()); // Mark all entries as unknown. for (PHPIniEntry entry : extensions) { entry.setValidationState(VALIDATION.UNKNOWN, null); } Shell activeShell = PHPDebugPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(); try { IRunnableWithProgress op = new ExtensionsValidatorRunnable(extensions); ProgressMonitorDialog progressMonitorDialog = new ProgressMonitorDialog(activeShell); progressMonitorDialog.run(true, true, op); } catch (InvocationTargetException e) { // handle exception IdeLog.logError(PHPDebugPlugin.getDefault(), "Error while validating the PHP extensions", e, //$NON-NLS-1$ IDebugScopes.DEBUG); } catch (InterruptedException e) // $codepro.audit.disable emptyCatchClause { // handle cancellation in the finally block } finally { // Revert the changes made to the ini for (PHPIniEntry entry : faultingExtensions) { provider.uncommentEntry(entry); } faultingExtensions.clear(); // Mark all the unknown entries as resolved. for (PHPIniEntry entry : mappedEntries.values()) { if (validationCanceled) { entry.setValidationState(VALIDATION.UNKNOWN, null); } else if (entry.getValidationState() == VALIDATION.UNKNOWN) { entry.setValidationState(VALIDATION.OK, null); } } try { provider.save(); } catch (IOException e) { IdeLog.logError(PHPDebugPlugin.getDefault(), "Error while saving the php.ini configuration.", e); //$NON-NLS-1$ } synchronized (lock) { isRunning = false; } } }
From source file:com.arc.embeddedcdt.launch.LaunchShortcut.java
License:Open Source License
/** * Method searchAndLaunch.// w w w . j ava2s. com * @param objects * @param mode */ private void searchAndLaunch(final Object[] elements, String mode) { if (elements != null && elements.length > 0) { IBinary bin = null; if (elements.length == 1 && elements[0] instanceof IBinary) { bin = (IBinary) elements[0]; } else { final List results = new ArrayList(); ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell()); IRunnableWithProgress runnable = new IRunnableWithProgress() { public void run(IProgressMonitor pm) throws InterruptedException { int nElements = elements.length; pm.beginTask("Looking for executables", nElements); //$NON-NLS-1$ try { IProgressMonitor sub = new SubProgressMonitor(pm, 1); for (int i = 0; i < nElements; i++) { if (elements[i] instanceof IAdaptable) { IResource r = (IResource) ((IAdaptable) elements[i]) .getAdapter(IResource.class); if (r != null) { ICProject cproject = CoreModel.getDefault().create(r.getProject()); if (cproject != null) { try { IBinary[] bins = cproject.getBinaryContainer().getBinaries(); for (int j = 0; j < bins.length; j++) { if (bins[j].isExecutable()) { results.add(bins[j]); } } } catch (CModelException e) { } } } } if (pm.isCanceled()) { throw new InterruptedException(); } sub.done(); } } finally { pm.done(); } } }; try { dialog.run(true, true, runnable); } catch (InterruptedException e) { return; } catch (InvocationTargetException e) { MessageDialog.openError(getShell(), LaunchMessages.getString("CApplicationLaunchShortcut.Application_Launcher"), //$NON-NLS-1$ e.getMessage()); return; } int count = results.size(); if (count == 0) { MessageDialog.openError(getShell(), LaunchMessages.getString("CApplicationLaunchShortcut.Application_Launcher"), //$NON-NLS-1$ LaunchMessages.getString("CApplicationLaunchShortcut.Launch_failed_no_binaries")); //$NON-NLS-1$ } else if (count > 1) { bin = chooseBinary(results, mode); } else { bin = (IBinary) results.get(0); } } if (bin != null) { launch(bin, mode); } } else { MessageDialog.openError(getShell(), LaunchMessages.getString("CApplicationLaunchShortcut.Application_Launcher"), //$NON-NLS-1$ LaunchMessages.getString("CApplicationLaunchShortcut.Launch_failed_no_project_selected")); //$NON-NLS-1$ } }
From source file:com.archimatetool.jasperreports.ExportJasperReportsWizard.java
License:Open Source License
@Override public boolean performFinish() { fPage1.saveSettings();//from w ww.j av a2 s .com fMainTemplateFile = fPage2.getMainTemplateFile(); // Check this exists if (fMainTemplateFile == null || !fMainTemplateFile.exists()) { MessageDialog.openError(getShell(), Messages.ExportJasperReportsWizard_1, Messages.ExportJasperReportsWizard_2); return false; } fExportFolder = fPage1.getExportFolder(); fExportFileName = fPage1.getExportFilename(); fReportTitle = fPage1.getReportTitle(); fIsPDF = fPage1.isExportPDF(); fIsHTML = fPage1.isExportHTML(); fIsDOCX = fPage1.isExportDOCX(); fIsPPT = fPage1.isExportPPT(); fIsODT = fPage1.isExportODT(); fIsRTF = fPage1.isExportRTF(); // Check valid dir and file name try { File file = new File(fExportFolder, fExportFileName); file.getCanonicalPath(); fExportFolder.mkdirs(); } catch (Exception ex) { MessageDialog.openError(getShell(), Messages.ExportJasperReportsWizard_3, Messages.ExportJasperReportsWizard_4); return false; } Display.getCurrent().asyncExec(new Runnable() { @Override public void run() { ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell()); try { dialog.run(false, true, new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { export(monitor); } catch (Exception ex) { ex.printStackTrace(); MessageDialog.openError(getShell(), Messages.ExportJasperReportsWizard_5, ex.getMessage()); } finally { monitor.done(); } } }); } catch (Exception ex) { ex.printStackTrace(); } } }); return true; }
From source file:com.aspose.eclipse.maven.wizard.AsposeMavenNewProjectWizard.java
License:Open Source License
/** * /*from w w w. j a v a 2 s . c o m*/ */ @Override public boolean performFinish() { final Model model = getModel(); // final String projectName = importConfiguration.getProjectName(model); final String projectName = model.getName(); IStatus nameStatus = importConfiguration.validateProjectName(model); if (!nameStatus.isOK()) { MessageDialog.openError(getShell(), NLS.bind(Messages.wizardProjectJobFailed, projectName), nameStatus.getMessage()); return false; } if (!AsposeMavenManager.isInternetConnected()) { MessageDialog.openError(getShell(), NLS.bind(AsposeConstants.INTERNET_CONNECTION_REQUIRED_MESSAGE_TITLE, projectName), AsposeConstants.MAVEN_INTERNET_CONNECTION_REQUIRED_MESSAGE); return false; } IWorkspace workspace = ResourcesPlugin.getWorkspace(); final IPath location; if (!_pageTwo.useDefaults()) { location = _pageTwo.getLocationPath(); } else location = null; final IWorkspaceRoot root = workspace.getRoot(); final IProject project = importConfiguration.getProject(root, model); final IPath pomFile; if (location == null || root.getLocation().equals(location)) { pomFile = root.getLocation().append(project.getName()).append(IMavenConstants.POM_FILE_NAME); } else { pomFile = location.append(IMavenConstants.POM_FILE_NAME); } if (pomFile.toFile().exists()) { MessageDialog.openError(getShell(), NLS.bind(Messages.wizardProjectJobFailed, projectName), Messages.wizardProjectErrorPomAlreadyExists); return false; } final AbstractCreateMavenProjectJob job; final String[] folders = _pageOne.getFolders(); ProgressMonitorDialog dialog = new ProgressMonitorDialog(null); try { dialog.run(true, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) { monitor.beginTask("Retrieving Aspose Maven Dependencies ...", AsposeMavenProject.getApiList().size()); AsposeMavenManager.retrieveAsposeMavenDependencies(monitor); } }); } catch (InvocationTargetException | InterruptedException e2) { // TODO Auto-generated catch block e2.printStackTrace(); } job = new AbstractCreateMavenProjectJob(NLS.bind(Messages.wizardProjectJobCreatingProject, projectName), workingSets) { @Override protected List<IProject> doCreateMavenProjects(IProgressMonitor monitor) throws CoreException { MavenPlugin.getProjectConfigurationManager().createSimpleProject(project, location, model, folders, // importConfiguration, monitor); try { Document pomDocument = AsposeMavenManager.getXmlDocument(pomFile.toString()); // Get the root element Node projectNode = pomDocument.getFirstChild(); // Adding Aspose Cloud Maven Repository configuration // setting here AsposeMavenManager.addAsposeMavenRepositoryConfiguration(pomDocument, projectNode); // Adding Dependencies here Element dependenciesTag = pomDocument.createElement("dependencies"); projectNode.appendChild(dependenciesTag); for (Metadata dependency : AsposeMavenManager.getAsposeProjectMavenDependencies()) { AsposeMavenManager.addAsposeMavenDependency(pomDocument, dependenciesTag, dependency); } AsposeMavenManager.updatePOM(pomDocument, monitor, project); } catch (ParserConfigurationException | SAXException | IOException | TransformerConfigurationException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (TransformerException e) { // TODO Auto-generated catch block e.printStackTrace(); } return Arrays.asList(project); } }; job.addJobChangeListener(new JobChangeAdapter() { public void done(IJobChangeEvent event) { final IStatus result = event.getResult(); if (!result.isOK()) { Display.getDefault().asyncExec(new Runnable() { public void run() { MessageDialog.openError(getShell(), // NLS.bind(Messages.wizardProjectJobFailed, projectName), result.getMessage()); } }); } MappingDiscoveryJob discoveryJob = new MappingDiscoveryJob(job.getCreatedProjects()); discoveryJob.schedule(); } }); job.setRule(MavenPlugin.getProjectConfigurationManager().getRule()); job.schedule(); return true; }
From source file:com.astra.ses.spell.dev.database.DatabaseManager.java
License:Open Source License
/*************************************************************************** * Load the database for the given project * //w w w .j a v a 2 s .c om * @param project * @throws DatabaseLoadException **************************************************************************/ private void loadProjectdatabase(IProject project, IProgressMonitor monitor) throws DatabaseLoadException { DatabasePropertiesManager manager = new DatabasePropertiesManager(project); String driver = manager.getDatabaseDriverName(); String path = manager.getDatabasePath(); DatabaseLoadJob dbLoad = new DatabaseLoadJob(project, driver, path); IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); if (window != null) { ProgressMonitorDialog dialog = new ProgressMonitorDialog(window.getShell()); try { dialog.setCancelable(false); dialog.run(true, false, dbLoad); if (dbLoad.result.getSeverity() == IStatus.ERROR) { throw new DatabaseLoadException(dbLoad.result.getMessage()); } } catch (Exception ex) { ex.printStackTrace(); } } else { dbLoad.run(monitor); if (dbLoad.result.getSeverity() == IStatus.ERROR) { throw new DatabaseLoadException(dbLoad.result.getMessage()); } } }
From source file:com.astra.ses.spell.dev.scheck.ui.handlers.JobHelper.java
License:Open Source License
public static void executeJob(IRunnableWithProgress job, boolean fork, boolean cancelable) { IWorkbenchWindow window = Activator.getDefault().getWorkbench().getActiveWorkbenchWindow(); ProgressMonitorDialog dialog = new ProgressMonitorDialog(window.getShell()); try {/*from w ww .ja v a2 s . com*/ dialog.run(true, true, job); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } }
From source file:com.astra.ses.spell.dev.wizards.ProcedureWizard.java
License:Open Source License
@Override public boolean performFinish() { Path path = m_infoPage.getAbsoluteFilePath(); IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); boolean result = false; try {/*from www . j ava 2 s . com*/ final IFile file = root.getFile(path); InputStream header = getSourceCodeHeader(); file.create(header, true, null); /* * Perform extended actions */ final ArrayList<IRunnableWithProgress> runnables = new ArrayList<IRunnableWithProgress>(); for (IProcedureCreationExtension extension : m_procedureExtensions) { IRunnableWithProgress job = extension.prepareJob(file); if (job != null) { runnables.add(job); } } Display.getDefault().asyncExec(new Runnable() { @Override public void run() { ProgressMonitorDialog dialog = new ProgressMonitorDialog(new Shell()); try { dialog.setCancelable(true); for (IRunnableWithProgress job : runnables) { dialog.run(false, true, job); } } catch (InvocationTargetException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } } }); /* * Open the editor if possible */ IWorkbenchWindow dw = m_workbench.getActiveWorkbenchWindow(); if (dw != null) { IWorkbenchPage page = dw.getActivePage(); if (page != null) { IDE.openEditor(page, file, true); } } result = true; } catch (CoreException e) { e.printStackTrace(); } return result; }
From source file:com.astra.ses.spell.dev.wizards.procs.pages.ProcedureControlVersionWizardPage.java
License:Open Source License
@Override public void performActions() { if (m_controlVersionJob == null) return;//from w ww .j a v a 2 s . c om ProgressMonitorDialog dialog = new ProgressMonitorDialog(new Shell()); try { dialog.setCancelable(true); dialog.run(false, true, m_controlVersionJob); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } }