Revision 8195658e
Added by Andreas Kohlbecker about 3 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/view/reference/RegistrationUiReferenceEditorFormConfigurator.java | ||
---|---|---|
10 | 10 |
|
11 | 11 |
import java.util.EnumSet; |
12 | 12 |
|
13 |
import eu.etaxonomy.cdm.model.reference.Reference; |
|
13 | 14 |
import eu.etaxonomy.cdm.model.reference.ReferenceType; |
14 | 15 |
import eu.etaxonomy.vaadin.mvp.AbstractPopupEditor; |
16 |
import eu.etaxonomy.vaadin.mvp.BeanInstantiator; |
|
15 | 17 |
import eu.etaxonomy.vaadin.mvp.EditorFormConfigurator; |
16 | 18 |
|
17 | 19 |
/** |
... | ... | |
21 | 23 |
*/ |
22 | 24 |
public class RegistrationUiReferenceEditorFormConfigurator implements EditorFormConfigurator<ReferencePopupEditor> { |
23 | 25 |
|
24 |
boolean newReferenceInstantiatorExists; |
|
26 |
boolean limitToSectionEditing; |
|
27 |
|
|
28 |
boolean typeSelectReadonly; |
|
25 | 29 |
|
26 | 30 |
EnumSet<ReferenceType> sectionTypes = EnumSet.of(ReferenceType.Section, ReferenceType.BookSection); |
27 | 31 |
|
28 |
public RegistrationUiReferenceEditorFormConfigurator(boolean newReferenceInstantiatorExists){ |
|
29 |
this.newReferenceInstantiatorExists = newReferenceInstantiatorExists; |
|
32 |
public static RegistrationUiReferenceEditorFormConfigurator create(boolean limitToSectionEditing) { |
|
33 |
return new RegistrationUiReferenceEditorFormConfigurator(limitToSectionEditing); |
|
34 |
} |
|
35 |
|
|
36 |
public RegistrationUiReferenceEditorFormConfigurator configure(ReferencePopupEditor referenceEditorPopup, BeanInstantiator<Reference> beanInstantiator) { |
|
37 |
referenceEditorPopup.setEditorComponentsConfigurator(this); |
|
38 |
if(beanInstantiator != null) { |
|
39 |
referenceEditorPopup.setBeanInstantiator(beanInstantiator); |
|
40 |
} |
|
41 |
return this; |
|
42 |
} |
|
43 |
|
|
44 |
private RegistrationUiReferenceEditorFormConfigurator(boolean limitToSectionEditing){ |
|
45 |
this.limitToSectionEditing = limitToSectionEditing; |
|
46 |
} |
|
47 |
|
|
48 |
public RegistrationUiReferenceEditorFormConfigurator typeSelectReadonly(boolean typeSelectReadonly) { |
|
49 |
this.typeSelectReadonly = typeSelectReadonly; |
|
50 |
return this; |
|
30 | 51 |
} |
31 | 52 |
|
32 | 53 |
@Override |
33 | 54 |
public void updateComponentStates(AbstractPopupEditor<?, ?> popupEditor) { |
34 |
if(newReferenceInstantiatorExists){
|
|
35 |
ReferencePopupEditor refEditor = (ReferencePopupEditor)popupEditor;
|
|
55 |
ReferencePopupEditor refEditor = (ReferencePopupEditor)popupEditor;
|
|
56 |
if(limitToSectionEditing){
|
|
36 | 57 |
boolean isSection = sectionTypes.contains(refEditor.getBean().getType()); |
37 | 58 |
// editing of the inRefernce should be allowed if the reference in the editor is not a section |
38 | 59 |
refEditor.getInReferenceCombobox().setAddButtonEnabled(!isSection); |
... | ... | |
41 | 62 |
refEditor.getInReferenceCombobox().setEditButtonEnabled(true); |
42 | 63 |
refEditor.getTypeSelect().setEnabled(false); |
43 | 64 |
} |
65 |
if(typeSelectReadonly) { |
|
66 |
refEditor.getTypeSelect().setEnabled(false); |
|
67 |
} |
|
44 | 68 |
} |
45 | 69 |
|
46 | 70 |
} |
Also available in: Unified diff
fix #9480 SpecimenTypeDesignationEditor: limiting designationReference editing to sections of published unit