Skip to content

Commit 657015f

Browse files
authored
Merge pull request #2653 from lorenzgerber/pca
PCA, add update on focus where relevant
2 parents 4eb524a + 0d76f0d commit 657015f

File tree

13 files changed

+246
-13
lines changed

13 files changed

+246
-13
lines changed

chemclipse/plugins/org.eclipse.chemclipse.xxd.process.supplier.pca.ui/src/org/eclipse/chemclipse/xxd/process/supplier/pca/ui/Activator.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*
1010
* Contributors:
1111
* Philip Wenig - initial API and implementation
12+
* Lorenz Gerber - add DataUpdate topics
1213
*******************************************************************************/
1314
package org.eclipse.chemclipse.xxd.process.supplier.pca.ui;
1415

@@ -149,6 +150,11 @@ private Map<String, String> getImageHashMap() {
149150
private void initialize(DataUpdateSupport dataUpdateSupport) {
150151

151152
dataUpdateSupport.subscribe(IChemClipseEvents.TOPIC_PCA_UPDATE_RESULT, IChemClipseEvents.EVENT_BROKER_DATA);
153+
dataUpdateSupport.subscribe(IChemClipseEvents.TOPIC_PCA_UPDATE_FEATURES, IChemClipseEvents.EVENT_BROKER_DATA);
154+
dataUpdateSupport.subscribe(IChemClipseEvents.TOPIC_PCA_UPDATE_SELECTION, IChemClipseEvents.EVENT_BROKER_DATA);
155+
dataUpdateSupport.subscribe(IChemClipseEvents.TOPIC_PCA_UPDATE_COLORSCHEME, IChemClipseEvents.EVENT_BROKER_DATA);
156+
dataUpdateSupport.subscribe(IChemClipseEvents.TOPIC_PCA_UPDATE_LABELS, IChemClipseEvents.EVENT_BROKER_DATA);
157+
dataUpdateSupport.subscribe(IChemClipseEvents.TOPIC_PCA_UPDATE_GROUPS, IChemClipseEvents.EVENT_BROKER_DATA);
152158
dataUpdateSupport.subscribe(IChemClipseEvents.TOPIC_PCA_UPDATE_HIGHLIGHT_LIST_VARIABLE, IChemClipseEvents.EVENT_BROKER_DATA);
153159
dataUpdateSupport.subscribe(IChemClipseEvents.TOPIC_PCA_UPDATE_HIGHLIGHT_STATLIST_VARIABLE, IChemClipseEvents.EVENT_BROKER_DATA);
154160
dataUpdateSupport.subscribe(IChemClipseEvents.TOPIC_PCA_UPDATE_HIGHLIGHT_PLOT_VARIABLE, IChemClipseEvents.EVENT_BROKER_DATA);

chemclipse/plugins/org.eclipse.chemclipse.xxd.process.supplier.pca.ui/src/org/eclipse/chemclipse/xxd/process/supplier/pca/ui/editors/PCAEditor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2018, 2025 Lablicate GmbH.
2+
* Copyright (c) 2018, 2026 Lablicate GmbH.
33
*
44
* This program and the accompanying materials are made
55
* available under the terms of the Eclipse Public License 2.0
@@ -10,6 +10,7 @@
1010
* Contributors:
1111
* Jan Holy - initial API and implementation
1212
* Philip Wenig - get rid of JavaFX
13+
* Lorenz Gerber - fix data update
1314
*******************************************************************************/
1415
package org.eclipse.chemclipse.xxd.process.supplier.pca.ui.editors;
1516

@@ -76,6 +77,5 @@ public void preDestroy() {
7677
public void setFocus() {
7778

7879
analysisEditorUI.setFocus();
79-
analysisEditorUI.reloadData();
8080
}
8181
}

chemclipse/plugins/org.eclipse.chemclipse.xxd.process.supplier.pca.ui/src/org/eclipse/chemclipse/xxd/process/supplier/pca/ui/parts/LoadingsPlotPart.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2020, 2025 Lablicate GmbH.
2+
* Copyright (c) 2020, 2026 Lablicate GmbH.
33
*
44
* This program and the accompanying materials are made
55
* available under the terms of the Eclipse Public License 2.0
@@ -29,6 +29,15 @@ public LoadingsPlotPart(Composite parent) {
2929
super(parent);
3030
}
3131

32+
@Override
33+
public void setFocus() {
34+
35+
ExtendedLoadingsPlot control = getControl();
36+
if(control != null) {
37+
control.setFocus();
38+
}
39+
}
40+
3241
@Override
3342
protected ExtendedLoadingsPlot createControl(Composite parent) {
3443

chemclipse/plugins/org.eclipse.chemclipse.xxd.process.supplier.pca.ui/src/org/eclipse/chemclipse/xxd/process/supplier/pca/ui/parts/ScorePlot2DPart.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2020, 2025 Lablicate GmbH.
2+
* Copyright (c) 2020, 2026 Lablicate GmbH.
33
*
44
* This program and the accompanying materials are made
55
* available under the terms of the Eclipse Public License 2.0
@@ -9,6 +9,7 @@
99
*
1010
* Contributors:
1111
* Philip Wenig - initial API and implementation
12+
* Lorenz Gerber - data update on focus
1213
*******************************************************************************/
1314
package org.eclipse.chemclipse.xxd.process.supplier.pca.ui.parts;
1415

@@ -29,6 +30,15 @@ public ScorePlot2DPart(Composite parent) {
2930
super(parent);
3031
}
3132

33+
@Override
34+
public void setFocus() {
35+
36+
ExtendedScorePlot2D control = getControl();
37+
if(control != null) {
38+
control.setFocus();
39+
}
40+
}
41+
3242
@Override
3343
protected ExtendedScorePlot2D createControl(Composite parent) {
3444

chemclipse/plugins/org.eclipse.chemclipse.xxd.process.supplier.pca.ui/src/org/eclipse/chemclipse/xxd/process/supplier/pca/ui/parts/ScorePlotBarPart.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@ public ScorePlotBarPart(Composite parent) {
2929
super(parent);
3030
}
3131

32+
@Override
33+
public void setFocus() {
34+
35+
ExtendedScorePlotBarChart control = getControl();
36+
if(control != null) {
37+
control.setFocus();
38+
}
39+
}
40+
3241
@Override
3342
protected ExtendedScorePlotBarChart createControl(Composite parent) {
3443

chemclipse/plugins/org.eclipse.chemclipse.xxd.process.supplier.pca.ui/src/org/eclipse/chemclipse/xxd/process/supplier/pca/ui/parts/ScoreTablePart.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@ public ScoreTablePart(Composite parent) {
2929
super(parent);
3030
}
3131

32+
@Override
33+
public void setFocus() {
34+
35+
ExtendedScoreTable control = getControl();
36+
if(control != null) {
37+
control.setFocus();
38+
}
39+
}
40+
3241
@Override
3342
protected ExtendedScoreTable createControl(Composite parent) {
3443

chemclipse/plugins/org.eclipse.chemclipse.xxd.process.supplier.pca.ui/src/org/eclipse/chemclipse/xxd/process/supplier/pca/ui/parts/VariancePart.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2018, 2025 Lablicate GmbH.
2+
* Copyright (c) 2018, 2026 Lablicate GmbH.
33
*
44
* This program and the accompanying materials are made
55
* available under the terms of the Eclipse Public License 2.0
@@ -30,6 +30,15 @@ public VariancePart(Composite parent) {
3030
super(parent);
3131
}
3232

33+
@Override
34+
public void setFocus() {
35+
36+
ExtendedVarianceUI control = getControl();
37+
if(control != null) {
38+
control.setFocus();
39+
}
40+
}
41+
3342
@Override
3443
protected ExtendedVarianceUI createControl(Composite parent) {
3544

chemclipse/plugins/org.eclipse.chemclipse.xxd.process.supplier.pca.ui/src/org/eclipse/chemclipse/xxd/process/supplier/pca/ui/swt/AnalysisEditorUI.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,6 @@ public void setInput(ISamplesPCA<IVariable, ISample> samples) {
144144
updateControls();
145145
}
146146

147-
public void reloadData() {
148-
149-
if(this.evaluation != null) {
150-
UpdateNotifierUI.update(DisplayUtils.getDisplay(), IChemClipseEvents.TOPIC_PCA_UPDATE_SELECTION, this.evaluation);
151-
}
152-
}
153-
154147
private void createControl() {
155148

156149
setLayout(new GridLayout(1, true));

chemclipse/plugins/org.eclipse.chemclipse.xxd.process.supplier.pca.ui/src/org/eclipse/chemclipse/xxd/process/supplier/pca/ui/swt/ExtendedLoadingsPlot.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,13 @@ public void update(String topic, List<Object> objects) {
112112
});
113113
}
114114

115+
@Override
116+
public boolean setFocus() {
117+
118+
updateOnFocus();
119+
return true;
120+
}
121+
115122
public void setInput(EvaluationPCA evaluationPCA) {
116123

117124
this.evaluationPCA = evaluationPCA;
@@ -614,4 +621,33 @@ private boolean isBoxSelection() {
614621
}
615622
return false;
616623
}
624+
625+
private void updateOnFocus() {
626+
627+
DataUpdateSupport dataUpdateSupport = Activator.getDefault().getDataUpdateSupport();
628+
List<Object> objects = dataUpdateSupport.getUpdates(getLastTopic(dataUpdateSupport.getTopics()));
629+
630+
if(!objects.isEmpty()) {
631+
Object object = objects.get(0);
632+
if(object instanceof EvaluationPCA evaluation) {
633+
setInput(evaluation);
634+
updateInput();
635+
}
636+
}
637+
}
638+
639+
private String getLastTopic(List<String> topics) {
640+
641+
Collections.reverse(topics);
642+
for(String topic : topics) {
643+
if(topic.equals(IChemClipseEvents.TOPIC_PCA_UPDATE_RESULT)) {
644+
return topic;
645+
}
646+
if(topic.equals(IChemClipseEvents.TOPIC_PCA_UPDATE_SELECTION)) {
647+
return topic;
648+
}
649+
}
650+
651+
return "";
652+
}
617653
}

chemclipse/plugins/org.eclipse.chemclipse.xxd.process.supplier.pca.ui/src/org/eclipse/chemclipse/xxd/process/supplier/pca/ui/swt/ExtendedScorePlot2D.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,13 @@ public void update(String topic, List<Object> objects) {
111111
});
112112
}
113113

114+
@Override
115+
public boolean setFocus() {
116+
117+
updateOnFocus();
118+
return true;
119+
}
120+
114121
public void setInput(EvaluationPCA evaluationPCA) {
115122

116123
this.evaluationPCA = evaluationPCA;
@@ -606,4 +613,33 @@ private boolean isBoxSelection() {
606613
}
607614
return false;
608615
}
616+
617+
private void updateOnFocus() {
618+
619+
DataUpdateSupport dataUpdateSupport = Activator.getDefault().getDataUpdateSupport();
620+
List<Object> objects = dataUpdateSupport.getUpdates(getLastTopic(dataUpdateSupport.getTopics()));
621+
622+
if(!objects.isEmpty()) {
623+
Object object = objects.get(0);
624+
if(object instanceof EvaluationPCA evaluation) {
625+
setInput(evaluation);
626+
updatePlot();
627+
}
628+
}
629+
}
630+
631+
private String getLastTopic(List<String> topics) {
632+
633+
Collections.reverse(topics);
634+
for(String topic : topics) {
635+
if(topic.equals(IChemClipseEvents.TOPIC_PCA_UPDATE_RESULT)) {
636+
return topic;
637+
}
638+
if(topic.equals(IChemClipseEvents.TOPIC_PCA_UPDATE_SELECTION)) {
639+
return topic;
640+
}
641+
}
642+
643+
return "";
644+
}
609645
}

0 commit comments

Comments
 (0)