Revision 88bf6890
Added by Andreas Kohlbecker about 4 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/view/reference/ReferencePopupEditor.java | ||
---|---|---|
24 | 24 |
import com.vaadin.ui.Component; |
25 | 25 |
import com.vaadin.ui.Field; |
26 | 26 |
import com.vaadin.ui.GridLayout; |
27 |
import com.vaadin.ui.Label; |
|
27 | 28 |
import com.vaadin.ui.NativeSelect; |
28 | 29 |
import com.vaadin.ui.TextField; |
29 | 30 |
|
... | ... | |
74 | 75 |
|
75 | 76 |
private final static int GRID_ROWS = 14; |
76 | 77 |
|
78 |
private final static int COL_FIELD_WIDTH_PX = 160; |
|
79 |
|
|
80 |
private final static String COL_FIELD_WIDTH_STR = COL_FIELD_WIDTH_PX + "px"; |
|
81 |
|
|
77 | 82 |
private NativeSelect typeSelect; |
78 | 83 |
|
79 | 84 |
private ToOneRelatedEntityCombobox<Reference> inReferenceCombobox; |
... | ... | |
124 | 129 |
grid.setSpacing(true); |
125 | 130 |
grid.setMargin(true); |
126 | 131 |
|
132 |
|
|
127 | 133 |
/* |
128 | 134 |
"type", |
129 | 135 |
"uri", |
... | ... | |
249 | 255 |
|
250 | 256 |
variableGridStartRow = row; |
251 | 257 |
|
252 |
addTextField("Organization", "organization", 0, row).setWidth(100, Unit.PERCENTAGE);
|
|
258 |
addTextField("Organization", "organization", 0, row).setWidth(COL_FIELD_WIDTH_STR);
|
|
253 | 259 |
row++; |
254 |
addTextField("Series", "seriesPart", 0, row).setWidth(100, Unit.PERCENTAGE);
|
|
255 |
addTextField("Volume", "volume", 1, row).setWidth(100, Unit.PERCENTAGE);
|
|
256 |
addTextField("Pages", "pages", 2, row).setWidth(100, Unit.PERCENTAGE);
|
|
257 |
addTextField("Edition", "edition", 3, row).setWidth(100, Unit.PERCENTAGE);
|
|
260 |
addTextField("Series", "seriesPart", 0, row).setWidth(COL_FIELD_WIDTH_STR);
|
|
261 |
addTextField("Volume", "volume", 1, row).setWidth(COL_FIELD_WIDTH_STR);
|
|
262 |
addTextField("Pages", "pages", 2, row).setWidth(COL_FIELD_WIDTH_STR);
|
|
263 |
addTextField("Edition", "edition", 3, row).setWidth(COL_FIELD_WIDTH_STR);
|
|
258 | 264 |
row++; |
259 | 265 |
|
260 |
addTextField("Place published", "placePublished", 0, row, 0, row).setWidth(100, Unit.PERCENTAGE);
|
|
266 |
addTextField("Place published", "placePublished", 0, row, 0, row).setWidth(COL_FIELD_WIDTH_STR);
|
|
261 | 267 |
TextField publisherField = addTextField("Publisher", "publisher", 1, row, 1, row); |
262 |
publisherField.setWidth(100, Unit.PERCENTAGE);
|
|
263 |
addTextField("Editor", "editor", 2, row).setWidth(100, Unit.PERCENTAGE);
|
|
268 |
publisherField.setWidth(COL_FIELD_WIDTH_STR);
|
|
269 |
addTextField("Editor", "editor", 2, row).setWidth(COL_FIELD_WIDTH_STR);
|
|
264 | 270 |
row++; |
265 | 271 |
|
266 |
addTextField("ISSN", "issn", 0, row).setWidth(100, Unit.PERCENTAGE);
|
|
267 |
addTextField("ISBN", "isbn", 1, row).setWidth(100, Unit.PERCENTAGE);
|
|
272 |
addTextField("ISSN", "issn", 0, row).setWidth(COL_FIELD_WIDTH_STR);
|
|
273 |
addTextField("ISBN", "isbn", 1, row).setWidth(COL_FIELD_WIDTH_STR);
|
|
268 | 274 |
TextFieldNFix doiField = new TextFieldNFix("DOI"); |
269 | 275 |
doiField.setConverter(new DoiConverter()); |
270 |
doiField.setWidth(100, Unit.PERCENTAGE);
|
|
276 |
doiField.setWidth(COL_FIELD_WIDTH_STR);
|
|
271 | 277 |
addField(doiField, "doi", 2, row); |
272 | 278 |
TextFieldNFix uriField = new TextFieldNFix("Uri"); |
273 | 279 |
uriField.setConverter(new UriConverter()); |
274 |
uriField.setWidth(100, Unit.PERCENTAGE);
|
|
280 |
uriField.setWidth(COL_FIELD_WIDTH_STR);
|
|
275 | 281 |
addField(uriField, "uri", 3, row); |
276 | 282 |
|
277 | 283 |
|
... | ... | |
329 | 335 |
grid.setCursorY(variableGridStartRow); |
330 | 336 |
grid.setCursorX(0); |
331 | 337 |
|
332 |
// place the fields which are required for the given referenceType in the variable grid part while
|
|
338 |
// place the fields which are required for the given referenceType in the variable grid part |
|
333 | 339 |
// and retain the original order which is recorded in the adaptiveFields |
334 | 340 |
try { |
335 | 341 |
Map<String, String> fieldPropertyDefinition = ReferencePropertyDefinitions.fieldPropertyDefinition(referenceType); |
... | ... | |
349 | 355 |
institutionCombobox.setVisible(fieldPropertyDefinition.containsKey("institution")); |
350 | 356 |
schoolCombobox.setVisible(fieldPropertyDefinition.containsKey("school")); |
351 | 357 |
|
358 |
int componentCount = 0; |
|
352 | 359 |
for(String fieldName : adaptiveFields.keySet()){ // iterate over the LinkedHashMap to retain the original order of the fields |
353 | 360 |
if(fieldPropertyDefinition.containsKey(fieldName)){ |
354 | 361 |
Field<?> field = adaptiveFields.get(fieldName); |
355 | 362 |
grid.addComponent(field); |
363 |
componentCount++; |
|
356 | 364 |
String propertyName = fieldPropertyDefinition.get(fieldName); |
357 | 365 |
if(propertyName != fieldName){ |
358 | 366 |
field.setCaption(inReferenceCaption(propertyName)); |
359 | 367 |
} |
360 | 368 |
} |
361 | 369 |
} |
370 |
// add placeholders to fill the remaining cells in the row |
|
371 |
for(int pi = componentCount % 4; pi > 0; pi--){ |
|
372 |
Label placeholder = new Label(); |
|
373 |
placeholder.setWidth(COL_FIELD_WIDTH_STR); |
|
374 |
grid.addComponent(placeholder); |
|
375 |
} |
|
362 | 376 |
} catch (UnimplemetedCaseException e) { |
363 | 377 |
logger.error(e); |
364 | 378 |
// enable all fields |
Also available in: Unified diff
ref #8548 fixed width for grid cells in reference editor