List of usage examples for org.eclipse.jface.dialogs ProgressMonitorDialog ProgressMonitorDialog
public ProgressMonitorDialog(Shell parent)
From source file:de.gulden.modeling.wave.presentation.WaveEditor.java
License:Open Source License
/** * This is for implementing {@link IEditorPart} and simply saves the model file. * <!-- begin-user-doc -->/*from w w w . j a 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); // 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. // WaveEditPlugin.INSTANCE.log(exception); } updateProblemIndication = true; updateProblemIndication(); }
From source file:de.hentschel.visualdbc.dbcmodel.presentation.DbcmodelEditor.java
License:Open Source License
/** * This is for implementing {@link IEditorPart} and simply saves the model file. * <!-- begin-user-doc -->/*from w w w . j a v a 2s . 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. // DbCEditorPlugin.INSTANCE.log(exception); } updateProblemIndication = true; updateProblemIndication(); }
From source file:de.hoesel.dav.buv.twitter.baustelle.BaustelleTwitternDialogOeffnenHandler.java
License:Open Source License
@SuppressWarnings("rawtypes") @Override//w ww . j a v a 2 s . c om public Object execute(ExecutionEvent event) throws ExecutionException { final Shell activeShell = HandlerUtil.getActiveShell(event); ISelection menuSelection = HandlerUtil.getActiveMenuSelection(event); if (menuSelection instanceof IStructuredSelection) { Iterator iterator = ((IStructuredSelection) menuSelection).iterator(); while (iterator.hasNext()) { Object obj = iterator.next(); final SystemObjekt objekt = (SystemObjekt) Platform.getAdapterManager().getAdapter(obj, SystemObjekt.class); if (objekt instanceof Baustelle) { final Baustelle baustelle = (Baustelle) objekt; final CacheService cacheService = RahmenwerkService.getService().getCacheService(); final NetzCacheExtended netzCache = cacheService .getNetzCacheExtended(cacheService.getDefaultNetzPid()); if (!netzCache.isInitialisiert()) { ProgressMonitorDialog progress = new ProgressMonitorDialog(activeShell); try { progress.run(true, true, new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask("Warte auf Caches ...", IProgressMonitor.UNKNOWN); while (!netzCache.isInitialisiert()) { Thread.sleep(100); } monitor.done(); final BaustelleTwitternDialog dialog = new BaustelleTwitternDialog(activeShell, baustelle); activeShell.getDisplay().asyncExec(new Runnable() { @Override public void run() { dialog.open(); } }); } }); } catch (InvocationTargetException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } // progress.open(); } else { final BaustelleTwitternDialog dialog = new BaustelleTwitternDialog(activeShell, baustelle); dialog.open(); } } } } return null; }
From source file:de.hub.emffrag.model.emffrag.presentation.EmfFragEditor.java
License:Apache License
/** * This is for implementing {@link IEditorPart} and simply saves the model file. * <!-- begin-user-doc -->//from w w w. j a va2 s. 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. // emffragEditorPlugin.INSTANCE.log(exception); } updateProblemIndication = true; updateProblemIndication(); }
From source file:de.itemis.gmf.tools.contribution.GMFToolsHandler.java
License:Open Source License
public Object execute(ExecutionEvent event) throws ExecutionException { window = HandlerUtil.getActiveWorkbenchWindowChecked(event); try {/*from ww w. j a v a2s . c o m*/ gmfModel = getGmfModel(event); lastGmfModel = gmfModel; if (gmfModel != null) { for (GmfModel model : gmfModel) { new ProgressMonitorDialog(window.getShell()).run(false, true, new GMFToolsGeneration(model, Collections.<String, String>emptyMap())); } } else { MessageDialog.openInformation(window.getShell(), "No GMF file set selected", "Go to Preferences -> GMF Tools and create a set of files for the editor first."); } } catch (Exception e) { reportError(e); } return null; }
From source file:de.jcup.egradle.eclipse.ide.ui.RootProjectConfigUIDelegate.java
License:Apache License
private void createValidationGroup(Composite parent) { if (!mode.isValidationGroupNeeded()) { return;//from w w w .ja v a2 s . com } /* ------------------------------------ */ /* - Check output - */ /* ------------------------------------ */ GridData groupLayoutData = new GridData(); groupLayoutData.horizontalAlignment = GridData.FILL; groupLayoutData.verticalAlignment = GridData.FILL; groupLayoutData.grabExcessHorizontalSpace = true; groupLayoutData.grabExcessVerticalSpace = true; groupLayoutData.verticalSpan = 2; groupLayoutData.horizontalSpan = 3; Group validationGroup = SWTFactory.createGroup(parent, "Validate preferences correct", 1, 10, SWT.FILL); validationGroup.setLayoutData(groupLayoutData); GridData labelGridData = new GridData(); labelGridData.horizontalAlignment = GridData.FILL; labelGridData.verticalAlignment = GridData.BEGINNING; labelGridData.grabExcessHorizontalSpace = false; labelGridData.grabExcessVerticalSpace = false; GridData gridDataLastColumn = new GridData(); gridDataLastColumn.horizontalAlignment = GridData.FILL; gridDataLastColumn.verticalAlignment = GridData.FILL; gridDataLastColumn.grabExcessHorizontalSpace = true; gridDataLastColumn.grabExcessVerticalSpace = true; gridDataLastColumn.verticalSpan = 2; gridDataLastColumn.horizontalSpan = 2; gridDataLastColumn.minimumHeight = 50; gridDataLastColumn.heightHint = 100; validationOutputField = new Text(validationGroup, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.READ_ONLY); validationOutputField.setLayoutData(gridDataLastColumn); validationButton = new Button(validationGroup, SWT.NONE); validationButton.setText("Start validation"); validationButton.setImage(getValidationButtonImage()); validationButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (validationRunning == true) { return; } setValid(false); handleValidationRunning(true); validationOutputField.setText("Start validation...\n"); OutputHandler validationOutputHandler = new OutputHandler() { @Override public void output(String line) { EclipseUtil.safeAsyncExec(new Runnable() { @Override public void run() { validationOutputField.append(line + "\n"); } }); } }; MutableGradleConfiguration configuration = new MutableGradleConfiguration(); configuration.setGradleCommand(getGradleCommand()); configuration.setGradleBinDirectory(getGradleBinDirectory()); configuration.setShellCommand(getShellCommand()); configuration.setWorkingDirectory(getWorkingDirectory()); configuration.setJavaHome(getGlobalJavaHomePath()); startValidation(validationOutputHandler, configuration); } private void startValidation(OutputHandler validationOutputHandler, MutableGradleConfiguration configuration) { try { RootProjectConfigUIDelegate observer = RootProjectConfigUIDelegate.this; ProgressMonitorDialog progressMonitorDialog = new ProgressMonitorDialog( EclipseUtil.getActiveWorkbenchShell()); RootProjectValidationProgressRunnable runnable = new RootProjectValidationProgressRunnable( new CancelStateProvider() { @Override public boolean isCanceled() { return progressMonitorDialog.getProgressMonitor().isCanceled(); } }, configuration, observer, validationOutputHandler); /* * use own progress monitor dialog here - progress service * did not work well because this is in model state */ progressMonitorDialog.run(true, true, runnable); } catch (InvocationTargetException | InterruptedException e1) { IDEUtil.logError("Was not able to execute validation", e1); } } }); }
From source file:de.jcup.egradle.eclipse.ide.wizards.RootProjectImportSupport.java
License:Apache License
void doImport(IPath path, IProgressMonitor monitor) throws Exception { UpdateRunnable op = new UpdateRunnable(); op.path = path;/*from w ww. j av a 2 s. c o m*/ Job job = new Job("Finalize egradle import") { @Override protected IStatus run(IProgressMonitor monitor) { getSafeDisplay().asyncExec(new Runnable() { @Override public void run() { try { new ProgressMonitorDialog(getActiveWorkbenchShell()).run(true, true, op); } catch (InvocationTargetException e) { IDEUtil.logError("Assemble task failed", e); EGradleMessageDialogSupport.INSTANCE.showBuildFailed("Assemble task failed"); } catch (InterruptedException e) { /* ignore - user interrupted */ } } }); return Status.OK_STATUS; } }; job.schedule(); }
From source file:de.jcup.egradle.eclipse.importWizards.EGradleRootProjectImportWizard.java
License:Apache License
private void doImport(IPath path, IProgressMonitor monitor) throws Exception { UpdateRunnable op = new UpdateRunnable(); op.path = path;/*from ww w .j a va2s . com*/ Job job = new Job("Finalize egradle import") { @Override protected IStatus run(IProgressMonitor monitor) { EGradleUtil.getSafeDisplay().asyncExec(new Runnable() { @Override public void run() { try { new ProgressMonitorDialog(EGradleUtil.getActiveWorkbenchShell()).run(true, true, op); } catch (InvocationTargetException e) { EGradleUtil .log(new Status(Status.ERROR, Activator.PLUGIN_ID, "Assemble task failed", e)); EGradleMessageDialogSupport.INSTANCE.showBuildFailed("Assemble task failed"); } catch (InterruptedException e) { /* ignore - user interrupted */ } } }); return Status.OK_STATUS; } }; job.schedule(); }
From source file:de.jcup.egradle.eclipse.ui.RootProjectConfigUIDelegate.java
License:Apache License
private void createValidationGroup(Composite parent) { /* ------------------------------------ */ /* - Check output - */ /* ------------------------------------ */ GridData groupLayoutData = new GridData(); groupLayoutData.horizontalAlignment = GridData.FILL; groupLayoutData.verticalAlignment = GridData.FILL; groupLayoutData.grabExcessHorizontalSpace = true; groupLayoutData.grabExcessVerticalSpace = true; groupLayoutData.verticalSpan = 2;//from ww w .ja va 2 s.co m groupLayoutData.horizontalSpan = 3; Group validationGroup = SWTFactory.createGroup(parent, "Validate preferences correct", 1, 10, SWT.FILL); validationGroup.setLayoutData(groupLayoutData); GridData labelGridData = new GridData(); labelGridData.horizontalAlignment = GridData.FILL; labelGridData.verticalAlignment = GridData.BEGINNING; labelGridData.grabExcessHorizontalSpace = false; labelGridData.grabExcessVerticalSpace = false; GridData gridDataLastColumn = new GridData(); gridDataLastColumn.horizontalAlignment = GridData.FILL; gridDataLastColumn.verticalAlignment = GridData.FILL; gridDataLastColumn.grabExcessHorizontalSpace = true; gridDataLastColumn.grabExcessVerticalSpace = true; gridDataLastColumn.verticalSpan = 2; gridDataLastColumn.horizontalSpan = 2; gridDataLastColumn.minimumHeight = 50; gridDataLastColumn.heightHint = 100; validationOutputField = new Text(validationGroup, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.READ_ONLY); validationOutputField.setLayoutData(gridDataLastColumn); validationButton = new Button(validationGroup, SWT.NONE); validationButton.setText("Start validation"); validationButton.setImage(getValidationButtonImage()); validationButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (validationRunning == true) { return; } setValid(false); handleValidationRunning(true); validationOutputField.setText("Start validation...\n"); OutputHandler validationOutputHandler = new OutputHandler() { @Override public void output(String line) { EGradleUtil.safeAsyncExec(new Runnable() { @Override public void run() { validationOutputField.append(line + "\n"); } }); } }; MutableGradleConfiguration configuration = new MutableGradleConfiguration(); configuration.setGradleCommand(getGradleCommand()); configuration.setGradleBinDirectory(getGradleBinDirectory()); configuration.setShellCommand(getShellCommand()); configuration.setWorkingDirectory(getWorkingDirectory()); configuration.setJavaHome(getGlobalJavaHomePath()); startValidation(validationOutputHandler, configuration); } private void startValidation(OutputHandler validationOutputHandler, MutableGradleConfiguration configuration) { try { RootProjectConfigUIDelegate observer = RootProjectConfigUIDelegate.this; ProgressMonitorDialog progressMonitorDialog = new ProgressMonitorDialog( EGradleUtil.getActiveWorkbenchShell()); RootProjectValidationProgressRunnable runnable = new RootProjectValidationProgressRunnable( new CancelStateProvider() { @Override public boolean isCanceled() { return progressMonitorDialog.getProgressMonitor().isCanceled(); } }, configuration, observer, validationOutputHandler); /* use own progress monitor dialog here - progress service did not work well because this is in model state */ progressMonitorDialog.run(true, true, runnable); } catch (InvocationTargetException | InterruptedException e1) { EGradleUtil.log(e1); } } }); }
From source file:de.loskutov.eclipse.jdepend.preferences.JDependPreferencePage.java
License:Open Source License
/** * Utility method to create and return a selection dialog that allows * selection of a specific Java package. Empty packages are not returned. * If Java Projects are provided, only packages found within those projects * are included. If no Java projects are provided, all Java projects in the * workspace are considered./*from w w w .java2 s . co m*/ */ public static ElementListSelectionDialog createAllPackagesDialog(Shell shell, IJavaProject[] originals, final boolean includeDefaultPackage) throws JavaModelException { final List<IPackageFragment> packageList = new ArrayList<IPackageFragment>(); if (originals == null) { IWorkspaceRoot wsroot = ResourcesPlugin.getWorkspace().getRoot(); IJavaModel model = JavaCore.create(wsroot); originals = model.getJavaProjects(); } final IJavaProject[] projects = originals; final JavaModelException[] exception = new JavaModelException[1]; ProgressMonitorDialog monitor = new ProgressMonitorDialog(shell); IRunnableWithProgress r = new IRunnableWithProgress() { @Override public void run(IProgressMonitor myMonitor) { try { Set<String> packageNameSet = new HashSet<String>(); myMonitor.beginTask(JDepend4EclipsePlugin.getResourceString("JDependPreferencePage.Searching"), //$NON-NLS-1$ projects.length); for (int i = 0; i < projects.length; i++) { IPackageFragment[] pkgs = projects[i].getPackageFragments(); for (int j = 0; j < pkgs.length; j++) { IPackageFragment pkg = pkgs[j]; if (!pkg.hasChildren() && (pkg.getNonJavaResources().length > 0)) { continue; } String pkgName = pkg.getElementName(); if (!includeDefaultPackage && pkgName.length() == 0) { continue; } if (packageNameSet.add(pkgName)) { packageList.add(pkg); } } myMonitor.worked(1); } myMonitor.done(); } catch (JavaModelException jme) { exception[0] = jme; } } }; try { monitor.run(false, false, r); } catch (InvocationTargetException e) { JDepend4EclipsePlugin.logError(e, "ooo"); //$NON-NLS-1$ } catch (InterruptedException e) { JDepend4EclipsePlugin.logError(e, "ooo"); //$NON-NLS-1$ } if (exception[0] != null) { throw exception[0]; } int flags = JavaElementLabelProvider.SHOW_DEFAULT; ElementListSelectionDialog dialog = new ElementListSelectionDialog(shell, new JavaElementLabelProvider(flags)); dialog.setIgnoreCase(false); dialog.setElements(packageList.toArray()); // XXX inefficient return dialog; }