Example usage for org.eclipse.jface.dialogs ProgressMonitorDialog run

List of usage examples for org.eclipse.jface.dialogs ProgressMonitorDialog run

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs ProgressMonitorDialog run.

Prototype

@Override
public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable)
        throws InvocationTargetException, InterruptedException 

Source Link

Document

This implementation of IRunnableContext#run(boolean, boolean, IRunnableWithProgress) runs the given IRunnableWithProgress using the progress monitor for this progress dialog and blocks until the runnable has been run, regardless of the value of fork.

Usage

From source file:net.openchrom.chromatogram.msd.processor.supplier.massshiftdetector.ui.swt.EnhancedScanMarkerEditor.java

License:Open Source License

private void calculateScanMarker(Shell shell) {

    ProcessorData processorData = editorProcessor.getProcessorData();
    ScanMarkerDetectorRunnable runnable = new ScanMarkerDetectorRunnable(processorData);
    ProgressMonitorDialog monitor = new ProgressMonitorDialog(shell);
    ////from  w w w  . jav a2 s.  c om
    try {
        monitor.run(true, true, runnable);
    } catch (InterruptedException e1) {
        logger.warn(e1);
    } catch (InvocationTargetException e1) {
        logger.warn(e1);
    }
    //
    List<IScanMarker> scanMarker = runnable.getScanMarker();
    processorData.getProcessorModel().setScanMarker(scanMarker);
    scanMarkerListUI.setInput(scanMarker);
    if (scanMarker.size() > 0) {
        scanMarkerListUI.getTable().select(0);
    }
    updateMassShiftList();
    updateComparisonViews();
    setScanMarkerInfoLabel(scanMarker.size());
}

From source file:net.openchrom.chromatogram.msd.processor.supplier.massshiftdetector.ui.swt.EnhancedScanMarkerEditor.java

License:Open Source License

private Button createSaveButton(Composite parent, GridData gridData) {

    Shell shell = Display.getDefault().getActiveShell();
    ////from   www .  j av  a 2  s .  c  o  m
    Button button = new Button(parent, SWT.PUSH);
    button.setText("Save");
    button.setImage(ApplicationImageFactory.getInstance().getImage(IApplicationImage.IMAGE_SAVE,
            IApplicationImage.SIZE_16x16));
    button.setLayoutData(gridData);
    button.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {

            ProgressMonitorDialog monitor = new ProgressMonitorDialog(shell);
            try {
                monitor.run(true, true, new IRunnableWithProgress() {

                    @Override
                    public void run(IProgressMonitor monitor)
                            throws InvocationTargetException, InterruptedException {

                        editorProcessor.doSave(monitor);
                    }
                });
            } catch (InvocationTargetException e1) {
                logger.warn(e1);
            } catch (InterruptedException e1) {
                logger.warn(e1);
            }
        }
    });
    return button;
}

From source file:net.openchrom.chromatogram.xxd.baseline.detector.supplier.tic.ui.handlers.DetectorHandler.java

License:Open Source License

@Execute
public void execute(@Named(IServiceConstants.ACTIVE_PART) MPart part) {

    /*/* w w w .j  av a  2 s .c o m*/
     * Try to select and show the perspective and view.
     */
    PerspectiveSwitchHandler.focusPerspectiveAndView(IPerspectiveAndViewIds.PERSPECTIVE_MSD,
            IPerspectiveAndViewIds.VIEW_BASELINE);
    /*
     * Get the actual cursor, create a new wait cursor and show the wait
     * cursor.<br/> Show the origin cursor when finished.<br/> Use the
     * Display.asyncExec instances to show the messages properly.<br/> I
     * really don't like the GUI stuff, maybe there is a smarter way to
     * inform the user.<br/> So, i thought also on Eclipse "jobs", but there
     * will be problems, when the operation method updates the
     * chromatogramSelection.<br/> A progress bar would be also applicable,
     * but the IProgressMonitorDialog (monitor.beginTask(TASK_NAME,
     * IProgressMonitor.UNKNOWN) didn't showed a progress under linux.
     */
    if (chromatogramSelection != null) {
        final Display display = Display.getCurrent();
        StatusLineLogger.setInfo(InfoType.MESSAGE, "Start TIC Baseline Detector");
        IRunnableWithProgress runnable = new BaselineDetectorRunnable(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: Baseline detected");
    }
}

From source file:net.openchrom.chromatogram.xxd.filter.supplier.meannormalizer.ui.handlers.FilterHandler.java

License:Open Source License

@Execute
public void execute(@Named(IServiceConstants.ACTIVE_PART) MPart part) {

    /*//from  w ww  .  j a  va 2s  .c o  m
     * Get the actual cursor, create a new wait cursor and show the wait
     * cursor.<br/> Show the origin cursor when finished.<br/> Use the
     * Display.asyncExec instances to show the messages properly.<br/> I
     * really don't like the GUI stuff, maybe there is a smarter way to
     * inform the user.<br/> So, i thought also on Eclipse "jobs", but there
     * will be problems, when the operation method updates the
     * chromatogramSelection.<br/> A progress bar would be also applicable,
     * but the IProgressMonitorDialog (monitor.beginTask(TASK_NAME,
     * IProgressMonitor.UNKNOWN) didn't showed a progress under linux.
     */
    if (chromatogramSelection != null) {
        final Display display = Display.getCurrent();
        StatusLineLogger.setInfo(InfoType.MESSAGE, "Start Filter Mean Normalizer");
        /*
         * Do the operation.<br/> Open a progress monitor dialog.
         */
        IRunnableWithProgress runnable = new FilterModifier(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, "Filter Mean Normalizer finished");
    }
}

From source file:net.openchrom.chromatogram.xxd.filter.supplier.normalizer.ui.handlers.FilterHandler.java

License:Open Source License

@Execute
public void execute(@Named(IServiceConstants.ACTIVE_PART) MPart part) {

    /*/*from   ww  w  .j  a  v a  2 s  .c  o m*/
     * Get the actual cursor, create a new wait cursor and show the wait
     * cursor.<br/> Show the origin cursor when finished.<br/> Use the
     * Display.asyncExec instances to show the messages properly.<br/> I
     * really don't like the GUI stuff, maybe there is a smarter way to
     * inform the user.<br/> So, i thought also on Eclipse "jobs", but there
     * will be problems, when the operation method updates the
     * chromatogramSelection.<br/> A progress bar would be also applicable,
     * but the IProgressMonitorDialog (monitor.beginTask(TASK_NAME,
     * IProgressMonitor.UNKNOWN) didn't showed a progress under linux.
     */
    if (chromatogramSelection != null) {
        final Display display = Display.getCurrent();
        StatusLineLogger.setInfo(InfoType.MESSAGE, "Start Filter Normalizer");
        /*
         * Do the operation.<br/> Open a progress monitor dialog.
         */
        IRunnableWithProgress runnable = new FilterModifier(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, "Filter Normalizer finished");
    }
}

From source file:net.openchrom.chromatogram.xxd.filter.supplier.unitsumnormalizer.ui.handlers.FilterHandler.java

License:Open Source License

@Execute
public void execute(@Named(IServiceConstants.ACTIVE_PART) MPart part) {

    /*//from w  w  w  .  j  a  v a 2s .  c o m
     * Get the actual cursor, create a new wait cursor and show the wait
     * cursor.<br/> Show the origin cursor when finished.<br/> Use the
     * Display.asyncExec instances to show the messages properly.<br/> I
     * really don't like the GUI stuff, maybe there is a smarter way to
     * inform the user.<br/> So, i thought also on Eclipse "jobs", but there
     * will be problems, when the operation method updates the
     * chromatogramSelection.<br/> A progress bar would be also applicable,
     * but the IProgressMonitorDialog (monitor.beginTask(TASK_NAME,
     * IProgressMonitor.UNKNOWN) didn't showed a progress under linux.
     */
    if (chromatogramSelection != null) {
        final Display display = Display.getCurrent();
        StatusLineLogger.setInfo(InfoType.MESSAGE, "Start Unit Sum Normalizer Filter");
        /*
         * Do the operation.<br/> Open a progress monitor dialog.
         */
        IRunnableWithProgress runnable = new FilterModifier(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, "Unit Sum Normalizer Filter finished");
    }
}

From source file:net.openchrom.chromatogram.xxd.process.supplier.alignment.ui.editors.EditorAlignment.java

License:Open Source License

public void calculateAlignment() {

    dirtyable.setDirty(true);/*  w ww  . j  av a2s  . c o m*/
    List<IDataInputEntry> dataInputEntries = pageInputFiles.getDataInputEntries();
    /*
     * Run the process.
     */
    IAlignmentSettings alignmentSettings = new AlignmentSettings();
    alignmentSettings.getAlignmentRanges().clear();
    alignmentSettings.getAlignmentRanges().addAll(pageProcessingWindows.getAlignmentRanges());
    CalculateAlignmentRunnable runnable = new CalculateAlignmentRunnable(dataInputEntries, alignmentSettings);
    ProgressMonitorDialog monitor = new ProgressMonitorDialog(Display.getCurrent().getActiveShell());
    try {
        /*
         * Calculate the results and show the score plot page.
         */
        monitor.run(true, true, runnable);
        //
        List<IChromatogramSelection> chromatogramSelectionsRaw = new ArrayList<IChromatogramSelection>();
        List<IChromatogramSelection> chromatogramSelectionsShifted = new ArrayList<IChromatogramSelection>();
        //
        alignmentResults = runnable.getAlignmentResults();
        Map<ISample, IAlignmentResult> alignmentResultMap = alignmentResults.getAlignmentResultMap();
        for (Entry<ISample, IAlignmentResult> entry : alignmentResultMap.entrySet()) {
            IAlignmentResult alignmentResult = entry.getValue();
            try {
                chromatogramSelectionsRaw
                        .add(new ChromatogramSelection(alignmentResult.getTicBeforeAlignment()));
                chromatogramSelectionsShifted
                        .add(new ChromatogramSelection(alignmentResult.getTicAfterAlignment()));
            } catch (Exception e) {
                logger.warn(e);
            }
        }
        /*
         * Show the results.
         */
        pageResults.setChromatogramData(chromatogramSelectionsRaw, chromatogramSelectionsShifted);
        //
        reloadResults();
        reloadProcessingWindows();
    } catch (InvocationTargetException e) {
        logger.warn(e);
        logger.warn(e.getCause());
    } catch (InterruptedException e) {
        logger.warn(e);
    }
}

From source file:net.openchrom.chromatogram.xxd.process.supplier.alignment.ui.editors.EditorAlignment.java

License:Open Source License

public void applyAlignment() {

    List<IDataInputEntry> dataInputEntries = pageInputFiles.getDataInputEntries();
    IAlignmentSettings alignmentSettings = new AlignmentSettings();
    // IAlignmentResults alignmentResults = new AlignmentResults();
    alignmentSettings.getAlignmentRanges().clear();
    alignmentSettings.getAlignmentRanges().addAll(pageProcessingWindows.getAlignmentRanges());
    ApplyAlignmentRunnable runnable = new ApplyAlignmentRunnable(dataInputEntries, alignmentSettings,
            this.alignmentResults);
    ProgressMonitorDialog monitor = new ProgressMonitorDialog(Display.getCurrent().getActiveShell());
    try {//from  w ww. j a va  2 s. co m
        /*
         * Apply the results and save the files.
         */
        monitor.run(true, true, runnable);
        //
    } catch (InvocationTargetException e) {
        logger.warn(e);
        logger.warn(e.getCause());
    } catch (InterruptedException e) {
        logger.warn(e);
    }
}

From source file:net.openchrom.xxd.processor.supplier.tracecompare.ui.swt.EnhancedResultsEditor.java

License:Open Source License

private Button createSaveButton(Composite parent, GridData gridData) {

    Shell shell = Display.getDefault().getActiveShell();
    ////from   ww  w . java 2s  .  c  o m
    Button button = new Button(parent, SWT.PUSH);
    button.setText("Save");
    button.setImage(ApplicationImageFactory.getInstance().getImage(IApplicationImage.IMAGE_SAVE,
            IApplicationImage.SIZE_16x16));
    button.setLayoutData(gridData);
    button.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {

            ProgressMonitorDialog monitor = new ProgressMonitorDialog(shell);
            try {
                monitor.run(true, true, new IRunnableWithProgress() {

                    @Override
                    public void run(IProgressMonitor monitor)
                            throws InvocationTargetException, InterruptedException {

                        Display.getDefault().asyncExec(new Runnable() {

                            @Override
                            public void run() {

                                editorProcessor.doSave(monitor);
                            }
                        });
                    }
                });
            } catch (InvocationTargetException e1) {
                logger.warn(e1);
            } catch (InterruptedException e1) {
                logger.warn(e1);
            }
        }
    });
    return button;
}

From source file:net.openchrom.xxd.processor.supplier.tracecompare.ui.swt.TraceCompareEditorUI.java

License:Open Source License

private Map<Integer, Map<String, ISeriesData>> extractMeasurementsData(List<File> measurementFiles) {

    Map<Integer, Map<String, ISeriesData>> measurementsData = new HashMap<Integer, Map<String, ISeriesData>>();
    ///*from w  w w  .j  a  va  2s  .com*/
    MeasurementImportRunnable runnable = new MeasurementImportRunnable(measurementFiles);
    ProgressMonitorDialog monitor = new ProgressMonitorDialog(Display.getDefault().getActiveShell());
    try {
        monitor.run(true, true, runnable);
    } catch (InterruptedException e1) {
        logger.warn(e1);
    } catch (InvocationTargetException e1) {
        logger.warn(e1);
    }
    //
    ISeriesData seriesData;
    //
    List<IChromatogramWSD> measurements = runnable.getMeasurements();
    for (IChromatogram measurement : measurements) {
        /*
         * Track 1
         */
        int index = 1;
        seriesData = extractMeasurement(measurement);
        addMeasurementData(measurementsData, seriesData, index++);
        /*
         * Track 2 ... n
         */
        for (IChromatogram additionalMeasurement : measurement.getReferencedChromatograms()) {
            seriesData = extractMeasurement(additionalMeasurement);
            addMeasurementData(measurementsData, seriesData, index++);
        }
    }
    //
    return measurementsData;
}