diff --git a/chemclipse/plugins/org.eclipse.chemclipse.ux.extension.xxd.ui/src/org/eclipse/chemclipse/ux/extension/xxd/ui/parts/PeakScanListPart.java b/chemclipse/plugins/org.eclipse.chemclipse.ux.extension.xxd.ui/src/org/eclipse/chemclipse/ux/extension/xxd/ui/parts/PeakScanListPart.java index 9a50a43e18..03f9a20e31 100644 --- a/chemclipse/plugins/org.eclipse.chemclipse.ux.extension.xxd.ui/src/org/eclipse/chemclipse/ux/extension/xxd/ui/parts/PeakScanListPart.java +++ b/chemclipse/plugins/org.eclipse.chemclipse.ux.extension.xxd.ui/src/org/eclipse/chemclipse/ux/extension/xxd/ui/parts/PeakScanListPart.java @@ -82,6 +82,7 @@ protected boolean updateData(List objects, String topic) { } else { if(isChromatogramEvent(topic)) { if(object instanceof IChromatogramSelection) { + logger.info(object); IChromatogramSelection chromatogramSelection = (IChromatogramSelection)object; getControl().updateChromatogramSelection(chromatogramSelection); return true; diff --git a/chemclipse/plugins/org.eclipse.chemclipse.ux.extension.xxd.ui/src/org/eclipse/chemclipse/ux/extension/xxd/ui/parts/ScanChartPart.java b/chemclipse/plugins/org.eclipse.chemclipse.ux.extension.xxd.ui/src/org/eclipse/chemclipse/ux/extension/xxd/ui/parts/ScanChartPart.java index 37936c9ec0..7554cf482d 100644 --- a/chemclipse/plugins/org.eclipse.chemclipse.ux.extension.xxd.ui/src/org/eclipse/chemclipse/ux/extension/xxd/ui/parts/ScanChartPart.java +++ b/chemclipse/plugins/org.eclipse.chemclipse.ux.extension.xxd.ui/src/org/eclipse/chemclipse/ux/extension/xxd/ui/parts/ScanChartPart.java @@ -16,8 +16,10 @@ import javax.inject.Inject; +import org.eclipse.chemclipse.model.core.IChromatogram; import org.eclipse.chemclipse.model.core.IPeak; import org.eclipse.chemclipse.model.core.IScan; +import org.eclipse.chemclipse.model.selection.IChromatogramSelection; import org.eclipse.chemclipse.support.events.IChemClipseEvents; import org.eclipse.chemclipse.ux.extension.xxd.ui.swt.ExtendedScanChartUI; import org.eclipse.swt.SWT; @@ -26,6 +28,7 @@ public class ScanChartPart extends AbstractPart { private static final String TOPIC = IChemClipseEvents.TOPIC_SCAN_XXD_UPDATE_SELECTION; + private IChromatogram cachedChromatogram = null; @Inject public ScanChartPart(Composite parent) { @@ -39,6 +42,16 @@ protected ExtendedScanChartUI createControl(Composite parent) { return new ExtendedScanChartUI(parent, SWT.NONE); } + private boolean hasChanged(IChromatogramSelection chromatogramSelection) { + + if(chromatogramSelection != null) { + if(chromatogramSelection.getChromatogram() != cachedChromatogram) { + return true; + } + } + return false; + } + @Override protected boolean updateData(List objects, String topic) { @@ -54,6 +67,11 @@ protected boolean updateData(List objects, String topic) { } else if(object instanceof IPeak) { IPeak peak = (IPeak)object; scan = peak.getPeakModel().getPeakMaximum(); + } else if(isChromatogramTopic(topic)) { + IChromatogramSelection chromatogramSelection = (IChromatogramSelection)object; + if(hasChanged(chromatogramSelection)) { + scan = chromatogramSelection.getSelectedScan(); + } } getControl().update(scan); return true; @@ -66,7 +84,12 @@ protected boolean updateData(List objects, String topic) { @Override protected boolean isUpdateTopic(String topic) { - return isScanTopic(topic) || isPeakTopic(topic) || isCloseEvent(topic); + return isChromatogramTopic(topic) || isScanTopic(topic) || isPeakTopic(topic) || isCloseEvent(topic); + } + + private boolean isChromatogramTopic(String topic) { + + return IChemClipseEvents.TOPIC_CHROMATOGRAM_XXD_UPDATE_SELECTION.equals(topic); } private boolean isScanTopic(String topic) { diff --git a/chemclipse/plugins/org.eclipse.chemclipse.ux.extension.xxd.ui/src/org/eclipse/chemclipse/ux/extension/xxd/ui/parts/ScanTablePart.java b/chemclipse/plugins/org.eclipse.chemclipse.ux.extension.xxd.ui/src/org/eclipse/chemclipse/ux/extension/xxd/ui/parts/ScanTablePart.java index 04b1c5755d..f8edbe6dcc 100644 --- a/chemclipse/plugins/org.eclipse.chemclipse.ux.extension.xxd.ui/src/org/eclipse/chemclipse/ux/extension/xxd/ui/parts/ScanTablePart.java +++ b/chemclipse/plugins/org.eclipse.chemclipse.ux.extension.xxd.ui/src/org/eclipse/chemclipse/ux/extension/xxd/ui/parts/ScanTablePart.java @@ -15,6 +15,9 @@ import javax.inject.Inject; +import org.eclipse.chemclipse.model.core.IChromatogram; +import org.eclipse.chemclipse.model.core.IScan; +import org.eclipse.chemclipse.model.selection.IChromatogramSelection; import org.eclipse.chemclipse.support.events.IChemClipseEvents; import org.eclipse.chemclipse.ux.extension.xxd.ui.swt.ExtendedScanTableUI; import org.eclipse.swt.SWT; @@ -23,6 +26,7 @@ public class ScanTablePart extends AbstractPart { private static final String TOPIC = IChemClipseEvents.TOPIC_SCAN_XXD_UPDATE_SELECTION; + private IChromatogram cachedChromatogram = null; @Inject public ScanTablePart(Composite parent) { @@ -36,16 +40,35 @@ protected ExtendedScanTableUI createControl(Composite parent) { return new ExtendedScanTableUI(parent, SWT.NONE); } + private boolean hasChanged(IChromatogramSelection chromatogramSelection) { + + if(chromatogramSelection != null) { + if(chromatogramSelection.getChromatogram() != cachedChromatogram) { + return true; + } + } + return false; + } + @Override protected boolean updateData(List objects, String topic) { if(objects.size() == 1) { - if(isScanEvent(topic) || isPeakEvent(topic)) { - getControl().setInput(objects.get(0)); - return true; - } else if(isCloseEvent(topic)) { + if(isCloseEvent(topic)) { getControl().setInput(null); return false; + } else { + Object object = objects.get(0); + if(isScanEvent(topic) || isPeakEvent(topic)) { + getControl().setInput(object); + return true; + } else if(isChromatogramTopic(topic)) { + IChromatogramSelection chromatogramSelection = (IChromatogramSelection)object; + if(hasChanged(chromatogramSelection)) { + IScan scan = chromatogramSelection.getSelectedScan(); + getControl().setInput(scan); + } + } } } // @@ -55,7 +78,12 @@ protected boolean updateData(List objects, String topic) { @Override protected boolean isUpdateTopic(String topic) { - return isScanEvent(topic) || isPeakEvent(topic) || isCloseEvent(topic); + return isChromatogramTopic(topic) || isScanEvent(topic) || isPeakEvent(topic) || isCloseEvent(topic); + } + + private boolean isChromatogramTopic(String topic) { + + return IChemClipseEvents.TOPIC_CHROMATOGRAM_XXD_UPDATE_SELECTION.equals(topic); } private boolean isScanEvent(String topic) {