Revision 78159090
Added by Andreas Kohlbecker about 5 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TaxonNameEditorPresenter.java | ||
---|---|---|
55 | 55 |
import eu.etaxonomy.cdm.vaadin.ui.RegistrationUIDefaults; |
56 | 56 |
import eu.etaxonomy.cdm.vaadin.util.CdmTitleCacheCaptionGenerator; |
57 | 57 |
import eu.etaxonomy.cdm.vaadin.view.reference.ReferencePopupEditor; |
58 |
import eu.etaxonomy.cdm.vaadin.view.reference.RegistrationUiReferenceEditorFormConfigurator; |
|
58 | 59 |
import eu.etaxonomy.vaadin.component.CompositeCustomField; |
59 | 60 |
import eu.etaxonomy.vaadin.component.ReloadableLazyComboBox; |
60 | 61 |
import eu.etaxonomy.vaadin.component.ToOneRelatedEntityCombobox; |
... | ... | |
340 | 341 |
referenceEditorPopup.grantToCurrentUser(EnumSet.of(CRUD.UPDATE, CRUD.DELETE)); |
341 | 342 |
referenceEditorPopup.withDeleteButton(true); |
342 | 343 |
referenceEditorPopup.setBeanInstantiator(newReferenceInstantiator); |
344 |
// TODO this should be configurable per UI - RegistrationUiReferenceEditorFormConfigurator as spring bean, different spring profiles |
|
345 |
referenceEditorPopup.setEditorComponentsConfigurator(new RegistrationUiReferenceEditorFormConfigurator(newReferenceInstantiator != null)); |
|
343 | 346 |
referenceEditorPopup.loadInEditor(null); |
344 |
if(newReferenceInstantiator != null){ |
|
345 |
// this is a bit clumsy, we actually need to inject something like a view configurer |
|
346 |
// which can enable, disable fields |
|
347 |
referenceEditorPopup.getInReferenceCombobox().setEnabled(false); |
|
348 |
referenceEditorPopup.getTypeSelect().setEnabled(false); |
|
349 |
} |
|
347 |
// if(newReferenceInstantiator != null){
|
|
348 |
// // this is a bit clumsy, we actually need to inject something like a view configurer
|
|
349 |
// // which can enable, disable fields
|
|
350 |
// referenceEditorPopup.getInReferenceCombobox().setEnabled(false);
|
|
351 |
// referenceEditorPopup.getTypeSelect().setEnabled(false);
|
|
352 |
// }
|
|
350 | 353 |
} |
351 | 354 |
|
352 | 355 |
@EventBusListenerMethod(filter = EditorActionTypeFilter.Edit.class) |
... | ... | |
360 | 363 |
|
361 | 364 |
referenceEditorPopup.withDeleteButton(true); |
362 | 365 |
referenceEditorPopup.setBeanInstantiator(newReferenceInstantiator); |
366 |
// TODO this should be configurable per UI - RegistrationUiReferenceEditorFormConfigurator as spring bean, different spring profiles |
|
367 |
referenceEditorPopup.setEditorComponentsConfigurator(new RegistrationUiReferenceEditorFormConfigurator(newReferenceInstantiator != null)); |
|
363 | 368 |
referenceEditorPopup.loadInEditor(event.getEntityUuid()); |
364 |
if(newReferenceInstantiator != null){ |
|
365 |
// this is a bit clumsy, we actually need to inject something like a view configurator |
|
366 |
// which can enable, disable fields |
|
367 |
referenceEditorPopup.getInReferenceCombobox().setEnabled(false); |
|
368 |
referenceEditorPopup.getTypeSelect().setEnabled(false); |
|
369 |
} |
|
369 |
// if(newReferenceInstantiator != null){ |
|
370 |
// // this is a bit clumsy, we actually need to inject something like a view configurator |
|
371 |
// // which can enable, disable fields |
|
372 |
// referenceEditorPopup.getInReferenceCombobox().setEnabled(false); |
|
373 |
// referenceEditorPopup.getInReferenceCombobox().setEditButtonEnabled(false); // <------- |
|
374 |
// referenceEditorPopup.getTypeSelect().setEnabled(false); |
|
375 |
// } |
|
370 | 376 |
} |
371 | 377 |
|
372 | 378 |
@EventBusListenerMethod |
src/main/java/eu/etaxonomy/cdm/vaadin/view/reference/RegistrationUiReferenceEditorFormConfigurator.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2019 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
package eu.etaxonomy.cdm.vaadin.view.reference; |
|
10 |
|
|
11 |
import java.util.EnumSet; |
|
12 |
|
|
13 |
import eu.etaxonomy.cdm.model.reference.ReferenceType; |
|
14 |
import eu.etaxonomy.vaadin.mvp.AbstractPopupEditor; |
|
15 |
import eu.etaxonomy.vaadin.mvp.EditorFormConfigurator; |
|
16 |
|
|
17 |
/** |
|
18 |
* @author a.kohlbecker |
|
19 |
* @since Mar 22, 2019 |
|
20 |
* |
|
21 |
*/ |
|
22 |
public class RegistrationUiReferenceEditorFormConfigurator implements EditorFormConfigurator<ReferencePopupEditor> { |
|
23 |
|
|
24 |
boolean newReferenceInstantiatorExists; |
|
25 |
|
|
26 |
EnumSet<ReferenceType> sectionTypes = EnumSet.of(ReferenceType.Section, ReferenceType.BookSection); |
|
27 |
|
|
28 |
public RegistrationUiReferenceEditorFormConfigurator(boolean newReferenceInstantiatorExists){ |
|
29 |
this.newReferenceInstantiatorExists = newReferenceInstantiatorExists; |
|
30 |
} |
|
31 |
|
|
32 |
@Override |
|
33 |
public void updateComponentStates(AbstractPopupEditor<?, ?> popupEditor) { |
|
34 |
if(newReferenceInstantiatorExists){ |
|
35 |
ReferencePopupEditor refEditor = (ReferencePopupEditor)popupEditor; |
|
36 |
boolean isSection = sectionTypes.contains(refEditor.getBean().getType()); |
|
37 |
// editing of the inRefernce should be allowed if the reference in the editor is not a section |
|
38 |
refEditor.getInReferenceCombobox().setAddButtonEnabled(!isSection); |
|
39 |
refEditor.getInReferenceCombobox().getSelect().setEnabled(!isSection); |
|
40 |
// the user should be able to edit the inRefernce of a section from here |
|
41 |
refEditor.getInReferenceCombobox().setEditButtonEnabled(true); |
|
42 |
refEditor.getTypeSelect().setEnabled(false); |
|
43 |
} |
|
44 |
} |
|
45 |
|
|
46 |
} |
src/main/java/eu/etaxonomy/vaadin/mvp/AbstractPopupEditor.java | ||
---|---|---|
131 | 131 |
|
132 | 132 |
private Button advancedModeButton; |
133 | 133 |
|
134 |
private EditorFormConfigurator<? extends AbstractPopupEditor<DTO, P>> editorComponentsConfigurator; |
|
135 |
|
|
134 | 136 |
public AbstractPopupEditor(Layout layout, Class<DTO> dtoType) { |
135 | 137 |
|
136 | 138 |
mainLayout = new VerticalLayout(); |
... | ... | |
866 | 868 |
* You can now implement this method if you need to modify the state or value of individual fields. |
867 | 869 |
*/ |
868 | 870 |
protected void afterItemDataSourceSet() { |
871 |
if(editorComponentsConfigurator != null){ |
|
872 |
editorComponentsConfigurator.updateComponentStates(this); |
|
873 |
} |
|
869 | 874 |
} |
870 | 875 |
|
871 | 876 |
// ------------------------ issue related temporary solutions --------------------- // |
... | ... | |
931 | 936 |
return newField; |
932 | 937 |
} |
933 | 938 |
|
939 |
public EditorFormConfigurator<? extends AbstractPopupEditor<DTO, P>> getEditorComponentsConfigurator() { |
|
940 |
return editorComponentsConfigurator; |
|
941 |
} |
|
942 |
|
|
943 |
public void setEditorComponentsConfigurator( |
|
944 |
EditorFormConfigurator<? extends AbstractPopupEditor<DTO, P>> editorComponentsConfigurator) { |
|
945 |
this.editorComponentsConfigurator = editorComponentsConfigurator; |
|
946 |
} |
|
947 |
|
|
934 | 948 |
} |
src/main/java/eu/etaxonomy/vaadin/mvp/EditorFormConfigurator.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2019 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
package eu.etaxonomy.vaadin.mvp; |
|
10 |
|
|
11 |
/** |
|
12 |
* @author a.kohlbecker |
|
13 |
* @since Mar 22, 2019 |
|
14 |
* |
|
15 |
*/ |
|
16 |
public interface EditorFormConfigurator<T extends AbstractPopupEditor<?,?>> { |
|
17 |
|
|
18 |
public void updateComponentStates(AbstractPopupEditor<?, ?> abstractPopupEditor); |
|
19 |
} |
Also available in: Unified diff
ref #8191 intoducing the long awaited EditorFormConfigurator for fine tuning of the inReference button enabled states