GroupDef bugfix, Refactoring

master
Markus Kreth 7 years ago
parent 184bbf1e20
commit c60b46c02a
  1. 21
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/data/GroupDef.java
  2. 64
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/PersonGrid.java
  3. 1
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/SingleEventView.java

@ -67,29 +67,28 @@ public class GroupDef extends BaseEntity implements Serializable {
final int prime = 31;
int result = super.hashCode();
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + ((persongroups == null) ? 0 : persongroups.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
if (this == obj) {
return true;
if (!super.equals(obj))
}
if (!super.equals(obj)) {
return false;
if (getClass() != obj.getClass())
}
if (getClass() != obj.getClass()) {
return false;
}
GroupDef other = (GroupDef) obj;
if (name == null) {
if (other.name != null)
return false;
} else if (!name.equals(other.name))
if (other.name != null) {
return false;
if (persongroups == null) {
if (other.persongroups != null)
return false;
} else if (!persongroups.equals(other.persongroups))
}
} else if (!name.equals(other.name)) {
return false;
}
return true;
}

@ -19,10 +19,10 @@ import com.vaadin.icons.VaadinIcons;
import com.vaadin.ui.Button;
import com.vaadin.ui.CheckBox;
import com.vaadin.ui.ComboBox;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.Grid;
import com.vaadin.ui.Grid.SelectionMode;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Layout;
import com.vaadin.ui.MultiSelect;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.themes.ValoTheme;
@ -33,7 +33,7 @@ import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubEvent;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.GroupDef;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Person;
public class PersonGrid extends CustomComponent {
public class PersonGrid extends VerticalLayout {
private static final long serialVersionUID = -8148097982839343673L;
private final transient Logger log = LoggerFactory.getLogger(getClass());
@ -58,52 +58,64 @@ public class PersonGrid extends CustomComponent {
setCaption("Teilnehmer");
addStyleName("bold-caption");
checkIncluded = new CheckBox("Nur gemeldete");
checkIncluded.setId("person.filter.checked");
checkIncluded.addValueChangeListener(ev -> onSelectedOnly(ev));
comboGroups = new ComboBox<>("Gruppenfilter");
comboGroups.setId("person.filter.groups");
comboGroups.setEmptySelectionAllowed(true);
comboGroups.setEmptySelectionCaption("Alle");
comboGroups.setItemCaptionGenerator(GroupDef::getName);
comboGroups.addSelectionListener(ev -> onGroupSelected(ev));
Layout filters = setupFilterComponents();
allGroups = groupDao.listAll();
comboGroups.setItems(allGroups);
log.info("Loaded Groups: {}", allGroups);
HorizontalLayout filters = new HorizontalLayout();
filters.addComponents(checkIncluded, comboGroups);
filter = new PersonFilter(personDao);
dataProvider = DataProvider.ofCollection(filter.asCollection());
grid = new Grid<>();
setupPersonGrid(personDao);
Button close = new Button("Schließen", ev -> {
PersonGrid.this.setVisible(false);
if (closedFunction != null) {
closedFunction.closed();
}
});
close.setId("person.close");
setMargin(false);
addComponents(filters, grid, close);
}
public void setupPersonGrid(PersonDao personDao) {
filter.add(() -> {
setEvent(currentEvent);
});
dataProvider = DataProvider.ofCollection(filter.asCollection());
dataProvider.addDataProviderListener(filter);
grid = new Grid<>();
grid.setDataProvider(dataProvider);
grid.setId("person.grid");
grid.addColumn(Person::getPrename).setCaption("Vorname");
grid.addColumn(Person::getSurname).setCaption("Nachname");
grid.addColumn(Person::getBirth, b -> b != null ? birthFormat.format(b) : "").setCaption("Geburtstag");
grid.addComponentColumn(this::buildDeleteButton);
grid.addComponentColumn(this::buildPersonEditButton);
grid.setSelectionMode(SelectionMode.MULTI);
Button close = new Button("Schließen", ev -> {
PersonGrid.this.setVisible(false);
if (closedFunction != null) {
closedFunction.closed();
}
});
close.setId("person.close");
VerticalLayout panel = new VerticalLayout();
panel.addComponents(filters, grid, close);
setCompositionRoot(panel);
private Layout setupFilterComponents() {
checkIncluded.setId("person.filter.checked");
checkIncluded.addValueChangeListener(ev -> onSelectedOnly(ev));
comboGroups.setId("person.filter.groups");
comboGroups.setEmptySelectionAllowed(true);
comboGroups.setEmptySelectionCaption("Alle");
comboGroups.setItemCaptionGenerator(GroupDef::getName);
comboGroups.addSelectionListener(ev -> onGroupSelected(ev));
HorizontalLayout filters = new HorizontalLayout();
filters.setMargin(false);
filters.addComponents(checkIncluded, comboGroups);
return filters;
}
private Button buildDeleteButton(Person p) {
private Button buildPersonEditButton(Person p) {
Button button = new Button(VaadinIcons.EDIT);
button.addStyleName(ValoTheme.BUTTON_SMALL);
button.addClickListener(e -> showPersonDetails(p));

@ -32,6 +32,7 @@ public class SingleEventView extends CustomComponent {
textLocation.setSizeFull();
VerticalLayout panel = new VerticalLayout();
panel.setMargin(false);
panel.addComponents(textTitle, textLocation);
setCompositionRoot(panel);
}

Loading…
Cancel
Save