List of usage examples for org.eclipse.jface.dialogs ProgressMonitorDialog ProgressMonitorDialog
public ProgressMonitorDialog(Shell parent)
From source file:ext.org.eclipse.jdt.internal.ui.packageview.FileTransferDragAdapter.java
License:Open Source License
private void runOperation(IRunnableWithProgress op, boolean fork, boolean cancelable) { try {/*w ww .ja va 2s . c o m*/ Shell parent = JavaPlugin.getActiveWorkbenchShell(); new ProgressMonitorDialog(parent).run(fork, cancelable, op); } catch (InvocationTargetException e) { String message = PackagesMessages.DragAdapter_problem; String title = PackagesMessages.DragAdapter_problemTitle; ExceptionHandler.handle(e, title, message); } catch (InterruptedException e) { // Do nothing. Operation has been canceled by user. } }
From source file:ext.org.eclipse.jdt.internal.ui.packageview.GotoTypeAction.java
License:Open Source License
@Override public void run() { Shell shell = JavaPlugin.getActiveWorkbenchShell(); SelectionDialog dialog = null;//from w w w . j ava 2 s . c o m try { dialog = JavaUI.createTypeDialog(shell, new ProgressMonitorDialog(shell), SearchEngine.createWorkspaceScope(), IJavaElementSearchConstants.CONSIDER_ALL_TYPES, false); } catch (JavaModelException e) { String title = getDialogTitle(); String message = PackagesMessages.GotoType_error_message; ExceptionHandler.handle(e, title, message); return; } dialog.setTitle(getDialogTitle()); dialog.setMessage(PackagesMessages.GotoType_dialog_message); if (dialog.open() == IDialogConstants.CANCEL_ID) { return; } Object[] types = dialog.getResult(); if (types != null && types.length > 0) { gotoType((IType) types[0]); } }
From source file:ext.org.eclipse.jdt.internal.ui.preferences.BuildPathsPropertyPage.java
License:Open Source License
@Override public boolean performOk() { if (fBuildPathsBlock != null) { getSettings().put(INDEX, fBuildPathsBlock.getPageIndex()); if (fBuildPathsBlock.hasChangesInDialog() || fBuildPathsBlock.isClassfileMissing()) { IWorkspaceRunnable runnable = new IWorkspaceRunnable() { public void run(IProgressMonitor monitor) throws CoreException, OperationCanceledException { fBuildPathsBlock.configureJavaProject(monitor); }/*from www . j av a 2 s.c o m*/ }; WorkbenchRunnableAdapter op = new WorkbenchRunnableAdapter(runnable); if (fBlockOnApply) { try { new ProgressMonitorDialog(getShell()).run(true, true, op); } catch (InvocationTargetException e) { ExceptionHandler.handle(e, getShell(), PreferencesMessages.BuildPathsPropertyPage_error_title, PreferencesMessages.BuildPathsPropertyPage_error_message); return false; } catch (InterruptedException e) { return false; } } else { op.runAsUserJob(PreferencesMessages.BuildPathsPropertyPage_job_title, null); } } } return true; }
From source file:ext.org.eclipse.jdt.internal.ui.preferences.ClasspathContainerPreferencePage.java
License:Open Source License
/** * Apply the changes to the classpath/* w w w. ja va 2s .c o m*/ */ @Override protected void applyChanges() { IClasspathEntry[] created = ((ClasspathContainerWizard) getWizard()).getNewEntries(); if (created == null || created.length != 1) return; final IClasspathEntry result = created[0]; if (result == null || result.equals(fEntry)) return; try { IClasspathEntry[] entries = fJavaProject.getRawClasspath(); int idx = indexInClasspath(entries, fEntry); if (idx == -1) return; final IClasspathEntry[] newEntries = new IClasspathEntry[entries.length]; System.arraycopy(entries, 0, newEntries, 0, entries.length); newEntries[idx] = result; IRunnableContext context = new ProgressMonitorDialog(getShell()); context = PlatformUI.getWorkbench().getProgressService(); context.run(true, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { if (result.getEntryKind() == IClasspathEntry.CPE_CONTAINER) { IPath path = result.getPath(); String eeID = JavaRuntime.getExecutionEnvironmentId(path); if (eeID != null) { BuildPathSupport.setEEComplianceOptions(fJavaProject, eeID, null); } } fJavaProject.setRawClasspath(newEntries, fJavaProject.getOutputLocation(), monitor); } catch (CoreException e) { throw new InvocationTargetException(e); } } }); fEntry = result; } catch (JavaModelException e) { String title = ActionMessages.ConfigureContainerAction_error_title; String message = ActionMessages.ConfigureContainerAction_error_creationfailed_message; ExceptionHandler.handle(e, getShell(), title, message); } catch (InvocationTargetException e) { String title = ActionMessages.ConfigureContainerAction_error_title; String message = ActionMessages.ConfigureContainerAction_error_applyingfailed_message; ExceptionHandler.handle(e, getShell(), title, message); } catch (InterruptedException e) { // user cancelled } }
From source file:ext.org.eclipse.jdt.internal.ui.refactoring.ChangeExceptionHandler.java
License:Open Source License
private void performUndo(final Change undo) { IWorkspaceRunnable runnable = new IWorkspaceRunnable() { public void run(IProgressMonitor monitor) throws CoreException { monitor.beginTask("", 11); //$NON-NLS-1$ try { undo.initializeValidationData( new NotCancelableProgressMonitor(new SubProgressMonitor(monitor, 1))); if (undo.isValid(new SubProgressMonitor(monitor, 1)).hasFatalError()) { monitor.done();/*from ww w . j av a 2s. co m*/ return; } undo.perform(new SubProgressMonitor(monitor, 9)); } finally { undo.dispose(); } } }; WorkbenchRunnableAdapter adapter = new WorkbenchRunnableAdapter(runnable, ResourcesPlugin.getWorkspace().getRoot()); ProgressMonitorDialog dialog = new ProgressMonitorDialog(fParent); try { dialog.run(false, false, adapter); } catch (InvocationTargetException e) { ExceptionHandler.handle(e, fParent, RefactoringMessages.ChangeExceptionHandler_undo_dialog_title, RefactoringMessages.ChangeExceptionHandler_undo_dialog_message + fName); } catch (InterruptedException e) { // can't happen } }
From source file:ext.org.eclipse.jdt.internal.ui.wizards.buildpaths.VariableBlock.java
License:Open Source License
public boolean performOk() { ArrayList<String> removedVariables = new ArrayList<String>(); ArrayList<String> changedVariables = new ArrayList<String>(); removedVariables.addAll(Arrays.asList(JavaCore.getClasspathVariableNames())); // remove all unchanged List<CPVariableElement> changedElements = fVariablesList.getElements(); for (int i = changedElements.size() - 1; i >= 0; i--) { CPVariableElement curr = changedElements.get(i); if (curr.isReadOnly()) { changedElements.remove(curr); } else {//from w w w .ja v a 2 s .c o m IPath path = curr.getPath(); IPath prevPath = JavaCore.getClasspathVariable(curr.getName()); if (prevPath != null && prevPath.equals(path)) { changedElements.remove(curr); } else { changedVariables.add(curr.getName()); } } removedVariables.remove(curr.getName()); } int steps = changedElements.size() + removedVariables.size(); if (steps > 0) { boolean needsBuild = false; if (fAskToBuild && doesChangeRequireFullBuild(removedVariables, changedVariables)) { String title = NewWizardMessages.VariableBlock_needsbuild_title; String message = NewWizardMessages.VariableBlock_needsbuild_message; MessageDialog buildDialog = new MessageDialog(getShell(), title, null, message, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 2); int res = buildDialog.open(); if (res != 0 && res != 1) { return false; } needsBuild = (res == 0); } final VariableBlockRunnable runnable = new VariableBlockRunnable(removedVariables, changedElements); final ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell()); try { PlatformUI.getWorkbench().getProgressService().runInUI(dialog, runnable, ResourcesPlugin.getWorkspace().getRoot()); } catch (InvocationTargetException e) { ExceptionHandler.handle(new InvocationTargetException(new NullPointerException()), getShell(), NewWizardMessages.VariableBlock_variableSettingError_titel, NewWizardMessages.VariableBlock_variableSettingError_message); return false; } catch (InterruptedException e) { return false; } if (needsBuild) { CoreUtility.getBuildJob(null).schedule(); } } return true; }
From source file:featureDiagram.presentation.FeatureDiagramEditor.java
License:Open Source License
/** * This is for implementing {@link IEditorPart} and simply saves the model file. * <!-- begin-user-doc -->/* www .j a va 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. // FeatureDiagramEditorPlugin.INSTANCE.log(exception); } updateProblemIndication = true; updateProblemIndication(); }
From source file:fr.gouv.mindef.safran.database.scaffold.presentation.ScaffoldEditor.java
License:Open Source License
/** * This is for implementing {@link IEditorPart} and simply saves the model file. * <!-- begin-user-doc -->//from w w w.ja v a 2 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. // ScaffoldEditorPlugin.INSTANCE.log(exception); } updateProblemIndication = true; updateProblemIndication(); }
From source file:fr.imag.adele.cadse.cadseg.eclipse.RenameJavaClassMappingOperartion.java
License:Apache License
protected void refactoringRename(String id, String... params) { try {/*from w w w .j av a 2 s . c o m*/ IJavaElement oldElement = getJavaElement(_oldcontext); IJavaElement newElement = getJavaElement(_newcontext); Map<String, String> arguments = new HashMap<String, String>(); for (int i = 0; i < params.length;) { String k = params[i++]; String v = params[i++]; arguments.put(k, v); } arguments.put("name", newElement.getElementName()); arguments.put("input", oldElement.getHandleIdentifier()); RenameJavaElementDescriptor javaElementDescriptor = new RenameJavaElementDescriptor(id, id == IJavaRefactorings.RENAME_JAVA_PROJECT ? null : oldElement.getResource().getProject().getName(), _desc, _desc, arguments, 0); javaElementDescriptor.setJavaElement(oldElement); javaElementDescriptor.setNewName(newElement.getElementName()); int type = oldElement.getElementType(); switch (type) { case IJavaElement.PACKAGE_FRAGMENT: case IJavaElement.TYPE: javaElementDescriptor.setUpdateQualifiedNames(true); break; default: } if (oldElement.getElementType() != IJavaElement.PACKAGE_FRAGMENT_ROOT) { javaElementDescriptor.setUpdateReferences(true); } RenameSupport renameSupport = RenameSupport.create(javaElementDescriptor); Shell parent = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); renameSupport.perform(parent, new ProgressMonitorDialog(parent)); } catch (CoreException e1) { e1.printStackTrace(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InvocationTargetException e) { // TODO Auto-generated catch block e.printStackTrace(); } }