16
16
import java .util .Set ;
17
17
import java .util .stream .Collectors ;
18
18
19
+ import javax .swing .JOptionPane ;
20
+ import javax .swing .JSpinner ;
21
+ import javax .swing .SpinnerNumberModel ;
22
+
19
23
import org .baderlab .csplugins .enrichmentmap .AfterInjection ;
20
24
import org .baderlab .csplugins .enrichmentmap .PropertyManager ;
21
25
import org .baderlab .csplugins .enrichmentmap .actions .OpenPathwayCommonsTask ;
@@ -97,7 +101,7 @@ public class HeatMapMediator implements RowsSetListener, SetCurrentNetworkViewLi
97
101
@ Inject private HeatMapPanel heatMapPanel ;
98
102
@ Inject private Provider <HeatMapContentPanel > contentPanelProvider ;
99
103
100
- private HeatMapContentPanel contentPanel2 ;
104
+ private HeatMapContentPanel contentPanel ;
101
105
private final CoalesceTimer selectionEventTimer = new CoalesceTimer (200 , 1 );
102
106
private boolean onlyEdges ;
103
107
@@ -108,6 +112,7 @@ public class HeatMapMediator implements RowsSetListener, SetCurrentNetworkViewLi
108
112
public void setPropertyListeners () {
109
113
propertyManager .addListener (PropertyManager .HEATMAP_DATASET_SYNC , (prop , value ) -> reset ());
110
114
propertyManager .addListener (PropertyManager .HEATMAP_SELECT_SYNC , (prop , value ) -> reset ());
115
+ propertyManager .addListener (PropertyManager .HEATMAP_NAME_LENGTH , (prop , value ) -> reset ());
111
116
}
112
117
113
118
@@ -123,33 +128,34 @@ private HeatMapContentPanel getContentPanel() {
123
128
showValueActionListener = evt -> updateSetting_ShowValues ();
124
129
125
130
// Tool Bar
126
- if (contentPanel2 == null ) {
127
- contentPanel2 = contentPanelProvider .get ();
128
- contentPanel2 .getOperatorCombo ().addActionListener (operatorActionListener );
129
- contentPanel2 .getNormCombo ().addActionListener (normActionListener );
130
- contentPanel2 .getCompressCombo ().addActionListener (compressActionListener );
131
- contentPanel2 .getShowValuesCheck ().addActionListener (showValueActionListener );
131
+ if (contentPanel == null ) {
132
+ contentPanel = contentPanelProvider .get ();
133
+ contentPanel .getOperatorCombo ().addActionListener (operatorActionListener );
134
+ contentPanel .getNormCombo ().addActionListener (normActionListener );
135
+ contentPanel .getCompressCombo ().addActionListener (compressActionListener );
136
+ contentPanel .getShowValuesCheck ().addActionListener (showValueActionListener );
132
137
133
138
// Fire a setting changed event when column sort changes
134
- contentPanel2 .getTable ().getRowSorter ().addRowSorterListener (e -> settingChanged ());
139
+ contentPanel .getTable ().getRowSorter ().addRowSorterListener (e -> settingChanged ());
135
140
136
141
// Options Popup
137
- contentPanel2 .getOptionsPopup ().setDistanceConsumer (this ::updateSetting_Distance );
138
- contentPanel2 .getOptionsPopup ().getGeneManiaButton ().addActionListener (e -> runGeneMANIA ());
139
- contentPanel2 .getOptionsPopup ().getStringButton ().addActionListener (e -> runString ());
140
- contentPanel2 .getOptionsPopup ().getPathwayCommonsButton ().addActionListener (e -> runPathwayCommons ());
141
- contentPanel2 .getOptionsPopup ().getAddRanksButton ().addActionListener (e -> addRankings ());
142
- contentPanel2 .getOptionsPopup ().getExportTxtButton ().addActionListener (txtActionFactory .create (contentPanel2 .getTable ()));
143
- contentPanel2 .getOptionsPopup ().getExportPdfButton ().addActionListener (pdfActionFactory .create (contentPanel2 .getTable (), contentPanel2 ::getRankingOption , contentPanel2 ::isShowValues ));
142
+ contentPanel .getOptionsPopup ().setDistanceConsumer (this ::updateSetting_Distance );
143
+ contentPanel .getOptionsPopup ().getGeneManiaButton ().addActionListener (e -> runGeneMANIA ());
144
+ contentPanel .getOptionsPopup ().getStringButton ().addActionListener (e -> runString ());
145
+ contentPanel .getOptionsPopup ().getPathwayCommonsButton ().addActionListener (e -> runPathwayCommons ());
146
+ contentPanel .getOptionsPopup ().getAddRanksButton ().addActionListener (e -> addRankings ());
147
+ contentPanel .getOptionsPopup ().getNameLengthButton ().addActionListener (e -> promptForNameLength ());
148
+ contentPanel .getOptionsPopup ().getExportTxtButton ().addActionListener (txtActionFactory .create (contentPanel .getTable ()));
149
+ contentPanel .getOptionsPopup ().getExportPdfButton ().addActionListener (pdfActionFactory .create (contentPanel .getTable (), contentPanel ::getRankingOption , contentPanel ::isShowValues ));
144
150
145
151
// Property Change Listeners
146
- contentPanel2 .addPropertyChangeListener ("selectedRankingOption" , evt -> settingChanged ());
152
+ contentPanel .addPropertyChangeListener ("selectedRankingOption" , evt -> settingChanged ());
147
153
}
148
- return contentPanel2 ;
154
+ return contentPanel ;
149
155
}
150
156
151
157
private void disposeContentPanel () {
152
- contentPanel2 = null ;
158
+ contentPanel = null ;
153
159
heatMapPanel .showContentPanel (null );
154
160
}
155
161
@@ -599,6 +605,21 @@ private void runPathwayCommons() {
599
605
taskManager .execute (new TaskIterator (task ));
600
606
}
601
607
}
608
+
609
+ private void promptForNameLength () {
610
+ int length = propertyManager .getValue (PropertyManager .HEATMAP_NAME_LENGTH );
611
+ var spinnerModel = new SpinnerNumberModel (length , 10 , 200 , 1 );
612
+ var spinner = new JSpinner (spinnerModel );
613
+
614
+ int option = JOptionPane .showOptionDialog (null , spinner , "DataSet Max Length" , JOptionPane .OK_CANCEL_OPTION , JOptionPane .QUESTION_MESSAGE , null , null , null );
615
+
616
+ if (option == JOptionPane .OK_OPTION ) {
617
+ int newLength = spinnerModel .getNumber ().intValue ();
618
+ if (newLength != length ) {
619
+ propertyManager .setValue (PropertyManager .HEATMAP_NAME_LENGTH , newLength );
620
+ }
621
+ }
622
+ }
602
623
603
624
private boolean isHeatMapPanelRegistered () {
604
625
try {
0 commit comments