Revision 4cb460fd
Added by Fabian Reimeier over 6 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/view/distributionStatus/DistributionTableViewBean.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.cdm.vaadin.view.distributionStatus; |
10 | 10 |
|
11 |
import java.sql.SQLException; |
|
12 |
import java.util.ArrayList; |
|
13 |
import java.util.Arrays; |
|
11 | 14 |
import java.util.Collection; |
12 | 15 |
import java.util.List; |
13 | 16 |
import java.util.UUID; |
... | ... | |
16 | 19 |
import org.springframework.security.core.GrantedAuthority; |
17 | 20 |
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer; |
18 | 21 |
|
19 |
import com.vaadin.data.fieldgroup.FieldGroup.CommitEvent; |
|
20 |
import com.vaadin.data.fieldgroup.FieldGroup.CommitException; |
|
21 |
import com.vaadin.data.fieldgroup.FieldGroup.CommitHandler; |
|
22 |
import com.vaadin.data.util.converter.Converter; |
|
22 |
import com.vaadin.data.Item; |
|
23 |
import com.vaadin.data.Property; |
|
23 | 24 |
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent; |
24 | 25 |
import com.vaadin.spring.annotation.SpringView; |
25 | 26 |
import com.vaadin.spring.annotation.ViewScope; |
26 | 27 |
import com.vaadin.ui.AbsoluteLayout; |
27 |
import com.vaadin.ui.AbstractSelect.ItemCaptionMode; |
|
28 | 28 |
import com.vaadin.ui.Button; |
29 | 29 |
import com.vaadin.ui.Grid; |
30 |
import com.vaadin.ui.Grid.Column; |
|
31 |
import com.vaadin.ui.Grid.FooterCell; |
|
32 | 30 |
import com.vaadin.ui.Grid.FooterRow; |
33 |
import com.vaadin.ui.NativeSelect;
|
|
31 |
import com.vaadin.ui.ListSelect;
|
|
34 | 32 |
import com.vaadin.ui.Notification; |
35 | 33 |
import com.vaadin.ui.Notification.Type; |
36 | 34 |
import com.vaadin.ui.Table; |
37 | 35 |
import com.vaadin.ui.UI; |
36 |
import com.vaadin.ui.VerticalLayout; |
|
38 | 37 |
import com.vaadin.ui.Window; |
39 | 38 |
|
39 |
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper; |
|
40 | 40 |
import eu.etaxonomy.cdm.i10n.Messages; |
41 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
|
41 | 42 |
import eu.etaxonomy.cdm.model.common.Language; |
43 |
import eu.etaxonomy.cdm.model.common.Representation; |
|
42 | 44 |
import eu.etaxonomy.cdm.model.description.DescriptionElementBase; |
43 |
import eu.etaxonomy.cdm.model.location.NamedArea;
|
|
45 |
import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm;
|
|
44 | 46 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
45 | 47 |
import eu.etaxonomy.cdm.vaadin.component.DetailWindow; |
46 | 48 |
import eu.etaxonomy.cdm.vaadin.component.DistributionToolbar; |
47 | 49 |
import eu.etaxonomy.cdm.vaadin.container.CdmSQLContainer; |
48 | 50 |
import eu.etaxonomy.cdm.vaadin.security.AccessRestrictedView; |
51 |
import eu.etaxonomy.cdm.vaadin.util.CdmQueryFactory; |
|
49 | 52 |
import eu.etaxonomy.cdm.vaadin.util.CdmSpringContextHelper; |
50 | 53 |
import eu.etaxonomy.cdm.vaadin.util.DistributionEditorUtil; |
51 |
import eu.etaxonomy.cdm.vaadin.util.DistributionStatusQuery; |
|
52 |
import eu.etaxonomy.cdm.vaadin.util.converter.PresenceAbsenceTermUuidObjectConverter; |
|
53 |
import eu.etaxonomy.cdm.vaadin.util.converter.PresenceAbsenceTermUuidTitleStringConverter; |
|
54 | 54 |
import eu.etaxonomy.cdm.vaadin.view.AbstractPageView; |
55 | 55 |
|
56 | 56 |
/** |
... | ... | |
95 | 95 |
//Horizontal Toolbar |
96 | 96 |
mainLayout.addComponent(toolbar, "top:0.0px;right:0.0px;"); //$NON-NLS-1$ |
97 | 97 |
|
98 |
// // table + formatting
|
|
99 |
// table = new Table(){
|
|
100 |
// private static final long serialVersionUID = -5148756917468804385L;
|
|
101 |
// |
|
102 |
// @Override
|
|
103 |
// protected String formatPropertyValue(Object rowId, Object colId, Property<?> property) {
|
|
104 |
// String formattedValue = null;
|
|
105 |
// PresenceAbsenceTerm presenceAbsenceTerm = null;
|
|
106 |
// Object value = property.getValue();
|
|
107 |
// if(value instanceof String){
|
|
98 |
// table + formatting |
|
99 |
table = new Table(){ |
|
100 |
private static final long serialVersionUID = -5148756917468804385L; |
|
101 |
|
|
102 |
@Override |
|
103 |
protected String formatPropertyValue(Object rowId, Object colId, Property<?> property) { |
|
104 |
String formattedValue = null; |
|
105 |
PresenceAbsenceTerm presenceAbsenceTerm = null; |
|
106 |
Object value = property.getValue(); |
|
107 |
if(value instanceof String){ |
|
108 | 108 |
// presenceAbsenceTerm = TermCacher.getInstance().getPresenceAbsenceTerm((String) value); |
109 |
// } |
|
110 |
// if(presenceAbsenceTerm != null){ |
|
111 |
// Representation representation = presenceAbsenceTerm.getRepresentation(Language.DEFAULT()); |
|
112 |
// if(representation!=null){ |
|
113 |
// if(DistributionEditorUtil.isAbbreviatedLabels()){ |
|
114 |
// formattedValue = representation.getAbbreviatedLabel(); |
|
115 |
// } |
|
116 |
// else{ |
|
117 |
// formattedValue = representation.getLabel(); |
|
118 |
// } |
|
119 |
// } |
|
120 |
// if(formattedValue==null){ |
|
121 |
// formattedValue = presenceAbsenceTerm.getTitleCache(); |
|
122 |
// } |
|
123 |
// return formattedValue; |
|
124 |
// } |
|
125 |
// return super.formatPropertyValue(rowId, colId, property); |
|
126 |
// } |
|
127 |
// }; |
|
128 |
// table.setImmediate(false); |
|
129 |
// table.setWidth("100.0%"); |
|
130 |
// table.setHeight("100.0%"); |
|
131 |
// |
|
132 |
// table.setColumnReorderingAllowed(true); |
|
133 |
// table.setSortEnabled(false); |
|
134 |
// |
|
135 |
// table.setColumnCollapsingAllowed(true); |
|
136 |
// table.setSelectable(true); |
|
137 |
// table.setPageLength(20); |
|
138 |
// table.setFooterVisible(true); |
|
139 |
// table.setCacheRate(20); |
|
140 |
// |
|
141 |
// table.addItemClickListener(event -> { |
|
142 |
// if(!(event.getPropertyId().toString().equalsIgnoreCase(CdmQueryFactory.TAXON_COLUMN)) |
|
143 |
// && !(event.getPropertyId().toString().equalsIgnoreCase(CdmQueryFactory.RANK_COLUMN)) |
|
144 |
// // TODO: HACK FOR RL 2017, REMOVE AS SOON AS POSSIBLE |
|
145 |
// && !(event.getPropertyId().toString().equalsIgnoreCase("DE")) |
|
146 |
// && !(event.getPropertyId().toString().equalsIgnoreCase("Deutschland"))){ |
|
147 |
// final Item item = event.getItem(); |
|
148 |
// Property<?> itemProperty = item.getItemProperty("uuid"); |
|
149 |
// UUID uuid = UUID.fromString(itemProperty.getValue().toString()); |
|
150 |
// final Taxon taxon = CdmBase.deproxy(CdmSpringContextHelper.getTaxonService() |
|
151 |
// .load(uuid,Arrays.asList("descriptions.descriptionElements","name.taxonBases","updatedBy")), Taxon.class); |
|
152 |
// final String areaID = (String)event.getPropertyId(); |
|
153 |
// PresenceAbsenceTerm presenceAbsenceTerm = null; |
|
154 |
// Object statusValue = item.getItemProperty(areaID).getValue(); |
|
155 |
// if(statusValue instanceof String){ |
|
109 |
try { |
|
110 |
presenceAbsenceTerm = (PresenceAbsenceTerm)CdmSpringContextHelper.getTermService().load(UUID.fromString((String)value)); |
|
111 |
}catch(IllegalArgumentException|ClassCastException e) { |
|
112 |
// Not a PresenceAbsenceTerm Column |
|
113 |
} |
|
114 |
} |
|
115 |
if(presenceAbsenceTerm != null){ |
|
116 |
Representation representation = presenceAbsenceTerm.getRepresentation(Language.DEFAULT()); |
|
117 |
if(representation!=null){ |
|
118 |
if(DistributionEditorUtil.isAbbreviatedLabels()){ |
|
119 |
formattedValue = representation.getAbbreviatedLabel(); |
|
120 |
} |
|
121 |
else{ |
|
122 |
formattedValue = representation.getLabel(); |
|
123 |
} |
|
124 |
} |
|
125 |
if(formattedValue==null){ |
|
126 |
formattedValue = presenceAbsenceTerm.getTitleCache(); |
|
127 |
} |
|
128 |
return formattedValue; |
|
129 |
} |
|
130 |
return super.formatPropertyValue(rowId, colId, property); |
|
131 |
} |
|
132 |
}; |
|
133 |
table.setImmediate(false); |
|
134 |
table.setWidth("100.0%"); |
|
135 |
table.setHeight("100.0%"); |
|
136 |
|
|
137 |
table.setColumnReorderingAllowed(true); |
|
138 |
table.setSortEnabled(false); |
|
139 |
|
|
140 |
table.setColumnCollapsingAllowed(true); |
|
141 |
table.setSelectable(true); |
|
142 |
table.setPageLength(20); |
|
143 |
table.setFooterVisible(true); |
|
144 |
table.setCacheRate(20); |
|
145 |
|
|
146 |
table.addItemClickListener(event -> { |
|
147 |
if(!(event.getPropertyId().toString().equalsIgnoreCase(CdmQueryFactory.TAXON_COLUMN)) |
|
148 |
&& !(event.getPropertyId().toString().equalsIgnoreCase(CdmQueryFactory.RANK_COLUMN)) |
|
149 |
// TODO: HACK FOR RL 2017, REMOVE AS SOON AS POSSIBLE |
|
150 |
&& !(event.getPropertyId().toString().equalsIgnoreCase("DE")) |
|
151 |
&& !(event.getPropertyId().toString().equalsIgnoreCase("Deutschland"))){ |
|
152 |
final Item item = event.getItem(); |
|
153 |
Property<?> itemProperty = item.getItemProperty("uuid"); |
|
154 |
UUID uuid = UUID.fromString(itemProperty.getValue().toString()); |
|
155 |
final Taxon taxon = CdmBase.deproxy(CdmSpringContextHelper.getTaxonService() |
|
156 |
.load(uuid,Arrays.asList("descriptions.descriptionElements","name.taxonBases","updatedBy")), Taxon.class); |
|
157 |
final String areaID = (String)event.getPropertyId(); |
|
158 |
PresenceAbsenceTerm presenceAbsenceTerm = null; |
|
159 |
Object statusValue = item.getItemProperty(areaID).getValue(); |
|
160 |
if(statusValue instanceof String){ |
|
156 | 161 |
// presenceAbsenceTerm = TermCacher.getInstance().getPresenceAbsenceTerm((String) statusValue); |
157 |
// } |
|
158 |
// //popup window |
|
159 |
// final Window popup = new Window("Choose distribution status"); |
|
160 |
// final ListSelect termSelect = new ListSelect(); |
|
161 |
// termSelect.setSizeFull(); |
|
162 |
// termSelect.setContainerDataSource(getPresenter().getPresenceAbsenceTermContainer()); |
|
163 |
// termSelect.setNullSelectionAllowed(presenceAbsenceTerm != null); |
|
164 |
// if(presenceAbsenceTerm != null){ |
|
165 |
// termSelect.setNullSelectionItemId("[no status]"); |
|
166 |
// }else{ |
|
167 |
// logger.debug("No distribution status exists yet for area"); |
|
168 |
// } |
|
169 |
// termSelect.setValue(presenceAbsenceTerm); |
|
170 |
// termSelect.addValueChangeListener(valueChangeEvent -> { |
|
171 |
// Object distributionStatus = valueChangeEvent.getProperty().getValue(); |
|
172 |
// getPresenter().updateDistributionField(areaID, distributionStatus, taxon); |
|
173 |
// container.refresh(); |
|
174 |
// popup.close(); |
|
175 |
// }); |
|
176 |
// VerticalLayout layout = new VerticalLayout(termSelect); |
|
177 |
// popup.setContent(layout); |
|
178 |
// popup.setModal(true); |
|
179 |
// popup.center(); |
|
180 |
// UI.getCurrent().addWindow(popup); |
|
181 |
// } |
|
182 |
// }); |
|
183 |
// |
|
184 |
// mainLayout.addComponent(table, "top:75px;right:10.0px;left:10.0px;"); |
|
162 |
try { |
|
163 |
presenceAbsenceTerm = (PresenceAbsenceTerm)CdmSpringContextHelper.getTermService().load(UUID.fromString((String)statusValue)); |
|
164 |
}catch(IllegalArgumentException|ClassCastException e) { |
|
165 |
// Not a PresenceAbsenceTerm Column |
|
166 |
} |
|
167 |
} |
|
168 |
//popup window |
|
169 |
final Window popup = new Window("Choose distribution status"); |
|
170 |
final ListSelect termSelect = new ListSelect(); |
|
171 |
termSelect.setSizeFull(); |
|
172 |
termSelect.setContainerDataSource(getPresenter().getPresenceAbsenceTermContainer()); |
|
173 |
termSelect.setNullSelectionAllowed(presenceAbsenceTerm != null); |
|
174 |
if(presenceAbsenceTerm != null){ |
|
175 |
termSelect.setNullSelectionItemId("[no status]"); |
|
176 |
}else{ |
|
177 |
logger.debug("No distribution status exists yet for area"); |
|
178 |
} |
|
179 |
termSelect.setValue(presenceAbsenceTerm); |
|
180 |
termSelect.addValueChangeListener(valueChangeEvent -> { |
|
181 |
Object distributionStatus = valueChangeEvent.getProperty().getValue(); |
|
182 |
getPresenter().updateDistributionField(areaID, distributionStatus, taxon); |
|
183 |
container.refresh(); |
|
184 |
popup.close(); |
|
185 |
}); |
|
186 |
VerticalLayout layout = new VerticalLayout(termSelect); |
|
187 |
popup.setContent(layout); |
|
188 |
popup.setModal(true); |
|
189 |
popup.center(); |
|
190 |
UI.getCurrent().addWindow(popup); |
|
191 |
} |
|
192 |
}); |
|
185 | 193 |
|
186 |
grid = new Grid(); |
|
187 |
grid.setSizeFull(); |
|
188 |
grid.setEditorEnabled(true); |
|
189 |
grid.setFooterVisible(true); |
|
190 |
mainLayout.addComponent(grid, "top:75px;right:10.0px;left:10.0px;"); //$NON-NLS-1$ |
|
194 |
mainLayout.addComponent(table, "top:75px;right:10.0px;left:10.0px;"); |
|
195 |
|
|
196 |
// grid = new Grid(); |
|
197 |
// grid.setSizeFull(); |
|
198 |
// grid.setEditorEnabled(true); |
|
199 |
// grid.setFooterVisible(true); |
|
200 |
// mainLayout.addComponent(grid, "top:75px;right:10.0px;left:10.0px;"); //$NON-NLS-1$ |
|
191 | 201 |
|
192 | 202 |
return mainLayout; |
193 | 203 |
} |
... | ... | |
205 | 215 |
*/ |
206 | 216 |
@Override |
207 | 217 |
public void update(){ |
208 |
// try {
|
|
209 |
// container = getPresenter().getSQLContainer();
|
|
210 |
// } catch (SQLException e) {
|
|
211 |
// DistributionEditorUtil.showSqlError(e);
|
|
212 |
// return;
|
|
213 |
// }
|
|
214 |
// if(container==null){
|
|
215 |
// return;
|
|
216 |
// }
|
|
217 |
|
|
218 |
// table.setContainerDataSource(container);
|
|
219 |
// |
|
220 |
// List<String> columnHeaders = new ArrayList<>(Arrays.asList(table.getColumnHeaders()));
|
|
221 |
// columnHeaders.remove(CdmQueryFactory.DTYPE_COLUMN);
|
|
222 |
// columnHeaders.remove(CdmQueryFactory.ID_COLUMN);
|
|
223 |
// columnHeaders.remove(CdmQueryFactory.UUID_COLUMN);
|
|
224 |
// columnHeaders.remove(CdmQueryFactory.CLASSIFICATION_COLUMN);
|
|
218 |
try { |
|
219 |
container = getPresenter().getSQLContainer(); |
|
220 |
} catch (SQLException e) { |
|
221 |
DistributionEditorUtil.showSqlError(e); |
|
222 |
return; |
|
223 |
} |
|
224 |
if(container==null){ |
|
225 |
return; |
|
226 |
} |
|
227 |
|
|
228 |
table.setContainerDataSource(container); |
|
229 |
|
|
230 |
List<String> columnHeaders = new ArrayList<>(Arrays.asList(table.getColumnHeaders())); |
|
231 |
columnHeaders.remove(CdmQueryFactory.DTYPE_COLUMN); |
|
232 |
columnHeaders.remove(CdmQueryFactory.ID_COLUMN); |
|
233 |
columnHeaders.remove(CdmQueryFactory.UUID_COLUMN); |
|
234 |
columnHeaders.remove(CdmQueryFactory.CLASSIFICATION_COLUMN); |
|
225 | 235 |
// columnHeaders.sort(new Comparator<String>() { |
226 | 236 |
// @Override |
227 | 237 |
// public int compare(String o1, String o2) { |
... | ... | |
241 | 251 |
// return o1.compareTo(o2); |
242 | 252 |
// } |
243 | 253 |
// }); |
244 |
// |
|
245 |
// List<String> columnList = new ArrayList<>(columnHeaders); |
|
246 |
// |
|
247 |
// String[] string = new String[columnList.size()]; |
|
248 |
// |
|
249 |
// table.setVisibleColumns(columnList.toArray()); |
|
250 |
// table.setColumnHeaders(columnList.toArray(string)); |
|
251 |
// table.setColumnFooter(CdmQueryFactory.TAXON_COLUMN, "Total amount of Taxa displayed: " + container.size()); |
|
252 |
|
|
253 |
gridcontainer = getPresenter().getAreaDistributionStatusContainer(); |
|
254 |
if(gridcontainer==null){ |
|
255 |
return; |
|
256 |
} |
|
257 | 254 |
|
258 |
if(footerRow != null) { |
|
259 |
grid.removeFooterRow(footerRow); |
|
260 |
} |
|
261 |
grid.removeAllColumns(); |
|
262 |
|
|
263 |
grid.setContainerDataSource(gridcontainer); |
|
264 |
|
|
265 |
Column uuidColumn = grid.getColumn(DistributionStatusQuery.UUID_COLUMN); |
|
266 |
uuidColumn.setEditable(false); |
|
267 |
uuidColumn.setHidden(true); |
|
268 |
Column taxonColumn = grid.getColumn(DistributionStatusQuery.TAXON_COLUMN); |
|
269 |
taxonColumn.setEditable(false); |
|
270 |
taxonColumn.setHeaderCaption(Messages.DistributionTableViewBean_TAXON); |
|
271 |
taxonColumn.setLastFrozenColumn(); |
|
272 |
|
|
273 |
Converter<String, UUID> displayConverter = new PresenceAbsenceTermUuidTitleStringConverter(); |
|
274 |
Converter<Object, UUID> editorConverter = new PresenceAbsenceTermUuidObjectConverter(); |
|
275 |
for(Column c : grid.getColumns()) { |
|
276 |
if(c.isEditable()) { |
|
277 |
NamedArea namedArea = (NamedArea) CdmSpringContextHelper.getTermService().load((UUID.fromString(c.getHeaderCaption()))); |
|
278 |
String caption = DistributionEditorUtil.isAbbreviatedLabels() ? |
|
279 |
namedArea.getRepresentation(Language.DEFAULT()).getAbbreviatedLabel() : namedArea.getTitleCache(); |
|
280 |
c.setHeaderCaption(caption); |
|
281 |
c.setConverter(displayConverter); |
|
282 |
|
|
283 |
NativeSelect termSelect = new NativeSelect(); |
|
284 |
termSelect.setSizeFull(); |
|
285 |
termSelect.setContainerDataSource(getPresenter().getPresenceAbsenceTermContainer()); |
|
286 |
termSelect.setItemCaptionMode(ItemCaptionMode.PROPERTY); |
|
287 |
termSelect.setItemCaptionPropertyId("titleCache"); //$NON-NLS-1$ |
|
288 |
termSelect.setConverter(editorConverter); |
|
289 |
termSelect.setImmediate(true); |
|
290 |
c.setEditorField(termSelect); |
|
291 |
} |
|
292 |
} |
|
293 |
grid.getEditorFieldGroup().addCommitHandler(new CommitHandler() { |
|
294 |
private static final long serialVersionUID = 7515807188410712420L; |
|
255 |
List<String> columnList = new ArrayList<>(columnHeaders); |
|
295 | 256 |
|
296 |
@Override |
|
297 |
public void preCommit(CommitEvent commitEvent) throws CommitException { |
|
257 |
String[] string = new String[columnList.size()]; |
|
298 | 258 |
|
299 |
} |
|
259 |
table.setVisibleColumns(columnList.toArray()); |
|
260 |
table.setColumnHeaders(columnList.toArray(string)); |
|
261 |
table.setColumnFooter(CdmQueryFactory.TAXON_COLUMN, "Total amount of Taxa displayed: " + container.size()); |
|
300 | 262 |
|
301 |
@Override |
|
302 |
public void postCommit(CommitEvent commitEvent) throws CommitException { |
|
303 |
gridcontainer.commit(); |
|
304 |
} |
|
305 |
}); |
|
306 |
|
|
307 |
footerRow = grid.appendFooterRow(); |
|
308 |
Object[] cells = grid.getColumns().stream().map(c -> c.getPropertyId()).toArray(Object[]::new); |
|
309 |
if(cells.length == 0) { |
|
310 |
return; |
|
311 |
} |
|
312 |
FooterCell footerCell = null; |
|
313 |
if(cells.length > 1) { |
|
314 |
footerCell = footerRow.join(cells); |
|
315 |
}else { |
|
316 |
footerCell = footerRow.getCell(cells[0]); |
|
317 |
} |
|
318 |
footerCell.setText(String.format(Messages.DistributionTableViewBean_TOTAL_TAXA, gridcontainer.size())); |
|
263 |
// gridcontainer = getPresenter().getAreaDistributionStatusContainer(); |
|
264 |
// if(gridcontainer==null){ |
|
265 |
// return; |
|
266 |
// } |
|
267 |
// |
|
268 |
// if(footerRow != null) { |
|
269 |
// grid.removeFooterRow(footerRow); |
|
270 |
// } |
|
271 |
// grid.removeAllColumns(); |
|
272 |
// |
|
273 |
// grid.setContainerDataSource(gridcontainer); |
|
274 |
// |
|
275 |
// Column uuidColumn = grid.getColumn(DistributionStatusQuery.UUID_COLUMN); |
|
276 |
// uuidColumn.setEditable(false); |
|
277 |
// uuidColumn.setHidden(true); |
|
278 |
// Column taxonColumn = grid.getColumn(DistributionStatusQuery.TAXON_COLUMN); |
|
279 |
// taxonColumn.setEditable(false); |
|
280 |
// taxonColumn.setHeaderCaption(Messages.DistributionTableViewBean_TAXON); |
|
281 |
// taxonColumn.setLastFrozenColumn(); |
|
282 |
// |
|
283 |
// Converter<String, UUID> displayConverter = new PresenceAbsenceTermUuidTitleStringConverter(); |
|
284 |
// Converter<Object, UUID> editorConverter = new PresenceAbsenceTermUuidObjectConverter(); |
|
285 |
// for(Column c : grid.getColumns()) { |
|
286 |
// if(c.isEditable()) { |
|
287 |
// NamedArea namedArea = (NamedArea) CdmSpringContextHelper.getTermService().load((UUID.fromString(c.getHeaderCaption()))); |
|
288 |
// String caption = DistributionEditorUtil.isAbbreviatedLabels() ? |
|
289 |
// namedArea.getRepresentation(Language.DEFAULT()).getAbbreviatedLabel() : namedArea.getTitleCache(); |
|
290 |
// c.setHeaderCaption(caption); |
|
291 |
// c.setConverter(displayConverter); |
|
292 |
// |
|
293 |
// NativeSelect termSelect = new NativeSelect(); |
|
294 |
// termSelect.setSizeFull(); |
|
295 |
// termSelect.setContainerDataSource(getPresenter().getPresenceAbsenceTermContainer()); |
|
296 |
// termSelect.setItemCaptionMode(ItemCaptionMode.PROPERTY); |
|
297 |
// termSelect.setItemCaptionPropertyId("titleCache"); //$NON-NLS-1$ |
|
298 |
// termSelect.setConverter(editorConverter); |
|
299 |
// termSelect.setImmediate(true); |
|
300 |
// c.setEditorField(termSelect); |
|
301 |
// } |
|
302 |
// } |
|
303 |
// grid.getEditorFieldGroup().addCommitHandler(new CommitHandler() { |
|
304 |
// private static final long serialVersionUID = 7515807188410712420L; |
|
305 |
// |
|
306 |
// @Override |
|
307 |
// public void preCommit(CommitEvent commitEvent) throws CommitException { |
|
308 |
// |
|
309 |
// } |
|
310 |
// |
|
311 |
// @Override |
|
312 |
// public void postCommit(CommitEvent commitEvent) throws CommitException { |
|
313 |
// gridcontainer.commit(); |
|
314 |
// } |
|
315 |
// }); |
|
316 |
// |
|
317 |
// footerRow = grid.appendFooterRow(); |
|
318 |
// Object[] cells = grid.getColumns().stream().map(c -> c.getPropertyId()).toArray(Object[]::new); |
|
319 |
// if(cells.length == 0) { |
|
320 |
// return; |
|
321 |
// } |
|
322 |
// FooterCell footerCell = null; |
|
323 |
// if(cells.length > 1) { |
|
324 |
// footerCell = footerRow.join(cells); |
|
325 |
// }else { |
|
326 |
// footerCell = footerRow.getCell(cells[0]); |
|
327 |
// } |
|
328 |
// footerCell.setText(String.format(Messages.DistributionTableViewBean_TOTAL_TAXA, gridcontainer.size())); |
|
319 | 329 |
} |
320 | 330 |
|
321 | 331 |
private void createEditClickListener(){ |
... | ... | |
323 | 333 |
Button detailButton = toolbar.getDetailButton(); |
324 | 334 |
detailButton.setCaption(Messages.DistributionTableViewBean_TAXON_DETAILS); |
325 | 335 |
detailButton.addClickListener(event -> { |
326 |
// Object selectedItemId = DistributionTableViewBean.this.table.getValue();
|
|
327 |
Object selectedItemId = DistributionTableViewBean.this.grid.getSelectedRow(); |
|
336 |
Object selectedItemId = DistributionTableViewBean.this.table.getValue(); |
|
337 |
// Object selectedItemId = DistributionTableViewBean.this.grid.getSelectedRow();
|
|
328 | 338 |
if(selectedItemId!=null){ |
329 |
// final UUID uuid = UUID.fromString(table.getContainerDataSource().getItem(selectedItemId).getItemProperty("uuid").getValue().toString());
|
|
330 |
final UUID uuid = (UUID) selectedItemId; |
|
331 |
// Taxon taxon = HibernateProxyHelper.deproxy(CdmSpringContextHelper.getTaxonService().load(uuid), Taxon.class);
|
|
332 |
Taxon taxon = (Taxon) CdmSpringContextHelper.getTaxonService().load(uuid); |
|
339 |
final UUID uuid = UUID.fromString(table.getContainerDataSource().getItem(selectedItemId).getItemProperty("uuid").getValue().toString()); |
|
340 |
// final UUID uuid = (UUID) selectedItemId;
|
|
341 |
Taxon taxon = HibernateProxyHelper.deproxy(CdmSpringContextHelper.getTaxonService().load(uuid), Taxon.class); |
|
342 |
// Taxon taxon = (Taxon) CdmSpringContextHelper.getTaxonService().load(uuid);
|
|
333 | 343 |
List<DescriptionElementBase> listDescriptions = getPresenter().listDescriptionElementsForTaxon(taxon, null); |
334 | 344 |
DetailWindow detailWindow = new DetailWindow(taxon, listDescriptions); |
335 | 345 |
Window window = detailWindow.createWindow(); |
Also available in: Unified diff
switched back to vaadin-table for performance