From cf912b0558b40f706dff1f3cf0ded78cd7aeb099 Mon Sep 17 00:00:00 2001 From: Markus Kreth Date: Tue, 20 Aug 2019 09:28:12 +0200 Subject: [PATCH] All commands with icons --- .../vaadinclubhelper/data/BaseEntity.java | 3 ++- .../vaadinclubhelper/data/ClubEvent.java | 1 + .../vaadinclubhelper/data/EntityAccessor.java | 2 ++ .../ui/commands/AddPersonCommand.java | 3 ++- .../ui/commands/CreateMeldungCommand.java | 3 ++- .../vaadinclubhelper/ui/commands/LoginCommand.java | 2 +- .../ui/commands/LogoutCommand.java | 2 +- .../ui/components/menu/CommandWrapper.java | 3 +++ .../ui/components/menu/LoggedOffState.java | 14 ++++++++------ .../menu/LoggedinEditPersonViewMenuitemState.java | 4 ++-- .../ui/components/menu/LoggedinMenuitemState.java | 13 ++++++------- 11 files changed, 30 insertions(+), 20 deletions(-) diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/data/BaseEntity.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/data/BaseEntity.java index 5da1aa2..18c186c 100644 --- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/data/BaseEntity.java +++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/data/BaseEntity.java @@ -60,7 +60,8 @@ public abstract class BaseEntity implements EntityAccessor { this.deleted = new Date(deleted.getTime()); } - public int getId() { + @Override + public Integer getId() { return id; } diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/data/ClubEvent.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/data/ClubEvent.java index 9a53ba0..8920463 100644 --- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/data/ClubEvent.java +++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/data/ClubEvent.java @@ -150,6 +150,7 @@ public class ClubEvent extends BasicItem implements EntityAccessor { // noCreateDateStored } + @Override public String getId() { return id; } diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/data/EntityAccessor.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/data/EntityAccessor.java index 3a5b36c..330770c 100644 --- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/data/EntityAccessor.java +++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/data/EntityAccessor.java @@ -4,6 +4,8 @@ import java.util.Date; public interface EntityAccessor { + Object getId(); + boolean hasValidId(); void setChanged(Date changed); diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/commands/AddPersonCommand.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/commands/AddPersonCommand.java index c476d3e..25c4f75 100644 --- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/commands/AddPersonCommand.java +++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/commands/AddPersonCommand.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.function.Consumer; +import com.vaadin.icons.VaadinIcons; import com.vaadin.server.Resource; import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.GroupDef; @@ -28,7 +29,7 @@ public class AddPersonCommand implements ClubCommand { @Override public Resource getIcon() { - return null; + return VaadinIcons.USER_STAR; } @Override diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/commands/CreateMeldungCommand.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/commands/CreateMeldungCommand.java index 89e5456..ebea7b5 100644 --- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/commands/CreateMeldungCommand.java +++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/commands/CreateMeldungCommand.java @@ -4,6 +4,7 @@ import java.util.function.Consumer; import org.springframework.context.ApplicationContext; +import com.vaadin.icons.VaadinIcons; import com.vaadin.server.Resource; import de.kreth.vaadin.clubhelper.vaadinclubhelper.business.EventBusiness; @@ -27,7 +28,7 @@ public class CreateMeldungCommand implements ClubCommand { @Override public Resource getIcon() { - return null; + return VaadinIcons.NEWSPAPER; } @Override diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/commands/LoginCommand.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/commands/LoginCommand.java index 7b58179..0d6668a 100644 --- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/commands/LoginCommand.java +++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/commands/LoginCommand.java @@ -27,7 +27,7 @@ public class LoginCommand implements ClubCommand { @Override public Resource getIcon() { - return VaadinIcons.USER; + return VaadinIcons.SIGN_IN; } } diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/commands/LogoutCommand.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/commands/LogoutCommand.java index c19bf89..8bffc81 100644 --- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/commands/LogoutCommand.java +++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/commands/LogoutCommand.java @@ -26,7 +26,7 @@ public class LogoutCommand implements ClubCommand { @Override public Resource getIcon() { - return VaadinIcons.USER; + return VaadinIcons.SIGN_OUT; } @Override diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/menu/CommandWrapper.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/menu/CommandWrapper.java index 641583c..e5f2db3 100644 --- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/menu/CommandWrapper.java +++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/menu/CommandWrapper.java @@ -35,4 +35,7 @@ public class CommandWrapper implements Command, ClubCommand { command.execute(); } + MenuItem addTo(MenuItem parent) { + return parent.addItem(getLabel(), getIcon(), this); + } } diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/menu/LoggedOffState.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/menu/LoggedOffState.java index a32c8c5..7750960 100644 --- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/menu/LoggedOffState.java +++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/menu/LoggedOffState.java @@ -54,16 +54,18 @@ class LoggedOffState implements MenuItemState { CommandWrapper exportCalendarMonthCommand = new CommandWrapper( new ExportCalendarMonthCommand(startProvider, endProvider, dataProvider, printConsumer)); - fileMenu.addItem(exportCalendarMonthCommand.getLabel(), exportCalendarMonthCommand); + exportCalendarMonthCommand.addTo(fileMenu); + ClubCommand exportCalendarYearCommand = new ExportCalendarYearCommand(startProvider, endProvider, dataProvider, printConsumer); - fileMenu.addItem(exportCalendarYearCommand.getLabel(), new CommandWrapper(exportCalendarYearCommand)); - ClubCommand exportCsvCommand = new ExportCsvCommand(menuBar, context); - fileMenu.addItem(exportCsvCommand.getLabel(), ev -> exportCsvCommand.execute()); + new CommandWrapper(exportCalendarYearCommand).addTo(fileMenu); + + CommandWrapper exportCsvCommand = new CommandWrapper(new ExportCsvCommand(menuBar, context)); + exportCsvCommand.addTo(fileMenu); fileMenu.addSeparator(); - ClubCommand loginCommand = loginOutCommand(); - fileMenu.addItem(loginCommand.getLabel(), new CommandWrapper(loginCommand)); + CommandWrapper loginCommand = new CommandWrapper(loginOutCommand()); + loginCommand.addTo(fileMenu); } diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/menu/LoggedinEditPersonViewMenuitemState.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/menu/LoggedinEditPersonViewMenuitemState.java index 1a77c25..ab329ea 100644 --- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/menu/LoggedinEditPersonViewMenuitemState.java +++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/menu/LoggedinEditPersonViewMenuitemState.java @@ -44,7 +44,7 @@ class LoggedinEditPersonViewMenuitemState extends LoggedinMenuitemState { GroupDef defaultGroup = groupDao.get(1); editMenu.addSeparator(); - AddPersonCommand addPersonCommand = new AddPersonCommand(newPersonConsumer, defaultGroup); - editMenu.addItem(addPersonCommand.getLabel(), new CommandWrapper(addPersonCommand)); + CommandWrapper addPersonCommand = new CommandWrapper(new AddPersonCommand(newPersonConsumer, defaultGroup)); + addPersonCommand.addTo(editMenu); } } diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/menu/LoggedinMenuitemState.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/menu/LoggedinMenuitemState.java index 5af631d..a032dbb 100644 --- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/menu/LoggedinMenuitemState.java +++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/menu/LoggedinMenuitemState.java @@ -101,17 +101,17 @@ class LoggedinMenuitemState extends LoggedOffState { CommandWrapper calendarView = new CommandWrapper( new SwitchViewCommand(context, "Hauptansicht", VaadinIcons.CALENDAR, ClubhelperViews.MainView)); - calendarMenuItem = viewMenu.addItem(calendarView.getLabel(), calendarView); + calendarMenuItem = calendarView.addTo(viewMenu); calendarMenuItem.setCheckable(true); CommandWrapper openPersonEditor = new CommandWrapper( new SwitchViewCommand(context, "Personen verwalten", VaadinIcons.EDIT, ClubhelperViews.PersonEditView)); - openPersonMenuItem = viewMenu.addItem(openPersonEditor.getLabel(), openPersonEditor); + openPersonMenuItem = openPersonEditor.addTo(viewMenu); openPersonMenuItem.setCheckable(true); CommandWrapper detailViewCommand = new CommandWrapper( new SwitchViewCommand(context, "Veranstaltung Detail", null, ClubhelperViews.EventDetails)); - eventDetailItem = viewMenu.addItem(detailViewCommand.getLabel(), detailViewCommand); + eventDetailItem = detailViewCommand.addTo(viewMenu); eventDetailItem.setCheckable(true); } @@ -119,12 +119,11 @@ class LoggedinMenuitemState extends LoggedOffState { MenuItem editMenu = menuBar.getEditMenuItem(); editMenu.setVisible(true); - CreateMeldungCommand createMeldungCommand = new CreateMeldungCommand(context, this::show); - createMeldungMenuItem = editMenu.addItem(createMeldungCommand.getLabel(), - new CommandWrapper(createMeldungCommand)); + CommandWrapper createMeldungCommand = new CommandWrapper(new CreateMeldungCommand(context, this::show)); + createMeldungMenuItem = createMeldungCommand.addTo(editMenu); CommandWrapper deleeteEvent = new CommandWrapper(new DeleteEventCommand(this::deleteEvent)); - deleteMenuItem = editMenu.addItem(deleeteEvent.getLabel(), deleeteEvent); + deleteMenuItem = deleeteEvent.addTo(editMenu); }