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:org.eclipse.pde.internal.ui.preferences.TargetPlatformPreferencePage.java
License:Open Source License
private void handleReload() { IStructuredSelection selection = (IStructuredSelection) fTableViewer.getSelection(); if (!selection.isEmpty()) { isOutOfSynch = false;/*from w w w . j a v a2 s .c o m*/ ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell()) { @Override protected void configureShell(Shell shell) { super.configureShell(shell); shell.setText(PDEUIMessages.TargetPlatformPreferencePage2_12); } }; try { dialog.run(true, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { if (monitor.isCanceled()) { throw new InterruptedException(); } // Resolve the target fActiveTarget.resolve(monitor); if (monitor.isCanceled()) { throw new InterruptedException(); } } }); } catch (InvocationTargetException e) { PDEPlugin.log(e); setErrorMessage(e.getMessage()); } catch (InterruptedException e) { // Do nothing, resolve will happen when user presses ok } if (fActiveTarget.isResolved()) { // Check if the bundle resolution has errors IStatus bundleStatus = fActiveTarget.getStatus(); if (bundleStatus.getSeverity() == IStatus.ERROR) { ErrorDialog.openError(getShell(), PDEUIMessages.TargetPlatformPreferencePage2_14, PDEUIMessages.TargetPlatformPreferencePage2_15, bundleStatus, IStatus.ERROR); } // Compare the target to the existing platform try { if (fPrevious != null && bundleStatus.getSeverity() != IStatus.ERROR && fActiveTarget.getHandle().equals(fPrevious.getHandle()) && ((TargetDefinition) fPrevious).isContentEquivalent(fActiveTarget)) { IStatus compare = getTargetService().compareWithTargetPlatform(fActiveTarget); if (!compare.isOK()) { MessageDialog.openInformation(getShell(), PDEUIMessages.TargetPlatformPreferencePage2_17, PDEUIMessages.TargetPlatformPreferencePage2_18); isOutOfSynch = true; } } } catch (CoreException e) { PDEPlugin.log(e); setErrorMessage(e.getMessage()); } } fTableViewer.refresh(true); } }
From source file:org.eclipse.pde.targetplatformexporter.wizards.TargetPlatformExporterWizard.java
License:Open Source License
@Override public boolean performFinish() { targetDefinitionFileSelectionWizardPage.saveState(); final String repoPath = targetDefinitionFileSelectionWizardPage.getRepoPath(); final boolean p2Mirror = targetDefinitionFileSelectionWizardPage.getP2Mirror(); final AtomicReference<MultiStatus> multiStatusReference = new AtomicReference<>(); final Set<URI> repoURIs = new HashSet<>(); final Set<IInstallableUnit> installableUnitSet = new HashSet<>(); ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell()) { protected void configureShell(Shell shell) { super.configureShell(shell); shell.setText("Resolving and exporting target platform(s)"); }//from ww w . ja v a 2 s. com }; try { dialog.run(true, true, new IRunnableWithProgress() { @SuppressWarnings("unchecked") public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { int combinations = targetDefinitionFileSelectionWizardPage.getTargetFiles().size() * targetDefinitionFileSelectionWizardPage.getConfigurations().size(); SubMonitor subMonitor = SubMonitor.convert(monitor, 2 * combinations); try { subMonitor.setTaskName("Resolving and exporting target platform(s)"); ITargetPlatformService service = (ITargetPlatformService) PDECore.getDefault() .acquireService(ITargetPlatformService.class.getName()); for (IFile file : targetDefinitionFileSelectionWizardPage.getTargetFiles()) { for (ExportConfiguration config : targetDefinitionFileSelectionWizardPage .getConfigurations()) { try { ITargetHandle fileHandle = service.getTarget(file); ITargetDefinition targetDefinition; targetDefinition = fileHandle.getTargetDefinition(); targetDefinition.setArch(config.getArch()); targetDefinition.setWS(config.getWs()); targetDefinition.setOS(config.getOs()); P2TargetUtils.deleteProfile(fileHandle); // Resolve the target targetDefinition.resolve(subMonitor.newChild(1)); //TODO Check targetDefinition.getStatus() if (monitor.isCanceled()) { throw new InterruptedException(); } if (p2Mirror) { IQueryResult<?> iUs = P2TargetUtils.getIUs(targetDefinition, subMonitor.newChild(1)); installableUnitSet.addAll((Set<IInstallableUnit>) iUs.toSet()); ITargetLocation[] targetLocations = targetDefinition.getTargetLocations(); for (ITargetLocation targetLocation : targetLocations) { IUBundleContainer bundleContainer = (IUBundleContainer) targetLocation; for (URI uri : bundleContainer.getRepositories()) { repoURIs.add(uri); } } } else { subMonitor.subTask("Exporting target configuration"); Job job = new ExportTargetJob(targetDefinition, new File(repoPath).toURI(), false); job.schedule(); job.join(); subMonitor.worked(1); } } catch (CoreException e) { e.printStackTrace(); throw new InvocationTargetException(e, "Error exporting target platform(s): " + e); } } } } finally { monitor.done(); } if (p2Mirror) { P2MirrorTool p2MirrorTool = new P2MirrorTool(repoURIs, installableUnitSet, repoPath); try { MultiStatus status = p2MirrorTool.mirror(monitor); multiStatusReference.set(status); } catch (MirrorException e) { throw new InvocationTargetException(e); } } } }); if (multiStatusReference.get() != null) { StringBuilder sb = new StringBuilder(); getMessage(multiStatusReference.get(), sb); if (sb.length() > 0) { MessageDialog.openError(getShell(), "Error", sb.toString()); return false; } } MessageDialog.openInformation(getShell(), "Mirror p2 repository", "Operation successful"); return true; } catch (InvocationTargetException e) { e.printStackTrace(); if (e.getCause() instanceof MirrorException) { MessageDialog.openError(getShell(), "Error", e.getCause().getMessage()); } else { String message = e.getLocalizedMessage(); if (e.getCause() != null) { message = e.getCause().getMessage(); } MessageDialog.openError(getShell(), "Error", message); } } catch (InterruptedException e) { } return false; }
From source file:org.eclipse.php.internal.debug.ui.preferences.phps.InstalledPHPsBlock.java
License:Open Source License
/** * Search for installed VMs in the file system *//*from w w w . jav a2 s . c o m*/ protected void search() { // choose a root directory for the search final DirectoryDialog dialog = new DirectoryDialog(getShell()); dialog.setMessage(PHPDebugUIMessages.InstalledPHPsBlock_9); dialog.setText(PHPDebugUIMessages.InstalledPHPsBlock_10); final String path = dialog.open(); if (path == null) return; final File rootDir = new File(path); final List<File> locations = new ArrayList<File>(); final List<PHPexeItem> found = new ArrayList<PHPexeItem>(); final IRunnableWithProgress r = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) { monitor.beginTask(PHPDebugUIMessages.InstalledPHPsBlock_11, IProgressMonitor.UNKNOWN); search(rootDir, locations, monitor); if (!locations.isEmpty()) { monitor.setTaskName(PHPDebugUIMessages.InstalledPHPsBlock_Processing_search_results); Iterator<File> iter2 = locations.iterator(); while (iter2.hasNext()) { if (monitor.isCanceled()) break; File location = iter2.next(); PHPexeItem phpExe = new PHPexeItem(null, location, null, null, true); if (phpExe.getName() == null) continue; String nameCopy = new String(phpExe.getName()); monitor.subTask(MessageFormat .format(PHPDebugUIMessages.InstalledPHPsBlock_Fetching_php_exe_info, nameCopy)); List<PHPModuleInfo> modules = PHPExeUtil.getModules(phpExe); AbstractDebuggerConfiguration[] debuggers = PHPDebuggersRegistry .getDebuggersConfigurations(); for (AbstractDebuggerConfiguration debugger : debuggers) { for (PHPModuleInfo m : modules) if (m.getName().equalsIgnoreCase(debugger.getModuleId())) { phpExe.setDebuggerID(debugger.getDebuggerId()); break; } } if (phpExe.getDebuggerID() == null) phpExe.setDebuggerID(PHPDebuggersRegistry.NONE_DEBUGGER_ID); int i = 1; // Check for duplicated names duplicates: while (true) { if (isDuplicateName(nameCopy)) { nameCopy = phpExe.getName() + ' ' + '[' + i++ + ']'; continue duplicates; } else { for (PHPexeItem item : found) if (nameCopy.equalsIgnoreCase(item.getName())) { nameCopy = phpExe.getName() + ' ' + '[' + i++ + ']'; continue duplicates; } } break duplicates; } phpExe.setName(nameCopy); if (phpExe.getExecutable() != null) { found.add(phpExe); } } } monitor.done(); } }; // Perform searching try { final ProgressMonitorDialog progress = new ProgressMonitorDialog( PlatformUI.getWorkbench().getDisplay().getActiveShell()) { protected void configureShell(Shell shell) { super.configureShell(shell); shell.setText(PHPDebugUIMessages.InstalledPHPsBlock_PHP_executables_search); }; }; progress.run(true, true, r); } catch (final InvocationTargetException e) { PHPDebugUIPlugin.log(e); } catch (final InterruptedException e) { // cancelled return; } // Show results if (!found.isEmpty()) { Comparator<PHPexeItem> sorter = new Comparator<PHPexeItem>() { @Override public int compare(PHPexeItem a, PHPexeItem b) { return b.getVersion().compareTo(a.getVersion()); } }; Collections.sort(found, sorter); PHPsSearchResultDialog searchDialog = new PHPsSearchResultDialog(found, MessageFormat.format(PHPDebugUIMessages.InstalledPHPsBlock_Search_result_dialog_message, path)); searchDialog.open(); List<PHPexeItem> itemsToAdd = searchDialog.getPHPExecutables(); for (PHPexeItem item : itemsToAdd) { fPHPexes.add(item); PHPexes.getInstance().addItem(item); PHPexes.getInstance().save(); DBGpProxyHandlersManager.INSTANCE.registerHandler(item.getUniqueId()); PHPExeVerifier.verify(PHPexes.getInstance().getAllItems()); } fPHPExeList.refresh(); } else { MessageDialog.openInformation(PlatformUI.getWorkbench().getDisplay().getActiveShell(), PHPDebugUIMessages.InstalledPHPsBlock_12, MessageFormat.format(PHPDebugUIMessages.InstalledPHPsBlock_13, new Object[] { path })); } }
From source file:org.eclipse.ptp.pldt.common.actions.RunAnalyseHandlerBase.java
License:Open Source License
/** * Do the "Run Analysis" on a resource (project, folder, or file). Descends * to all child nodes, collecting artifacts on each. * //from w w w . j a v a 2s . c o m */ public void run() { if (traceOn) { System.out.println("RunAnalyseHandlerBase.run()..."); //$NON-NLS-1$ } cancelledByUser = false; err = false; cumulativeArtifacts = 0; readPreferences(); final int indent = 0; if ((selection == null) || selection.isEmpty()) { MessageDialog.openWarning(null, Messages.RunAnalyseHandlerBase_no_files_selected, Messages.RunAnalyseHandlerBase_please_select); return; } else { // get preference for include paths final List<String> includes = getIncludePath(); if (areIncludePathsNeeded() && includes.isEmpty()) { // System.out.println("RunAnalyseHandlerBase.run(), no include paths found."); MessageDialog.openWarning(shell, name + Messages.RunAnalyseHandlerBase_include_paths_not_found, Messages.RunAnalyseHandlerBase_please_first_specify + name + Messages.RunAnalyseHandlerBase_incl_paths_in_pref_page); } else { // batch ws modifications *and* report progress WorkspaceModifyOperation wmo = new WorkspaceModifyOperation() { @Override protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException { err = runResources(monitor, indent, includes); } }; ProgressMonitorDialog pmdialog = new ProgressMonitorDialog(shell); try { pmdialog.run(true, true, wmo); // fork=true; if false, not // cancelable } catch (InvocationTargetException e) { err = true; Throwable cause = e.getCause(); System.out.println("Error running analysis: ITE: " //$NON-NLS-1$ + e.getMessage()); System.out.println(" cause: " + cause + " - " //$NON-NLS-1$ //$NON-NLS-2$ + cause.getMessage()); cause.printStackTrace(); } catch (InterruptedException e) { cancelledByUser = true; } } // end else } if (traceOn) { System.out.println("RunAnalyseBase: retd from run iterator, err=" //$NON-NLS-1$ + err); } String artsFound = "\nNumber of " + name + " Artifacts found: " //$NON-NLS-1$ //$NON-NLS-2$ + cumulativeArtifacts; if (cancelledByUser) { MessageDialog.openInformation(null, Messages.RunAnalyseHandlerBase_partial_analysis_complete, Messages.RunAnalyseHandlerBase_15 + artsFound); } else { String msg = Messages.RunAnalyseHandlerBase_cancelled_by_user; if (!err) { String key = IDs.SHOW_ANALYSIS_CONFIRMATION; IPreferenceStore pf = CommonPlugin.getDefault().getPreferenceStore(); boolean showDialog = pf.getBoolean(IDs.SHOW_ANALYSIS_CONFIRMATION); if (showDialog) { String title = Messages.RunAnalyseHandlerBase_analysis_complete; StringBuffer sMsg = new StringBuffer(cumulativeArtifacts + " " + name //$NON-NLS-1$ + Messages.RunAnalyseHandlerBase_artifacts_found); // provide some explanation of why perhaps no artifacts were // found. // Note: should this perhaps be in a "Details" section of // the dialog? if (cumulativeArtifacts == 0) { // Unless "Recognize artifacts by prefix alone" is set in the preferences (this is the default), // this could be a problem with the include file for this API. sMsg.append(Messages.RunAnalyseHandlerBase_notfound_0).append(name) .append(Messages.RunAnalyseHandlerBase_notfound_1); sMsg.append(name).append(Messages.RunAnalyseHandlerBase_notfound_2); sMsg.append(Messages.RunAnalyseHandlerBase_notfound_3); } String togMsg = Messages.RunAnalyseHandlerBase_dont_show_this_again; MessageDialogWithToggle.openInformation(shell, title, sMsg.toString(), togMsg, false, pf, key); showStatusMessage(sMsg.toString(), "RunAnalyseBase.run()"); //$NON-NLS-1$ } activateProblemsView(); activateArtifactView(); } else { // error occurred showStatusMessage(msg, "RunAnalyseBase.run() error"); //$NON-NLS-1$ msg = Messages.RunAnalyseHandlerBase_27; MessageDialog.openError(null, Messages.RunAnalyseHandlerBase_28, msg + artsFound); } } }
From source file:org.eclipse.ptp.rm.ui.wizards.AbstractRemoteProxyResourceManagerConfigurationWizardPage.java
License:Open Source License
/** * Check if the proxy path supplied in proxyPathText is a valid file on the * remote system./*w w w . j ava2 s.c o m*/ * * @return true if valid * @since 1.1 */ protected boolean validateProxyPath() { if (!proxyPathEnabled) { return true; } proxyPathIsValid = false; final String path = proxyPathText.getText(); if (path != null && !path.equals("")) { //$NON-NLS-1$ if (connection != null) { checkConnection(); if (connection.isOpen()) { if (remoteServices != null) { final IRemoteFileManager fileMgr = remoteServices.getFileManager(connection); if (fileMgr != null) { IRunnableWithProgress op = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { IFileStore file = fileMgr.getResource(path); if (!monitor.isCanceled()) { proxyPathIsValid = file.fetchInfo(EFS.NONE, monitor).exists(); } } catch (CoreException e) { throw new InvocationTargetException(e); } } }; try { ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell()); dialog.setOpenOnRun(false); dialog.run(true, true, op); } catch (InvocationTargetException e) { // return false } catch (InterruptedException e) { // return false } } } } } } return proxyPathIsValid; }
From source file:org.eclipse.qvt.declarative.editor.ui.paged.BaseEditor.java
License:Open Source License
/** * This is for implementing {@link IEditorPart} and simply saves the model file. *//* w ww . j av a 2 s. co m*/ public void doResourceSetSave(IProgressMonitor progressMonitor) { // Save only resources that have actually changed. // Map<Object, Object> saveOptions = new HashMap<Object, Object>(); saveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED, Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER); // Do the work within an operation because this is a long running activity that modifies the workbench. // WorkspaceModifyOperation operation1 = new SaveOperation1(saveOptions); WorkspaceModifyOperation operation2 = new SaveOperation2(); updateProblemIndication = false; try { // This runs the options, and shows progress. // ProgressMonitorDialog progressMonitorDialog = new ProgressMonitorDialog(getShell()); progressMonitorDialog.run(true, false, operation1); // Refresh the necessary state. // if (QVTEditorPlugin.EDITOR_SAVE.isActive()) QVTEditorPlugin.EDITOR_SAVE.println(getClass(), "Saved all"); try { // This runs the options, and shows progress. // progressMonitorDialog.run(true, false, operation2); // Refresh the necessary state. // if (QVTEditorPlugin.EDITOR_SAVE.isActive()) QVTEditorPlugin.EDITOR_SAVE.println(getClass(), "Saved all2"); savingResources.clear(); } catch (Exception exception) { // Something went wrong that shouldn't. // QVTEditorPlugin.INSTANCE.log(exception); } getCommandStack().saveIsDone(); // FIXME operation history firePropertyChange(IEditorPart.PROP_DIRTY); } catch (Exception exception) { // Something went wrong that shouldn't. // QVTEditorPlugin.INSTANCE.log(exception); } updateProblemIndication = true; updateProblemIndication(); }
From source file:org.eclipse.rap.demo.controls.DialogsTab.java
License:Open Source License
private void showProgressDialog() { ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell()); try {// w w w . j ava 2 s .c o m dialog.run(true, true, new IRunnableWithProgress() { public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask("Counting from one to 20...", 20); for (int i = 1; !monitor.isCanceled() && i <= 20; i++) { monitor.worked(1); Thread.sleep(1000); } monitor.done(); } }); } catch (Exception e) { MessageDialog.openError(getShell(), "Error", e.getMessage()); } }
From source file:org.eclipse.rap.examples.pages.DialogExamplePage.java
License:Open Source License
private void showProgressDialog() { ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell()) { @Override//from w w w. j a va2 s . c o m public boolean close() { return super.close(); } }; dialog.setBlockOnOpen(false); try { dialog.run(true, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask("Counting to 12...", 12); for (int i = 1; !monitor.isCanceled() && i <= 12; i++) { monitor.worked(1); Thread.sleep(300); } monitor.done(); } }); } catch (Exception e) { MessageDialogUtil.openError(getShell(), "Error", e.getMessage(), null); } }
From source file:org.eclipse.rcptt.ui.launching.LaunchUtils.java
License:Open Source License
private static void doLaunch(final Aut aut, final Shell shell, final AtomicReference<AutLaunch> launch) { final ProgressMonitorDialog progress = new ProgressMonitorDialog(shell); final AtomicReference<IStatus> status = new AtomicReference<IStatus>(); try {/*w w w . j a va 2 s . c o m*/ progress.run(true, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) { try { launch.set(aut.launch(new SyncProgressMonitor(monitor, shell.getDisplay()))); status.set(Status.OK_STATUS); } catch (CoreException e) { status.set(e.getStatus()); } finally { if (status.get() == null) { status.set(Status.CANCEL_STATUS); } } } }); } catch (InvocationTargetException e1) { status.set(RcpttPlugin.createStatus("Failed to launch " + aut.getName(), e1.getCause())); } catch (InterruptedException e1) { return; } IStatus s = status.get(); if (s.matches(IStatus.CANCEL)) { return; } if (!s.isOK()) { RcpttPlugin.getDefault().getLog().log(s); AUTConnectionErrorDialog.showAUTConnectionError(shell, s, aut.getConfig()); return; } try { ShellUtilsProvider.getShellUtils().forceActive(shell); } catch (CoreException e) { throw new RuntimeException(e); } }
From source file:org.eclipse.rcptt.ui.report.internal.RcpttReportEditor.java
License:Open Source License
public void openReport(final String id, final String title) { final ProgressMonitorDialog dialog = new ProgressMonitorDialog(getSite().getShell()); try {//from w ww. j a v a 2s . c o m final Q7ReportIterator reportList = (Q7ReportIterator) reportListObservable.getValue(); if (reportList == null) return; dialog.run(true, false, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask("Opening report...", IProgressMonitor.UNKNOWN); Iterator<Report> iterator = reportList.iterator(); while (iterator.hasNext()) { monitor.worked(1); final Report next = iterator.next(); Node root = next.getRoot(); EMap<String, EObject> properties = root.getProperties(); final Q7Info info = (Q7Info) properties.get(IQ7ReportConstants.ROOT); if (info != null) { if (info.getId().equals(id)) { dialog.getShell().getDisplay().asyncExec(new Runnable() { public void run() { openReportPage(id, title, next, info); } }); return; } } } monitor.done(); } }); } catch (Throwable e) { Q7UIReportPlugin.log(e); } }