1 |
60e38397
|
Fabian Reimeier
|
/**
|
2 |
|
|
* Copyright (C) 2017 EDIT
|
3 |
|
|
* European Distributed Institute of Taxonomy
|
4 |
|
|
* http://www.e-taxonomy.eu
|
5 |
|
|
*
|
6 |
|
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7 |
|
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8 |
|
|
*/
|
9 |
|
|
package eu.etaxonomy.cdm.vaadin.view.distributionStatus;
|
10 |
|
|
|
11 |
4cb460fd
|
Fabian Reimeier
|
import java.sql.SQLException;
|
12 |
|
|
import java.util.ArrayList;
|
13 |
|
|
import java.util.Arrays;
|
14 |
60e38397
|
Fabian Reimeier
|
import java.util.Collection;
|
15 |
|
|
import java.util.List;
|
16 |
|
|
import java.util.UUID;
|
17 |
|
|
|
18 |
b1fe8acf
|
Fabian Reimeier
|
import org.springframework.beans.factory.annotation.Autowired;
|
19 |
efb45d70
|
Fabian Reimeier
|
import org.springframework.orm.hibernate5.HibernateSystemException;
|
20 |
60e38397
|
Fabian Reimeier
|
import org.springframework.security.core.GrantedAuthority;
|
21 |
33fe82c4
|
Fabian Reimeier
|
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
|
22 |
60e38397
|
Fabian Reimeier
|
|
23 |
4cb460fd
|
Fabian Reimeier
|
import com.vaadin.data.Item;
|
24 |
|
|
import com.vaadin.data.Property;
|
25 |
60e38397
|
Fabian Reimeier
|
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
|
26 |
|
|
import com.vaadin.spring.annotation.SpringView;
|
27 |
33fe82c4
|
Fabian Reimeier
|
import com.vaadin.spring.annotation.ViewScope;
|
28 |
60e38397
|
Fabian Reimeier
|
import com.vaadin.ui.AbsoluteLayout;
|
29 |
|
|
import com.vaadin.ui.Button;
|
30 |
|
|
import com.vaadin.ui.Grid;
|
31 |
33fe82c4
|
Fabian Reimeier
|
import com.vaadin.ui.Grid.FooterRow;
|
32 |
4cb460fd
|
Fabian Reimeier
|
import com.vaadin.ui.ListSelect;
|
33 |
60e38397
|
Fabian Reimeier
|
import com.vaadin.ui.Notification;
|
34 |
|
|
import com.vaadin.ui.Notification.Type;
|
35 |
|
|
import com.vaadin.ui.Table;
|
36 |
|
|
import com.vaadin.ui.UI;
|
37 |
4cb460fd
|
Fabian Reimeier
|
import com.vaadin.ui.VerticalLayout;
|
38 |
60e38397
|
Fabian Reimeier
|
import com.vaadin.ui.Window;
|
39 |
|
|
|
40 |
4cb460fd
|
Fabian Reimeier
|
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
|
41 |
4fc74453
|
Fabian Reimeier
|
import eu.etaxonomy.cdm.i18n.Messages;
|
42 |
4cb460fd
|
Fabian Reimeier
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
43 |
60e38397
|
Fabian Reimeier
|
import eu.etaxonomy.cdm.model.common.Language;
|
44 |
4cb460fd
|
Fabian Reimeier
|
import eu.etaxonomy.cdm.model.common.Representation;
|
45 |
60e38397
|
Fabian Reimeier
|
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
|
46 |
4cb460fd
|
Fabian Reimeier
|
import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm;
|
47 |
60e38397
|
Fabian Reimeier
|
import eu.etaxonomy.cdm.model.taxon.Taxon;
|
48 |
6bf65de0
|
Fabian Reimeier
|
import eu.etaxonomy.cdm.vaadin.component.distributionStatus.AreaAndTaxonSettingsConfigWindow;
|
49 |
|
|
import eu.etaxonomy.cdm.vaadin.component.distributionStatus.DetailWindow;
|
50 |
|
|
import eu.etaxonomy.cdm.vaadin.component.distributionStatus.DistributionStatusSettingsConfigWindow;
|
51 |
|
|
import eu.etaxonomy.cdm.vaadin.component.distributionStatus.DistributionToolbar;
|
52 |
|
|
import eu.etaxonomy.cdm.vaadin.component.distributionStatus.HelpWindow;
|
53 |
60e38397
|
Fabian Reimeier
|
import eu.etaxonomy.cdm.vaadin.container.CdmSQLContainer;
|
54 |
efb45d70
|
Fabian Reimeier
|
import eu.etaxonomy.cdm.vaadin.event.error.DelegatingErrorHandler;
|
55 |
|
|
import eu.etaxonomy.cdm.vaadin.event.error.HibernateSystemErrorHandler;
|
56 |
60e38397
|
Fabian Reimeier
|
import eu.etaxonomy.cdm.vaadin.security.AccessRestrictedView;
|
57 |
4cb460fd
|
Fabian Reimeier
|
import eu.etaxonomy.cdm.vaadin.util.CdmQueryFactory;
|
58 |
60e38397
|
Fabian Reimeier
|
import eu.etaxonomy.cdm.vaadin.util.CdmSpringContextHelper;
|
59 |
|
|
import eu.etaxonomy.cdm.vaadin.util.DistributionEditorUtil;
|
60 |
|
|
import eu.etaxonomy.cdm.vaadin.view.AbstractPageView;
|
61 |
|
|
|
62 |
|
|
/**
|
63 |
|
|
* @author freimeier
|
64 |
|
|
* @since 18.10.2017
|
65 |
|
|
*
|
66 |
|
|
*/
|
67 |
33fe82c4
|
Fabian Reimeier
|
@ViewScope
|
68 |
60e38397
|
Fabian Reimeier
|
@SpringView(name=DistributionTableViewBean.NAME)
|
69 |
725b6f1f
|
Andreas Müller
|
public class DistributionTableViewBean
|
70 |
|
|
extends AbstractPageView<DistributionTablePresenter>
|
71 |
|
|
implements IDistributionTableView, AccessRestrictedView {
|
72 |
60e38397
|
Fabian Reimeier
|
|
73 |
|
|
private static final long serialVersionUID = 1L;
|
74 |
5ca9eaf3
|
Fabian Reimeier
|
public static final String NAME = "distGrid"; //$NON-NLS-1$
|
75 |
60e38397
|
Fabian Reimeier
|
|
76 |
b1fe8acf
|
Fabian Reimeier
|
@Autowired
|
77 |
|
|
private DistributionToolbar toolbar;
|
78 |
|
|
|
79 |
60e38397
|
Fabian Reimeier
|
private Table table;
|
80 |
|
|
private Grid grid;
|
81 |
33fe82c4
|
Fabian Reimeier
|
private FooterRow footerRow;
|
82 |
60e38397
|
Fabian Reimeier
|
|
83 |
|
|
private CdmSQLContainer container;
|
84 |
33fe82c4
|
Fabian Reimeier
|
private LazyQueryContainer gridcontainer;
|
85 |
450785be
|
Fabian Reimeier
|
private AreaAndTaxonSettingsConfigWindow areaAndTaxonConfigWindow;;
|
86 |
|
|
private DistributionStatusSettingsConfigWindow distributionStatusConfigWindow;
|
87 |
6bf65de0
|
Fabian Reimeier
|
private HelpWindow helpWindow;
|
88 |
60e38397
|
Fabian Reimeier
|
|
89 |
|
|
public DistributionTableViewBean() {
|
90 |
|
|
super();
|
91 |
|
|
}
|
92 |
|
|
|
93 |
|
|
private AbsoluteLayout initLayout() {
|
94 |
|
|
AbsoluteLayout mainLayout = new AbsoluteLayout();
|
95 |
|
|
mainLayout.setImmediate(false);
|
96 |
5ca9eaf3
|
Fabian Reimeier
|
mainLayout.setWidth("100%"); //$NON-NLS-1$
|
97 |
|
|
mainLayout.setHeight("100%"); //$NON-NLS-1$
|
98 |
60e38397
|
Fabian Reimeier
|
|
99 |
5ca9eaf3
|
Fabian Reimeier
|
setWidth("100.0%"); //$NON-NLS-1$
|
100 |
|
|
setHeight("100.0%"); //$NON-NLS-1$
|
101 |
60e38397
|
Fabian Reimeier
|
|
102 |
|
|
//Horizontal Toolbar
|
103 |
5ca9eaf3
|
Fabian Reimeier
|
mainLayout.addComponent(toolbar, "top:0.0px;right:0.0px;"); //$NON-NLS-1$
|
104 |
60e38397
|
Fabian Reimeier
|
|
105 |
4cb460fd
|
Fabian Reimeier
|
// table + formatting
|
106 |
|
|
table = new Table(){
|
107 |
|
|
private static final long serialVersionUID = -5148756917468804385L;
|
108 |
|
|
|
109 |
|
|
@Override
|
110 |
|
|
protected String formatPropertyValue(Object rowId, Object colId, Property<?> property) {
|
111 |
|
|
String formattedValue = null;
|
112 |
|
|
PresenceAbsenceTerm presenceAbsenceTerm = null;
|
113 |
|
|
Object value = property.getValue();
|
114 |
|
|
if(value instanceof String){
|
115 |
33fe82c4
|
Fabian Reimeier
|
// presenceAbsenceTerm = TermCacher.getInstance().getPresenceAbsenceTerm((String) value);
|
116 |
4cb460fd
|
Fabian Reimeier
|
try {
|
117 |
|
|
presenceAbsenceTerm = (PresenceAbsenceTerm)CdmSpringContextHelper.getTermService().load(UUID.fromString((String)value));
|
118 |
|
|
}catch(IllegalArgumentException|ClassCastException e) {
|
119 |
|
|
// Not a PresenceAbsenceTerm Column
|
120 |
|
|
}
|
121 |
|
|
}
|
122 |
|
|
if(presenceAbsenceTerm != null){
|
123 |
|
|
Representation representation = presenceAbsenceTerm.getRepresentation(Language.DEFAULT());
|
124 |
|
|
if(representation!=null){
|
125 |
|
|
if(DistributionEditorUtil.isAbbreviatedLabels()){
|
126 |
|
|
formattedValue = representation.getAbbreviatedLabel();
|
127 |
|
|
}
|
128 |
|
|
else{
|
129 |
|
|
formattedValue = representation.getLabel();
|
130 |
|
|
}
|
131 |
|
|
}
|
132 |
|
|
if(formattedValue==null){
|
133 |
|
|
formattedValue = presenceAbsenceTerm.getTitleCache();
|
134 |
|
|
}
|
135 |
|
|
return formattedValue;
|
136 |
|
|
}
|
137 |
|
|
return super.formatPropertyValue(rowId, colId, property);
|
138 |
|
|
}
|
139 |
|
|
};
|
140 |
|
|
table.setImmediate(false);
|
141 |
|
|
table.setWidth("100.0%");
|
142 |
|
|
table.setHeight("100.0%");
|
143 |
|
|
|
144 |
|
|
table.setColumnReorderingAllowed(true);
|
145 |
|
|
table.setSortEnabled(false);
|
146 |
|
|
|
147 |
|
|
table.setColumnCollapsingAllowed(true);
|
148 |
|
|
table.setSelectable(true);
|
149 |
|
|
table.setPageLength(20);
|
150 |
|
|
table.setFooterVisible(true);
|
151 |
|
|
table.setCacheRate(20);
|
152 |
|
|
|
153 |
|
|
table.addItemClickListener(event -> {
|
154 |
|
|
if(!(event.getPropertyId().toString().equalsIgnoreCase(CdmQueryFactory.TAXON_COLUMN))
|
155 |
|
|
&& !(event.getPropertyId().toString().equalsIgnoreCase(CdmQueryFactory.RANK_COLUMN))
|
156 |
|
|
// TODO: HACK FOR RL 2017, REMOVE AS SOON AS POSSIBLE
|
157 |
|
|
&& !(event.getPropertyId().toString().equalsIgnoreCase("DE"))
|
158 |
|
|
&& !(event.getPropertyId().toString().equalsIgnoreCase("Deutschland"))){
|
159 |
|
|
final Item item = event.getItem();
|
160 |
|
|
Property<?> itemProperty = item.getItemProperty("uuid");
|
161 |
|
|
UUID uuid = UUID.fromString(itemProperty.getValue().toString());
|
162 |
|
|
final Taxon taxon = CdmBase.deproxy(CdmSpringContextHelper.getTaxonService()
|
163 |
|
|
.load(uuid,Arrays.asList("descriptions.descriptionElements","name.taxonBases","updatedBy")), Taxon.class);
|
164 |
|
|
final String areaID = (String)event.getPropertyId();
|
165 |
|
|
PresenceAbsenceTerm presenceAbsenceTerm = null;
|
166 |
|
|
Object statusValue = item.getItemProperty(areaID).getValue();
|
167 |
|
|
if(statusValue instanceof String){
|
168 |
33fe82c4
|
Fabian Reimeier
|
// presenceAbsenceTerm = TermCacher.getInstance().getPresenceAbsenceTerm((String) statusValue);
|
169 |
4cb460fd
|
Fabian Reimeier
|
try {
|
170 |
|
|
presenceAbsenceTerm = (PresenceAbsenceTerm)CdmSpringContextHelper.getTermService().load(UUID.fromString((String)statusValue));
|
171 |
|
|
}catch(IllegalArgumentException|ClassCastException e) {
|
172 |
|
|
// Not a PresenceAbsenceTerm Column
|
173 |
|
|
}
|
174 |
|
|
}
|
175 |
|
|
//popup window
|
176 |
c3333d6a
|
Fabian Reimeier
|
final Window popup = new Window(Messages.getLocalizedString(Messages.DistributionTableViewBean_CHOOSE_DISTRIBUTION_STATUS));
|
177 |
efb45d70
|
Fabian Reimeier
|
DelegatingErrorHandler errorHandler = new DelegatingErrorHandler();
|
178 |
|
|
errorHandler.registerHandler(HibernateSystemException.class, new HibernateSystemErrorHandler());
|
179 |
|
|
popup.setErrorHandler(errorHandler);
|
180 |
4cb460fd
|
Fabian Reimeier
|
final ListSelect termSelect = new ListSelect();
|
181 |
|
|
termSelect.setSizeFull();
|
182 |
|
|
termSelect.setContainerDataSource(getPresenter().getPresenceAbsenceTermContainer());
|
183 |
|
|
termSelect.setNullSelectionAllowed(presenceAbsenceTerm != null);
|
184 |
|
|
if(presenceAbsenceTerm != null){
|
185 |
c3333d6a
|
Fabian Reimeier
|
termSelect.setNullSelectionItemId(Messages.getLocalizedString(Messages.DistributionTableViewBean_NO_STATUS_SELECT));
|
186 |
4cb460fd
|
Fabian Reimeier
|
}else{
|
187 |
|
|
logger.debug("No distribution status exists yet for area");
|
188 |
|
|
}
|
189 |
|
|
termSelect.setValue(presenceAbsenceTerm);
|
190 |
|
|
termSelect.addValueChangeListener(valueChangeEvent -> {
|
191 |
|
|
Object distributionStatus = valueChangeEvent.getProperty().getValue();
|
192 |
|
|
getPresenter().updateDistributionField(areaID, distributionStatus, taxon);
|
193 |
|
|
container.refresh();
|
194 |
|
|
popup.close();
|
195 |
|
|
});
|
196 |
|
|
VerticalLayout layout = new VerticalLayout(termSelect);
|
197 |
|
|
popup.setContent(layout);
|
198 |
|
|
popup.setModal(true);
|
199 |
|
|
popup.center();
|
200 |
|
|
UI.getCurrent().addWindow(popup);
|
201 |
|
|
}
|
202 |
|
|
});
|
203 |
60e38397
|
Fabian Reimeier
|
|
204 |
4cb460fd
|
Fabian Reimeier
|
mainLayout.addComponent(table, "top:75px;right:10.0px;left:10.0px;");
|
205 |
|
|
|
206 |
|
|
// grid = new Grid();
|
207 |
|
|
// grid.setSizeFull();
|
208 |
|
|
// grid.setEditorEnabled(true);
|
209 |
|
|
// grid.setFooterVisible(true);
|
210 |
|
|
// mainLayout.addComponent(grid, "top:75px;right:10.0px;left:10.0px;"); //$NON-NLS-1$
|
211 |
60e38397
|
Fabian Reimeier
|
|
212 |
|
|
return mainLayout;
|
213 |
|
|
}
|
214 |
|
|
|
215 |
|
|
/**
|
216 |
|
|
* {@inheritDoc}
|
217 |
|
|
*/
|
218 |
|
|
@Override
|
219 |
|
|
public void enter(ViewChangeEvent event) {
|
220 |
|
|
update();
|
221 |
|
|
}
|
222 |
|
|
|
223 |
|
|
/**
|
224 |
|
|
* {@inheritDoc}
|
225 |
|
|
*/
|
226 |
|
|
@Override
|
227 |
|
|
public void update(){
|
228 |
4cb460fd
|
Fabian Reimeier
|
try {
|
229 |
|
|
container = getPresenter().getSQLContainer();
|
230 |
|
|
} catch (SQLException e) {
|
231 |
|
|
DistributionEditorUtil.showSqlError(e);
|
232 |
|
|
return;
|
233 |
|
|
}
|
234 |
|
|
if(container==null){
|
235 |
|
|
return;
|
236 |
|
|
}
|
237 |
60e38397
|
Fabian Reimeier
|
|
238 |
4cb460fd
|
Fabian Reimeier
|
table.setContainerDataSource(container);
|
239 |
|
|
|
240 |
|
|
List<String> columnHeaders = new ArrayList<>(Arrays.asList(table.getColumnHeaders()));
|
241 |
|
|
columnHeaders.remove(CdmQueryFactory.DTYPE_COLUMN);
|
242 |
|
|
columnHeaders.remove(CdmQueryFactory.ID_COLUMN);
|
243 |
|
|
columnHeaders.remove(CdmQueryFactory.UUID_COLUMN);
|
244 |
|
|
columnHeaders.remove(CdmQueryFactory.CLASSIFICATION_COLUMN);
|
245 |
33fe82c4
|
Fabian Reimeier
|
// columnHeaders.sort(new Comparator<String>() {
|
246 |
|
|
// @Override
|
247 |
|
|
// public int compare(String o1, String o2) {
|
248 |
|
|
// if(o1.equals(CdmQueryFactory.TAXON_COLUMN) || o2.equals(CdmQueryFactory.TAXON_COLUMN)) {
|
249 |
|
|
// return o1.equals(CdmQueryFactory.TAXON_COLUMN) ? -1 : 1;
|
250 |
|
|
// }
|
251 |
|
|
// if(o1.equals(CdmQueryFactory.RANK_COLUMN) || o2.equals(CdmQueryFactory.RANK_COLUMN)) {
|
252 |
|
|
// return o1.equals(CdmQueryFactory.RANK_COLUMN) ? -1 : 1;
|
253 |
|
|
// }
|
254 |
|
|
//
|
255 |
|
|
// // TODO: HACK FOR RL 2017, REMOVE AS SOON AS POSSIBLE
|
256 |
|
|
// if(o1.equals("DE") || o1.equals("Deutschland")
|
257 |
|
|
// || o2.equals("DE") || o2.equals("Deutschland")) {
|
258 |
|
|
// return (o1.equals("DE") || o1.equals("Deutschland")) ? -1 : 1;
|
259 |
|
|
// }
|
260 |
|
|
//
|
261 |
|
|
// return o1.compareTo(o2);
|
262 |
|
|
// }
|
263 |
|
|
// });
|
264 |
0cb1d0ac
|
Fabian Reimeier
|
|
265 |
4cb460fd
|
Fabian Reimeier
|
List<String> columnList = new ArrayList<>(columnHeaders);
|
266 |
0cb1d0ac
|
Fabian Reimeier
|
|
267 |
4cb460fd
|
Fabian Reimeier
|
String[] string = new String[columnList.size()];
|
268 |
33fe82c4
|
Fabian Reimeier
|
|
269 |
4cb460fd
|
Fabian Reimeier
|
table.setVisibleColumns(columnList.toArray());
|
270 |
|
|
table.setColumnHeaders(columnList.toArray(string));
|
271 |
c3333d6a
|
Fabian Reimeier
|
table.setColumnFooter(CdmQueryFactory.TAXON_COLUMN, String.format(Messages.getLocalizedString(Messages.DistributionTableViewBean_TOTAL_TAXA), container.size()));
|
272 |
33fe82c4
|
Fabian Reimeier
|
|
273 |
4cb460fd
|
Fabian Reimeier
|
// gridcontainer = getPresenter().getAreaDistributionStatusContainer();
|
274 |
|
|
// if(gridcontainer==null){
|
275 |
|
|
// return;
|
276 |
|
|
// }
|
277 |
|
|
//
|
278 |
|
|
// if(footerRow != null) {
|
279 |
|
|
// grid.removeFooterRow(footerRow);
|
280 |
|
|
// }
|
281 |
|
|
// grid.removeAllColumns();
|
282 |
|
|
//
|
283 |
|
|
// grid.setContainerDataSource(gridcontainer);
|
284 |
|
|
//
|
285 |
|
|
// Column uuidColumn = grid.getColumn(DistributionStatusQuery.UUID_COLUMN);
|
286 |
|
|
// uuidColumn.setEditable(false);
|
287 |
|
|
// uuidColumn.setHidden(true);
|
288 |
|
|
// Column taxonColumn = grid.getColumn(DistributionStatusQuery.TAXON_COLUMN);
|
289 |
|
|
// taxonColumn.setEditable(false);
|
290 |
|
|
// taxonColumn.setHeaderCaption(Messages.DistributionTableViewBean_TAXON);
|
291 |
|
|
// taxonColumn.setLastFrozenColumn();
|
292 |
|
|
//
|
293 |
|
|
// Converter<String, UUID> displayConverter = new PresenceAbsenceTermUuidTitleStringConverter();
|
294 |
|
|
// Converter<Object, UUID> editorConverter = new PresenceAbsenceTermUuidObjectConverter();
|
295 |
|
|
// for(Column c : grid.getColumns()) {
|
296 |
|
|
// if(c.isEditable()) {
|
297 |
|
|
// NamedArea namedArea = (NamedArea) CdmSpringContextHelper.getTermService().load((UUID.fromString(c.getHeaderCaption())));
|
298 |
|
|
// String caption = DistributionEditorUtil.isAbbreviatedLabels() ?
|
299 |
|
|
// namedArea.getRepresentation(Language.DEFAULT()).getAbbreviatedLabel() : namedArea.getTitleCache();
|
300 |
|
|
// c.setHeaderCaption(caption);
|
301 |
|
|
// c.setConverter(displayConverter);
|
302 |
|
|
//
|
303 |
|
|
// NativeSelect termSelect = new NativeSelect();
|
304 |
|
|
// termSelect.setSizeFull();
|
305 |
|
|
// termSelect.setContainerDataSource(getPresenter().getPresenceAbsenceTermContainer());
|
306 |
|
|
// termSelect.setItemCaptionMode(ItemCaptionMode.PROPERTY);
|
307 |
|
|
// termSelect.setItemCaptionPropertyId("titleCache"); //$NON-NLS-1$
|
308 |
|
|
// termSelect.setConverter(editorConverter);
|
309 |
|
|
// termSelect.setImmediate(true);
|
310 |
|
|
// c.setEditorField(termSelect);
|
311 |
|
|
// }
|
312 |
|
|
// }
|
313 |
|
|
// grid.getEditorFieldGroup().addCommitHandler(new CommitHandler() {
|
314 |
|
|
// private static final long serialVersionUID = 7515807188410712420L;
|
315 |
|
|
//
|
316 |
|
|
// @Override
|
317 |
|
|
// public void preCommit(CommitEvent commitEvent) throws CommitException {
|
318 |
|
|
//
|
319 |
|
|
// }
|
320 |
|
|
//
|
321 |
|
|
// @Override
|
322 |
|
|
// public void postCommit(CommitEvent commitEvent) throws CommitException {
|
323 |
|
|
// gridcontainer.commit();
|
324 |
|
|
// }
|
325 |
|
|
// });
|
326 |
|
|
//
|
327 |
|
|
// footerRow = grid.appendFooterRow();
|
328 |
|
|
// Object[] cells = grid.getColumns().stream().map(c -> c.getPropertyId()).toArray(Object[]::new);
|
329 |
|
|
// if(cells.length == 0) {
|
330 |
|
|
// return;
|
331 |
|
|
// }
|
332 |
|
|
// FooterCell footerCell = null;
|
333 |
|
|
// if(cells.length > 1) {
|
334 |
|
|
// footerCell = footerRow.join(cells);
|
335 |
|
|
// }else {
|
336 |
|
|
// footerCell = footerRow.getCell(cells[0]);
|
337 |
|
|
// }
|
338 |
|
|
// footerCell.setText(String.format(Messages.DistributionTableViewBean_TOTAL_TAXA, gridcontainer.size()));
|
339 |
60e38397
|
Fabian Reimeier
|
}
|
340 |
|
|
|
341 |
|
|
private void createEditClickListener(){
|
342 |
fc53e2e8
|
Andreas Müller
|
//details
|
343 |
|
|
Button detailButton = toolbar.getDetailButton();
|
344 |
4fc74453
|
Fabian Reimeier
|
detailButton.setCaption(Messages.getLocalizedString(Messages.DistributionTableViewBean_TAXON_DETAILS));
|
345 |
60e38397
|
Fabian Reimeier
|
detailButton.addClickListener(event -> {
|
346 |
4cb460fd
|
Fabian Reimeier
|
Object selectedItemId = DistributionTableViewBean.this.table.getValue();
|
347 |
|
|
// Object selectedItemId = DistributionTableViewBean.this.grid.getSelectedRow();
|
348 |
60e38397
|
Fabian Reimeier
|
if(selectedItemId!=null){
|
349 |
4cb460fd
|
Fabian Reimeier
|
final UUID uuid = UUID.fromString(table.getContainerDataSource().getItem(selectedItemId).getItemProperty("uuid").getValue().toString());
|
350 |
|
|
// final UUID uuid = (UUID) selectedItemId;
|
351 |
|
|
Taxon taxon = HibernateProxyHelper.deproxy(CdmSpringContextHelper.getTaxonService().load(uuid), Taxon.class);
|
352 |
|
|
// Taxon taxon = (Taxon) CdmSpringContextHelper.getTaxonService().load(uuid);
|
353 |
60e38397
|
Fabian Reimeier
|
List<DescriptionElementBase> listDescriptions = getPresenter().listDescriptionElementsForTaxon(taxon, null);
|
354 |
|
|
DetailWindow detailWindow = new DetailWindow(taxon, listDescriptions);
|
355 |
|
|
Window window = detailWindow.createWindow();
|
356 |
|
|
window.center();
|
357 |
|
|
getUI().addWindow(window);
|
358 |
|
|
}
|
359 |
|
|
else{
|
360 |
4fc74453
|
Fabian Reimeier
|
Notification.show(Messages.getLocalizedString(Messages.DistributionTableViewBean_SELECT_TAXON), Type.HUMANIZED_MESSAGE);
|
361 |
60e38397
|
Fabian Reimeier
|
}
|
362 |
|
|
}
|
363 |
|
|
);
|
364 |
|
|
|
365 |
fc53e2e8
|
Andreas Müller
|
//area and taxon
|
366 |
|
|
Button areaAndTaxonSettingsButton = toolbar.getDistributionSettingsButton();
|
367 |
|
|
areaAndTaxonSettingsButton.addClickListener(event -> openAreaAndTaxonSettings());
|
368 |
60e38397
|
Fabian Reimeier
|
|
369 |
fc53e2e8
|
Andreas Müller
|
//distr status
|
370 |
|
|
Button distrStatusButton = toolbar.getSettingsButton();
|
371 |
|
|
distrStatusButton.addClickListener(event -> openStatusSettings());
|
372 |
6bf65de0
|
Fabian Reimeier
|
|
373 |
|
|
//help
|
374 |
|
|
Button helpButton = toolbar.getHelpButton();
|
375 |
|
|
helpButton.addClickListener(event -> openHelpWindow());
|
376 |
60e38397
|
Fabian Reimeier
|
}
|
377 |
|
|
|
378 |
|
|
/**
|
379 |
|
|
* {@inheritDoc}
|
380 |
|
|
*/
|
381 |
|
|
@Override
|
382 |
fc53e2e8
|
Andreas Müller
|
public void openStatusSettings() {
|
383 |
450785be
|
Fabian Reimeier
|
if(distributionStatusConfigWindow==null){
|
384 |
|
|
distributionStatusConfigWindow = new DistributionStatusSettingsConfigWindow(this);
|
385 |
|
|
}
|
386 |
4fc74453
|
Fabian Reimeier
|
Window window = distributionStatusConfigWindow.createWindow(Messages.getLocalizedString(Messages.DistributionTableViewBean_STATUS));
|
387 |
5ca9eaf3
|
Fabian Reimeier
|
window.setWidth("25%"); //$NON-NLS-1$
|
388 |
|
|
window.setHeight("60%"); //$NON-NLS-1$
|
389 |
450785be
|
Fabian Reimeier
|
UI.getCurrent().addWindow(window);
|
390 |
60e38397
|
Fabian Reimeier
|
}
|
391 |
|
|
|
392 |
|
|
/**
|
393 |
|
|
* {@inheritDoc}
|
394 |
|
|
*/
|
395 |
|
|
@Override
|
396 |
fc53e2e8
|
Andreas Müller
|
public void openAreaAndTaxonSettings() {
|
397 |
450785be
|
Fabian Reimeier
|
if(areaAndTaxonConfigWindow==null){
|
398 |
|
|
areaAndTaxonConfigWindow = new AreaAndTaxonSettingsConfigWindow(this);
|
399 |
60e38397
|
Fabian Reimeier
|
}
|
400 |
4fc74453
|
Fabian Reimeier
|
Window window = areaAndTaxonConfigWindow.createWindow(Messages.getLocalizedString(Messages.DistributionTableViewBean_AREAS_AND_TAXA));
|
401 |
60e38397
|
Fabian Reimeier
|
UI.getCurrent().addWindow(window);
|
402 |
|
|
}
|
403 |
|
|
|
404 |
6bf65de0
|
Fabian Reimeier
|
public void openHelpWindow() {
|
405 |
|
|
if(helpWindow==null){
|
406 |
|
|
helpWindow = new HelpWindow(this);
|
407 |
|
|
}
|
408 |
|
|
Window window = helpWindow.createWindow(Messages.getLocalizedString(Messages.DistributionToolbar_HELP));
|
409 |
|
|
UI.getCurrent().addWindow(window);
|
410 |
|
|
}
|
411 |
|
|
|
412 |
60e38397
|
Fabian Reimeier
|
/**
|
413 |
|
|
* {@inheritDoc}
|
414 |
|
|
*/
|
415 |
|
|
@Override
|
416 |
|
|
public boolean allowAnonymousAccess() {
|
417 |
|
|
// TODO Auto-generated method stub
|
418 |
|
|
return false;
|
419 |
|
|
}
|
420 |
|
|
|
421 |
|
|
/**
|
422 |
|
|
* {@inheritDoc}
|
423 |
|
|
*/
|
424 |
|
|
@Override
|
425 |
|
|
public Collection<Collection<GrantedAuthority>> allowedGrantedAuthorities() {
|
426 |
|
|
// TODO Auto-generated method stub
|
427 |
|
|
return null;
|
428 |
|
|
}
|
429 |
|
|
|
430 |
|
|
/**
|
431 |
|
|
* {@inheritDoc}
|
432 |
|
|
*/
|
433 |
|
|
@Override
|
434 |
|
|
protected String getHeaderText() {
|
435 |
|
|
// TODO Auto-generated method stub
|
436 |
|
|
return null;
|
437 |
|
|
}
|
438 |
|
|
|
439 |
|
|
/**
|
440 |
|
|
* {@inheritDoc}
|
441 |
|
|
*/
|
442 |
|
|
@Override
|
443 |
|
|
protected String getSubHeaderText() {
|
444 |
|
|
// TODO Auto-generated method stub
|
445 |
|
|
return null;
|
446 |
|
|
}
|
447 |
|
|
|
448 |
|
|
/**
|
449 |
|
|
* {@inheritDoc}
|
450 |
|
|
*/
|
451 |
|
|
@Override
|
452 |
|
|
protected void initContent() {
|
453 |
f28d9400
|
Fabian Reimeier
|
// initialize layout
|
454 |
4cfb3625
|
Fabian Reimeier
|
AbsoluteLayout mainLayout = initLayout();
|
455 |
|
|
setCompositionRoot(mainLayout);
|
456 |
f28d9400
|
Fabian Reimeier
|
// add click listener on DistributionToolbar-buttons
|
457 |
4cfb3625
|
Fabian Reimeier
|
createEditClickListener();
|
458 |
60e38397
|
Fabian Reimeier
|
}
|
459 |
|
|
}
|