List of usage examples for org.eclipse.jface.dialogs ProgressMonitorDialog ProgressMonitorDialog
public ProgressMonitorDialog(Shell parent)
From source file:al.gov.asp.smc.e4.linkapp.handlers.SaveHandler.java
License:Open Source License
@Execute public void execute(IEclipseContext context, @Named(IServiceConstants.ACTIVE_SHELL) Shell shell, @Named(IServiceConstants.ACTIVE_PART) final MContribution contribution) throws InvocationTargetException, InterruptedException { final IEclipseContext pmContext = context.createChild(); ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell); dialog.open();//from ww w. j a v a 2 s .c o m dialog.run(true, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { pmContext.set(IProgressMonitor.class.getName(), monitor); if (contribution != null) { } } }); pmContext.dispose(); }
From source file:application.e4.handlers.SaveHandler.java
License:Open Source License
@Execute public void execute(IEclipseContext context, @Named(IServiceConstants.ACTIVE_SHELL) Shell shell, @Named(IServiceConstants.ACTIVE_PART) final MContribution contribution) throws InvocationTargetException, InterruptedException { final IEclipseContext pmContext = context.createChild(); ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell); dialog.open();//from w w w. j av a2 s. c om dialog.run(true, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { pmContext.set(IProgressMonitor.class.getName(), monitor); if (contribution != null) { Object clientObject = contribution.getObject(); // ContextInjectionFactory.invoke(clientObject, Persist.class, //$NON-NLS-1$ // pmContext, null); } } }); pmContext.dispose(); }
From source file:ariba.ideplugin.eclipse.wizards.AWNewProjectWizard.java
License:Apache License
public boolean performFinish() { String msg = _page2.validate(); if (msg != null) { Status status = new Status(IStatus.ERROR, Activator.getDefault().getBundle().getSymbolicName(), 0, msg, null);/*from w w w . j a v a2 s.c om*/ ErrorDialog.openError(getShell(), null, null, status); return false; } CreateProject cproj = new CreateProject(getShell(), _connector, _page2.getProjectName(), (File) _page1.getSelectedTemplate().get(AWScriptRunner.TemplateDirKey), _page2.getParameterMap()); ProgressMonitorDialog pmd = new ProgressMonitorDialog(getShell()); try { pmd.run(true, false, cproj); } catch (InvocationTargetException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } return true; }
From source file:at.bestsolution.efxclipse.tooling.jdt.ui.internal.editors.JFXBuildConfigurationEditor.java
License:Open Source License
/** * This is for implementing {@link IEditorPart} and simply saves the model file. *//* w ww .j a v a 2s .c om*/ @Override public void doSave(IProgressMonitor progressMonitor) { // Save only resources that have actually changed. // final 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 operation = new WorkspaceModifyOperation() { // This is the method that gets invoked when the operation runs. // @Override public void execute(IProgressMonitor monitor) { // Save the resources to the file system. // boolean first = true; for (Resource resource : editingDomain.getResourceSet().getResources()) { if ((first || !resource.getContents().isEmpty() || isPersisted(resource)) && !editingDomain.isReadOnly(resource)) { try { long timeStamp = resource.getTimeStamp(); resource.save(saveOptions); if (resource.getTimeStamp() != timeStamp) { savedResources.add(resource); } } catch (Exception exception) { resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception)); } first = false; } } } }; updateProblemIndication = false; try { // This runs the options, and shows progress. // new ProgressMonitorDialog(getSite().getShell()).run(true, false, operation); // Refresh the necessary state. // ((BasicCommandStack) editingDomain.getCommandStack()).saveIsDone(); firePropertyChange(IEditorPart.PROP_DIRTY); } catch (Exception e) { // TODO e.printStackTrace(); } updateProblemIndication = true; updateProblemIndication(); }
From source file:at.bitandart.zoubek.mervin.handlers.SaveReview.java
License:Open Source License
@SuppressWarnings("restriction") @Execute//from w ww .ja v a 2 s . c o m public void execute(final Shell shell, final IReviewRepositoryService repoService, final @Named(IMervinContextConstants.ACTIVE_MODEL_REVIEW) ModelReview modelReview, final User reviewer) { ProgressMonitorDialog progressMonitorDialog = new ProgressMonitorDialog(shell); try { progressMonitorDialog.run(true, false, new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { repoService.saveReview(new URI(modelReview.getRepositoryURI()), modelReview, reviewer, monitor); } catch (RepositoryIOException e) { logger.error(e, MessageFormat.format( "IO Error while saving the review with id \"{0}\" to repository \"{1}\"", modelReview.getId(), modelReview.getRepositoryURI())); MessageDialog.openError(shell, "Repository IO Error", "An IO error occured while saving the review. Make sure the originating repository is available and writeable. See error log for details."); } catch (InvalidReviewRepositoryException e) { logger.error(e, MessageFormat.format( "Invalid review repository detected while saving the review with id \"{0}\" to repository \"{1}\"", modelReview.getId(), modelReview.getRepositoryURI())); MessageDialog.openError(shell, "Invalid Repository", "The repository URI points to an invalid repository. Make sure the originating repository is available and writeable. See error log for details."); } catch (InvalidReviewException e) { logger.error(e, MessageFormat.format( "Invalid review detected while saving the review with id \"{0}\" to repository \"{1}\"", modelReview.getId(), modelReview.getRepositoryURI())); MessageDialog.openError(shell, "Invalid Review", "The current review is invalid:\n" + e.getMessage()); } catch (URISyntaxException e) { logger.error(e, MessageFormat.format( "Invalid URI detected while saving the review with id \"{0}\" to repository \"{1}\"", modelReview.getId(), modelReview.getRepositoryURI())); MessageDialog.openError(shell, "Invalid URI", MessageFormat.format("The URI \"{0}\" is invalid. See error log for details.", modelReview.getRepositoryURI())); } } }); } catch (InvocationTargetException | InterruptedException e) { logger.error(e, MessageFormat.format("Error while saving the review with id \"{0}\" to repository \"{1}\"", modelReview.getId(), modelReview.getRepositoryURI())); MessageDialog.openError(shell, "Unexpected Error", "An unexpected error occured while saving the review. See error log for details."); } }
From source file:at.bitandart.zoubek.mervin.model.modelreview.presentation.ModelReviewEditor.java
License:Open Source License
/** * This is for implementing {@link IEditorPart} and simply saves the model * file. <!-- begin-user-doc --> <!-- end-user-doc --> * /*from www . j a v a 2s. c o m*/ * @generated */ @Override public void doSave(IProgressMonitor progressMonitor) { // Save only resources that have actually changed. // final Map<Object, Object> saveOptions = new HashMap<Object, Object>(); saveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED, Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER); saveOptions.put(Resource.OPTION_LINE_DELIMITER, Resource.OPTION_LINE_DELIMITER_UNSPECIFIED); // Do the work within an operation because this is a long running // activity that modifies the workbench. // WorkspaceModifyOperation operation = new WorkspaceModifyOperation() { // This is the method that gets invoked when the operation runs. // @Override public void execute(IProgressMonitor monitor) { // Save the resources to the file system. // boolean first = true; for (Resource resource : editingDomain.getResourceSet().getResources()) { if ((first || !resource.getContents().isEmpty() || isPersisted(resource)) && !editingDomain.isReadOnly(resource)) { try { long timeStamp = resource.getTimeStamp(); resource.save(saveOptions); if (resource.getTimeStamp() != timeStamp) { savedResources.add(resource); } } catch (Exception exception) { resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception)); } first = false; } } } }; updateProblemIndication = false; try { // This runs the options, and shows progress. // new ProgressMonitorDialog(getSite().getShell()).run(true, false, operation); // Refresh the necessary state. // ((BasicCommandStack) editingDomain.getCommandStack()).saveIsDone(); firePropertyChange(IEditorPart.PROP_DIRTY); } catch (Exception exception) { // Something went wrong that shouldn't. // MervinModelReviewEditorPlugin.INSTANCE.log(exception); } updateProblemIndication = true; updateProblemIndication(); }
From source file:at.bitandart.zoubek.mervin.review.ReviewOptionsView.java
License:Open Source License
/** * updates the selected model comparison of the current model review. *//*from w w w . java2s. c om*/ private void udpateSelectedComparison() { ProgressMonitorDialog progressMonitorDialog = new ProgressMonitorDialog(shell); try { progressMonitorDialog.run(true, false, new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { ModelReview modelReview = getCurrentModelReview(); diffService.updateSelectedComparison(modelReview, monitor); monitor.done(); } }); } catch (InvocationTargetException | InterruptedException e) { logger.error(e, "Could not udapte the selected comparison"); } }
From source file:at.bitandart.zoubek.mervin.review.wizards.LoadReviewWizard.java
License:Open Source License
@SuppressWarnings("restriction") @Override//from w w w .j a v a 2 s. c o m public boolean performFinish() { String repositoryPath = selectRepositoryPage.getSelectedRepositoryPath(); final URI uri; final String id = gerritChangeSelectionPage.getReviewId(); try { uri = new URI(repositoryPath); } catch (URISyntaxException e) { // this should actually never happen, but to be sure: MessageDialog.openError(getShell(), "Invalid repository path", "Invalid repository path"); return false; } try { new ProgressMonitorDialog(getShell()).run(true, false, new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { /* * TODO add reviewer selection page and let the user * choose the reviewer */ modelReview = repoService.loadReview(uri, id, reviewer, monitor); } catch (RepositoryIOException | InvalidReviewRepositoryException | InvalidReviewException e) { new InvocationTargetException(e); } } }); } catch (InvocationTargetException e) { Throwable cause = e.getCause(); if (cause instanceof RepositoryIOException) { logger.error(cause, MessageFormat.format( "An IO error occurred while loading the review with id \"{0}\" from repository at \"{0}\".", id, uri)); MessageDialog.openError(getShell(), "IO Error", "An IO error occurred while loading the review. See the error log for details"); } else if (cause instanceof InvalidReviewRepositoryException) { MessageDialog.openError(getShell(), "Invalid repository", "The specified repository cannot be found or is not accessible. Make sure to select a valid accessible repository."); } else if (cause instanceof InvalidReviewException) { MessageDialog.openError(getShell(), "Invalid review.", "The specified review does not exist or is not accessible. Make sure to select a valid accessible review."); } else { logger.error(cause, MessageFormat .format("Unexpected error during loading the review with id {0} and uri {1}", id, uri)); MessageDialog.openError(getShell(), "Unexpected Error occured.", "Unexpected Error occured, see error log for details."); } return false; } catch (InterruptedException e) { logger.error(e, MessageFormat .format("Unexpected error during loading the review with id {0} and uri {1}", id, uri)); MessageDialog.openError(getShell(), "Unexpected Error occured.", "Unexpected Error occured, see error log for details."); return false; } return true; }
From source file:at.bitandart.zoubek.mervin.review.wizards.ReviewSelectionPage.java
License:Open Source License
@SuppressWarnings("restriction") private void loadChanges(final String uri) { try {/*from w w w. jav a2s . c om*/ ProgressMonitorDialog progressMonitorDialog = new ProgressMonitorDialog(getShell()); progressMonitorDialog.run(true, true, new ReviewListUpdater(uri)); } catch (InvocationTargetException | InterruptedException e) { logger.error(e); uiSync.syncExec(new Runnable() { @Override public void run() { MessageDialog.openError(getShell(), "Review list retrieval error", "Could not load all review for this repository. " + "Make sure the repository remote \"origin\" points at the correct " + "accessible remote gerrit repository. " + "See the error log for more details."); } }); } }
From source file:at.medevit.ch.artikelstamm.elexis.common.ui.provider.atccache.ATCCodeCache.java
License:Open Source License
@SuppressWarnings("unchecked") private static void deserializeFromDatabase(String id) throws IOException, ClassNotFoundException { NamedBlob2 cacheStorage = NamedBlob2.load(id); if (cacheStorage != null) { ByteArrayInputStream ba = new ByteArrayInputStream(cacheStorage.getBytes()); ObjectInputStream oba = new ObjectInputStream(ba); cache = (HashMap<String, Integer>) oba.readObject(); oba.close();/*w w w. ja va 2 s. co m*/ ba.close(); } else { ProgressMonitorDialog pmd = new ProgressMonitorDialog(UiDesk.getTopShell()); try { pmd.run(false, false, new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { rebuildCache(monitor); } }); } catch (InvocationTargetException | InterruptedException e) { e.printStackTrace(); } } }