Skip to content

Commit

Permalink
Merge pull request #913 from Mailaender/peak-scan-list-update
Browse files Browse the repository at this point in the history
Fixed Peak/Scan list not updating when hidden in the background
  • Loading branch information
eselmeister authored Feb 22, 2022
2 parents 0417c49 + 42e866e commit 8bb9fdd
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ void execute(MPart part, MDirectToolItem toolItem) {
}
}

@Override
public void setFocus() {

ExtendedPeakScanListUI control = getControl();
if(control != null) {
getControl().setFocus();
}
}

@Inject
@Optional
public void updatePeakSelection(@UIEventTopic(IChemClipseEvents.TOPIC_PEAK_XXD_UPDATE_SELECTION) IPeak peak) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
import org.eclipse.chemclipse.ux.extension.xxd.ui.internal.support.TableConfigSupport;
import org.eclipse.chemclipse.ux.extension.xxd.ui.operations.DeletePeaksOperation;
import org.eclipse.chemclipse.ux.extension.xxd.ui.operations.DeleteScansOperation;
import org.eclipse.chemclipse.ux.extension.xxd.ui.part.support.DataUpdateSupport;
import org.eclipse.chemclipse.ux.extension.xxd.ui.preferences.PreferenceConstants;
import org.eclipse.chemclipse.ux.extension.xxd.ui.preferences.PreferencePageLists;
import org.eclipse.chemclipse.ux.extension.xxd.ui.preferences.PreferencePageMergePeaks;
Expand Down Expand Up @@ -111,6 +112,7 @@ public class ExtendedPeakScanListUI extends Composite implements IExtendedPartUI
private ScanIdentifierUI scanIdentifierUI;
private Button buttonTableEdit;
private AtomicReference<PeakScanListUI> tableViewer = new AtomicReference<>();
//
private IChromatogramSelection chromatogramSelection;
//
private boolean showScans;
Expand Down Expand Up @@ -142,6 +144,14 @@ private void updateFromPreferences() {
@Override
public boolean setFocus() {

DataUpdateSupport dataUpdateSupport = Activator.getDefault().getDataUpdateSupport();
List<Object> objects = dataUpdateSupport.getUpdates(IChemClipseEvents.TOPIC_CHROMATOGRAM_XXD_UPDATE_SELECTION);
if(!objects.isEmpty()) {
Object first = objects.get(0);
if(first instanceof IChromatogramSelection) {
chromatogramSelection = (IChromatogramSelection)first;
}
}
updateChromatogramSelection();
return true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2017, 2021 Lablicate GmbH.
* Copyright (c) 2017, 2022 Lablicate GmbH.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand Down Expand Up @@ -751,28 +751,26 @@ public void run() {
if(eventBroker != null) {
DataUpdateSupport dataUpdateSupport = Activator.getDefault().getDataUpdateSupport();
List<Object> objects = dataUpdateSupport.getUpdates(IChemClipseEvents.TOPIC_CHROMATOGRAM_XXD_UPDATE_SELECTION);
if(objects != null && objects.size() > 0) {
if(objects != null && !objects.isEmpty()) {
Object object = objects.get(0);
if(object instanceof IChromatogramSelection) {
IChromatogramSelection chromatogramSelection = (IChromatogramSelection)object;
if(chromatogramSelection != null) {
if(scan != null) {
/*
* We assume that the subtraction takes place in the same
* chromatogram. It could happen, that one scan is selected
* and set to edit modus and afterwards another chromatogram
* is selected. This could lead to misleading behavior.
* But it's unclear how to solve it hear. This is currently
* the best way to prevent unwanted behavior. The scan chart shows
* data from scans and peaks.
*/
IChromatogram<IPeak> chromatogram = chromatogramSelection.getChromatogram();
int retentionTime = scan.getRetentionTime();
int scanNumber = chromatogram.getScanNumber(retentionTime);
IScan scanReference = chromatogram.getScan(scanNumber);
if(scan == scanReference) {
chromatogramSelection.setSelectedScan(scan);
}
if(scan != null) {
/*
* We assume that the subtraction takes place in the same
* chromatogram. It could happen, that one scan is selected
* and set to edit modus and afterwards another chromatogram
* is selected. This could lead to misleading behavior.
* But it's unclear how to solve it hear. This is currently
* the best way to prevent unwanted behavior. The scan chart shows
* data from scans and peaks.
*/
IChromatogram<IPeak> chromatogram = chromatogramSelection.getChromatogram();
int retentionTime = scan.getRetentionTime();
int scanNumber = chromatogram.getScanNumber(retentionTime);
IScan scanReference = chromatogram.getScan(scanNumber);
if(scan == scanReference) {
chromatogramSelection.setSelectedScan(scan);
}
/*
* Update the chromatogram
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ private void addIdentifiedScansData(List<ILineSeriesData> lineSeriesDataList, IT

private void addIdentifiedScansData(List<ILineSeriesData> lineSeriesDataList, List<IScan> scans, PlotSymbolType plotSymbolType, int symbolSize, Color symbolColor, String seriesId) {

if(scans.size() > 0) {
if(!scans.isEmpty()) {
ILineSeriesData lineSeriesData = null;
lineSeriesData = scanChartSupport.getLineSeriesDataPoint(scans, false, seriesId, displayType, chromatogramSelection);
ILineSeriesSettings lineSeriesSettings = lineSeriesData.getSettings();
Expand Down

0 comments on commit 8bb9fdd

Please sign in to comment.