Revision f9ea11c9
Added by Patrick Plitzner over 7 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/view/dbstatus/DistributionTableView.java | ||
---|---|---|
8 | 8 |
|
9 | 9 |
import com.vaadin.data.Item; |
10 | 10 |
import com.vaadin.data.Property; |
11 |
import com.vaadin.data.Property.ValueChangeEvent; |
|
12 |
import com.vaadin.data.Property.ValueChangeListener; |
|
11 | 13 |
import com.vaadin.event.ItemClickEvent; |
12 | 14 |
import com.vaadin.event.ItemClickEvent.ItemClickListener; |
13 | 15 |
import com.vaadin.navigator.View; |
14 | 16 |
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent; |
15 | 17 |
import com.vaadin.ui.AbsoluteLayout; |
16 |
import com.vaadin.ui.Alignment; |
|
17 | 18 |
import com.vaadin.ui.Button; |
18 | 19 |
import com.vaadin.ui.Button.ClickEvent; |
19 | 20 |
import com.vaadin.ui.Button.ClickListener; |
... | ... | |
132 | 133 |
UUID uuid = UUID.fromString(itemProperty.getValue().toString()); |
133 | 134 |
final Taxon taxon = HibernateProxyHelper.deproxy(listener.getTaxonService().load(uuid), Taxon.class); |
134 | 135 |
final String areaID = (String) event.getPropertyId(); |
135 |
|
|
136 |
PresenceAbsenceTerm presenceAbsenceTerm = null; |
|
137 |
Object statusValue = item.getItemProperty(areaID).getValue(); |
|
138 |
if(statusValue instanceof String){ |
|
139 |
presenceAbsenceTerm = TermCacher.getInstance().getPresenceAbsenceTerm((String) statusValue); |
|
140 |
} |
|
136 | 141 |
//popup window |
137 | 142 |
final Window popup = new Window("Choose distribution status"); |
138 | 143 |
final ListSelect termSelect = new ListSelect(); |
139 | 144 |
termSelect.setSizeFull(); |
140 |
termSelect.setNullSelectionAllowed(true); |
|
141 | 145 |
termSelect.setContainerDataSource(PresenceAbsenceTermContainer.getInstance()); |
142 |
Button btnOk = new Button("OK", new ClickListener() { |
|
143 |
private static final long serialVersionUID = -3732219609337335697L; |
|
144 |
@Override |
|
145 |
public void buttonClick(ClickEvent event) { |
|
146 |
Object distributionStatus = termSelect.getValue(); |
|
147 |
listener.updateDistributionField(areaID, distributionStatus, taxon); |
|
148 |
container.refresh(); |
|
149 |
popup.close(); |
|
150 |
} |
|
151 |
}); |
|
152 |
VerticalLayout layout = new VerticalLayout(termSelect, btnOk); |
|
153 |
layout.setComponentAlignment(btnOk, Alignment.BOTTOM_RIGHT); |
|
146 |
termSelect.setNullSelectionAllowed(true); |
|
147 |
termSelect.setValue(presenceAbsenceTerm); |
|
148 |
termSelect.addValueChangeListener(new ValueChangeListener() { |
|
149 |
|
|
150 |
private static final long serialVersionUID = 1883728509174752769L; |
|
151 |
|
|
152 |
@Override |
|
153 |
public void valueChange(ValueChangeEvent event) { |
|
154 |
System.out.println(event); |
|
155 |
Object distributionStatus = event.getProperty().getValue(); |
|
156 |
listener.updateDistributionField(areaID, distributionStatus, taxon); |
|
157 |
container.refresh(); |
|
158 |
popup.close(); |
|
159 |
} |
|
160 |
}); |
|
161 |
VerticalLayout layout = new VerticalLayout(termSelect); |
|
154 | 162 |
popup.setContent(layout); |
155 | 163 |
popup.setModal(true); |
156 | 164 |
popup.center(); |
Also available in: Unified diff
ref #5458 Allow one-click selection for status term