List of usage examples for org.eclipse.jface.dialogs ProgressMonitorDialog run
@Override public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException
IRunnableWithProgress
using the progress monitor for this progress dialog and blocks until the runnable has been run, regardless of the value of fork
. From source file:org.eclipse.rcptt.ui.report.ReportAction.java
License:Open Source License
@Override public void run() { File root = Q7UIPlugin.getDefault().getStateLocation().append("reporting").toFile(); //$NON-NLS-1$ root.mkdirs();/* w w w. ja v a 2 s .c o m*/ File reportFile = new File(root, "current.report"); //$NON-NLS-1$ if (reportFile.exists()) { reportFile.delete(); } final SherlockReportOutputStream out; try { out = new SherlockReportOutputStream(new BufferedOutputStream(new FileOutputStream(reportFile))); } catch (FileNotFoundException e1) { Q7UIPlugin.log(e1); return; } ProgressMonitorDialog monDialog = new ProgressMonitorDialog(shell.getShell()); try { monDialog.run(false, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { new ReportMaker(out).make(session, monitor); out.close(); monitor.done(); } }); } catch (Throwable e) { Q7UIPlugin.log(e); } ReportWizard wizard = new ReportWizard(new Q7ReportIterator(reportFile), session.getName() + "_" //$NON-NLS-1$ + new SimpleDateFormat("yyyy_MM_dd").format(new Date())); //$NON-NLS-1$ IDialogSettings ds = Q7UIPlugin.getDefault().getDialogSettings().getSection("q7.reporting"); //$NON-NLS-1$ if (ds == null) { ds = Q7UIPlugin.getDefault().getDialogSettings().addNewSection("q7.reporting"); //$NON-NLS-1$ } wizard.setNeedsProgressMonitor(true); wizard.setDialogSettings(ds); WizardDialog dialog = new WizardDialog(shell.getShell(), wizard); dialog.open(); }
From source file:org.eclipse.rcptt.ui.resources.wizards.WizardFileSystemResourceImportPage1.java
License:Open Source License
/** * Update the tree to only select those elements that match the selected * types/*from w w w. j av a2 s . com*/ */ protected void setupSelectionsBasedOnSelectedTypes() { ProgressMonitorDialog dialog = new org.eclipse.ui.internal.progress.ProgressMonitorJobsDialog( getContainer().getShell()); final Map selectionMap = new Hashtable(); final org.eclipse.ui.internal.ide.dialogs.IElementFilter filter = new org.eclipse.ui.internal.ide.dialogs.IElementFilter() { public void filterElements(Collection files, IProgressMonitor monitor) throws InterruptedException { if (files == null) { throw new InterruptedException(); } Iterator filesList = files.iterator(); while (filesList.hasNext()) { if (monitor.isCanceled()) { throw new InterruptedException(); } checkFile(filesList.next()); } } public void filterElements(Object[] files, IProgressMonitor monitor) throws InterruptedException { if (files == null) { throw new InterruptedException(); } for (int i = 0; i < files.length; i++) { if (monitor.isCanceled()) { throw new InterruptedException(); } checkFile(files[i]); } } @SuppressWarnings("unchecked") private void checkFile(Object fileElement) { MinimizedFileSystemElement file = (MinimizedFileSystemElement) fileElement; if (isExportableExtension(file.getFileNameExtension())) { List elements = new ArrayList(); FileSystemElement parent = file.getParent(); if (selectionMap.containsKey(parent)) { elements = (List) selectionMap.get(parent); } elements.add(file); selectionMap.put(parent, elements); } } }; IRunnableWithProgress runnable = new IRunnableWithProgress() { public void run(final IProgressMonitor monitor) throws InterruptedException { monitor.beginTask( org.eclipse.ui.internal.wizards.datatransfer.DataTransferMessages.ImportPage_filterSelections, IProgressMonitor.UNKNOWN); getSelectedResources(filter, monitor); } }; try { dialog.run(true, true, runnable); } catch (InvocationTargetException exception) { // Couldn't start. Do nothing. return; } catch (InterruptedException exception) { // Got interrupted. Do nothing. return; } // make sure that all paint operations caused by closing the progress // dialog get flushed, otherwise extra pixels will remain on the screen // until // updateSelections is completed getShell().update(); // The updateSelections method accesses SWT widgets so cannot be // executed // as part of the above progress dialog operation since the operation // forks // a new process. if (selectionMap != null) { updateSelections(selectionMap); } }
From source file:org.eclipse.rmf.reqif10.pror.editor.presentation.Reqif10Editor.java
License:Open Source License
/** * This is the method used by the framework to install your own controls. * <!-- begin-user-doc --> We build one page only. The Editor may add a page * with error messages.<!-- end-user-doc --> * /*from w w w . ja v a2 s . com*/ * @generated NOT */ @Override public void createPages() { ProgressMonitorDialog monitorDialog = new ProgressMonitorDialog(getSite().getShell()); try { monitorDialog.run(false, false, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { editingDomain.getResourceSet().getLoadOptions().put(ReqIFResourceSetImpl.PROGRESS_MONITOR, monitor); createModel(); monitor.done(); } }); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } reqif = openReqif(); // Only creates the other pages if there is something that can be // edited if (!getEditingDomain().getResourceSet().getResources().isEmpty()) { ReqifMainForm form = new ReqifMainForm(getContainer(), this); addPage(form.getForm()); } // Ensures that this editor will only display the page's tab // area if there are more than one page getContainer().addControlListener(new ControlAdapter() { boolean guard = false; @Override public void controlResized(ControlEvent event) { if (!guard) { guard = true; hideTabs(); guard = false; } } }); getSite().getShell().getDisplay().asyncExec(new Runnable() { public void run() { updateProblemIndication(); } }); }
From source file:org.eclipse.robotml.generators.acceleo.aroccam.ui.handler.GenerateAroccamCodeCommand.java
License:Open Source License
/** * @see org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand#doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor, * org.eclipse.core.runtime.IAdaptable) * //from www . j ava 2s .c o m * @param monitor * @param info * @return * @throws ExecutionException */ @Override protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { // TODO Auto-generated method stub // System.err.println("Model Exlorer generation menu Aroccam"); Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); final ProgressMonitorDialog monitordialog = new ProgressMonitorDialog(shell); try { monitordialog.run(true, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask("Generating Acceleo files", 100); AcceleoAroccamCodeGenerator codeGenerator = new AcceleoAroccamCodeGenerator(); codeGenerator.runAcceleoTransformation(selectedElement, aroccamTargetFolderPath); monitor.done(); } }); } catch (InvocationTargetException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } return CommandResult.newOKCommandResult(); }
From source file:org.eclipse.robotml.generators.acceleo.cycabtk.ui.handler.GenerateCycabTKCodeCommand.java
License:Open Source License
/** * @see org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand#doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor, * org.eclipse.core.runtime.IAdaptable) * /*from ww w . j a v a 2 s .co m*/ * @param monitor * @param info * @return * @throws ExecutionException */ @Override protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { // TODO Auto-generated method stub System.err.println("Model Exlorer generation menu RTMaps"); Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); final ProgressMonitorDialog monitordialog = new ProgressMonitorDialog(shell); try { monitordialog.run(true, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask("Generating Acceleo files", 100); AcceleoCycabTKCodeGenerator codeGenerator = new AcceleoCycabTKCodeGenerator(); codeGenerator.runAcceleoTransformation(selectedElement, cycabtkTargetFolderPath); monitor.done(); } }); } catch (InvocationTargetException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } return CommandResult.newOKCommandResult(); }
From source file:org.eclipse.search.internal.ui.SearchManager.java
License:Open Source License
void removeAllSearches() { SearchPlugin.getWorkspace().removeResourceChangeListener(this); WorkspaceModifyOperation op = new WorkspaceModifyOperation(null) { protected void execute(IProgressMonitor monitor) throws CoreException { monitor.beginTask(SearchMessages.SearchManager_updating, 100); SearchPlugin.getWorkspace().getRoot().deleteMarkers(SearchUI.SEARCH_MARKER, true, IResource.DEPTH_INFINITE); monitor.worked(100);/*w w w.ja v a 2 s . com*/ monitor.done(); } }; boolean isAutoBuilding = SearchPlugin.setAutoBuilding(false); try { ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell()); dialog.run(true, true, op); } catch (InvocationTargetException ex) { ExceptionHandler.handle(ex, SearchMessages.Search_Error_deleteMarkers_title, SearchMessages.Search_Error_deleteMarkers_message); } catch (InterruptedException e) { // Do nothing. Operation has been canceled. } finally { SearchPlugin.getWorkspace().addResourceChangeListener(this); SearchPlugin.setAutoBuilding(isAutoBuilding); } // clear searches fPreviousSearches = new LinkedList(); fCurrentSearch = null; // update viewers Iterator iter = fListeners.iterator(); while (iter.hasNext()) { SearchResultViewer viewer = (SearchResultViewer) iter.next(); handleAllSearchesRemoved(viewer); } }
From source file:org.eclipse.search.internal.ui.SearchManager.java
License:Open Source License
void setCurrentSearch(final Search search) { if (fCurrentSearch == search) return;// w w w.ja v a2 s . c om SearchPlugin.getWorkspace().removeResourceChangeListener(this); WorkspaceModifyOperation op = new WorkspaceModifyOperation(null) { protected void execute(IProgressMonitor monitor) throws CoreException { internalSetCurrentSearch(search, monitor); } }; boolean isAutoBuilding = SearchPlugin.setAutoBuilding(false); try { ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell()); dialog.run(true, true, op); } catch (InvocationTargetException ex) { ExceptionHandler.handle(ex, SearchMessages.Search_Error_switchSearch_title, SearchMessages.Search_Error_switchSearch_message); } catch (InterruptedException e) { // Do nothing. Operation has been canceled. } finally { SearchPlugin.setAutoBuilding(isAutoBuilding); } getPreviousSearches().remove(search); getPreviousSearches().addFirst(search); }
From source file:org.eclipse.sirius.diagram.ui.tools.internal.actions.refresh.RefreshDiagramAction.java
License:Open Source License
/** * Refresh from the selection.// ww w . j ava2 s . co m * * @param selection * ISelection */ public static void refresh(final ISelection selection) { if (selection instanceof IStructuredSelection) { IStructuredSelection structuredSelection = (IStructuredSelection) selection; final Collection<EditPart> minimizedSelection = RefreshDiagramAction .minimizeSelection(Arrays.asList(structuredSelection.toArray())); if (!minimizedSelection.isEmpty()) { DDiagram diagram = DDiagramHelper.findParentDDiagram( Iterables.filter(minimizedSelection, IGraphicalEditPart.class).iterator().next()); if (diagram != null) { RefreshActionListenerRegistry.INSTANCE.notifyRepresentationIsAboutToBeRefreshed(diagram); } } final Shell activeShell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); final ProgressMonitorDialog monitorDialog = new ProgressMonitorDialog(activeShell); try { monitorDialog.run(true, false, new RefreshRunnableWithProgress(minimizedSelection)); } catch (final InvocationTargetException e) { MessageDialog.openError(activeShell, "Error", e.getTargetException().getMessage()); SiriusPlugin.getDefault().error("Error while refreshing diagram", e); } catch (final InterruptedException e) { MessageDialog.openInformation(activeShell, "Cancelled", e.getMessage()); } } }
From source file:org.eclipse.sirius.table.ui.tools.internal.editor.action.EditorRefreshAction.java
License:Open Source License
/** * {@inheritDoc}//w w w . jav a 2 s . c om * * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) */ public void run(final IAction action) { if (workbenchPart instanceof AbstractDTableEditor) { final IRunnableWithProgress op = new IRunnableWithProgress() { public void run(final IProgressMonitor monitor) { final AbstractDTableEditor tableEditor = (AbstractDTableEditor) workbenchPart; tableEditor.enablePropertiesUpdate(false); RefreshActionListenerRegistry.INSTANCE .notifyRepresentationIsAboutToBeRefreshed(tableEditor.getTableModel()); tableEditor.getEditingDomain().getCommandStack().execute(new RefreshRepresentationsCommand( tableEditor.getEditingDomain(), monitor, tableEditor.getTableModel())); tableEditor.enablePropertiesUpdate(true); } }; final Shell activeShell = workbenchPart.getSite().getShell(); final ProgressMonitorDialog monitorDialog = new ProgressMonitorDialog(activeShell); try { monitorDialog.run(false, false, op); } catch (final InvocationTargetException e) { MessageDialog.openError(activeShell, "Error", e.getTargetException().getMessage()); SiriusPlugin.getDefault().error("Error while refreshing table", e); } catch (final InterruptedException e) { MessageDialog.openInformation(activeShell, "Cancelled", e.getMessage()); } } }
From source file:org.eclipse.sirius.table.ui.tools.internal.editor.action.RefreshAction.java
License:Open Source License
@Override public void run() { IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); if (activePage != null) { IEditorPart activeEditor = activePage.getActiveEditor(); if (activeEditor instanceof AbstractDTableEditor) { tableEditor = (AbstractDTableEditor) activeEditor; final IRunnableWithProgress op = new IRunnableWithProgress() { public void run(final IProgressMonitor monitor) { TransactionalEditingDomain domain = tableEditor.getEditingDomain(); domain.getCommandStack().execute( new RefreshRepresentationsCommand(domain, monitor, tableEditor.getTableModel())); }/* w w w . j a v a2 s . c o m*/ }; final Shell activeShell = tableEditor.getSite().getShell(); final ProgressMonitorDialog monitorDialog = new ProgressMonitorDialog(activeShell); try { tableEditor.enablePropertiesUpdate(false); RefreshActionListenerRegistry.INSTANCE .notifyRepresentationIsAboutToBeRefreshed(tableEditor.getTableModel()); monitorDialog.run(true, false, op); } catch (final InvocationTargetException e) { MessageDialog.openError(activeShell, "Error", e.getTargetException().getMessage()); SiriusPlugin.getDefault().error("Error while refreshing table", e); } catch (final InterruptedException e) { MessageDialog.openInformation(activeShell, "Cancelled", e.getMessage()); } finally { tableEditor.enablePropertiesUpdate(true); } } } }