List of usage examples for org.eclipse.jface.dialogs ProgressMonitorDialog ProgressMonitorDialog
public ProgressMonitorDialog(Shell parent)
From source file:com.nokia.tools.screen.ui.actions.NewPackageAction.java
License:Open Source License
public void run() { final IEditorPart currentEditor = EclipseUtils.getActiveSafeEditor(); if (currentEditor == null) return;//from w w w .j av a 2s . com if (currentEditor.isDirty()) { boolean saveWithoutConfirm = false; IPreferenceStore store = UiPlugin.getDefault().getPreferenceStore(); saveWithoutConfirm = store.getBoolean(IScreenConstants.PREF_SAVE_BEFORE_PACKAGING_ASK); if (!saveWithoutConfirm) { IBrandingManager branding = BrandingExtensionManager.getBrandingManager(); Image image = null; if (branding != null) { image = branding.getIconImageDescriptor().createImage(); } MessageDialog messageDialog = new MessageDialogWithCheckBox( PlatformUI.getWorkbench().getDisplay().getActiveShell(), Messages.NewPackageAction_Save_MsgBox_Title, image, Messages.NewPackageAction_Save_MsgBox_Message, Messages.NewPackageAction_Save_MsgBox_Confirmation_text, saveWithoutConfirm, null, null, null, 3, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0); messageDialog.open(); if (image != null) { image.dispose(); } store.setValue(IScreenConstants.PREF_SAVE_BEFORE_PACKAGING_ASK, ((MessageDialogWithCheckBox) messageDialog).getCheckBoxValue()); if (messageDialog.getReturnCode() != 0) return; } try { new ProgressMonitorDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell()).run(false, false, new IRunnableWithProgress() { /* * (non-Javadoc) * * @see org.eclipse.jface.operation.IRunnableWithProgress#run(org.eclipse.core.runtime.IProgressMonitor) */ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { currentEditor.doSave(monitor); } }); } catch (Exception e) { UiPlugin.error(e); } performPackaging(); } else performPackaging(); }
From source file:com.nokia.tools.variant.carbidev.perspective.actions.UpdateAction.java
License:Open Source License
/** * Software Updates//from ww w.j av a2 s .com * */ public void run(IAction action) { final Shell activeShell = Display.getCurrent().getActiveShell(); ProgressMonitorDialog dialog = new ProgressMonitorDialog(activeShell); try { dialog.run(false, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) { UpdateCommand command; try { boolean updated = false; command = new UpdateCommand("com.nokia.tools.variant.feature.carbidev2", "false"); if (command.run(monitor)) { updated = true; } if (isFeatureInstalled("com.nokia.tools.variant.feature.s60.components")) { command = new UpdateCommand("com.nokia.tools.variant.feature.s60.components", "false"); if (command.run(monitor)) { updated = true; } } if (updated) { String message = "Carbide.v was updated successfully. " + "It is recommended you restart Carbide.v for the changes to take effect. " + "Would you like to restart now?"; int choice = showQuestionMessage(activeShell, message); switch (choice) { case SWT.YES: PlatformUI.getWorkbench().restart(); break; case SWT.NO: break; } // boolean temp = // PlatformUI.getPreferenceStore().getBoolean // (IWorkbenchPreferenceConstants // .CLOSE_EDITORS_ON_EXIT); // PlatformUI.getPreferenceStore().setValue( // IWorkbenchPreferenceConstants // .CLOSE_EDITORS_ON_EXIT, false); // PlatformUI.getWorkbench().restart(); // PlatformUI.getPreferenceStore().setValue( // IWorkbenchPreferenceConstants // .CLOSE_EDITORS_ON_EXIT, temp); } else { String message = "No updates for the currently installed feature(s) found, " + "try again later."; showInfoMessage(activeShell, message); } } catch (Exception e) { // e.printStackTrace(); String message = "No updates for the currently installed feature(s) found, " + "try again later."; showInfoMessage(activeShell, message); } } }); } catch (InvocationTargetException e) { // e.printStackTrace(); } catch (InterruptedException e) { // e.printStackTrace(); } }
From source file:com.nokia.tools.vct.appshell.appshellmodel.presentation.EAppshellModelEditor.java
License:Open Source License
/** * This is for implementing {@link IEditorPart} and simply saves the model * file. <!-- begin-user-doc --> <!-- end-user-doc --> * //from w w w .j av 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); // 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. // AppshellPlugin.INSTANCE.log(exception); } updateProblemIndication = true; updateProblemIndication(); }
From source file:com.nokia.tools.vct.confml.editor.include.xincmodel.presentation.EXincModelEditor.java
License:Open Source License
/** * This is for implementing {@link IEditorPart} and simply saves the model file. * <!-- begin-user-doc -->/*from ww w . jav a2s . c o 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); // 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. // XIncludeEditorPlugin.INSTANCE.log(exception); } updateProblemIndication = true; updateProblemIndication(); }
From source file:com.nokia.tools.vct.confml.model.confml1.edit.presentation.EConfML1Editor.java
License:Open Source License
/** * This is for implementing {@link IEditorPart} and simply saves the model file. * <!-- begin-user-doc -->// w w w .j ava2 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); // 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. // ConfMLXMIEditorPlugin.INSTANCE.log(exception); } updateProblemIndication = true; updateProblemIndication(); }
From source file:com.nokia.tools.vct.crml.crmodel.presentation.ECRMLEditor.java
License:Open Source License
/** * This is for implementing {@link IEditorPart} and simply saves the model file. * <!-- begin-user-doc -->/*w w w . j a v a 2 s. c o 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); // 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. // CRMLModelEditorPlugin.INSTANCE.log(exception); } updateProblemIndication = true; updateProblemIndication(); }
From source file:com.nokia.tools.vct.gcfml.gcfmlmodel.presentation.EGCFMLEditor.java
License:Open Source License
/** * This is for implementing {@link IEditorPart} and simply saves the model file. * <!-- begin-user-doc -->/*w w w .ja va 2 s.c o 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); // 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. // PersistencegcfmlEditorPlugin.INSTANCE.log(exception); } updateProblemIndication = true; updateProblemIndication(); }
From source file:com.nokia.tools.vct.ibyml.ibymodel.presentation.EIBYModelEditor.java
License:Open Source License
/** * This is for implementing {@link IEditorPart} and simply saves the model file. * <!-- begin-user-doc -->/*from ww w . j a va2 s . c o 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); // 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. // IBYMLModelEditorPlugin.INSTANCE.log(exception); } updateProblemIndication = true; updateProblemIndication(); }
From source file:com.opcoach.training.e4.rental.ui.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 a v a 2 s . co 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:com.opengridsystems.wtf.submission.ui.wizard.SubmitWizard.java
License:Open Source License
@Override public boolean performFinish() { final String name = page.name.getText().trim(); final String email = page.email.getText().trim(); final String subject = page.subject.getText().trim(); final String message = page.message.getText(); final String code = page.code.getText(); final boolean doNotPublish = page.publish.getSelection(); ProgressMonitorDialog pmD = new ProgressMonitorDialog(this.getShell()); IRunnableWithProgress loader = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { SubmitWTF ws = new SubmitWTF(WSDL_URL); SubmitWTFSoap wsSoap = ws.getSubmitWTFSoap(); try { String response = wsSoap.submit(name, email, subject, message, code, doNotPublish); if (response == null || !response.equals("")) throw new InvocationTargetException( new Exception("Your WTF has not been submitted\n\nResponse: " + response)); } catch (Exception ex) { throw new InvocationTargetException(ex); }/*from ww w. j a va2s . c om*/ } }; try { pmD.run(true, false, loader); } catch (InvocationTargetException ex) { ErrorDialog.openError(getShell(), "Error", ex.getMessage(), new Status(Status.ERROR, Activator.PLUGIN_ID, ex.getMessage(), ex)); return false; } catch (InterruptedException ex) { ErrorDialog.openError(getShell(), "Error", ex.getMessage(), new Status(Status.ERROR, Activator.PLUGIN_ID, ex.getMessage(), ex)); return false; } MessageDialog.openInformation(getShell(), "Submitted", "Your WTF has been submitted"); return true; }