List of usage examples for org.eclipse.jface.dialogs ProgressMonitorDialog ProgressMonitorDialog
public ProgressMonitorDialog(Shell parent)
From source file:demo.handler.LoadProjectHandler.java
License:Open Source License
@Override public Object execute(ExecutionEvent event) throws ExecutionException { FileDialog fileDialog = new FileDialog(new Shell(), SWT.OPEN); fileDialog.setText("Load LineUp Project"); String[] filterExt = { "*.lineup" }; fileDialog.setFilterExtensions(filterExt); final String fileName = fileDialog.open(); if (fileName == null) return null; final File project = new File(fileName); try {/* ww w . j a v a 2 s. c o m*/ final IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); final demo.project.ProjectManager manager = new demo.project.ProjectManager(true, project, page); new ProgressMonitorDialog(Display.getCurrent().getActiveShell()).run(false, false, manager); } catch (InvocationTargetException | InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().setText("LineUp - " + project.getName()); return null; }
From source file:demo.handler.SaveProjectHandler.java
License:Open Source License
@Override public Object execute(ExecutionEvent event) throws ExecutionException { FileDialog fileDialog = new FileDialog(new Shell(), SWT.SAVE); fileDialog.setText("Save LineUp Project"); String[] filterExt = { "*.lineup" }; fileDialog.setFilterExtensions(filterExt); String filePath = "lineup-project_" + new SimpleDateFormat("yyyy.MM.dd_HH.mm").format(new Date()) + ".lineup"; fileDialog.setFileName(filePath);/*from w w w . j a v a 2 s.co m*/ final String fileName = fileDialog.open(); if (fileName == null) return null; final File project = new File(fileName); try { final IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); final demo.project.ProjectManager manager = new demo.project.ProjectManager(false, project, page); new ProgressMonitorDialog(Display.getCurrent().getActiveShell()).run(true, false, manager); } catch (InvocationTargetException | InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().setText("LineUp - " + project.getName()); return null; }
From source file:demo.internal.DemoApplication.java
License:Open Source License
/** * *//* w ww . ja v a2s . c om*/ public void loadProject() { if (projectLocation == null || !projectLocation.exists()) return; final IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); final demo.project.ProjectManager manager = new demo.project.ProjectManager(true, projectLocation, page); try { new ProgressMonitorDialog(Display.getCurrent().getActiveShell()).run(false, false, manager); } catch (InvocationTargetException | InterruptedException e) { Logger.create(DemoApplication.class).error("can't load project: " + projectLocation, e); } }
From source file:descent.internal.ui.preferences.BuildPathsPropertyPage.java
License:Open Source License
public boolean performOk() { if (fBuildPathsBlock != null) { getSettings().put(INDEX, fBuildPathsBlock.getPageIndex()); if (fBuildPathsBlock.hasChangesInDialog()) { IWorkspaceRunnable runnable = new IWorkspaceRunnable() { public void run(IProgressMonitor monitor) throws CoreException, OperationCanceledException { fBuildPathsBlock.configureJavaProject(monitor); }// ww w .ja va 2 s . c om }; 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:descent.internal.ui.refactoring.reorg.ReorgCopyStarter.java
License:Open Source License
public void run(Shell parent) throws InterruptedException, InvocationTargetException { IRunnableContext context = new ProgressMonitorDialog(parent); fCopyProcessor.setNewNameQueries(new NewNameQueries(parent)); fCopyProcessor.setReorgQueries(new ReorgQueries(parent)); new RefactoringExecutionHelper(new CopyRefactoring(fCopyProcessor), RefactoringCore.getConditionCheckingFailedSeverity(), false, parent, context).perform(false); }
From source file:descent.internal.ui.refactoring.reorg.ReorgMoveStarter.java
License:Open Source License
public void run(Shell parent) throws InterruptedException, InvocationTargetException { try {/*from w ww. j a v a2 s . co m*/ JavaMoveRefactoring ref = new JavaMoveRefactoring(fMoveProcessor); if (fMoveProcessor.hasAllInputSet()) { IRunnableContext context = new ProgressMonitorDialog(parent); fMoveProcessor.setCreateTargetQueries(new CreateTargetQueries(parent)); fMoveProcessor.setReorgQueries(new ReorgQueries(parent)); new RefactoringExecutionHelper(ref, RefactoringCore.getConditionCheckingFailedSeverity(), true, parent, context).perform(false); } else { RefactoringWizard wizard = new ReorgMoveWizard(ref); /* * We want to get the shell from the refactoring dialog but it's not known at this point, * so we pass the wizard and then, once the dialog is open, we will have access to its shell. */ fMoveProcessor.setCreateTargetQueries(new CreateTargetQueries(wizard)); fMoveProcessor.setReorgQueries(new ReorgQueries(wizard)); new RefactoringStarter().activate(ref, wizard, parent, RefactoringMessages.OpenRefactoringWizardAction_refactoring, true); } } catch (JavaModelException e) { ExceptionHandler.handle(e, RefactoringMessages.OpenRefactoringWizardAction_refactoring, RefactoringMessages.OpenRefactoringWizardAction_exception); } }
From source file:descent.internal.ui.wizards.buildpaths.newsourcepage.LinkFolderDialog.java
License:Open Source License
/** * Creates a new folder with the given name and optionally linking to * the specified link target.// ww w . ja va 2s .c om * * @param folderName name of the new folder * @param linkTargetName name of the link target folder. may be null. * @return IFolder the new folder */ private IFolder createNewFolder(final String folderName, final String linkTargetName) { final IFolder folderHandle = createFolderHandle(folderName); WorkspaceModifyOperation operation = new WorkspaceModifyOperation() { public void execute(IProgressMonitor monitor) throws CoreException { try { monitor.beginTask(NewWizardMessages.NewFolderDialog_progress, 2000); if (monitor.isCanceled()) throw new OperationCanceledException(); // create link to folder folderHandle.createLink(Path.fromOSString(fDependenciesGroup.getLinkTarget()), IResource.ALLOW_MISSING_LOCAL, monitor); if (monitor.isCanceled()) throw new OperationCanceledException(); } catch (StringIndexOutOfBoundsException e) { e.printStackTrace(); } finally { monitor.done(); } } }; try { new ProgressMonitorDialog(getShell()).run(true, true, operation); } catch (InterruptedException exception) { return null; } catch (InvocationTargetException exception) { if (exception.getTargetException() instanceof CoreException) { ErrorDialog.openError(getShell(), NewWizardMessages.NewFolderDialog_errorTitle, null, // no special message ((CoreException) exception.getTargetException()).getStatus()); } else { // CoreExceptions are handled above, but unexpected runtime exceptions and errors may still occur. JavaPlugin.log(new Exception(Messages.format("Exception in {0}.createNewFolder(): {1}", //$NON-NLS-1$ new Object[] { getClass().getName(), exception.getTargetException() }))); MessageDialog.openError(getShell(), NewWizardMessages.NewFolderDialog_errorTitle, Messages.format(NewWizardMessages.NewFolderDialog_internalError, new Object[] { exception.getTargetException().getMessage() })); } return null; } return folderHandle; }
From source file:descent.internal.ui.wizards.buildpaths.VariableBlock.java
License:Open Source License
public boolean performOk() { ArrayList removedVariables = new ArrayList(); ArrayList changedVariables = new ArrayList(); removedVariables.addAll(Arrays.asList(JavaCore.getClasspathVariableNames())); // remove all unchanged List changedElements = fVariablesList.getElements(); for (int i = changedElements.size() - 1; i >= 0; i--) { CPVariableElement curr = (CPVariableElement) changedElements.get(i); if (curr.isReserved()) { changedElements.remove(curr); } else {/*from www. j a v a2 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 { dialog.run(true, true, runnable); } 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:DiagramGlobalToolService.presentation.DiagramGlobalToolServiceEditor.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 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); 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. // DgtsEditorPlugin.INSTANCE.log(exception); } updateProblemIndication = true; updateProblemIndication(); }
From source file:distributed.plugin.ui.editor.GraphEditor.java
License:Open Source License
private boolean performSaveAs() { SaveAsDialog dialog = new SaveAsDialog(getSite().getWorkbenchWindow().getShell()); dialog.setOriginalFile(((IFileEditorInput) getEditorInput()).getFile()); dialog.open();//from www. java2s . c o m IPath path = dialog.getResult(); if (path == null) return false; IWorkspace workspace = ResourcesPlugin.getWorkspace(); final IFile file = workspace.getRoot().getFile(path); if (!file.exists()) { WorkspaceModifyOperation op = new WorkspaceModifyOperation() { public void execute(final IProgressMonitor monitor) { ByteArrayOutputStream out = null; try { out = new ByteArrayOutputStream(); createOutputStream(out); byte[] contents = out.toByteArray(); file.create(new ByteArrayInputStream(contents, 0, contents.length), true, monitor); } catch (Exception e) { e.printStackTrace(); System.err.println("[GraphEditor].performSaveAs().execute() " + e); } finally { if (out != null) { try { out.close(); } catch (IOException e) { } out = null; } } } }; try { new ProgressMonitorDialog(getSite().getWorkbenchWindow().getShell()).run(false, true, op); } catch (Exception e) { e.printStackTrace(); System.err.println("[GraphEditor].performSaveAs() " + e); } } try { this.superSetInput(new FileEditorInput(file)); this.getCommandStack().markSaveLocation(); } catch (Exception e) { e.printStackTrace(); System.err.println("[GraphEditor].performSaveAs() " + e); } return true; }