Skip to content

Commit

Permalink
Adding select all/unselect all menu items.
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickdalla committed Sep 5, 2023
1 parent a089532 commit 4b606ea
Showing 1 changed file with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ public class LegendItemPopupMenu extends JPopupMenu implements ActionListener {
JMenuItem filter;
JMenuItem unfilter;

JMenuItem selectAll;
JMenuItem unselectAll;

JMenuItem checkItems;
JMenuItem uncheckItems;

Expand All @@ -51,7 +54,15 @@ public LegendItemPopupMenu(IpedChartPanel ipedChartPanel) {
unfilter = new JMenuItem(Messages.getString("TimeLineGraph.unfilterEventFromResultSet", "Unfilter"));
unfilter.addActionListener(this);
add(unfilter);

selectAll = new JMenuItem("Select all event types");
selectAll.addActionListener(this);
add(selectAll);

unselectAll = new JMenuItem("Unselect all event types");
unselectAll.addActionListener(this);
add(unselectAll);

checkItems = new JMenuItem("Check corresponding events items");
checkItems.addActionListener(this);
add(checkItems);
Expand Down Expand Up @@ -198,14 +209,25 @@ public void actionPerformed(ActionEvent e) {
}
ipedChartPanel.filterSelection();
}

//IMPORTANT
if (e.getSource() == checkItems) {
checkEventItems(selLegends);
}
if (e.getSource() == uncheckItems) {
unselectEvents(selLegends);
}

if (e.getSource() == selectAll) {
JList list = ipedChartPanel.getIpedChartsPanel().getLegendList();
list.addSelectionInterval(0, list.getModel().getSize());
}

if (e.getSource() == unselectAll) {
JList list = ipedChartPanel.getIpedChartsPanel().getLegendList();
list.removeSelectionInterval(0, list.getModel().getSize());
}

}

@Override
Expand All @@ -219,6 +241,18 @@ public void show(Component invoker, int x, int y){
boolean selectionContainsSelect = false;
boolean selectionContainsUnselect = false;

if (selLegends.isEmpty()) {
unselectAll.setEnabled(false);
} else {
unselectAll.setEnabled(true);
}

if (selLegends.size() >= list.getModel().getSize()) {
selectAll.setEnabled(false);
} else {
selectAll.setEnabled(true);
}

for (Iterator iterator = selLegends.iterator(); iterator.hasNext();) {
LegendItemBlockContainer legendItemBlockContainer = (LegendItemBlockContainer) iterator.next();

Expand Down

0 comments on commit 4b606ea

Please sign in to comment.