List of usage examples for org.eclipse.jface.dialogs ProgressMonitorDialog ProgressMonitorDialog
public ProgressMonitorDialog(Shell parent)
From source file:edu.utah.cdmcc.e4.glucose.application.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 .ja va 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) { // Object clientObject = contribution.getObject(); // ContextInjectionFactory.invoke(clientObject, Persist.class, //$NON-NLS-1$ // pmContext, null); } } }); pmContext.dispose(); }
From source file:eldaEditor.dialogs.ChooseTypeDialog.java
License:Open Source License
public String open(Shell shell) { try {/*from w w w .j a v a 2s . c o m*/ IJavaProject project = JavaCore.create(getProject()); SelectionDialog dialog = JavaUI.createTypeDialog(shell, new ProgressMonitorDialog(shell), SearchEngine.createJavaSearchScope(new IJavaElement[] { project }), IJavaElementSearchConstants.CONSIDER_CLASSES, false); dialog.setTitle("Choose the variable type"); if (dialog.open() == SelectionDialog.OK) { Object[] result = dialog.getResult(); superClass = ((IType) result[0]).getFullyQualifiedName(); return superClass; } } catch (Exception ex) { } return null; }
From source file:ElementRegistry.presentation.ElementRegistryEditor.java
License:Open Source License
/** * This is for implementing {@link IEditorPart} and simply saves the model file. * <!-- begin-user-doc -->// w w w .ja v a 2 s.co m * <!-- end-user-doc --> * @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. // ElementRegistryEditorPlugin.INSTANCE.log(exception); } updateProblemIndication = true; updateProblemIndication(); }
From source file:era.foss.erf.presentation.ErfEditor.java
License:Open Source License
/** * This is for implementing {@link IEditorPart} and simply saves the model file. * <!-- begin-user-doc --> <!-- * end-user-doc -->/* w w w . j a v a 2 s. 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); // 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. // ErfEditorPlugin.INSTANCE.log(exception); } updateProblemIndication = true; updateProblemIndication(); }
From source file:era.foss.objecteditor.ErfObjectEditor.java
License:Open Source License
/** * This is for implementing {@link IEditorPart} and simply saves the model file. * //from w ww. j a va2 s. c o m * @param progressMonitor the progress monitor */ @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 exception) { // Something went wrong that shouldn't. // ErfObjectsEditorPlugin.INSTANCE.log(exception); } updateProblemIndication = true; updateProblemIndication(); }
From source file:ernest.architecture.presentation.ArchitectureEditor.java
License:Open Source License
/** * This is for implementing {@link IEditorPart} and simply saves the model file. * <!-- begin-user-doc -->// w w w. ja v a2s.com * <!-- end-user-doc --> * @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. // AnalysisEditorPlugin.INSTANCE.log(exception); } updateProblemIndication = true; updateProblemIndication(); }
From source file:es.axios.udig.ui.commons.util.DialogUtil.java
License:LGPL
public static ProgressMonitorDialog openProgressMonitorDialog(final Shell shell, final String dialogTitle, final boolean showRunInBackground, final boolean confirmCancelRequests) { ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell) { @Override// www . ja v a 2s . co m protected void cancelPressed() { boolean confirmed = true; if (confirmCancelRequests) { String title = Messages.DialogUtil_title; String message = Messages.DialogUtil_message; confirmed = DialogUtil.openQuestion(title, message); } if (confirmed) { super.cancelPressed(); } } @Override protected void configureShell(Shell shell) { super.configureShell(shell); shell.setText(dialogTitle); } @Override protected void createButtonsForButtonBar(Composite parent) { if (showRunInBackground) createBackgroundButton(parent); super.createButtonsForButtonBar(parent); } private void createBackgroundButton(Composite parent) { createButton(parent, IDialogConstants.BACK_ID, Messages.DialogUtil_runInBackground, true); } @Override protected void buttonPressed(int buttonId) { if (buttonId == IDialogConstants.BACK_ID) { getShell().setVisible(false); } else super.buttonPressed(buttonId); } }; return dialog; }
From source file:es.bsc.servicess.ide.dialogs.JarFileDialog.java
License:Apache License
private boolean loadWarFile(final String selectedDirectory) { final ProgressMonitorDialog dialog = new ProgressMonitorDialog(this.getShell()); try {/*from w ww . ja va 2 s.com*/ log.debug("Selected dir: " + selectedDirectory); final File warFile = new File(selectedDirectory); if (warFile.exists()) { dialog.run(false, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException { try { IFolder importFolder = project.getProject().getFolder(ProjectMetadata.IMPORT_FOLDER); if (!importFolder.exists()) importFolder.create(true, true, monitor); String name = PackagingUtils.getPackageName(warFile); log.debug("Package name is " + name); IFolder extractFolder = importFolder.getFolder(name); if (!extractFolder.exists()) { extractWar(warFile, extractFolder, monitor); } else log.info("Package already exists. Not extracting"); } catch (Exception e) { throw (new InvocationTargetException(e)); } } }); return true; } else throw (new InvocationTargetException(new Exception("The selected file doesn't exists"))); } catch (InvocationTargetException e) { log.error("Error loading package"); ErrorDialog.openError(dialog.getShell(), "Error loading new package file", "Exception when loading package", new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e)); return false; } catch (InterruptedException e) { log.error("Error loading package"); ErrorDialog.openError(dialog.getShell(), "Package load interrumped", "Exception when loading package", new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e)); return false; } }
From source file:es.bsc.servicess.ide.editors.BuildingDeploymentFormPage.java
License:Apache License
/** * Build the service packages/*from w ww . j ava 2s . co m*/ */ private void buildPackages() { final ProgressMonitorDialog dialog = new ProgressMonitorDialog(getSite().getShell()); try { dialog.run(true, true, new IRunnableWithProgress() { /* (non-Javadoc) * @see org.eclipse.jface.operation.IRunnableWithProgress#run(org.eclipse.core.runtime.IProgressMonitor) */ public void run(IProgressMonitor monitor) throws InvocationTargetException { IJavaProject project = ((ServiceFormEditor) getEditor()).getProject(); try { ProjectMetadata pr_meta = ((ServiceFormEditor) getEditor()).getProjectMetadata(); PackagingUtils.buildPackages(project, pr_meta, monitor); /* monitor.beginTask("Building project classes...", 100); IFolder output = project.getProject().getFolder( ProjectMetadata.OUTPUT_FOLDER); if (output == null || !output.exists()) { output.create(true, true, monitor); } project.getProject().build( IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor); // monitor.beginTask("Instrumenting Orchestrations...", // 100); // PackagingUtils.instrumentOrchestrations(pr_meta.getRuntimeLocation(),pr_meta.getOrchestrationClasses(), // output, monitor); monitor.beginTask("Creating packages...", 100); IFolder packages = output .getFolder(ProjectMetadata.PACKAGES_FOLDER); if (packages != null && packages.exists()) { packages.delete(true, monitor); } packages.create(true, true, monitor); // PackagingUtils.copyConfigFiles((ServiceFormEditor)getEditor()); log.debug("Getting packages..."); String[] packs = pr_meta.getPackages(); String runtime = pr_meta.getRuntimeLocation(); String[] orch_cls = pr_meta.getOrchestrationClasses(); IFolder src_fld = project.getProject().getFolder( pr_meta.getSourceDir()); IPackageFragmentRoot source = null; if (src_fld != null) source = project.findPackageFragmentRoot(src_fld .getFullPath()); IFolder gen_fld = project.getProject().getFolder( "generated"); IPackageFragmentRoot generated = null; if (gen_fld != null) generated = project.findPackageFragmentRoot(project .getProject().getFolder("generated") .getFullPath()); if (source != null && source.exists()) { if (constraintsElements == null) { constraintsElements = getElements(orch_cls, ProjectMetadata.CORE_TYPE, project, pr_meta); } if (packs != null && packs.length > 0) { log.debug("Building core element packages"); for (String p : packs) { String[] elements = pr_meta .getElementsInPackage(p); if (elements != null && elements.length > 0) { PackagingUtils.createCorePackage( runtime, p, elements, pr_meta.getDependencies(elements), constraintsElements, source, output, packages, monitor); } } } else { log.warn("Warning: No core element packages built"); monitor.setCanceled(true); throw (new InvocationTargetException( new Exception("No core element packages built"))); } if (orch_cls!= null && orch_cls.length>0){ log.debug("Generating Orchestration"); PackagingUtils.createServiceOrchestrationPackage( runtime, PackagingUtils.getClasspath(project), project.getProject().getName(), orch_cls, pr_meta.getDependencies(getOrchestrationElementsLabels( orch_cls, project, pr_meta)), source, generated, output, packages, monitor, shouldBeWarFile(pr_meta.getOrchestrationClassesTypes())); monitor.done(); }else{ log.warn("Warning: No orchestration element packages built"); monitor.setCanceled(true); throw (new InvocationTargetException( new Exception("No orchestration packages built"))); } } else { log.error("Source dir not found"); monitor.setCanceled(true); throw (new InvocationTargetException(new Exception( "Source dir " + src_fld.getFullPath() + " not found"))); }*/ } catch (Exception e) { throw (new InvocationTargetException(e)); } } }); } catch (InvocationTargetException e) { ErrorDialog.openError(dialog.getShell(), "Error creating packages", e.getMessage(), new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e)); e.printStackTrace(); } catch (InterruptedException e) { ErrorDialog.openError(dialog.getShell(), "Building interrumped", e.getMessage(), new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e)); e.printStackTrace(); } }
From source file:es.bsc.servicess.ide.editors.deployers.GridDeployer.java
License:Apache License
@Override public void deploy() { final Element master = resGRFile.getMasterResource(); if (master != null) { final Element[] workers = resGRFile.getWorkerResources(); if (workers != null && workers.length > 0) { ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell()); try { dialog.run(false, false, new IRunnableWithProgress() { @Override/*ww w . j a v a 2 s .co m*/ public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { executeDeployment(master, workers, monitor); } catch (Exception e) { throw (new InvocationTargetException(e)); } } }); } catch (InterruptedException e) { String message = e.getMessage(); System.err.println("Error message: " + message); ErrorDialog.openError(super.getShell(), "Error", "Deploying the service", new StatusInfo(IStatus.ERROR, message)); e.printStackTrace(); } catch (InvocationTargetException e) { String message = e.getMessage(); System.err.println("Error message: " + message); ErrorDialog.openError(super.getShell(), "Error", "Deploying the service", new StatusInfo(IStatus.ERROR, message)); e.printStackTrace(); } } else { ErrorDialog.openError(super.getShell(), "Error", "Deploying the service", new StatusInfo(IStatus.ERROR, "Worker resources not defined")); } } else { ErrorDialog.openError(super.getShell(), "Error", "Deploying the service", new StatusInfo(IStatus.ERROR, "Master resource not defined")); } }