List of usage examples for org.eclipse.jface.dialogs ProgressMonitorDialog ProgressMonitorDialog
public ProgressMonitorDialog(Shell parent)
From source file:com.bluexml.side.requirements.presentation.RequirementsEditor.java
License:Open Source License
/** * This is for implementing {@link IEditorPart} and simply saves the model file. * <!-- begin-user-doc -->/*w w w .j av a 2s . 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. // RequirementsEditorPlugin.INSTANCE.log(exception); } updateProblemIndication = true; updateProblemIndication(); }
From source file:com.bluexml.side.view.presentation.ViewEditor.java
License:Open Source License
/** * This is for implementing {@link IEditorPart} and simply saves the model file. * <!-- begin-user-doc -->/*from w ww.ja v a2 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. // ViewEditorPlugin.INSTANCE.log(exception); } updateProblemIndication = true; updateProblemIndication(); }
From source file:com.bluexml.side.workflow.presentation.WorkflowEditor.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 v a 2s.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); // 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. // WorkflowEditorPlugin.INSTANCE.log(exception); } updateProblemIndication = true; updateProblemIndication(); }
From source file:com.byterefinery.rmbench.util.ModelManager.java
License:Open Source License
/** * show a 3-option dialog asking the user whether the current model should be saved * /* w w w . j a v a 2s .c o m*/ * @return false if the dialog was cancelled, and thus the operation should not * proceed */ private boolean querySaveModel(final Shell shell) { MessageDialog dialog = new MessageDialog(shell, RMBenchMessages.ModelView_SaveDlg_Title, null, RMBenchMessages.ModelView_SaveChanged_Message, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 0); int result = dialog.open(); if (result == 0) { IRunnableWithProgress runnable = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { doSave(shell, monitor); } }; try { new ProgressMonitorDialog(shell).run(false, true, runnable); } catch (InvocationTargetException e) { RMBenchPlugin.logError(e); } catch (InterruptedException e) { RMBenchPlugin.logError(e); } } return result != 2; }
From source file:com.byterefinery.rmbench.util.UIRunnableWithProgress.java
License:Open Source License
public void start() { IProgressService progressService = RMBenchPlugin.getDefault().getWorkbench().getProgressService(); IRunnableContext context;//from w ww .ja v a2 s . c o m if (showDialog) context = new ProgressMonitorDialog(Display.getCurrent().getActiveShell()); else context = RMBenchPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow(); try { progressService.runInUI(context, this, null); } catch (InvocationTargetException e) { RMBenchPlugin.logError(e); } catch (InterruptedException e) { RMBenchPlugin.logError(e); } }
From source file:com.centurylink.mdw.plugin.rcp.MdwWorkbenchWindowAdvisor.java
License:Apache License
public void postWindowOpen() { IWorkbenchPage activePage = Activator.getActivePage(); // check for updates // IHandlerService handlerService = (IHandlerService) // activePage.getWorkbenchWindow().getService(IHandlerService.class); // try/* w w w.j av a 2 s .c o m*/ // { // Object result = // handlerService.executeCommand("org.eclipse.equinox.p2.ui.sdk.update", null); // System.out.println("result: " + result); // if (result != null) // System.out.println("result class: " + result.getClass().getName()); // } // catch (Exception ex) // { // ex.printStackTrace(); // } PluginMessages.log("MDW workbench startup..."); if (activePage != null) { activePage.hideActionSet("com.centurylink.mdw.plugin.actionset.tools"); activePage.hideActionSet("com.centurylink.mdw.plugin.actionset.dev"); activePage.hideActionSet("com.centurylink.mdw.plugin.actionset.designerClassic"); activePage.hideActionSet("org.eclipse.ui.edit.text.actionSet.navigation"); activePage.hideActionSet("org.eclipse.ui.edit.text.actionSet.annotationNavigation"); activePage.hideActionSet("org.eclipse.ui.externaltools.ExternalToolsSet"); activePage.showActionSet("org.eclipse.search.menu"); // make sure the process explorer view is visible try { ProcessExplorerView processExplorerView = (ProcessExplorerView) activePage .showView("mdw.views.designer.processes"); if (mdwHost != null && mdwPort != null) { final Shell shell = activePage.getActivePart().getSite().getShell(); BusyIndicator.showWhile(shell.getDisplay(), new Runnable() { public void run() { try { discoveryException = null; projectToImport = getWorkflowProject(mdwHost, mdwPort, mdwContextRoot); if (projectToImport == null) throw new DiscoveryException( "Unable to discover workflow app at: " + mdwHost + ":" + mdwPort); } catch (DiscoveryException ex) { discoveryException = ex; } } }); if (discoveryException != null) throw discoveryException; WorkflowProject existing = WorkflowProjectManager.getInstance() .getRemoteWorkflowProject(projectToImport.getName()); if (existing != null) WorkflowProjectManager.getInstance().deleteProject(existing); ProgressMonitorDialog progMonDlg = new ProgressMonitorDialog(shell); ProjectInflator projectInflator = new ProjectInflator(projectToImport, null); projectInflator.inflateRemoteProject(progMonDlg); ProjectImporter projectImporter = new ProjectImporter(projectToImport); projectImporter.doImport(); processExplorerView.handleRefresh(); // handle preselected entity if (preselectType != null && preselectType.trim().length() > 0 && preselectId != null && preselectId.trim().length() > 0) { if (!preselectType.equals(PRESELECT_PROCESS_INSTANCE)) throw new UnsupportedOperationException("Unsupported preselect type: " + preselectType); BusyIndicator.showWhile(shell.getDisplay(), new Runnable() { public void run() { // open the process instance IWorkbenchPage page = MdwPlugin.getActivePage(); try { WorkflowProcess instance = getProcessInstance(new Long(preselectId)); page.openEditor(instance, "mdw.editors.process"); page.showView("org.eclipse.ui.views.PropertySheet"); } catch (PartInitException ex) { PluginMessages.uiError(ex, "Open Process Instance", projectToImport); } } }); } } } catch (Exception ex) { PluginMessages.uiError(ex, "Initialize Workspace"); } } }
From source file:com.cloudbees.eclipse.run.ui.popup.actions.StartAction.java
License:Open Source License
/** * @see IActionDelegate#run(IAction)/*from w w w.ja v a2s.co m*/ */ @Override public void run(IAction action) { if (action instanceof ObjectPluginAction) { final ISelection selection = ((ObjectPluginAction) action).getSelection(); if (selection instanceof StructuredSelection) { try { ProgressMonitorDialog monitor = new ProgressMonitorDialog( Display.getCurrent().getActiveShell()); monitor.run(false, false, new IRunnableWithProgressImplementation(selection)); CloudBeesUIPlugin.getDefault().fireApplicationInfoChanged(); } catch (Exception e) { CBRunUiActivator.logError(e); } } } }
From source file:com.cloudbees.eclipse.run.ui.popup.actions.StopAction.java
License:Open Source License
/** * @see IActionDelegate#run(IAction)//from ww w . j a va 2 s. com */ @Override public void run(IAction action) { if (action instanceof ObjectPluginAction) { final ISelection selection = ((ObjectPluginAction) action).getSelection(); if (selection instanceof StructuredSelection) { ProgressMonitorDialog monitor = new ProgressMonitorDialog(Display.getCurrent().getActiveShell()); try { monitor.run(false, false, new IRunnableWithProgressImplementation(selection)); CloudBeesUIPlugin.getDefault().fireApplicationInfoChanged(); } catch (Exception e) { CBRunUiActivator.logError(e); } } } }
From source file:com.cloudbees.eclipse.ui.internal.preferences.GeneralPreferencePage.java
License:Open Source License
private void createCompositeLogin() { Group group = new Group(getFieldEditorParent(), SWT.SHADOW_ETCHED_IN); group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); GridLayout gl = new GridLayout(1, false); gl.marginLeft = 5;//from w w w.j a v a2 s .c om gl.marginRight = 5; gl.marginTop = 5; gl.marginBottom = 5; gl.horizontalSpacing = 5; group.setLayout(gl); Composite groupInnerComp = new Composite(group, SWT.NONE); groupInnerComp.setLayout(new GridLayout(2, false)); groupInnerComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); group.setText(Messages.pref_group_login); final StringFieldEditor fieldEmail = new StringFieldEditor(PreferenceConstants.P_EMAIL, Messages.pref_email, 30, groupInnerComp); fieldEmail.getTextControl(groupInnerComp).setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); addField(fieldEmail); final StringFieldEditor fieldPassword = new StringFieldEditor(PreferenceConstants.P_PASSWORD, Messages.pref_password, 30, groupInnerComp) { @Override protected void doLoad() { try { if (getTextControl() != null) { String value = CloudBeesUIPlugin.getDefault().readP(); getTextControl().setText(value); this.oldValue = value; } } catch (StorageException e) { // Ignore StorageException, very likely just // "No password provided." } } @Override protected void doStore() { try { CloudBeesUIPlugin.getDefault().storeP(getTextControl().getText()); } catch (Exception e) { CloudBeesUIPlugin.showError( "Saving password failed!\nPossible cause: Eclipse security master password is not set.", e); } } @Override protected void doFillIntoGrid(Composite parent, int numColumns) { super.doFillIntoGrid(parent, numColumns); getTextControl().setEchoChar('*'); } }; fieldPassword.getTextControl(groupInnerComp).setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); addField(fieldPassword); Composite signupAndValidateRow = new Composite(groupInnerComp, SWT.NONE); GridData signupRowData = new GridData(GridData.FILL_HORIZONTAL); signupRowData.horizontalSpan = 2; signupAndValidateRow.setLayoutData(signupRowData); GridLayout gl2 = new GridLayout(2, false); gl2.marginWidth = 0; gl2.marginHeight = 0; gl2.marginTop = 5; signupAndValidateRow.setLayout(gl2); createSignUpLink(signupAndValidateRow); Button b = new Button(signupAndValidateRow, SWT.PUSH); GridData validateButtonLayoutData = new GridData(GridData.HORIZONTAL_ALIGN_END); validateButtonLayoutData.widthHint = 75; b.setLayoutData(validateButtonLayoutData); b.setText(Messages.pref_validate_login); b.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { final String email = fieldEmail.getStringValue(); final String password = fieldPassword.getStringValue(); ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell()); try { dialog.run(true, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) { try { monitor.beginTask("Validating CloudBees account...", 100); //TODO i18n monitor.subTask("Connecting...");//TODO i18n monitor.worked(10); GrandCentralService gcs = new GrandCentralService(); gcs.setAuthInfo(email, password); monitor.worked(20); monitor.subTask("Validating...");//TODO i18n final boolean loginValid = gcs.validateUser(monitor); monitor.worked(50); PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { public void run() { if (loginValid) { MessageDialog.openInformation( CloudBeesUIPlugin.getDefault().getWorkbench().getDisplay() .getActiveShell(), "Validation result", "Validation successful!");//TODO i18n } else { MessageDialog.openError( CloudBeesUIPlugin.getDefault().getWorkbench().getDisplay() .getActiveShell(), "Validation result", "Validation was not successful!\nWrong email or password?");//TODO i18n } } }); monitor.worked(20); } catch (CloudBeesException e1) { throw new RuntimeException(e1); } finally { monitor.done(); } } }); } catch (InvocationTargetException e1) { Throwable t1 = e1.getTargetException().getCause() != null ? e1.getTargetException().getCause() : e1.getTargetException(); Throwable t2 = t1.getCause() != null ? t1.getCause() : null; CloudBeesUIPlugin.showError("Failed to validate your account.", t1.getMessage(), t2); } catch (InterruptedException e1) { CloudBeesUIPlugin.showError("Failed to validate your account.", e1); } } }); }
From source file:com.clustercontrol.collect.dialog.ExportDialog.java
License:Open Source License
/** * Customize button bar//from w ww. ja v a 2s .c om */ @Override protected void createButtonsForButtonBar(Composite parent) { // Button exportButton = this.createButton(parent, IDialogConstants.OPEN_ID, Messages.getString("export"), true); WidgetTestUtil.setTestId(this, "export", exportButton); this.getButton(IDialogConstants.OPEN_ID).addSelectionListener(new SelectionAdapter() { private FileDialog saveDialog; @Override public void widgetSelected(SelectionEvent e) { // ???? this.saveDialog = new FileDialog(getShell(), SWT.SAVE); boolean headerFlag = ExportDialog.this.headerCheckbox.getSelection(); //???([summaryType]_.zip?summaryType?) // ?????????????? // ?????ID()? SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); // ???????????(??????) String defaultDateStr = sdf.format(new Date(System.currentTimeMillis())); String defaultFileName = SummaryTypeMessage.typeToStringEN(m_summaryType) + '_' + defaultDateStr; this.saveDialog.setFilterExtensions(new String[] { "*.zip" }); defaultFileName += ".zip"; // ??????+????????????? defaultFileName = defaultFileName.replaceAll(" ", ""); this.saveDialog.setFileName(defaultFileName); String filePath = this.saveDialog.open(); if (filePath != null) { m_log.debug("filePath = " + filePath + ", defaultFileName = " + defaultFileName); output(m_managerFacilityIdNameMap, m_summaryType, m_collectKeyInfoPkList, m_targetManagerFacilityMap, headerFlag, filePath, defaultFileName, defaultDateStr); } } /** * Output */ protected void output(TreeMap<String, String> managerFacilityIdNameMap, Integer summaryType, List<CollectKeyInfoPK> targetCollectKeyInfoList, TreeMap<String, List<String>> targetManagerFacilityMap, boolean headerFlag, String filePath, String fileName, String defaultDateStr) { // DataWriter?? // ??? writer = new RecordDataWriter(managerFacilityIdNameMap, summaryType, targetCollectKeyInfoList, targetManagerFacilityMap, headerFlag, filePath, defaultDateStr); // Download & ??? try { IRunnableWithProgress op = new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { // ? ServiceContext context = ContextProvider.getContext(); writer.setContext(context); Thread exportThread = new Thread(writer); exportThread.start(); Thread.sleep(3000); monitor.beginTask(Messages.getString("export"), 100); // "?" int progress = 0; int buff = 0; while (progress < 100) { progress = writer.getProgress(); if (monitor.isCanceled()) { throw new InterruptedException(""); } if (writer.isCanceled()) { throw new InterruptedException(writer.getCancelMessage()); } Thread.sleep(50); monitor.worked(progress - buff); buff = progress; } monitor.done(); } }; // ? new ProgressMonitorDialog(getShell()).run(true, true, op); // Start download file if (ClusterControlPlugin.isRAP()) { FileDownloader.openBrowser(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), filePath, fileName); } else { MessageDialog.openInformation(getShell(), Messages.getString("confirmed"), Messages.getString("performance.export.success")); } } catch (InterruptedException e) { // ????? MessageDialog.openInformation(getShell(), Messages.getString("confirmed"), Messages.getString("performance.export.cancel") + " : " + e.getMessage()); } catch (Exception e) { // m_log.warn("output() : " + e.getMessage(), e); MessageDialog.openInformation(getShell(), Messages.getString("confirmed"), Messages.getString("performance.export.cancel") + " : " + e.getMessage() + "(" + e.getClass().getName() + ")"); } finally { writer.setCanceled(true); if (ClusterControlPlugin.isRAP()) { FileDownloader.cleanup(filePath); } } } }); createButton(parent, IDialogConstants.CANCEL_ID, "close", false); }