List of usage examples for org.eclipse.jface.dialogs ProgressMonitorDialog ProgressMonitorDialog
public ProgressMonitorDialog(Shell parent)
From source file:com.iw.plugins.spindle.editors.SpindleMultipageEditor.java
License:Mozilla Public License
protected void performSaveAs(IProgressMonitor monitor) { Shell shell = getSite().getShell();//from ww w . j a v a2 s .c om SaveAsDialog dialog = new SaveAsDialog(shell); if (dialog.open() == Dialog.CANCEL) { if (monitor != null) monitor.setCanceled(true); return; } IPath filePath = dialog.getResult(); if (filePath == null) { if (monitor != null) monitor.setCanceled(true); return; } filePath = makeValidSaveAsPath(filePath); filePath = filePath.removeTrailingSeparator(); final String fileName = filePath.lastSegment(); IPath folderPath = filePath.removeLastSegments(1); if (folderPath == null) { if (monitor != null) monitor.setCanceled(true); return; } IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IFile file = root.getFile(filePath); final FileEditorInput newInput = new FileEditorInput(file); WorkspaceModifyOperation op = new WorkspaceModifyOperation() { public void execute(final IProgressMonitor monitor) throws CoreException { getDocumentProvider().saveDocument(monitor, newInput, getDocumentProvider().getDocument(getEditorInput()), true); } }; boolean success = false; try { commitFormPages(true); resynchDocument(true); new ProgressMonitorDialog(shell).run(false, true, op); success = true; } catch (InterruptedException x) { } catch (InvocationTargetException x) { Throwable t = x.getTargetException(); TapestryPlugin.getDefault().logException(t); } finally { if (monitor != null) monitor.setCanceled(!success); } }
From source file:com.iw.plugins.spindle.project.actions.MigrateToTapestryDTD13.java
License:Mozilla Public License
private void findAllModels() { ProgressMonitorDialog dialog = new ProgressMonitorDialog( TapestryPlugin.getDefault().getActiveWorkbenchShell()); ModelCollectorRunnable runnable = new ModelCollectorRunnable(); try {//w w w. j a v a 2 s. co m dialog.run(false, false, runnable); mgr = runnable.getResult(); } catch (InvocationTargetException e) { } catch (InterruptedException e) { } }
From source file:com.iw.plugins.spindle.project.actions.MigrationModelManager.java
License:Mozilla Public License
/** * @see com.iw.plugins.spindle.model.manager.TapestryProjectModelManager#initializeProjectTapestryModels() *//* w w w .ja v a 2 s . com*/ protected void initializeProjectTapestryModels() { if (initialized) { return; } initialized = true; allModels = new ArrayList(); models = new HashMap(); Shell shell = TapestryPlugin.getDefault().getActiveWorkbenchShell(); ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell); try { dialog.run(false, false, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { populateAllModels(project, TapestryLookup.ACCEPT_TAPESTRY_PROJECTS_ONLY | TapestryLookup.WRITEABLE, monitor); try { int acceptFlags = TapestryLookup.ACCEPT_LIBRARIES | TapestryLookup.FULL_TAPESTRY_PATH; IJavaProject jproject = TapestryPlugin.getDefault().getJavaProjectFor(project); TapestryLookup lookup = new TapestryLookup(); lookup.configure(jproject); IStorage storage = lookup.findDefaultLibrary(); if (storage != null) { TapestryLibraryModel framework = new TapestryLibraryModel(storage); framework.load(); setDefaultLibrary(framework); } } catch (CoreException e) { ErrorDialog.openError(TapestryPlugin.getDefault().getActiveWorkbenchShell(), "Migration Error", "could not find the Tapestry Project", e.getStatus()); } } }); } catch (InvocationTargetException e) { } catch (InterruptedException e) { } finally { } }
From source file:com.iw.plugins.spindle.ui.properties.ProjectPropertyPage.java
License:Mozilla Public License
public boolean performOk() { Shell shell = UIPlugin.getDefault().getActiveWorkbenchShell(); if (shell == null) { try {/* w ww.jav a2 s.com*/ doOk(new NullProgressMonitor()); } catch (CoreException e) { UIPlugin.log(e); } } else { try { new ProgressMonitorDialog(shell).run(false, false, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { doOk(monitor); } catch (CoreException e) { UIPlugin.log(e); } } }); } catch (InvocationTargetException e) { UIPlugin.log(e); } catch (InterruptedException e) { UIPlugin.log(e); } } return true; }
From source file:com.iw.plugins.spindle.ui.RequiredSaveEditorAction.java
License:Mozilla Public License
public boolean save() { Shell parent = getShell();/*from www. jav a 2s . c o m*/ String message = "Warning, listed files need to be saved before continuing"; String title = "not saving all here will abort the current operation"; ListSelectionDialog dialog = new ListSelectionDialog(parent, unsavedEditors, new ListContentProvider(), new SaveLabelProvider(), message); dialog.setTitle(title); dialog.setBlockOnOpen(true); dialog.setInitialSelections(unsavedEditors); if (dialog.open() == ListSelectionDialog.CANCEL || dialog.getResult().length != unsavedEditors.length) { return false; } try { new ProgressMonitorDialog(getShell()).run(false, false, createRunnable(Arrays.asList(unsavedEditors))); } catch (InvocationTargetException e) { TapestryPlugin.getDefault().logException(e); return false; } catch (InterruptedException e) { // Can't happen. Operation isn't cancelable. } return true; }
From source file:com.iw.plugins.spindle.ui.TypeDialogCellEditor.java
License:Mozilla Public License
/** * @see DialogCellEditor#openDialogBox(Control) *///from w w w . jav a 2s. com protected Object openDialogBox(Control cellEditorWindow) { Object value = getValue(); try { SelectionDialog dialog = JavaUI.createTypeDialog(cellEditorWindow.getShell(), new ProgressMonitorDialog(cellEditorWindow.getShell()), createSearchScope(), searchFlags, false); dialog.setTitle("Type"); dialog.setMessage(hierarchyRoot == null ? "Choose the type" : "Choose a type (extends/implements " + hierarchyRoot + ")"); if (dialog.open() == dialog.OK) { return ((IType) dialog.getResult()[0]).getFullyQualifiedName(); //getFirstResult()); } } catch (JavaModelException jmex) { TapestryPlugin.getDefault().logException(jmex); } return value; }
From source file:com.iw.plugins.spindle.ui.wizards.fields.InterfaceChooser.java
License:Mozilla Public License
protected IRunnableContext getRunnableContext() { return (context == null ? new ProgressMonitorDialog(getShell()) : context); }
From source file:com.jasperassistant.designer.viewer.actions.AbstractExportAction.java
License:Open Source License
/** * Subclasses can override this method to implement an export method. * Default implementation opens a progress monitor dialog and then calls the * {@link #exportWithProgress(File, JRExportProgressMonitor)}method. * //from w w w. j a v a 2s .c o m * @param file * the destination file * @throws Throwable * if an error occurs during the export * @see #exportWithProgress(File, JRExportProgressMonitor) */ protected void export(final File file) throws Throwable { ProgressMonitorDialog pm = new ProgressMonitorDialog(Display.getCurrent().getActiveShell()); try { pm.run(true, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { int totalPages = getReportViewer().getDocument().getPages().size(); monitor.beginTask(Messages.getString("AbstractExportAction.taskLabel"), totalPages); //$NON-NLS-1$ exportWithProgress(file, new ProgressMonitorAdapter(monitor, totalPages)); } catch (Throwable e) { throw new InvocationTargetException(e); } finally { monitor.done(); } } }); } catch (InvocationTargetException e) { if (pm.getReturnCode() != ProgressMonitorDialog.CANCEL) { throw e; } } catch (InterruptedException e) { if (pm.getReturnCode() != ProgressMonitorDialog.CANCEL) { throw e; } } finally { if (pm.getReturnCode() == ProgressMonitorDialog.CANCEL) { file.delete(); } } }
From source file:com.javadude.antxr.eclipse.ui.actions.CompileAction.java
License:Open Source License
/** * @see IActionDelegate#run(IAction)/*from w w w . ja va 2s .c o m*/ */ public void run(IAction anAction) { Assert.isNotNull(fGrammarFile); Shell shell = AntxrUIPlugin.getActiveWorkbenchShell(); ProgressMonitorDialog pmd = new ProgressMonitorDialog(shell); try { pmd.run(true, false, new Operation(fGrammarFile)); // cancel button disabled } catch (InterruptedException e) { AntxrUIPlugin.log(e); } catch (InvocationTargetException e) { AntxrUIPlugin.log(e); } }
From source file:com.kdmanalytics.toif.report.internal.handlers.MergeTSV.java
License:Open Source License
/** * Process the tsv file. this method steps through each line of the TSV * file, extracts the details for that finding, and applies it to a matching * finding in the repository./*from w w w. ja va 2 s . com*/ * * @param shell2 * * @param file * the tsvFile that we are parsing * @param repo * the event from the handler. */ private void processTSVFile(final Shell shell, final File file, final Repository repo) { // count the line numbers. final int lineNumbers = countLineNumbers(file); ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell); try { dialog.run(true, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) { monitor.beginTask("Importing TSV File...", lineNumbers); BufferedReader bufRdr = null; try { bufRdr = new BufferedReader(new FileReader(file)); String line = null; RepositoryConnection con = null; try { con = repo.getConnection(); } catch (RepositoryException e) { e.printStackTrace(); } if (con == null) { System.err.println("Could not create the repository connection..."); return; } org.openrdf.model.ValueFactory factory = con.getValueFactory(); // read each line of text file= while ((line = bufRdr.readLine()) != null) { // split on a tab (tsv file). String[] tokens = line.split("\t"); if (tokens.length != 9) { monitor.worked(1); continue; } // get the details String valid = tokens[2]; String trust = tokens[3]; String resource = tokens[4]; String lineNumber = tokens[5]; String description = tokens[8]; try { String query = "SELECT ?finding ?description WHERE { ?codeLocation <http://toif/path> \"" + resource + "\". ?codeLocation <http://toif/lineNumber> \"" + lineNumber + "\". ?finding <http://toif/toif:FindingHasCodeLocation> ?codeLocation . ?finding <http://toif/toif:FindingIsDescribedByWeaknessDescription> ?descriptionId . ?descriptionId <http://toif/description> ?description }"; TupleQuery tupleQuery = con.prepareTupleQuery(QueryLanguage.SPARQL, query); // query the repository. TupleQueryResult queryResult = tupleQuery.evaluate(); while (queryResult.hasNext()) { String[] descriptionTokens = description.split(":"); if (descriptionTokens.length < 1) { continue; } String ident = descriptionTokens[0]; BindingSet adaptorSet = queryResult.next(); Value finding = adaptorSet.getValue("finding"); Value desc = adaptorSet.getValue("description"); if (!desc.stringValue().startsWith(ident)) { continue; } URI findingURI = factory.createURI(finding.stringValue()); // set the trust URI trustURI = factory.createURI("http://toif/trust"); con.remove(findingURI, trustURI, null); con.add(findingURI, trustURI, factory.createLiteral(trust)); // set the validity URI validURI = factory.createURI("http://toif/isWeakness"); con.remove(findingURI, validURI, null); con.add(findingURI, validURI, factory.createLiteral(valid)); } } catch (RepositoryException e) { e.printStackTrace(); } catch (MalformedQueryException e) { e.printStackTrace(); } catch (QueryEvaluationException e) { e.printStackTrace(); } // update the row for the progress. monitor.worked(1); } // close the file bufRdr.close(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { if (bufRdr != null) { try { bufRdr.close(); } catch (IOException e) { e.printStackTrace(); } } } monitor.done(); } }); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } }