4 package eu
.etaxonomy
.taxeditor
.ui
.section
;
6 import java
.util
.Arrays
;
7 import java
.util
.EnumSet
;
9 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
10 import eu
.etaxonomy
.cdm
.model
.common
.IIdentifiableEntity
;
11 import eu
.etaxonomy
.cdm
.persistence
.hibernate
.permission
.CRUD
;
12 import eu
.etaxonomy
.taxeditor
.preference
.IPreferenceKeys
;
13 import eu
.etaxonomy
.taxeditor
.preference
.PreferencesUtil
;
14 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
15 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
16 import eu
.etaxonomy
.taxeditor
.ui
.element
.ICdmFormElement
;
17 import eu
.etaxonomy
.taxeditor
.ui
.element
.ToggleableTextElement
;
23 public abstract class AbstractIdentifiableEntityDetailElement
<T
extends IIdentifiableEntity
> extends
24 AbstractCdmDetailElement
<T
> {
29 private static final EnumSet
<CRUD
> UPDATE
= EnumSet
.of(CRUD
.UPDATE
);
30 protected ToggleableTextElement toggleable_cache
;
31 protected boolean isAdvancedView
;
33 public AbstractIdentifiableEntityDetailElement(CdmFormFactory formFactory
, ICdmFormElement formElement
) {
34 super(formFactory
, formElement
);
35 updateToggleableCacheState();
36 initIsAdvancedDetailsView();
41 public void updateToggleableCacheField() {
42 if (toggleable_cache
!= null){
43 if (!getEntity().isProtectedTitleCache()) {
44 toggleable_cache
.setText(getEntity().generateTitle());
49 protected void handleToggleableCacheField() {
50 boolean pushedState
= toggleable_cache
.getState();
52 getEntity().setTitleCache(toggleable_cache
.getText(), pushedState
);
53 setIrrelevant(pushedState
, Arrays
.asList(new Object
[] { toggleable_cache
}));
54 updateToggleableCacheField();
59 protected void updateControlStates(){
60 super.updateControlStates();
61 updateToggleableCacheState();
65 private void updateToggleableCacheState() {
66 if(toggleable_cache
!= null){
67 toggleable_cache
.setEnabled(getEntity() != null && CdmStore
.currentAuthentiationHasPermission((CdmBase
) getEntity(), UPDATE
));
70 protected void initIsAdvancedDetailsView(){
71 if(PreferencesUtil
.getBooleanValue(IPreferenceKeys
.SHOW_SIMPLE_NAME_DETAILS_SECTION
)){
72 isAdvancedView
= false;
74 isAdvancedView
= true;