List of usage examples for org.eclipse.jface.dialogs ProgressMonitorDialog ProgressMonitorDialog
public ProgressMonitorDialog(Shell parent)
From source file:de.topicmapslab.onotoa.search.handler.AbstractUseFinderHandler.java
License:Open Source License
/** * @param shell/* ww w . j a v a 2 s .co m*/ * @param tt */ protected void startSearch(Shell shell, TopicType tt) { ProgressMonitorDialog dlg = new ProgressMonitorDialog(shell); try { FindRunnable runnable = new FindRunnable(tt); dlg.run(false, false, runnable); ResultDialog resultDlg = new ResultDialog(shell, tt); resultDlg.setInput(runnable.getResult()); resultDlg.open(); } catch (Exception e) { throw new RuntimeException(e); } }
From source file:de.topicmapslab.tmcledit.tmclimport.wizards.ImportWizard.java
License:Open Source License
public boolean performFinish() { ProgressMonitorDialog monitorDlg = new ProgressMonitorDialog(getShell()); monitorDlg.setCancelable(false);/*from ww w .j a va2 s.co m*/ try { monitorDlg.run(false, false, new LoaderRunnable()); } catch (Exception e) { Activator.logException(e); MessageDialog.openError(getShell(), "Error while importing schema", "An error occurred:" + e.getMessage() + "[" + e.getClass().getName() + "]"); } return true; }
From source file:de.tub.tfs.muvitor.ui.MuvitorTreeEditor.java
License:Open Source License
/** * This method will create an {@link EMFModelManager} that handles loading * and saving to the file the passed {@link IEditorInput} relies on. If * loading fails (possibly because we created a file with the creation * wizard) we create a new default model and put it to the file resource. * //from w w w . java2 s .c o m * @see #createDefaultModel() * @see org.eclipse.ui.part.EditorPart#setInput(org.eclipse.ui.IEditorInput) */ @Override protected void setInput(final IEditorInput input) { super.setInput(input); final IFile file = ((IFileEditorInput) input).getFile(); setPartName(file.getName()); setContentDescription(file.getName()); /* * This must be called before trying to load the model, so that the EMF * package has been initialized. */ final List<EObject> defaultModels = createDefaultModels(); for (final EObject defaultModel : defaultModels) { defaultModel.eClass().getEPackage(); } ProgressMonitorDialog dialog = new ProgressMonitorDialog(Display.getCurrent().getActiveShell()); try { dialog.run(false, true, new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { int lines = 0; try { BufferedReader r = new BufferedReader(new FileReader(file.getRawLocation().toFile())); while (r.ready()) { r.readLine(); lines++; } } catch (FileNotFoundException e) { lines = -1; } catch (IOException e) { lines = -1; } modelManager.setMonitor(monitor); monitor.beginTask("loading Ecore Model", lines); Thread t = new Thread() { @Override public void run() { modelRoots = new ArrayList<EObject>( modelManager.load(file.getFullPath(), defaultModels)); super.run(); } }; t.start(); while (t.isAlive()) { if (!Display.getCurrent().readAndDispatch()) Thread.sleep(20); } if (modelRoots == null || modelRoots.isEmpty()) { MuvitorActivator.logError( "The loaded or created model is corrupt and no default model could be created!", null); } // register the root model ID with the editor in the IDUtil IDUtil.registerEditor(MuvitorTreeEditor.this); monitor.done(); } }); } catch (InvocationTargetException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:de.tud.cs.st.vespucci.vespucci_model.presentation.Vespucci_modelEditor.java
License:Open Source License
/** * This is for implementing {@link IEditorPart} and simply saves the model file. * <!-- begin-user-doc -->//from ww w. j a v a 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. // VespucciEditorPlugin.INSTANCE.log(exception); } updateProblemIndication = true; updateProblemIndication(); }
From source file:de.tukl.cs.softech.agilereview.views.reviewexplorer.handler.CleanupHandler.java
License:Open Source License
@Override public Object execute(ExecutionEvent event) throws ExecutionException { IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getActiveMenuSelection(event); Object firstElement = selection.getFirstElement(); if (firstElement instanceof MultipleReviewWrapper) { MultipleReviewWrapper reviewWrapper = ((MultipleReviewWrapper) firstElement); if (!checkReviewOpen(event, reviewWrapper)) { return null; }//from w ww . java 2 s. c o m // ask user whether to delete comments and tags or only tags boolean deleteComments = true; MessageBox messageDialog = new MessageBox(HandlerUtil.getActiveShell(event), SWT.ICON_QUESTION | SWT.YES | SWT.NO | SWT.CANCEL); messageDialog.setText("AgileReview Cleanup"); messageDialog.setMessage("Delete comments? Otherwise they will be converted to global comments!"); int result = messageDialog.open(); if (result == SWT.CANCEL) { // cancel selected -> quit method return null; } else if (result == SWT.NO) { deleteComments = false; } // get selected project try { ProgressMonitorDialog pmd = new ProgressMonitorDialog(HandlerUtil.getActiveShell(event)); pmd.open(); pmd.run(true, false, new CleanupProcess(reviewWrapper.getWrappedReview(), deleteComments)); pmd.close(); } catch (InvocationTargetException e) { PluginLogger.logError(this.getClass().toString(), "execute", "InvocationTargetException", e); MessageDialog.openError(HandlerUtil.getActiveShell(event), "Error while performing cleanup", "An Eclipse internal error occured!\nRetry and please report the bug to the AgileReview team when it occurs again.\nCode:1"); } catch (InterruptedException e) { PluginLogger.logError(this.getClass().toString(), "execute", "InterruptedException", e); MessageDialog.openError(HandlerUtil.getActiveShell(event), "Error while performing cleanup", "An Eclipse internal error occured!\nRetry and please report the bug to the AgileReview team when it occurs again.\nCode:2"); } } if (ViewControl.isOpen(CommentTableView.class)) { CommentTableView.getInstance().reparseAllEditors(); } ViewControl.refreshViews(ViewControl.COMMMENT_TABLE_VIEW | ViewControl.REVIEW_EXPLORER, true); return null; }
From source file:de.unistuttgart.ipvs.pmp.editor.ui.editors.internals.ServerProviderDialogWrapper.java
License:Apache License
/** * Updates the {@link RGIS} list from the server, while downloading a {@link ProgressMonitorDialog} is displayed * //from w w w .j a va 2s . c om * @param shell * {@link Shell} to display the {@link ProgressMonitorDialog} */ public void updateServerListWithDialog(final Shell shell) { // Create the dialog ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell); try { // Run the dialog, not cancelable because the timeout is set to 1000 dialog.run(true, false, new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { // Start the task monitor.beginTask(I18N.general_rgdownloaddialog_task, 2); ServerProvider server = ServerProvider.getInstance(); try { // Refresh the list server.updateResourceGroupList(); monitor.worked(1); ServerProviderDialogWrapper.this.rgisList = server.getAvailableRessourceGroups(); monitor.done(); } catch (final IOException e) { // Show the error message in an asyncExectuable Display.getDefault().asyncExec(new Thread(new Runnable() { @Override public void run() { IStatus status = new Status(IStatus.ERROR, "PROGRESS_DIALOG", //$NON-NLS-1$ I18N.general_seedetails, e); ErrorDialog.openError(shell, I18N.general_rgdownloaddialog_downloaderror_title, I18N.general_rgdownloaddialog_downloaderror_text, status); } })); } } }); } catch (InvocationTargetException e) { IStatus status = new Status(IStatus.ERROR, "PROGRESS_DIALOG", I18N.general_seedetails, e); //$NON-NLS-1$ ErrorDialog.openError(shell, I18N.general_rgdownloaddialog_downloaderror_title, I18N.general_rgdownloaddialog_downloaderror_text, status); } catch (InterruptedException e) { IStatus status = new Status(IStatus.ERROR, "PROGRESS_DIALOG", I18N.general_seedetails, e); //$NON-NLS-1$ ErrorDialog.openError(shell, I18N.general_rgdownloaddialog_downloaderror_title, I18N.general_rgdownloaddialog_downloaderror_text, status); } }
From source file:de.uni_hildesheim.sse.qmApp.editors.ClassEditor.java
License:Apache License
/** * Create progress Dialog.//from w w w . j a v a 2 s . c om * * @param parent parent composite. * @param artifact The artifacts name. * @param isHardware If true only the master artifact will be downloaded and information from manifest * will be used. */ public static void createProgressDialog(Composite parent, String artifact, boolean isHardware) { try { ProgressMonitorDialog pmd = new ProgressMonitorDialog(parent.getShell()) { @Override protected void setShellStyle(int newShellStyle) { super.setShellStyle(SWT.CLOSE | SWT.INDETERMINATE | SWT.BORDER | SWT.TITLE); setBlockOnOpen(false); } }; ProgressDialogOperation pdo = new ProgressDialogOperation(); pdo.artifact = artifact; pdo.isHardware = isHardware; pmd.run(true, true, pdo); } catch (final InvocationTargetException e) { Throwable exc = e; if (null != e.getCause()) { exc = e.getCause(); } MessageDialog.openError(parent.getShell(), "Error", "Error: " + exc.getMessage()); e.printStackTrace(); } catch (final InterruptedException e) { MessageDialog.openInformation(parent.getShell(), "Cancelled", "Error: "); e.printStackTrace(); } }
From source file:de.walware.ecommons.emf.ui.forms.EFEditor.java
License:Open Source License
/** * This is for implementing {@link IEditorPart} and simply saves the model file. * <!-- begin-user-doc -->// w ww .ja v a2 s. c o m * <!-- end-user-doc --> * @generated */ @Override public void doSave(final IProgressMonitor progressMonitor) { if (getEditorInput() instanceof DirectResourceEditorInput && fEditingDomain.getResourceSet().getResources() .get(0).getURI().equals(DirectResourceEditorInput.NO_URI)) { doSaveAs(); return; } // 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(XMLResource.OPTION_ENCODING, "UTF-8"); //$NON-NLS-1$ // Do the work within an operation because this is a long running activity that modifies the workbench final WorkspaceModifyOperation operation = new WorkspaceModifyOperation() { // This is the method that gets invoked when the operation runs @Override public void execute(final IProgressMonitor monitor) { // Save the resources to the file system boolean first = true; for (final Resource resource : fEditingDomain.getResourceSet().getResources()) { if ((first || !resource.getContents().isEmpty() || isPersisted(resource)) && !fEditingDomain.isReadOnly(resource)) { try { final long timeStamp = resource.getTimeStamp(); resource.save(saveOptions); if (resource.getTimeStamp() != timeStamp) { fResourceListener.fSavedResources.add(resource); } } catch (final Exception exception) { fResourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception)); } first = false; } } } }; fUpdateProblemIndication = false; try { // This runs the options, and shows progress new ProgressMonitorDialog(getSite().getShell()).run(true, false, operation); // Refresh the necessary state ((BasicCommandStack) fEditingDomain.getCommandStack()).saveIsDone(); firePropertyChange(IEditorPart.PROP_DIRTY); } catch (final Exception e) { // Something went wrong that shouldn't operationFailed("saving config", e); //$NON-NLS-1$ } fUpdateProblemIndication = true; updateProblemIndication(); }
From source file:de.walware.statet.r.internal.console.ui.launching.RRemoteConsoleSelectionDialog.java
License:Open Source License
private void update() { final String input = fHostAddressControl.getText(); fRServerList = null;// ww w . j a v a 2s . c om final AtomicReference<IStatus> status = new AtomicReference<IStatus>(); if (input != null && input.length() > 0) { try { new ProgressMonitorDialog(getShell()).run(true, true, new IRunnableWithProgress() { @Override public void run(final IProgressMonitor monitor) throws InvocationTargetException { status.set(updateRServerList(input, monitor)); } }); } catch (final InvocationTargetException e) { // not used } catch (final InterruptedException e) { fRServerViewer = null; status.compareAndSet(null, Status.CANCEL_STATUS); } } if (status.get() != null) { updateStatus(status.get()); } getOkButton().setEnabled(false); if (fRServerList != null && fRServerList.size() > 0) { if (!fSpecialAddress.containsKey(input)) { fHistoryAddress.remove(input); fHistoryAddress.add(0, input); } if (fFilterOnlyRunning) { for (final Iterator<RemoteR> iter = fRServerList.iterator(); iter.hasNext();) { switch (iter.next().info.getState()) { case Server.S_NOT_STARTED: case Server.S_STOPPED: iter.remove(); } } } updateInput(); return; } else { fRServerViewer.setInput(null); } }
From source file:demo.handler.ExportTableHandler.java
License:Open Source License
@Override public Object execute(ExecutionEvent event) throws ExecutionException { IWorkbenchPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart(); if (!(part instanceof ARcpRankTableDemoView)) { return null; }//from w w w. j a v a 2 s. c o m RankTableModel table = ((ARcpRankTableDemoView) part).getTable(); if (table == null) return null; FileDialog fileDialog = new FileDialog(new Shell(), SWT.SAVE); fileDialog.setText("Export Table"); String[] filterExt = { "*.csv" }; fileDialog.setFilterExtensions(filterExt); String filePath = "lineup-table_" + new SimpleDateFormat("yyyy.MM.dd_HH.mm").format(new Date()) + ".csv"; fileDialog.setFileName(filePath); final String fileName = fileDialog.open(); if (fileName == null) return null; try { new ProgressMonitorDialog(Display.getCurrent().getActiveShell()).run(true, false, new ExportTable(table, new File(fileName))); } catch (InvocationTargetException | InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; }