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:kr.co.apexsoft.stella.modeler.explorer.dialog.ApexNavigatorSearchDialog.java
License:Open Source License
protected void launchSearch(final String pattern, final Object[] root) { final boolean caseSensitive = caseButton.getSelection(); ProgressMonitorDialog dialog = new ProgressMonitorDialog(null); try {/* w w w . j a v a 2s . c o m*/ dialog.run(true, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { matchedObjects = searchPattern(pattern, caseSensitive, Arrays.asList(root), monitor); currentIndex = 0; } }); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } }
From source file:LinGUIne.handlers.SaveHandler.java
License:Open Source License
@Execute public void execute(IEclipseContext context, @Named(IServiceConstants.ACTIVE_SHELL) Shell shell, @Named(IServiceConstants.ACTIVE_PART) final MContribution contribution) throws InvocationTargetException, InterruptedException { final IEclipseContext pmContext = context.createChild(); ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell); dialog.open();/*from w w w .ja v a 2 s . c om*/ dialog.run(true, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { pmContext.set(IProgressMonitor.class.getName(), monitor); if (contribution != null) { Object clientObject = contribution.getObject(); ContextInjectionFactory.invoke(clientObject, Persist.class, pmContext, null); } } }); pmContext.dispose(); }
From source file:net.geoprism.shapefile.GISManagerWindow.java
License:Open Source License
@Override public boolean close() { ProgressMonitorDialog dialog = new ProgressMonitorDialog(this.getShell()); try {//ww w.j ava 2 s .c o m IRunnableWithProgress runnable = new ShutdownRunnable(); dialog.run(true, false, runnable); } catch (Throwable e) { this.error(e); return false; } return super.close(); }
From source file:net.heartsome.license.handler.LicenseManageHandler.java
public Object execute(ExecutionEvent event) throws ExecutionException { ProgressMonitorDialog progress = new ProgressMonitorDialog(Display.getDefault().getActiveShell()); try {/*from w ww .j a va 2s .c o m*/ final String[] str = new String[3]; progress.run(true, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException { monitor.beginTask(Messages.getString("license.LicenseManageHandler.progress"), 10); String[] temp = TeSystemResourceUtil.load(monitor); str[0] = temp[0]; str[1] = temp[1]; str[2] = temp[2]; monitor.done(); } }); TeSystemResourceUtil.showDialog(str); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (InterruptedException e) { } return null; }
From source file:net.openchrom.chromatogram.msd.identifier.supplier.cdk.ui.handlers.CalculateSmilesChromatogramHandler.java
License:Open Source License
@Execute public void execute() { if (chromatogramSelection != null) { final Display display = Display.getCurrent(); StatusLineLogger.setInfo(InfoType.MESSAGE, "Start SMILES calculation."); IRunnableWithProgress runnable = new CalculateSmilesChromatogramRunnable(chromatogramSelection); ProgressMonitorDialog monitor = new ProgressMonitorDialog(display.getActiveShell()); try {//from ww w .j ava 2s . c om /* * Use true, true ... instead of false, true ... if the progress bar * should be shown in action. */ monitor.run(true, true, runnable); } catch (InvocationTargetException e) { logger.warn(e); } catch (InterruptedException e) { logger.warn(e); } StatusLineLogger.setInfo(InfoType.MESSAGE, "Done: SMILES calculated."); } }
From source file:net.openchrom.chromatogram.msd.identifier.supplier.cdk.ui.handlers.CalculateSmilesLibraryHandler.java
License:Open Source License
@Execute public void execute() { if (massSpectra != null) { final Display display = Display.getCurrent(); StatusLineLogger.setInfo(InfoType.MESSAGE, "Start SMILES calculation."); IRunnableWithProgress runnable = new CalculateSmilesLibraryRunnable(massSpectra); ProgressMonitorDialog monitor = new ProgressMonitorDialog(display.getActiveShell()); try {//from ww w . j a v a 2 s . com /* * Use true, true ... instead of false, true ... if the progress bar * should be shown in action. */ monitor.run(true, true, runnable); } catch (InvocationTargetException e) { logger.warn(e); } catch (InterruptedException e) { logger.warn(e); } StatusLineLogger.setInfo(InfoType.MESSAGE, "Done: SMILES calculated."); } }
From source file:net.openchrom.chromatogram.msd.identifier.supplier.cdk.ui.handlers.DeleteIdentificationsChromatogramHandler.java
License:Open Source License
@Execute public void execute() { if (chromatogramSelection != null) { /*// w ww .j a v a 2 s .c o m * Ask before deleting the identification entries. */ final Display display = Display.getCurrent(); MessageBox messageBox = new MessageBox(display.getActiveShell(), SWT.ICON_WARNING | SWT.YES | SWT.NO | SWT.CANCEL); messageBox.setText("Delete Identifications"); messageBox.setMessage("Do you really want to delete all identifications without SMILES?"); int decision = messageBox.open(); if (SWT.YES == decision) { /* * Yes, delete. */ StatusLineLogger.setInfo(InfoType.MESSAGE, "Start deleting identifications without SMILES."); IRunnableWithProgress runnable = new DeleteIdentificationsChromatogramRunnable( chromatogramSelection); ProgressMonitorDialog monitor = new ProgressMonitorDialog(display.getActiveShell()); try { /* * Use true, true ... instead of false, true ... if the progress bar * should be shown in action. */ monitor.run(true, true, runnable); } catch (InvocationTargetException e) { logger.warn(e); } catch (InterruptedException e) { logger.warn(e); } StatusLineLogger.setInfo(InfoType.MESSAGE, "Done: All identifications without formula have been removed."); } } }
From source file:net.openchrom.chromatogram.msd.process.supplier.jython.ui.Activator.java
License:Open Source License
@SuppressWarnings("unused") private ObtainInterpreterInfoOperation tryInterpreter(Tuple<String, String> interpreterNameAndExecutable, IInterpreterManager interpreterManager, boolean autoSelectFolders, boolean displayErrors, PrintWriter logger, Shell shell) throws Exception { String executable = interpreterNameAndExecutable.o2; logger.println("- Ok, file is non-null. Getting info on:" + executable); ProgressMonitorDialog monitorDialog = new AsynchronousProgressMonitorDialog(shell); monitorDialog.setBlockOnOpen(false); ObtainInterpreterInfoOperation operation; while (true) { operation = new ObtainInterpreterInfoOperation(interpreterNameAndExecutable.o2, logger, interpreterManager, autoSelectFolders); monitorDialog.run(true, false, operation); if (operation.e != null) { logger.println("- Some error happened while getting info on the interpreter:"); operation.e.printStackTrace(logger); String errorTitle = "Unable to get info on the interpreter: " + executable; if (operation.e instanceof SimpleJythonRunner.JavaNotConfiguredException) { SimpleJythonRunner.JavaNotConfiguredException javaNotConfiguredException = (SimpleJythonRunner.JavaNotConfiguredException) operation.e; if (displayErrors) { ErrorDialog.openError(shell, errorTitle, javaNotConfiguredException.getMessage(), PydevPlugin.makeStatus(IStatus.ERROR, "Java vm not configured.\n", javaNotConfiguredException)); }//w w w .j ava 2s . co m throw new Exception(javaNotConfiguredException); } else if (operation.e instanceof JDTNotAvailableException) { JDTNotAvailableException noJdtException = (JDTNotAvailableException) operation.e; if (displayErrors) { ErrorDialog.openError(shell, errorTitle, noJdtException.getMessage(), PydevPlugin.makeStatus(IStatus.ERROR, "JDT not available.\n", noJdtException)); } throw new Exception(noJdtException); } else { if (displayErrors) { // show the user a message (so that it does not fail silently)... String errorMsg = "Unable to get info on the interpreter: " + executable + "\n\n" + "Common reasons include:\n\n" + "- Using an unsupported version\n" + " (Python and Jython require at least version 2.1 and IronPython 2.6).\n" + "\n" + "- Specifying an invalid interpreter\n" + " (usually a link to the actual interpreter on Mac or Linux)" + ""; ErrorDialog.openError(shell, errorTitle, errorMsg, PydevPlugin.makeStatus(IStatus.ERROR, "See error log for details.", operation.e)); } throw new Exception(operation.e); } } else if (operation.result == null) { // Folder selection was canceled, exit return null; } // Ok, we got the result, so, let's check if things are correct (i.e.: do we have threading.py, traceback.py?) HashSet<String> hashSet = new HashSet<String>(); hashSet.add("threading"); hashSet.add("traceback"); String[] validSourceFiles = FileTypesPreferencesPage.getValidSourceFiles(); Set<String> extensions = new HashSet<String>(Arrays.asList(validSourceFiles)); for (String s : operation.result.libs) { File file = new File(s); if (file.isDirectory()) { String[] directoryFiles = file.list(); if (directoryFiles != null) { for (String found : directoryFiles) { List<String> split = StringUtils.split(found, '.'); if (split.size() == 2) { if (extensions.contains(split.get(1))) { hashSet.remove(split.get(0)); } } } } else { logger.append("Warning: unable to get contents of directory: " + file + " (permission not available, it's not a dir or dir does not exist)."); } } else if (file.isFile()) { // Zip file? try { try (ZipFile zipFile = new ZipFile(file)) { for (String extension : validSourceFiles) { if (zipFile.getEntry("threading." + extension) != null) { hashSet.remove("threading"); } if (zipFile.getEntry("traceback." + extension) != null) { hashSet.remove("traceback"); } } } } catch (Exception e) { // ignore (not zip file) } } } if (hashSet.size() > 0) { if (displayErrors) { // The /Lib folder wasn't there (or at least threading.py and traceback.py weren't found) int choice = PyDialogHelpers.openCriticalWithChoices( "Error: Python stdlib source files not found.", "Error: Python stdlib not found or stdlib found without .py files.\n" + "\n" + "It seems that the Python /Lib folder (which contains the standard library) " + "was not found/selected during the install process or the stdlib does not contain " + "the required .py files (i.e.: only has .pyc files).\n" + "\n" + "This folder (which contains files such as threading.py and traceback.py) is " + "required for PyDev to function properly, and it must contain the actual source files, not " + "only .pyc files. if you don't have the .py files in your install, please use an install from " + "python.org or grab the standard library for your install from there.\n" + "\n" + "If this is a virtualenv install, the /Lib folder from the base install needs to be selected " + "(unlike the site-packages which is optional).\n" + "\n" + "What do you want to do?\n\n" + "Note: if you choose to proceed, the /Lib with the standard library .py source files must " + "be added later on, otherwise PyDev may not function properly.", new String[] { "Re-select folders", "Cancel", "Proceed anyways" }); if (choice == 0) { // Keep on with outer while(true) continue; } if (choice == 1) { // Return nothing and exit quietly on a cancel return null; } } else { // Don't allow auto-selection of an interpreter missing these folders logger.println("- Could not find /Lib folder, exiting with error."); throw new Exception(ERMSG_NOLIBS + executable); } } operation.result.setName(interpreterNameAndExecutable.o1); logger.println("- Success getting the info. Result:" + operation.result); return operation; } }
From source file:net.openchrom.chromatogram.msd.processor.supplier.massshiftdetector.ui.editors.PageIsotopeHeatmap.java
License:Open Source License
public void initialize(Composite parent) { control = new Composite(parent, SWT.NONE); control.setLayout(new GridLayout()); ///*from w w w . java2 s . co m*/ enhancedIsotopeHeatmapEditor = new EnhancedIsotopeHeatmapEditor(control, SWT.NONE); enhancedIsotopeHeatmapEditor.setLayoutData(new GridData(GridData.FILL_BOTH)); enhancedIsotopeHeatmapEditor.setLayout(new GridLayout(1, true)); enhancedIsotopeHeatmapEditor.setBackground(Colors.WHITE); // enhancedIsotopeHeatmapEditor.addPreviousListener(new IPreviousListener() { @Override public void previousAction() { editorProcessor.setActivePage(EditorProcessor.PAGE_INDEX_SETTINGS); } }); // enhancedIsotopeHeatmapEditor.addNextListener(new INextListener() { @Override public void nextAction() { editorProcessor.setActivePage(EditorProcessor.PAGE_INDEX_SHIFT_TABLE); } }); // enhancedIsotopeHeatmapEditor.addProcessListener(new IProcessListener() { @Override public void processAction() { /* * Calculate the shifts. */ editorProcessor.setDirty(true); ProcessorData processorData = editorProcessor.getProcessorData(); if (processorData != null) { Shell shell = Display.getDefault().getActiveShell(); IonCertaintiesCalculatorRunnable runnable = new IonCertaintiesCalculatorRunnable(processorData); ProgressMonitorDialog monitor = new ProgressMonitorDialog(shell); // try { monitor.run(true, true, runnable); } catch (InterruptedException e1) { logger.warn(e1); } catch (InvocationTargetException e1) { logger.warn(e1); } // processorData.setCacluatedIonCertainties(runnable.getCalculatedIonCertainties()); processorData.getProcessorModel().setScanMarker(new ArrayList<IScanMarker>()); } enhancedIsotopeHeatmapEditor.setInput(processorData); } }); }
From source file:net.openchrom.chromatogram.msd.processor.supplier.massshiftdetector.ui.editors.PageSettings.java
License:Open Source License
private ImageHyperlink createCheckHyperlink(Composite client, String text) { Display display = Display.getDefault(); ImageHyperlink imageHyperlink = getFormToolkit().createImageHyperlink(client, SWT.NONE); imageHyperlink.setImage(ApplicationImageFactory.getInstance().getImage(IApplicationImage.IMAGE_CHECK, IApplicationImage.SIZE_16x16)); imageHyperlink.setText(text);/*from ww w . j a va 2s . c o m*/ GridData gridData = new GridData(GridData.FILL_HORIZONTAL); gridData.horizontalIndent = HORIZONTAL_INDENT; imageHyperlink.setLayoutData(gridData); imageHyperlink.addHyperlinkListener(new HyperlinkAdapter() { public void linkActivated(HyperlinkEvent e) { String pathChromatogramReference = referenceChromatogramText.getText().trim(); String pathChromatogramIsotope = isotopeChromatogramText.getText().trim(); ChromatogramImportRunnable runnable = new ChromatogramImportRunnable(pathChromatogramReference, pathChromatogramIsotope); ProgressMonitorDialog monitor = new ProgressMonitorDialog(display.getActiveShell()); // try { monitor.run(true, true, runnable); } catch (InterruptedException e1) { logger.warn(e1); } catch (InvocationTargetException e1) { logger.warn(e1); } // List<IChromatogramSelectionMSD> chromatogramSelections = runnable.getChromatogramSelections(); ProcessorData processorRawData = editorProcessor.getProcessorData(); processorRawData.setReferenceChromatogramSelection(chromatogramSelections.get(0)); processorRawData.setIsotopeChromatogramSelection(chromatogramSelections.get(1)); // display.asyncExec(new Runnable() { @Override public void run() { updateChromatogramSelections(); } }); } }); return imageHyperlink; }