Added new button 'Add flags to all activities'

This commit is contained in:
Robert Vokac 2024-04-06 10:55:59 +02:00
parent dcc27eefd2
commit 2fa262cf7d
No known key found for this signature in database
GPG Key ID: 693D30BEE3329055
2 changed files with 31 additions and 1 deletions

View File

@ -104,7 +104,7 @@ public class ActivityPanel extends JPanel implements Comparable<ActivityPanel> {
private final TTextField spentTime;
private final TTextField flags;
public final TTextField flags;
@Getter(AccessLevel.PRIVATE)
private final TTextField subject;

View File

@ -95,10 +95,12 @@ public class DayPanel extends JPanel {
JButton reviewButton = new JButton("Copy all Total comments to clipboard");
JButton statusButton = new JButton("Status");
JButton addFlagToAllActivitiesButton = new JButton("Add flag to all activities");
buttons.add(newButton);
buttons.add(pasteButton);
buttons.add(reviewButton);
buttons.add(statusButton);
buttons.add(addFlagToAllActivitiesButton);
add(buttons);
this.scrollPane
@ -208,8 +210,36 @@ public class DayPanel extends JPanel {
Utils.showNotification("Current status: done=" + NumberFormats.FORMATTER_TWO_DECIMAL_PLACES.format(doneHours) + "h, todo="+ NumberFormats.FORMATTER_TWO_DECIMAL_PLACES.format(todoHours));
});
addFlagToAllActivitiesButton.addActionListener(e -> {
String newFlag = (String) JOptionPane.showInputDialog(
null,
"Select new flag",
"New flag",
JOptionPane.PLAIN_MESSAGE,
null,
null,
""
);
if(newFlag != null) {
getActivityPanels().forEach(a->
{
a.getActivity().addFlag(newFlag);
a.flags.setText(a.getActivity().getFlags());
activityRepository.update(a.getActivity());
}
);
revalidate();
}
});
sortActivityPanels();
}
public List<ActivityPanel> getActivityPanels() {
return Arrays
.stream(panelInsideScrollPane.getComponents())
.filter(c-> c instanceof ActivityPanel)
.map(ap->((ActivityPanel) ap)).collect(Collectors.toList());
}
public List<Activity> getActivities() {
return Arrays
.stream(panelInsideScrollPane.getComponents())