List of usage examples for org.eclipse.jface.dialogs ProgressMonitorDialog ProgressMonitorDialog
public ProgressMonitorDialog(Shell parent)
From source file:edu.toronto.cs.se.modelepedia.relationaldatabase.presentation.RelationalDatabaseEditor.java
License:Open Source License
/** * This is for implementing {@link IEditorPart} and simply saves the model file. * <!-- begin-user-doc -->/* w w w.j a v a 2 s . 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. // RelationalDatabaseEditorPlugin.INSTANCE.log(exception); } updateProblemIndication = true; updateProblemIndication(); }
From source file:edu.toronto.cs.se.modelepedia.relationaldatabase_mavo.presentation.RelationalDatabase_MAVOEditor.java
License:Open Source License
/** * This is for implementing {@link IEditorPart} and simply saves the model file. * <!-- begin-user-doc -->// w w w .ja v a 2 s. c om * <!-- 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. // RelationalDatabase_MAVOEditorPlugin.INSTANCE.log(exception); } updateProblemIndication = true; updateProblemIndication(); }
From source file:edu.toronto.cs.se.modelepedia.statemachine.presentation.StateMachineEditor.java
License:Open Source License
/** * This is for implementing {@link IEditorPart} and simply saves the model file. * <!-- begin-user-doc -->//from w ww. j a v a2s .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); 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. // StateMachineEditorPlugin.INSTANCE.log(exception); } updateProblemIndication = true; updateProblemIndication(); }
From source file:edu.toronto.cs.se.modelepedia.statemachine_mavo.presentation.StateMachine_MAVOEditor.java
License:Open Source License
/** * This is for implementing {@link IEditorPart} and simply saves the model file. * <!-- begin-user-doc -->//from w w w . jav a2 s. 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); 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. // StateMachine_MAVOEditorPlugin.INSTANCE.log(exception); } updateProblemIndication = true; updateProblemIndication(); }
From source file:edu.toronto.cs.se.modelepedia.tutorial.army.presentation.ArmyEditor.java
License:Open Source License
/** * This is for implementing {@link IEditorPart} and simply saves the model file. * <!-- begin-user-doc -->/*from w w w.jav a2 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. // ArmyEditorPlugin.INSTANCE.log(exception); } updateProblemIndication = true; updateProblemIndication(); }
From source file:edu.toronto.cs.se.modelepedia.tutorial.economy.presentation.EconomyEditor.java
License:Open Source License
/** * This is for implementing {@link IEditorPart} and simply saves the model file. * <!-- begin-user-doc -->//w w w . j a va2 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); 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. // EconomyEditorPlugin.INSTANCE.log(exception); } updateProblemIndication = true; updateProblemIndication(); }
From source file:edu.toronto.cs.se.modelepedia.tutorial.state.presentation.StateEditor.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 .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); 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. // StateEditorPlugin.INSTANCE.log(exception); } updateProblemIndication = true; updateProblemIndication(); }
From source file:edu.tsinghua.lumaqq.ui.InfoManagerWindow.java
License:Open Source License
protected void onSearch() { records.clear();/* w w w .ja v a2 s. c o m*/ if (scope == 0) { // ? try { ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell()); dialog.run(true, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { RecordManager rm = main.getRecordManager(); monitor.beginTask("Searching...", scopes.size()); for (Object obj : scopes) { int scope; if (obj instanceof User) scope = ((User) obj).qq; else scope = ((Cluster) obj).clusterId; records.addAll( rm.search(scope, IKeyConstants.ALL, IKeyConstants.SUB_ALL, keyword, false, 0)); monitor.worked(1); if (monitor.isCanceled()) break; } monitor.done(); } }); } catch (InvocationTargetException e) { } catch (InterruptedException e) { } } else { records.clear(); records.addAll(searchOne(scope)); } RecordManager rm = main.getRecordManager(); if (records.isEmpty()) pageCount = 0; else pageCount = (records.size() + rm.getPageSize() - 1) / rm.getPageSize(); pageNum = 0; if (pageCount > 0) lblPage.setText(NLS.bind(info_page, String.valueOf(pageNum + 1), String.valueOf(pageCount))); else lblPage.setText(""); recordViewer.refresh(); refreshRichBox(null); resetNavigator(); }
From source file:edu.tum.cs.conqat.inspection.cm.presentation.CmEditor.java
License:Apache License
/** * This is for implementing {@link IEditorPart} and simply saves the model file. * <!-- begin-user-doc -->/*from www. j ava 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. // CmEditorPlugin.INSTANCE.log(exception); } updateProblemIndication = true; updateProblemIndication(); }
From source file:edu.umd.cs.eclipse.courseProjectManager.CVSOperations.java
License:Apache License
/** * Run a CVS operation synchronously (in the context of the current thread), * in a progress dialog or workbench status bar. Displays an error dialog if * the CVS operation does not complete successfully. * <p>//from w w w .j av a 2s. c o m * <b> NOTE: </b> I'm not sure this method works for adding files because it * keeps raising org.eclipse.swt.SWTException: Invalid thread access (error * code = 22 (ERROR_THREAD_INVALID_ACCESS)), which means that the wrong * thread is trying to do something. * * @param runnable * the operation * @param how * IN_STATUS_BAR to request running using the status bar, * IN_DIALOG to request running in a progress dialog * @param context * the OperationContext * @throws InvocationTargetException * @throws InterruptedException */ private static void syncExec(final Operation cvsOp, final int how, final OperationContext context) { // The Operation context, if present, may veto this entire operation. // This generally means that a previous asynchronously scheduled // operation // failed. final IWorkbenchWindow wwin = AutoCVSPlugin.getActiveWorkbenchWindow(); final Shell parent = (wwin != null) ? wwin.getShell() : null; try { Debug.print("syncExec: " + cvsOp.getOperationName() + " " + cvsOp.getMessage() + " " + Thread.currentThread().getName()); if (context != null && !context.operationMayProceed()) { Debug.print("Context is vetoing the following operation: " + cvsOp.getOperationName()); return; } // NOTE that the current plugin never uses the BUSY_INDICATOR option if (how == BUSY_INDICATOR) { Debug.print("BUSY_INDICATOR\n"); Runnable task = new Runnable() { public void run() { try { cvsOp.execute(null, null); } catch (Exception e) { // TODO what to do when BusyIndicator handles an // exception? System.err.println("Exception! " + e); } } }; org.eclipse.swt.custom.BusyIndicator.showWhile(null, task); return; } ISchedulingRule rule; IResource[] resources = cvsOp.getResources(); if (false && resources.length == 1) rule = resources[0]; else rule = cvsOp.getProject(); rule = ResourcesPlugin.getWorkspace().getRoot(); // Wrap the Operation in a WorkspaceModifyOperation WorkspaceModifyOperation runnable = new WorkspaceModifyOperation(rule) { protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException { try { monitor.setTaskName(cvsOp.getOperationName()); cvsOp.execute(parent, monitor); } finally { monitor.done(); } } }; try { if (how == IN_STATUS_BAR) { boolean bail = false; Debug.print("IN_STATUS_BAR"); if (false) for (StackTraceElement element : new RuntimeException().getStackTrace()) { if (element.getClassName() .equals("org.eclipse.jface.operation.ModalContext$ModalContextThread") && element.getMethodName().equals("block")) { Debug.print("invocation of " + cvsOp.getOperationName() + " since we are being invoked from a model context"); System.out.println("invocation of " + cvsOp.getOperationName() + " since we are being invoked from a model context"); bail = true; } } if (!bail && wwin != null) { // wwin.run(false, true, runnable); wwin.run(true, true, runnable); if (context != null) context.success(parent); return; } } // A modal progress dialog is the fall back for the // case where we can't get a handle on the workbench window. Debug.print("modal progress dialog rather than IN_STATUS_BAR"); System.out.println("modal progress dialog rather than IN_STATUS_BAR"); ProgressMonitorDialog dialog = new ProgressMonitorDialog(null); try { dialog.run(false, true, runnable); } catch (SWTException e) { System.out.println("Error code: " + e.code); if (e.getCause() != null) System.out.println("Cause: " + e.getCause()); else System.out.println("Cause is null!"); throw e; } context.success(parent); return; } catch (Throwable e) { Debug.print("Exception thrown by runnable"); // Failed operation! if (context != null) context.failure(parent); Debug.print("Exception, about to call parseStatus(): ", e); // Attempt to figure out the reason for the failure from the // exception. int statusCode = parseStatus(e); // Build a detailed message describing the failure and its // consequences. StringBuffer msg = new StringBuffer(); msg.append("The following operation failed: " + cvsOp.getOperationName()); String consequenceMessage = null; if (context != null) consequenceMessage = context.getConsequenceMessage(statusCode); if (consequenceMessage != null) { msg.append("\n\n"); msg.append(consequenceMessage); } if (AutoCVSPlugin.getPlugin().hasFailedOperation()) { // Add the generic message about how automatic CVS commands // are disabled. msg.append("\n\n"); msg.append(AutoCVSPlugin.getMessage("error.offline")); } // Alert the user. Dialogs.errorDialog(parent, "Warning: " + cvsOp.getOperationName() + " failed", msg.toString(), e); if (context != null) context.failure(parent); else Debug.print("context is null!"); } } catch (RuntimeException e) { Dialogs.errorDialog(parent, "Warning: runtime exception during " + cvsOp.getOperationName() + " failed", e.getMessage(), e); throw e; } }