Revision fda2cb06
Added by Patrick Plitzner over 7 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/presenter/dbstatus/DistributionTablePresenter.java | ||
---|---|---|
115 | 115 |
|
116 | 116 |
public Set<DefinedTermBase> getChosenTerms() { |
117 | 117 |
VaadinSession session = VaadinSession.getCurrent(); |
118 |
UUID termUUID = (UUID) session.getAttribute("selectedTerm");
|
|
118 |
UUID termUUID = (UUID) session.getAttribute(DistributionEditorUtil.SATTR_SELECTED_VOCABULARY_UUID);
|
|
119 | 119 |
TermVocabulary<DefinedTermBase> term = vocabularyService.load(termUUID); |
120 | 120 |
term = CdmBase.deproxy(term, TermVocabulary.class); |
121 | 121 |
return term.getTerms(); |
... | ... | |
140 | 140 |
return namedAreas; |
141 | 141 |
} |
142 | 142 |
|
143 |
public List<String> getNamedAreasLabels(boolean abbreviated){
|
|
143 |
public List<String> getNamedAreasLabels(){ |
|
144 | 144 |
Set<NamedArea> selectedAreas = getNamedAreas(); |
145 | 145 |
List<String> namedAreaTitles = new ArrayList<>(); |
146 | 146 |
for (NamedArea namedArea : selectedAreas) { |
147 | 147 |
String title = null; |
148 | 148 |
Representation representation = namedArea.getRepresentation(Language.DEFAULT()); |
149 | 149 |
if(representation!=null){ |
150 |
if(abbreviated){
|
|
150 |
if(DistributionEditorUtil.isAbbreviatedLabels()){
|
|
151 | 151 |
title = representation.getAbbreviatedLabel(); |
152 | 152 |
} |
153 | 153 |
else{ |
... | ... | |
164 | 164 |
|
165 | 165 |
private Set<NamedArea> getTermSet(){ |
166 | 166 |
VaadinSession session = VaadinSession.getCurrent(); |
167 |
UUID termUUID = (UUID) session.getAttribute("selectedTerm");
|
|
167 |
UUID termUUID = (UUID) session.getAttribute(DistributionEditorUtil.SATTR_SELECTED_VOCABULARY_UUID);
|
|
168 | 168 |
TermVocabulary<NamedArea> vocabulary = vocabularyService.load(termUUID); |
169 | 169 |
vocabulary = CdmBase.deproxy(vocabulary, TermVocabulary.class); |
170 | 170 |
return vocabulary.getTermsOrderedByLabels(Language.DEFAULT()); |
... | ... | |
213 | 213 |
|
214 | 214 |
public TaxonNode getChosenTaxonNode() { |
215 | 215 |
VaadinSession session = VaadinSession.getCurrent(); |
216 |
UUID taxonNodeUUID = (UUID) session.getAttribute("taxonNodeUUID");
|
|
216 |
UUID taxonNodeUUID = (UUID) session.getAttribute(DistributionEditorUtil.SATTR_TAXON_NODE_UUID);
|
|
217 | 217 |
TaxonNode classificationNode = taxonNodeService.load(taxonNodeUUID); |
218 | 218 |
return classificationNode; |
219 | 219 |
} |
... | ... | |
230 | 230 |
nodeIds.add(taxonNode.getId()); |
231 | 231 |
} |
232 | 232 |
Set<NamedArea> namesAreas = getNamedAreas(); |
233 |
CdmSQLContainer container = new CdmSQLContainer(CdmQueryFactory.generateTaxonDistributionQuery(nodeIds, namesAreas, true));
|
|
233 |
CdmSQLContainer container = new CdmSQLContainer(CdmQueryFactory.generateTaxonDistributionQuery(nodeIds, namesAreas)); |
|
234 | 234 |
return container; |
235 | 235 |
} |
236 | 236 |
|
src/main/java/eu/etaxonomy/cdm/vaadin/util/CdmQueryFactory.java | ||
---|---|---|
63 | 63 |
return generateQueryDelegate(SELECT_QUERY, COUNT_QUERY, CONTAINS_QUERY); |
64 | 64 |
} |
65 | 65 |
|
66 |
public static QueryDelegate generateTaxonDistributionQuery(List<Integer> taxonNodeIds, Collection<NamedArea> namedAreas, boolean abbreviatedLabels) throws SQLException {
|
|
66 |
public static QueryDelegate generateTaxonDistributionQuery(List<Integer> taxonNodeIds, Collection<NamedArea> namedAreas) throws SQLException { |
|
67 | 67 |
|
68 | 68 |
String idString = ""; |
69 | 69 |
Iterator<Integer> nodeIterator = taxonNodeIds.iterator(); |
... | ... | |
101 | 101 |
String label = null; |
102 | 102 |
Representation representation = namedArea.getRepresentation(Language.DEFAULT()); |
103 | 103 |
if(representation!=null){ |
104 |
if(abbreviatedLabels){
|
|
104 |
if(DistributionEditorUtil.isAbbreviatedLabels()){
|
|
105 | 105 |
label = representation.getAbbreviatedLabel(); |
106 | 106 |
} |
107 | 107 |
else{ |
src/main/java/eu/etaxonomy/cdm/vaadin/util/DistributionEditorUtil.java | ||
---|---|---|
40 | 40 |
//navigate to table view |
41 | 41 |
UI.getCurrent().getNavigator().navigateTo(VIEW_TABLE); |
42 | 42 |
} |
43 |
|
|
44 |
public static boolean isAbbreviatedLabels(){ |
|
45 |
Object isAbbreviated = VaadinSession.getCurrent().getAttribute(DistributionEditorUtil.SATTR_ABBREVIATED_LABELS); |
|
46 |
return (isAbbreviated==null || (boolean) isAbbreviated); |
|
47 |
} |
|
43 | 48 |
|
44 | 49 |
public static final String SATTR_CONVERSATION = "conversation"; |
45 | 50 |
|
src/main/java/eu/etaxonomy/cdm/vaadin/view/dbstatus/DistributionTableView.java | ||
---|---|---|
10 | 10 |
import com.vaadin.data.Property; |
11 | 11 |
import com.vaadin.data.Property.ValueChangeEvent; |
12 | 12 |
import com.vaadin.data.Property.ValueChangeListener; |
13 |
import com.vaadin.event.ContextClickEvent; |
|
14 |
import com.vaadin.event.ContextClickEvent.ContextClickListener; |
|
15 |
import com.vaadin.event.ItemClickEvent; |
|
16 |
import com.vaadin.event.ItemClickEvent.ItemClickListener; |
|
13 | 17 |
import com.vaadin.event.ShortcutAction.KeyCode; |
14 | 18 |
import com.vaadin.event.ShortcutAction.ModifierKey; |
15 | 19 |
import com.vaadin.navigator.View; |
... | ... | |
110 | 114 |
table.setSortEnabled(true); |
111 | 115 |
|
112 | 116 |
columnList = new ArrayList<String>(Arrays.asList(new String[]{CdmQueryFactory.TAXON_COLUMN,CdmQueryFactory.RANK_COLUMN})); |
113 |
List<String> namedAreas = listener.getNamedAreasLabels(true);
|
|
117 |
List<String> namedAreas = listener.getNamedAreasLabels(); |
|
114 | 118 |
columnList.addAll(namedAreas); |
115 | 119 |
table.setVisibleColumns(columnList.toArray()); |
116 | 120 |
|
117 | 121 |
headerList = new ArrayList<String>(Arrays.asList(new String[]{CdmQueryFactory.TAXON_COLUMN,"Rang"})); |
118 |
headerList.addAll(listener.getNamedAreasLabels(true));
|
|
122 |
headerList.addAll(listener.getNamedAreasLabels()); |
|
119 | 123 |
String[] string = new String[headerList.size()]; |
120 | 124 |
table.setColumnHeaders(headerList.toArray(string)); |
121 | 125 |
|
... | ... | |
127 | 131 |
table.setColumnFooter(CdmQueryFactory.TAXON_COLUMN, "Total amount of Taxa displayed: " + container.size()); |
128 | 132 |
|
129 | 133 |
table.setCacheRate(20); |
130 |
|
|
134 |
|
|
131 | 135 |
//add generated columns for NamedAreas |
132 | 136 |
Collection<?> containerPropertyIds = table.getContainerPropertyIds(); |
133 | 137 |
for (Object object : containerPropertyIds) { |
... | ... | |
217 | 221 |
String itemCaption = null; |
218 | 222 |
Representation representation = presenceAbsenceTerm.getRepresentation(Language.DEFAULT()); |
219 | 223 |
if(representation!=null){ |
220 |
if((Boolean)VaadinSession.getCurrent().getAttribute(DistributionEditorUtil.SATTR_ABBREVIATED_LABELS)){
|
|
224 |
if(DistributionEditorUtil.isAbbreviatedLabels()){
|
|
221 | 225 |
itemCaption = representation.getAbbreviatedLabel(); |
222 | 226 |
} |
223 | 227 |
else{ |
src/main/java/eu/etaxonomy/cdm/vaadin/view/dbstatus/SettingsConfigWindow.java | ||
---|---|---|
14 | 14 |
import com.vaadin.data.Container; |
15 | 15 |
import com.vaadin.data.Property.ValueChangeEvent; |
16 | 16 |
import com.vaadin.data.Property.ValueChangeListener; |
17 |
import com.vaadin.server.VaadinSession; |
|
17 | 18 |
import com.vaadin.ui.AbstractLayout; |
18 | 19 |
import com.vaadin.ui.Alignment; |
19 | 20 |
import com.vaadin.ui.Button; |
20 | 21 |
import com.vaadin.ui.Button.ClickEvent; |
21 | 22 |
import com.vaadin.ui.Button.ClickListener; |
23 |
import com.vaadin.ui.CheckBox; |
|
22 | 24 |
import com.vaadin.ui.ComboBox; |
23 | 25 |
import com.vaadin.ui.CustomComponent; |
24 | 26 |
import com.vaadin.ui.HorizontalLayout; |
... | ... | |
47 | 49 |
private ComboBox classificationBox; |
48 | 50 |
private ComboBox distAreaBox; |
49 | 51 |
private Tree taxonTree; |
52 |
private CheckBox boxToggleAbbreviatedLabels; |
|
50 | 53 |
private Button okButton; |
51 | 54 |
private Button cancelButton; |
52 | 55 |
private final SettingsPresenter presenter; |
... | ... | |
73 | 76 |
classificationBox.setContainerDataSource(taxonNodeContainer); |
74 | 77 |
classificationBox.setValue(presenter.getChosenTaxonNode().getClassification().getRootNode()); |
75 | 78 |
classificationBox.addValueChangeListener(new ValueChangeListener() { |
79 |
private static final long serialVersionUID = -8159622506131474118L; |
|
80 |
|
|
76 | 81 |
@Override |
77 | 82 |
public void valueChange(ValueChangeEvent event) { |
78 | 83 |
TaxonNode parentNode = (TaxonNode) event.getProperty().getValue(); |
... | ... | |
84 | 89 |
taxonTree.setValue(presenter.getChosenTaxonNode()); |
85 | 90 |
distAreaBox.setContainerDataSource(distributionContainer); |
86 | 91 |
distAreaBox.setValue(chosenArea); |
92 |
boxToggleAbbreviatedLabels.addValueChangeListener(new ValueChangeListener() { |
|
93 |
|
|
94 |
private static final long serialVersionUID = 5734502056399266546L; |
|
95 |
|
|
96 |
@Override |
|
97 |
public void valueChange(ValueChangeEvent event) { |
|
98 |
VaadinSession.getCurrent().setAttribute(DistributionEditorUtil.SATTR_ABBREVIATED_LABELS, event.getProperty().getValue()); |
|
99 |
|
|
100 |
} |
|
101 |
}); |
|
87 | 102 |
distStatusSelect.setContainerDataSource(presenter.getDistributionStatusContainer()); |
88 | 103 |
|
89 | 104 |
okButton.addClickListener(new ClickListener() { |
90 | 105 |
|
106 |
private static final long serialVersionUID = -2554281233796070939L; |
|
107 |
|
|
91 | 108 |
@Override |
92 | 109 |
public void buttonClick(ClickEvent event) { |
93 | 110 |
TaxonNode taxonNode; |
... | ... | |
103 | 120 |
}); |
104 | 121 |
cancelButton.addClickListener(new ClickListener() { |
105 | 122 |
|
123 |
private static final long serialVersionUID = -99532405408235383L; |
|
124 |
|
|
106 | 125 |
@Override |
107 | 126 |
public void buttonClick(ClickEvent event) { |
108 | 127 |
window.close(); |
... | ... | |
149 | 168 |
distStatusSelect = new TwinColSelect("Distribution Status:"); |
150 | 169 |
distStatusSelect.setImmediate(false); |
151 | 170 |
distStatusSelect.setWidth("100%"); |
171 |
|
|
172 |
//toggle abbreviated labels |
|
173 |
boxToggleAbbreviatedLabels = new CheckBox("Show abbreviated labels", DistributionEditorUtil.isAbbreviatedLabels()); |
|
174 |
boxToggleAbbreviatedLabels.setImmediate(true); |
|
152 | 175 |
|
153 | 176 |
//taxonomy |
154 | 177 |
taxonTree = new Tree("Taxonomy"); |
... | ... | |
156 | 179 |
|
157 | 180 |
verticalLayout.addComponent(classificationBox); |
158 | 181 |
verticalLayout.addComponent(distAreaBox); |
182 |
verticalLayout.addComponent(boxToggleAbbreviatedLabels); |
|
159 | 183 |
verticalLayout.addComponent(distStatusSelect); |
160 | 184 |
verticalLayout.setExpandRatio(distStatusSelect, 1); |
161 | 185 |
verticalLayout.setSizeFull(); |
Also available in: Unified diff
ref #5458 Add toggle button for abbreviations to settings menu