Skip to content

Commit b721085

Browse files
committed
Post Analysis button label changed from "+" icon to "Add Signature Gene Sets...". Removes "-" button and add context-menu item "Remove selected signature gene sets".
1 parent 3cdb861 commit b721085

File tree

3 files changed

+40
-95
lines changed

3 files changed

+40
-95
lines changed

EnrichmentMapPlugin/src/main/java/org/baderlab/csplugins/enrichmentmap/view/control/ControlPanel.java

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,6 @@ class EMViewControlPanel extends JPanel {
364364
private JLabel chartDataLabel = new JLabel("Chart Data:");
365365
private JLabel chartTypeLabel = new JLabel("Chart Type:");
366366
private JLabel chartColorsLabel = new JLabel("Chart Colors:");
367-
private JLabel dsFilterLabel = new JLabel("Data Sets:");
368367

369368
private DataSetSelector dataSetSelector;
370369
private JCheckBox publicationReadyCheck;
@@ -567,9 +566,8 @@ private JPanel createFilterPanel() {
567566
LookAndFeelUtil.equalizeSize(sliderPanelFields.toArray(new JComponent[sliderPanelFields.size()]));
568567
}
569568

570-
JPanel datasetListPanel = createDataSetListPanel();
571-
hGroup.addComponent(datasetListPanel);
572-
vGroup.addComponent(datasetListPanel);
569+
hGroup.addComponent(getDataSetSelector());
570+
vGroup.addPreferredGap(ComponentPlacement.UNRELATED).addComponent(getDataSetSelector());
573571

574572
if (LookAndFeelUtil.isAquaLAF())
575573
panel.setOpaque(false);
@@ -860,30 +858,6 @@ JButton getResetStyleButton() {
860858
return resetStyleButton;
861859
}
862860

863-
private JPanel createDataSetListPanel() {
864-
SwingUtil.makeSmall(dsFilterLabel);
865-
866-
final JPanel panel = new JPanel();
867-
final GroupLayout layout = new GroupLayout(panel);
868-
panel.setLayout(layout);
869-
layout.setAutoCreateContainerGaps(false);
870-
layout.setAutoCreateGaps(!LookAndFeelUtil.isAquaLAF());
871-
872-
layout.setHorizontalGroup(layout.createParallelGroup(LEADING, true)
873-
.addComponent(dsFilterLabel)
874-
.addComponent(getDataSetSelector(), DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE)
875-
);
876-
layout.setVerticalGroup(layout.createSequentialGroup()
877-
.addComponent(dsFilterLabel, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE)
878-
.addComponent(getDataSetSelector(), DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE)
879-
);
880-
881-
if (LookAndFeelUtil.isAquaLAF())
882-
panel.setOpaque(false);
883-
884-
return panel;
885-
}
886-
887861
void updateFilterPanel() {
888862
if (nodeCutoffGroup.getSelection() != null) {
889863
boolean isQValue = nodeCutoffGroup.getSelection().equals(getQValueRadio().getModel());

EnrichmentMapPlugin/src/main/java/org/baderlab/csplugins/enrichmentmap/view/control/ControlPanelMediator.java

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import java.util.concurrent.ForkJoinPool;
2424
import java.util.stream.Collectors;
2525

26-
import javax.swing.AbstractAction;
2726
import javax.swing.Action;
2827
import javax.swing.JCheckBoxMenuItem;
2928
import javax.swing.JComboBox;
@@ -375,7 +374,7 @@ private void setCurrentNetworkView(CyNetworkView netView) {
375374
});
376375
}
377376

378-
@SuppressWarnings({ "unchecked", "serial" })
377+
@SuppressWarnings("unchecked")
379378
private void addNetworkView(CyNetworkView netView) {
380379
invokeOnEDT(() -> {
381380
EnrichmentMap map = emManager.getEnrichmentMap(netView.getModel().getSUID());
@@ -453,10 +452,6 @@ private void addNetworkView(CyNetworkView netView) {
453452
viewPanel.getDataSetSelector().getAddButton().addActionListener(evt -> {
454453
postAnalysisPanelMediatorProvider.get().showDialog(viewPanel, netView);
455454
});
456-
viewPanel.getDataSetSelector().getRemoveButton().addActionListener(evt -> {
457-
removeSignatureDataSets(map, viewPanel);
458-
});
459-
460455
viewPanel.getDataSetSelector().getTable().addMouseListener(new MouseAdapter() {
461456
@Override
462457
public void mousePressed(final MouseEvent e) {
@@ -469,16 +464,29 @@ public void mouseReleased(final MouseEvent e) {
469464
private void maybeShowContextMenu(final MouseEvent e) {
470465
if (e.isPopupTrigger()) {
471466
final JPopupMenu contextMenu = new JPopupMenu();
472-
contextMenu.add(new JMenuItem(
473-
new AbstractAction("Select nodes and edges from selected data sets") {
474-
@Override
475-
public void actionPerformed(final ActionEvent e) {
476-
selectNodesEdges(
477-
viewPanel.getNetworkView(),
478-
viewPanel.getDataSetSelector().getSelectedItems()
479-
);
480-
}
481-
}));
467+
{
468+
JMenuItem mi = new JMenuItem("Select nodes and edges from selected data sets");
469+
mi.addActionListener(evt -> selectNodesEdges(viewPanel.getNetworkView(),
470+
viewPanel.getDataSetSelector().getSelectedItems()));
471+
contextMenu.add(mi);
472+
}
473+
contextMenu.addSeparator();
474+
{
475+
Set<AbstractDataSet> selected = viewPanel.getDataSetSelector().getSelectedItems();
476+
boolean onlySignatureSelected = !selected.isEmpty();
477+
478+
for (AbstractDataSet ds : selected) {
479+
if (ds instanceof EMSignatureDataSet == false) {
480+
onlySignatureSelected = false;
481+
break;
482+
}
483+
}
484+
485+
JMenuItem mi = new JMenuItem("Remove selected signature gene sets");
486+
mi.addActionListener(evt -> removeSignatureDataSets(map, viewPanel));
487+
mi.setEnabled(onlySignatureSelected);
488+
contextMenu.add(mi);
489+
}
482490
showContextMenu(contextMenu, e);
483491
}
484492
}

EnrichmentMapPlugin/src/main/java/org/baderlab/csplugins/enrichmentmap/view/control/DataSetSelector.java

Lines changed: 14 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ public class DataSetSelector extends JPanel {
6262
private JTable table;
6363
private JScrollPane tableScrollPane;
6464
private JButton addButton;
65-
private JButton removeButton;
6665
private JButton selectAllButton;
6766
private JButton selectNoneButton;
6867

@@ -104,7 +103,6 @@ public void update() {
104103

105104
updateTable();
106105
updateSelectionButtons();
107-
updateRemoveButton();
108106
}
109107

110108
public Set<AbstractDataSet> getAllItems() {
@@ -153,7 +151,9 @@ public Set<AbstractDataSet> getSelectedItems() {
153151
}
154152

155153
private void init() {
156-
LookAndFeelUtil.equalizeSize(getAddButton(), getRemoveButton());
154+
JLabel titleLabel = new JLabel("Data Sets:");
155+
makeSmall(titleLabel);
156+
157157
LookAndFeelUtil.equalizeSize(getSelectAllButton(), getSelectNoneButton());
158158

159159
final GroupLayout layout = new GroupLayout(this);
@@ -162,23 +162,22 @@ private void init() {
162162
layout.setAutoCreateGaps(!LookAndFeelUtil.isAquaLAF());
163163

164164
layout.setHorizontalGroup(layout.createParallelGroup(CENTER, true)
165-
.addComponent(getTableScrollPane(), DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE)
166-
.addGroup(layout.createSequentialGroup()
167-
.addComponent(getAddButton(), PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE)
168-
.addComponent(getRemoveButton(), PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE)
169-
.addGap(20, 20, Short.MAX_VALUE)
165+
.addGroup(layout.createSequentialGroup()
166+
.addComponent(titleLabel, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE)
170167
.addComponent(getSelectAllButton(), PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE)
171168
.addComponent(getSelectNoneButton(), PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE)
172169
)
170+
.addComponent(getTableScrollPane(), DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE)
171+
.addComponent(getAddButton(), PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE)
173172
);
174173
layout.setVerticalGroup(layout.createSequentialGroup()
175-
.addComponent(getTableScrollPane(), DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE)
176174
.addGroup(layout.createParallelGroup(CENTER, false)
177-
.addComponent(getAddButton(), DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE)
178-
.addComponent(getRemoveButton(), DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE)
179-
.addComponent(getSelectAllButton(), DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE)
180-
.addComponent(getSelectNoneButton(), DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE)
175+
.addComponent(titleLabel, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE)
176+
.addComponent(getSelectAllButton(), PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE)
177+
.addComponent(getSelectNoneButton(), PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE)
181178
)
179+
.addComponent(getTableScrollPane(), DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE)
180+
.addComponent(getAddButton(), PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE)
182181
);
183182

184183
if (isAquaLAF())
@@ -238,26 +237,6 @@ private void updateSelectionButtons() {
238237
getSelectNoneButton().setEnabled(hasChecked);
239238
}
240239

241-
private void updateRemoveButton() {
242-
boolean onlySignatureSelected = true;
243-
int[] selectedRows = getTable().getSelectedRows();
244-
245-
if (selectedRows.length > 0) {
246-
for (int r : selectedRows) {
247-
AbstractDataSet ds = (AbstractDataSet) table.getModel().getValueAt(r, NAME_COL_IDX);
248-
249-
if (ds instanceof EMSignatureDataSet == false) {
250-
onlySignatureSelected = false;
251-
break;
252-
}
253-
}
254-
} else {
255-
onlySignatureSelected = false;
256-
}
257-
258-
getRemoveButton().setEnabled(onlySignatureSelected);
259-
}
260-
261240
JTable getTable() {
262241
if (table == null) {
263242
final DefaultSelectorTableCellRenderer defRenderer = new DefaultSelectorTableCellRenderer();
@@ -281,7 +260,6 @@ public TableCellRenderer getCellRenderer(int row, int column) {
281260

282261
table.getSelectionModel().addListSelectionListener(e -> {
283262
if (!e.getValueIsAdjusting()) {
284-
updateRemoveButton();
285263
// Workaround for preventing a click on the check-box in a selected row
286264
// from changing the selection when multiple table rows are already selected
287265
if (table.getSelectedRowCount() > 0)
@@ -340,9 +318,8 @@ public void mousePressed(MouseEvent e) {
340318

341319
JButton getAddButton() {
342320
if (addButton == null) {
343-
addButton = new JButton(" " + IconManager.ICON_PLUS + " ");
344-
addButton.setFont(serviceRegistrar.getService(IconManager.class).getIconFont(11.0f));
345-
addButton.setToolTipText("Add Signature Gene Sets...");
321+
addButton = new JButton("Add Signature Gene Sets...");
322+
addButton.setToolTipText("Post Analysis");
346323
makeSmall(addButton);
347324

348325
if (isAquaLAF())
@@ -352,20 +329,6 @@ JButton getAddButton() {
352329
return addButton;
353330
}
354331

355-
JButton getRemoveButton() {
356-
if (removeButton == null) {
357-
removeButton = new JButton(IconManager.ICON_TRASH_O);
358-
removeButton.setFont(serviceRegistrar.getService(IconManager.class).getIconFont(14.0f));
359-
removeButton.setToolTipText("Remove Signature Gene Sets");
360-
makeSmall(removeButton);
361-
362-
if (isAquaLAF())
363-
removeButton.putClientProperty("JButton.buttonType", "gradient");
364-
}
365-
366-
return removeButton;
367-
}
368-
369332
JButton getSelectAllButton() {
370333
if (selectAllButton == null) {
371334
selectAllButton = new JButton("Select All");

0 commit comments

Comments
 (0)