Revision 41f187f1
Added by Patrick Plitzner over 7 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/view/dbstatus/AbstractSettingsDialogWindow.java | ||
---|---|---|
55 | 55 |
window.setContent(mainLayout); |
56 | 56 |
return window; |
57 | 57 |
} |
58 |
|
|
59 |
/** |
|
60 |
* Update OK/Cancel button depending on {@link #isValid()} |
|
61 |
*/ |
|
62 |
protected void updateButtons(){ |
|
63 |
okButton.setEnabled(isValid()); |
|
64 |
} |
|
65 |
|
|
66 |
/** |
|
67 |
* Evaluates if this dialog has all necessary values set in |
|
68 |
* a correct state |
|
69 |
* @return <code>true</code> if the status of this dialog is valid |
|
70 |
*/ |
|
71 |
protected abstract boolean isValid(); |
|
58 | 72 |
|
59 | 73 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/view/dbstatus/DistributionSettingsConfigWindow.java | ||
---|---|---|
24 | 24 |
import com.vaadin.ui.ComboBox; |
25 | 25 |
import com.vaadin.ui.HorizontalLayout; |
26 | 26 |
import com.vaadin.ui.ListSelect; |
27 |
import com.vaadin.ui.Notification; |
|
28 | 27 |
import com.vaadin.ui.Table.ColumnHeaderMode; |
29 | 28 |
import com.vaadin.ui.TreeTable; |
30 | 29 |
import com.vaadin.ui.VerticalLayout; |
... | ... | |
104 | 103 |
|
105 | 104 |
okButton.addClickListener(this); |
106 | 105 |
cancelButton.addClickListener(this); |
106 |
updateButtons(); |
|
107 | 107 |
} |
108 | 108 |
|
109 | 109 |
protected AbstractLayout buildMainLayout() { |
... | ... | |
209 | 209 |
NamedAreaContainer container = new NamedAreaContainer(vocabulary); |
210 | 210 |
namedAreaList.setContainerDataSource(container); |
211 | 211 |
} |
212 |
updateButtons(); |
|
213 |
} |
|
214 |
|
|
215 |
@Override |
|
216 |
protected boolean isValid() { |
|
217 |
return classificationBox.getValue()!=null && distAreaBox.getValue()!=null; |
|
212 | 218 |
} |
213 | 219 |
|
214 | 220 |
@Override |
... | ... | |
226 | 232 |
} |
227 | 233 |
term = (TermVocabulary<NamedArea>) distAreaBox.getValue(); |
228 | 234 |
Set<NamedArea> selectedAreas = (Set<NamedArea>) namedAreaList.getValue(); |
229 |
if(taxonNode==null){ |
|
230 |
Notification.show("Please choose a classification and/or taxon", Notification.Type.HUMANIZED_MESSAGE); |
|
231 |
return; |
|
232 |
} |
|
233 |
if(term==null){ |
|
234 |
Notification.show("Please choose a distribution area", Notification.Type.HUMANIZED_MESSAGE); |
|
235 |
return; |
|
236 |
} |
|
237 | 235 |
DistributionEditorUtil.openDistributionView(taxonNode, term, selectedAreas); |
238 | 236 |
window.close(); |
239 | 237 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/view/dbstatus/SettingsConfigWindow.java | ||
---|---|---|
55 | 55 |
|
56 | 56 |
okButton.addClickListener(this); |
57 | 57 |
cancelButton.addClickListener(this); |
58 |
updateButtons(); |
|
58 | 59 |
} |
59 | 60 |
|
60 | 61 |
protected AbstractLayout buildMainLayout() { |
... | ... | |
88 | 89 |
|
89 | 90 |
return mainLayout; |
90 | 91 |
} |
92 |
|
|
93 |
@Override |
|
94 |
protected boolean isValid() { |
|
95 |
return true; |
|
96 |
} |
|
91 | 97 |
|
92 | 98 |
@Override |
93 | 99 |
public void valueChange(ValueChangeEvent event) { |
Also available in: Unified diff
ref #5458 Validation for settings dialogs