1
|
package eu.etaxonomy.cdm.vaadin.util;
|
2
|
|
3
|
import java.sql.SQLException;
|
4
|
import java.util.Set;
|
5
|
|
6
|
import com.vaadin.server.VaadinSession;
|
7
|
import com.vaadin.ui.Notification;
|
8
|
import com.vaadin.ui.Notification.Type;
|
9
|
import com.vaadin.ui.UI;
|
10
|
|
11
|
import eu.etaxonomy.cdm.model.common.TermVocabulary;
|
12
|
import eu.etaxonomy.cdm.model.location.NamedArea;
|
13
|
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
|
14
|
|
15
|
public class DistributionEditorUtil {
|
16
|
|
17
|
public static final String VIEW_TABLE = "table";
|
18
|
|
19
|
public static final String SATTR_SELECTED_AREAS = "selectedAreas";
|
20
|
|
21
|
public static final String SATTR_SELECTED_VOCABULARY_UUID = "selectedVocabularyUuid";
|
22
|
|
23
|
public static final String SATTR_TAXON_NODE_UUID = "taxonNodeUUID";
|
24
|
|
25
|
public static final String SATTR_ABBREVIATED_LABELS = "abbreviatedLabels";
|
26
|
|
27
|
public static final String SATTR_DISTRIBUTION_STATUS = "distributionStatus";
|
28
|
|
29
|
public static final String SEPARATOR = ";;";
|
30
|
|
31
|
public static void openDistributionView(TaxonNode taxonNode, TermVocabulary<NamedArea> term, Set<NamedArea> selectedAreas) {
|
32
|
VaadinSession.getCurrent().setAttribute(SATTR_TAXON_NODE_UUID, taxonNode.getUuid());
|
33
|
VaadinSession.getCurrent().setAttribute(SATTR_SELECTED_VOCABULARY_UUID, term.getUuid());
|
34
|
VaadinSession.getCurrent().setAttribute(SATTR_SELECTED_AREAS, selectedAreas);
|
35
|
|
36
|
//navigate to table view
|
37
|
UI.getCurrent().getNavigator().navigateTo(VIEW_TABLE);
|
38
|
}
|
39
|
|
40
|
public static boolean isAbbreviatedLabels(){
|
41
|
Object isAbbreviated = VaadinSession.getCurrent().getAttribute(DistributionEditorUtil.SATTR_ABBREVIATED_LABELS);
|
42
|
return (isAbbreviated==null || (boolean) isAbbreviated);
|
43
|
}
|
44
|
|
45
|
public static void showSqlError(SQLException e) {
|
46
|
Notification.show("Error while accessing data base.","Cause: "+e.getMessage(), Type.ERROR_MESSAGE);
|
47
|
e.printStackTrace();
|
48
|
}
|
49
|
|
50
|
public static final String SATTR_CONVERSATION = "conversation";
|
51
|
|
52
|
|
53
|
}
|