Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [chemclipse-dev] What is the proper way to update the ChromatogramEditorMSD?

Trig,

I've added some demo code to your controller. It works now. Please pull the changes.
cn.edu.xmu.tidems.control.ui.usb9982.ADCardUSB9982ControlView

Effectively, your desired functionality can be achieved by the following code:

...
    private class ActiveAnalysis implements Runnable {

        private boolean acquireData = false;

        public void startAnalysis() {

            acquireData = true;
        }

        public void stopAnalysis() {

            acquireData = false;
        }

        @Override
        public void run() {

            if(acquireData && chromatogramSelection != null) {
                display.timerExec(1000, this);
                chromatogramSelection.getChromatogramMSD().addScan(getRandomScan(retentionTime));
                chromatogramSelection.setStopRetentionTime(retentionTime);
                retentionTime += retentionTimeDelta;
                chromatogramSelection.fireUpdateChange(true);
            }
        }
    }
...
    @Inject
    private Display display;
    private IChromatogramSelectionMSD chromatogramSelection = null;
    private int retentionTimeDelta = 500;
    private int retentionTime = 0;
    private ActiveAnalysis activeAnalysis;

    public ADCardUSB9982ControlView() {
        /*
         * Initialize the analysis.
         */
        activeAnalysis = new ActiveAnalysis();
    }
...
        final Button buttonStartAcquisition = new Button(pane, SWT.PUSH);
        buttonStartAcquisition.setText("Start Acquire");
        buttonStartAcquisition.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(final SelectionEvent event) {

                startAcquisitionDemo();
            }
        });

        final Button buttonStopAcquisition = new Button(pane, SWT.PUSH);
        buttonStopAcquisition.setText("Stop Acquire");
        buttonStopAcquisition.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(final SelectionEvent e) {

                stopAcquisitionDemo();
            }
        });
...
    private void startAcquisitionDemo() {

        /*
         * Initialize the record.
         */
        if(chromatogramSelection == null) {
            try {
                TideMSChromatogram chromatogram = new TideMSChromatogram();
                for(int i = 0; i < 100; i++) {
                    chromatogram.addScan(getRandomScan(retentionTime));
                    retentionTime += retentionTimeDelta;
                }
                //
                chromatogramSelection = new ChromatogramSelectionMSD(chromatogram);
                ChromatogramEditorSupport chromatogramEditorSupport = new ChromatogramEditorSupport();
                chromatogramEditorSupport.openEditor(chromatogramSelection.getChromatogramMSD(), modelService, application, partService);
                display.asyncExec(activeAnalysis);
                activeAnalysis.startAnalysis();
            } catch(ChromatogramIsNullException e) {
                logger.warn(e);
            }
        } else {
            /*
             * Start/proceed with the analysis.
             */
            display.asyncExec(activeAnalysis);
            activeAnalysis.startAnalysis();
        }
    }

    private void stopAcquisitionDemo() {

        /*
         * Stop the analysis.
         */
        activeAnalysis.stopAnalysis();
    }


Best,
Philip

Am 08.09.2016 um 10:51 schrieb Trig Chen:
Hi Philip,

Is  there any event that can be used by IEventBroker to handle these updates?

Best regards,

Trig

2016-09-08 16:10 GMT+08:00 Philip Wenig <philip.wenig@xxxxxxxxxxxxx>:
Trig,

yep, no problem.
I'll try to create a testcase today :-) or at least tomorrow.


Best,
Philip


Am 08.09.2016 um 09:57 schrieb Trig Chen:
Hi Philip,

Could you give me some demo code snippets for that? I get overwhelmed by these APIs.

Best regards,

Trig

2016-09-08 14:31 GMT+08:00 Philip Wenig <philip.wenig@xxxxxxxxxxxxx>:
You can rely on the functionality that the framework handles to open the chromatogram files correctly. Just use the ChromatogramSelectionMSD and its update method. There's no need to create a new ChromatogramSelectionMSD on change.


Philip


Am 07.09.2016 um 11:30 schrieb Trig Chen:
Hi all,

1. I created a ChromatogramMSD firstly,
          final TideMSChromatogram tideMSChromatogram = new TideMSChromatogram();
2. and then acquired some spectra from our home-built in situ TOF mass spectrometer and added these spectra to the tideMSChromatogram. After acquired more than 2 spectra, opened (or create if not existed) a ChromatogramEditorMSD editor part to display tideMSChromatogram. It's just because  ChromatogramEditorMSD open a empty ChromatogramMSD will cause exceptions.

      for(int i = 0; (i < getSpectraNumber()) && (!stopFlag); i++) {
acquireMassSpectrum(tideMSChromatogram, writer, i);
if(i == 10) {
openMSDEditor(tideMSChromatogram);
}
}


3.  In the method acquireMassSpectrum(tideMSChromatogram, writer, i) in step 2, I created scans to hold acquired data and added these scans to tideMSChromatogram, and then called the fireupdate method of tideMSChromatogram

tideMSChromatogram.addScan(scan);
try {
tideMSChromatogram.fireUpdate(new ChromatogramSelectionMSD(tideMSChromatogram, true));
} catch(final ChromatogramIsNullException e) {
logger.warn(e);
}

The tideMSChromatogram.fireUpdate(new ChromatogramSelectionMSD(tideMSChromatogram, true)) statement seems awkward. I doubt if the step 3 is the proper way to update a chromatogram in the chromatogram's editor? If not, what is the proper one?

PS:
In step 2, I used the following codes to create MSD Editor:
final MPart part = MBasicFactory.INSTANCE.createInputPart();
part.setElementId(ChromatogramEditorMSD.ID);
part.setContributionURI(ChromatogramEditorMSD.CONTRIBUTION_URI);
if(chromatogram != null) {
part.setObject(chromatogram);
part.setLabel(chromatogram.getName());
} else {
part.setObject(null);
part.setLabel("No valid chromatogram");
}
part.setIconURI(ChromatogramEditorMSD.ICON_URI);
part.setTooltip(ChromatogramEditorMSD.TOOLTIP);
part.setCloseable(true);
final MPartStack partStack = (MPartStack)modelService.find(IPerspectiveAndViewIds.EDITOR_PART_STACK_ID, application);
partStack.getChildren().add(part);
partService.showPart(part, PartState.ACTIVATE);
one more question:
               I created this ChromatogramEditorMSD part and shew it, but I could not cast it to ChromatogramEditorMSD lately in another way. Excepton occured:
java.lang.ClassCastException: org.eclipse.e4.ui.model.application.ui.basic.impl.InputPartImpl cannot be cast to org.eclipse.chemclipse.ux.extension.msd.ui.editors.ChromatogramEditorMSD
How can I convert a Part to the class object which this Part's contributionURI points to? 

Best regards,

Trig


_______________________________________________
chemclipse-dev mailing list
chemclipse-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/chemclipse-dev
-- 
~~~~~~~~~~~~~~~~~~~~~~~~
OpenChrom - the open source alternative for chromatography / mass spectrometry
Dr. Philip Wenig » Founder » philip.wenig@xxxxxxxxxxxxx » http://www.openchrom.net
~~~~~~~~~~~~~~~~~~~~~~~~
_______________________________________________ chemclipse-dev mailing list chemclipse-dev@xxxxxxxxxxx To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://dev.eclipse.org/mailman/listinfo/chemclipse-dev
_______________________________________________
chemclipse-dev mailing list
chemclipse-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/chemclipse-dev
-- 
~~~~~~~~~~~~~~~~~~~~~~~~
OpenChrom - the open source alternative for chromatography / mass spectrometry
Dr. Philip Wenig » Founder » philip.wenig@xxxxxxxxxxxxx » http://www.openchrom.net
~~~~~~~~~~~~~~~~~~~~~~~~
_______________________________________________ chemclipse-dev mailing list chemclipse-dev@xxxxxxxxxxx To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://dev.eclipse.org/mailman/listinfo/chemclipse-dev
_______________________________________________
chemclipse-dev mailing list
chemclipse-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/chemclipse-dev
-- 
~~~~~~~~~~~~~~~~~~~~~~~~
OpenChrom - the open source alternative for chromatography / mass spectrometry
Dr. Philip Wenig » Founder » philip.wenig@xxxxxxxxxxxxx » http://www.openchrom.net
~~~~~~~~~~~~~~~~~~~~~~~~

Back to the top