Skip to content

Commit d5fdb92

Browse files
committed
Post Analysis panel remembers previous inputs.
1 parent 6ad05da commit d5fdb92

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

EnrichmentMapPlugin/src/main/java/org/baderlab/csplugins/enrichmentmap/model/EnrichmentMapManager.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,11 @@
4848
import java.util.Map;
4949

5050
import org.baderlab.csplugins.enrichmentmap.view.heatmap.HeatMapParams;
51+
import org.baderlab.csplugins.enrichmentmap.view.postanalysis.PostAnalysisPanelMediator;
5152
import org.cytoscape.view.model.CyNetworkView;
5253

54+
import com.google.inject.Inject;
55+
import com.google.inject.Provider;
5356
import com.google.inject.Singleton;
5457

5558

@@ -59,6 +62,8 @@ public class EnrichmentMapManager {
5962
private Map<Long, EnrichmentMap> enrichmentMaps = new HashMap<>();
6063
private Map<Long, HeatMapParams> heatMapParams = new HashMap<>();
6164
private Map<Long, HeatMapParams> heatMapParamsEdges = new HashMap<>();
65+
66+
@Inject private Provider<PostAnalysisPanelMediator> postAnalysisMediatorProvider;
6267

6368
/**
6469
* Registers a newly created Network.
@@ -76,7 +81,11 @@ public EnrichmentMap getEnrichmentMap(Long networkId) {
7681
}
7782

7883
public EnrichmentMap removeEnrichmentMap(Long networkId) {
79-
return enrichmentMaps.remove(networkId);
84+
EnrichmentMap map = enrichmentMaps.remove(networkId);
85+
if(map != null) {
86+
postAnalysisMediatorProvider.get().removeEnrichmentMap(map);
87+
}
88+
return map;
8089
}
8190

8291
public boolean isEnrichmentMap(Long networkId) {

EnrichmentMapPlugin/src/main/java/org/baderlab/csplugins/enrichmentmap/view/postanalysis/PostAnalysisPanelMediator.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import java.util.List;
1010
import java.util.Optional;
1111
import java.util.Set;
12+
import java.util.WeakHashMap;
1213

1314
import javax.swing.AbstractAction;
1415
import javax.swing.JButton;
@@ -56,13 +57,16 @@ public class PostAnalysisPanelMediator {
5657
@Inject private CreateDiseaseSignatureTaskFactory.Factory signatureTaskFactoryFactory;
5758
@Inject private ErrorMessageDialog.Factory errorMessageDialogFactory;
5859

60+
private WeakHashMap<EnrichmentMap,PostAnalysisInputPanel> panels = new WeakHashMap<>();
61+
62+
5963

6064
@SuppressWarnings("serial")
6165
public void showDialog(Component parent, CyNetworkView netView) {
6266
final EnrichmentMap map = emManager.getEnrichmentMap(netView.getModel().getSUID());
6367

6468
invokeOnEDT(() -> {
65-
final PostAnalysisInputPanel panel = panelFactory.create(map);
69+
final PostAnalysisInputPanel panel = panels.computeIfAbsent(map, panelFactory::create);
6670

6771
final JDialog dialog = new JDialog(swingApplication.getJFrame(), "Add Signature Gene Sets", ModalityType.APPLICATION_MODAL);
6872
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
@@ -106,6 +110,9 @@ public void actionPerformed(ActionEvent e) {
106110
});
107111
}
108112

113+
public void removeEnrichmentMap(EnrichmentMap map) {
114+
panels.remove(map);
115+
}
109116

110117
private void addGeneSets(CyNetworkView netView, PostAnalysisParameters params) {
111118
CreateDiseaseSignatureTaskFactory taskFactory = signatureTaskFactoryFactory.create(netView, params);

0 commit comments

Comments
 (0)