|
|
|
@ -7,14 +7,15 @@ import java.util.concurrent.Executors; |
|
|
|
|
|
|
|
|
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
|
|
|
|
import org.vaadin.addon.borderlayout.BorderLayout; |
|
|
|
import org.vaadin.addon.calendar.ui.CalendarComponentEvents; |
|
|
|
import org.vaadin.addon.calendar.ui.CalendarComponentEvents; |
|
|
|
|
|
|
|
|
|
|
|
import com.vaadin.event.selection.SelectionEvent; |
|
|
|
import com.vaadin.event.selection.SelectionEvent; |
|
|
|
import com.vaadin.navigator.Navigator; |
|
|
|
import com.vaadin.navigator.Navigator; |
|
|
|
import com.vaadin.navigator.View; |
|
|
|
import com.vaadin.navigator.View; |
|
|
|
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent; |
|
|
|
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent; |
|
|
|
import com.vaadin.ui.HorizontalLayout; |
|
|
|
|
|
|
|
import com.vaadin.ui.UI; |
|
|
|
import com.vaadin.ui.UI; |
|
|
|
|
|
|
|
import com.vaadin.ui.VerticalLayout; |
|
|
|
|
|
|
|
|
|
|
|
import de.kreth.vaadin.clubhelper.vaadinclubhelper.business.EventBusiness; |
|
|
|
import de.kreth.vaadin.clubhelper.vaadinclubhelper.business.EventBusiness; |
|
|
|
import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.GroupDao; |
|
|
|
import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.GroupDao; |
|
|
|
@ -22,10 +23,13 @@ import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.PersonDao; |
|
|
|
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubEvent; |
|
|
|
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubEvent; |
|
|
|
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Person; |
|
|
|
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Person; |
|
|
|
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.CalendarComponent; |
|
|
|
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.CalendarComponent; |
|
|
|
|
|
|
|
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.CalendarComponent.ClubEventProvider; |
|
|
|
|
|
|
|
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.HeadComponent; |
|
|
|
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.PersonEditDialog; |
|
|
|
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.PersonEditDialog; |
|
|
|
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.PersonGrid; |
|
|
|
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.PersonGrid; |
|
|
|
|
|
|
|
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.SingleEventView; |
|
|
|
|
|
|
|
|
|
|
|
public class MainView extends HorizontalLayout implements View { |
|
|
|
public class MainView extends BorderLayout implements View { |
|
|
|
|
|
|
|
|
|
|
|
public static final String VIEW_NAME = ""; |
|
|
|
public static final String VIEW_NAME = ""; |
|
|
|
|
|
|
|
|
|
|
|
@ -42,12 +46,14 @@ public class MainView extends HorizontalLayout implements View { |
|
|
|
private EventBusiness eventBusiness; |
|
|
|
private EventBusiness eventBusiness; |
|
|
|
private Navigator navigator; |
|
|
|
private Navigator navigator; |
|
|
|
|
|
|
|
|
|
|
|
public MainView(PersonDao personDao, GroupDao groupDao, EventBusiness eventBusiness) { |
|
|
|
private HeadComponent head; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private SingleEventView eventView; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public MainView(PersonDao personDao, GroupDao groupDao, EventBusiness eventBusiness) { |
|
|
|
this.personDao = personDao; |
|
|
|
this.personDao = personDao; |
|
|
|
this.groupDao = groupDao; |
|
|
|
this.groupDao = groupDao; |
|
|
|
this.eventBusiness = eventBusiness; |
|
|
|
this.eventBusiness = eventBusiness; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
@ -55,23 +61,51 @@ public class MainView extends HorizontalLayout implements View { |
|
|
|
View.super.enter(event); |
|
|
|
View.super.enter(event); |
|
|
|
if (this.navigator == null) { |
|
|
|
if (this.navigator == null) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
initUI(event); |
|
|
|
|
|
|
|
LOGGER.info("Loaded UI and started fetch of Events"); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
loggedinPerson = (Person) getSession().getAttribute(Person.SESSION_LOGIN); |
|
|
|
|
|
|
|
if (loggedinPerson != null) { |
|
|
|
|
|
|
|
LOGGER.info("{} already initialized - opening Person View.", getClass().getName()); |
|
|
|
|
|
|
|
openPersonViewForEvent(eventBusiness.getCurrent()); |
|
|
|
|
|
|
|
calendar.setToday(eventBusiness.getCurrent().getStart()); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
LOGGER.info("{} already initialized - but not loggedin.", getClass().getName()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void initUI(ViewChangeEvent event) { |
|
|
|
navigator = event.getNavigator(); |
|
|
|
navigator = event.getNavigator(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
eventView = new SingleEventView(); |
|
|
|
|
|
|
|
eventView.setVisible(false); |
|
|
|
|
|
|
|
|
|
|
|
personGrid = new PersonGrid(groupDao, personDao); |
|
|
|
personGrid = new PersonGrid(groupDao, personDao); |
|
|
|
personGrid.setId("main.person"); |
|
|
|
personGrid.setId("main.person"); |
|
|
|
personGrid.setCaption("Personen"); |
|
|
|
personGrid.setCaption("Personen"); |
|
|
|
personGrid.onClosedFunction(() -> detailClosed()); |
|
|
|
personGrid.onClosedFunction(() -> detailClosed()); |
|
|
|
personGrid.onPersonSelect(ev -> personSelectionChange(ev)); |
|
|
|
personGrid.onPersonSelect(ev -> personSelectionChange(ev)); |
|
|
|
personGrid.onPersonEdit(p -> onPersonEdit(p)); |
|
|
|
personGrid.onPersonEdit(p -> onPersonEdit(p)); |
|
|
|
|
|
|
|
personGrid.setVisible(false); |
|
|
|
|
|
|
|
|
|
|
|
calendar = new CalendarComponent(); |
|
|
|
VerticalLayout eastLayout = new VerticalLayout(); |
|
|
|
|
|
|
|
eastLayout.addComponents(eventView, personGrid); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ClubEventProvider dataProvider = new ClubEventProvider(); |
|
|
|
|
|
|
|
calendar = new CalendarComponent(dataProvider); |
|
|
|
calendar.setId("main.calendar"); |
|
|
|
calendar.setId("main.calendar"); |
|
|
|
calendar.setHandler(this::onItemClick); |
|
|
|
calendar.setHandler(this::onItemClick); |
|
|
|
|
|
|
|
|
|
|
|
setSizeFull(); |
|
|
|
head = new HeadComponent(() -> calendar.getStartDate(), () -> calendar.getEndDate(), dataProvider); |
|
|
|
addComponents(calendar); |
|
|
|
head.updateMonthText(calendar.getStartDate()); |
|
|
|
|
|
|
|
calendar.add(dateTime -> head.updateMonthText(dateTime)); |
|
|
|
|
|
|
|
|
|
|
|
setSizeFull(); |
|
|
|
setSizeFull(); |
|
|
|
|
|
|
|
addComponent(head, BorderLayout.PAGE_START); |
|
|
|
|
|
|
|
addComponent(calendar, BorderLayout.CENTER); |
|
|
|
|
|
|
|
addComponent(eastLayout, BorderLayout.LINE_END); |
|
|
|
|
|
|
|
|
|
|
|
ExecutorService exec = Executors.newSingleThreadExecutor(); |
|
|
|
ExecutorService exec = Executors.newSingleThreadExecutor(); |
|
|
|
exec.execute(() -> { |
|
|
|
exec.execute(() -> { |
|
|
|
@ -86,18 +120,6 @@ public class MainView extends HorizontalLayout implements View { |
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
exec.shutdown(); |
|
|
|
exec.shutdown(); |
|
|
|
LOGGER.info("Loaded UI and started fetch of Events"); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
loggedinPerson = (Person) getSession().getAttribute(Person.SESSION_LOGIN); |
|
|
|
|
|
|
|
if (loggedinPerson != null) { |
|
|
|
|
|
|
|
LOGGER.info("{} already initialized - opening Person View.", getClass().getName()); |
|
|
|
|
|
|
|
openPersonViewForEvent(eventBusiness.getCurrent()); |
|
|
|
|
|
|
|
calendar.setToday(eventBusiness.getCurrent().getStart()); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
LOGGER.info("{} already initialized - but not loggedin.", getClass().getName()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void onPersonEdit(Person p) { |
|
|
|
private void onPersonEdit(Person p) { |
|
|
|
@ -113,7 +135,8 @@ public class MainView extends HorizontalLayout implements View { |
|
|
|
|
|
|
|
|
|
|
|
private void detailClosed() { |
|
|
|
private void detailClosed() { |
|
|
|
LOGGER.debug("Closing detail view."); |
|
|
|
LOGGER.debug("Closing detail view."); |
|
|
|
removeComponent(personGrid); |
|
|
|
personGrid.setVisible(false); |
|
|
|
|
|
|
|
eventView.setVisible(false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void onItemClick(CalendarComponentEvents.ItemClickEvent event) { |
|
|
|
private void onItemClick(CalendarComponentEvents.ItemClickEvent event) { |
|
|
|
@ -131,14 +154,17 @@ public class MainView extends HorizontalLayout implements View { |
|
|
|
public void openPersonViewForEvent(ClubEvent ev) { |
|
|
|
public void openPersonViewForEvent(ClubEvent ev) { |
|
|
|
LOGGER.debug("Opening detail view for {}", ev); |
|
|
|
LOGGER.debug("Opening detail view for {}", ev); |
|
|
|
|
|
|
|
|
|
|
|
removeComponent(personGrid); |
|
|
|
|
|
|
|
addComponent(personGrid); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
eventBusiness.setSelected(null); |
|
|
|
eventBusiness.setSelected(null); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
eventView.setEvent(ev); |
|
|
|
|
|
|
|
|
|
|
|
personGrid.setEnabled(false); |
|
|
|
personGrid.setEnabled(false); |
|
|
|
personGrid.setEvent(ev); |
|
|
|
personGrid.setEvent(ev); |
|
|
|
personGrid.setEnabled(true); |
|
|
|
personGrid.setEnabled(true); |
|
|
|
|
|
|
|
|
|
|
|
personGrid.setVisible(true); |
|
|
|
personGrid.setVisible(true); |
|
|
|
|
|
|
|
eventView.setVisible(true); |
|
|
|
|
|
|
|
|
|
|
|
eventBusiness.setSelected(ev); |
|
|
|
eventBusiness.setSelected(ev); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|