Revision c226920a
Added by Fabian Reimeier almost 6 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/util/DistributionEditorUtil.java | ||
---|---|---|
10 | 10 |
|
11 | 11 |
import eu.etaxonomy.cdm.model.common.TermVocabulary; |
12 | 12 |
import eu.etaxonomy.cdm.model.location.NamedArea; |
13 |
import eu.etaxonomy.cdm.model.taxon.Classification; |
|
14 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode; |
|
13 | 15 |
import eu.etaxonomy.cdm.vaadin.view.distributionStatus.IDistributionTableView; |
14 | 16 |
|
17 |
/** |
|
18 |
* A utility class for the distribution status editor. |
|
19 |
* |
|
20 |
*/ |
|
15 | 21 |
public class DistributionEditorUtil { |
16 | 22 |
|
17 | 23 |
public static final String VIEW_TABLE = "table"; |
... | ... | |
30 | 36 |
|
31 | 37 |
public static final String SEPARATOR = ";;"; |
32 | 38 |
|
39 |
/** |
|
40 |
* Updates the vaadin session attributes related to the chosen |
|
41 |
* {@link TaxonNode}s, {@link NamedArea}s and {@link Classification} |
|
42 |
* and refreshes the given {@code distributionStatusTableView}. |
|
43 |
* @param distributionTableView The view to refresh after updating the session variables. |
|
44 |
* @param taxonNodes The taxa to be shown in the {@code distributionTableView}. |
|
45 |
* @param areaVoc The {@link TermVocabulary} of {@link NamedArea}s to be used. |
|
46 |
* @param selectedAreas The {@link NamedArea}s to be availbale in the {@code distributionTableView}. |
|
47 |
* @param classificationUuid The {@link UUID} of the {@link Classification} the {@code taxonNodes} belong to. |
|
48 |
*/ |
|
33 | 49 |
public static void updateDistributionView(IDistributionTableView distributionTableView, List<UUID> taxonNodes, TermVocabulary<NamedArea> areaVoc, |
34 | 50 |
List<NamedArea> selectedAreas, UUID classificationUuid) { |
35 | 51 |
VaadinSession.getCurrent().setAttribute(SATTR_TAXON_NODES_UUID, taxonNodes); |
... | ... | |
39 | 55 |
distributionTableView.update(); |
40 | 56 |
} |
41 | 57 |
|
58 |
/** |
|
59 |
* Clears the session attributes related to the chosen |
|
60 |
* {@link TaxonNode}s, {@link TermVocabulary} of {@link NamedArea}s, |
|
61 |
* {@link NamedArea}s and {@link Classification}. |
|
62 |
*/ |
|
42 | 63 |
public static void clearSessionAttributes(){ |
43 | 64 |
VaadinSession.getCurrent().setAttribute(SATTR_TAXON_NODES_UUID, null); |
44 | 65 |
VaadinSession.getCurrent().setAttribute(SATTR_SELECTED_AREA_VOCABULARY_UUID, null); |
... | ... | |
46 | 67 |
VaadinSession.getCurrent().setAttribute(SATTR_CLASSIFICATION, null); |
47 | 68 |
} |
48 | 69 |
|
70 |
/** |
|
71 |
* Returns {@code true} if abbreviated labels should be used. |
|
72 |
* @return {@code true} if abbreviated labels should be used. |
|
73 |
*/ |
|
49 | 74 |
public static boolean isAbbreviatedLabels(){ |
50 | 75 |
Object isAbbreviated = VaadinSession.getCurrent().getAttribute(DistributionEditorUtil.SATTR_ABBREVIATED_LABELS); |
51 | 76 |
return (isAbbreviated==null || (boolean) isAbbreviated); |
52 | 77 |
} |
53 | 78 |
|
79 |
/** |
|
80 |
* Shows an {@link SQLException} to the user. |
|
81 |
* @param e The exception to show. |
|
82 |
*/ |
|
54 | 83 |
public static void showSqlError(SQLException e) { |
55 | 84 |
Notification.show("Error while accessing data base.","Cause: "+e.getMessage(), Type.ERROR_MESSAGE); |
56 | 85 |
e.printStackTrace(); |
Also available in: Unified diff
Documentation and refactoring