Skip to main content

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

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

Back to the top