Project

General

Profile

« Previous | Next » 

Revision ec4a9eb1

Added by Katja Luther almost 3 years ago

ref #9287: adapt all toggleable text fields to enableCache

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/AbstractCdmDetailElement.java
86 86
        updateContent();
87 87
	}
88 88

  
89
	public void setEntityWithoutUpdate(T entity){
90
	    this.entity = entity;
91
        // the id is always 0 if the entity was not yet saved, so it is new in this case
92
        if(getEntity() == null || (getEntity() instanceof CdmBase && StoreUtil.getCdmEntity(getEntity()).getId() == 0)) {
93
            // new entity, not yet saved
94
            requiredCrud = EnumSet.of(CRUD.CREATE);
95
        } else {
96
            requiredCrud = EnumSet.of(CRUD.UPDATE);
97
        }
98
	}
99

  
89 100
	@Override
90 101
    public T getEntity() {
91 102
		return entity;
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/agent/PersonDetailElement.java
98 98
	@Override
99 99
	protected void updateContent() {
100 100
		super.updateContent();
101
		toggleable_cache.setEnabled(getEntity().isProtectedTitleCache());
101
		toggleable_cache.setCacheEnabled(getEntity().isProtectedTitleCache());
102 102
		updateCacheRelevance();
103 103
	}
104 104

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/agent/TeamDetailElement.java
71 71
	protected void updateContent() {
72 72
		super.updateContent();
73 73
		if (toggleable_cache != null){
74
		    toggleable_cache.setEnabled(getEntity().isProtectedTitleCache());
74
		    toggleable_cache.setCacheEnabled(getEntity().isProtectedTitleCache());
75 75
		}
76 76
		if (toggleable_nomenclaturalTitleCache != null){
77
		    toggleable_nomenclaturalTitleCache.setEnabled(getEntity()
77
		    toggleable_nomenclaturalTitleCache.setCacheEnabled(getEntity()
78 78
				.isProtectedNomenclaturalTitleCache());
79 79
		}
80 80
		if (toggleable_collectorTitleCache != null){
81
            toggleable_collectorTitleCache.setEnabled(getEntity()
81
            toggleable_collectorTitleCache.setCacheEnabled(getEntity()
82 82
                .isProtectedCollectorTitleCache());
83 83
        }
84 84
		section_teamMembers.setEntity(getEntity());
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/DescriptionDetailElement.java
19 19
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
20 20
import eu.etaxonomy.taxeditor.ui.element.IEnableableFormElement;
21 21
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
22
import eu.etaxonomy.taxeditor.ui.element.ToggleableTextElement;
23 22
import eu.etaxonomy.taxeditor.ui.section.AbstractIdentifiableEntityDetailElement;
24 23

  
25 24
/**
......
66 65
            if (element instanceof IEnableableFormElement) {
67 66
                IEnableableFormElement enableableElement = (IEnableableFormElement) element;
68 67
                enableableElement.setEnabled(enabled);
69
                if (enableableElement instanceof ToggleableTextElement){
70
                    ToggleableTextElement toggle = (ToggleableTextElement)enableableElement;
71
                    toggle.getBtnToggleProtectTitleCache().setEnabled(enabled);
72
                }
68
//                if (enableableElement instanceof ToggleableTextElement){
69
//                    ToggleableTextElement toggle = (ToggleableTextElement)enableableElement;
70
//                    toggle.getBtnToggleProtectTitleCache().setEnabled(enabled);
71
//                }
73 72

  
74 73
            }
75 74
        }
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/AuthorshipDetailElement.java
125 125

  
126 126
		super.updateContent();
127 127
		if (toggleable_cache != null){
128
    		toggleable_cache.setEnabled(getEntity().isProtectedAuthorshipCache());
128
    		toggleable_cache.setCacheEnabled(getEntity().isProtectedAuthorshipCache());
129 129
    		updateCacheRelevance();
130 130
		}
131 131
	}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/NameDetailElement.java
25 25
import eu.etaxonomy.cdm.strategy.parser.ParserProblem;
26 26
import eu.etaxonomy.taxeditor.preference.NameDetailsConfigurator;
27 27
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
28
import eu.etaxonomy.taxeditor.store.StoreUtil;
29 28
import eu.etaxonomy.taxeditor.ui.combo.term.TermComboElement;
30 29
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
31 30
import eu.etaxonomy.taxeditor.ui.element.CheckboxElement;
......
84 83
			comparator = new Comparator<Rank>(){
85 84
				@Override
86 85
				public int compare(Rank o1, Rank o2) {
87
					return o2.compareTo(o1);
86
					return o1.compareTo(o2);
88 87
				}
89 88
			};
90 89
		}
......
161 160

  
162 161
		super.updateContent();
163 162
		if (toggleable_cache != null){
164
		    toggleable_cache.setEnabled(getEntity().isProtectedNameCache());
163
		    toggleable_cache.setCacheEnabled(getEntity().isProtectedNameCache());
165 164

  
166 165
    		if (config == null){
167 166
    			updateCacheRelevance();
......
273 272
			getEntity().setRank(combo_rank.getSelection());
274 273
			clearCheckRankWarnings();
275 274
			updateContent();
275

  
276
			((NameDetailSection)this.getParentElement()).layout(true, true);
276 277
            //this is needed for the "new" wizards in order to redraw correctly
277
            StoreUtil.reflowParentScrolledForm(getLayoutComposite(), true);
278
//            StoreUtil.reflowParentScrolledForm(getLayoutComposite(), true);
278 279
		}
279 280
		else if(eventSource == text_appendedPhrase){
280 281
			getEntity().setAppendedPhrase(text_appendedPhrase.getText());
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/NonViralNameDetailElement.java
105 105
		super.updateContent();
106 106

  
107 107
		if(toggleable_cache != null){
108
		    toggleable_cache.setEnabled(getEntity().isProtectedTitleCache() || getEntity().isProtectedFullTitleCache());
108
		    toggleable_cache.setCacheEnabled(getEntity().isProtectedTitleCache() || getEntity().isProtectedFullTitleCache());
109 109
		    updateCacheRelevance();
110 110
		}
111 111
	}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/reference/ReferenceDetailElement.java
17 17

  
18 18
import eu.etaxonomy.cdm.model.agent.Institution;
19 19
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
20
import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
20 21
import eu.etaxonomy.cdm.model.reference.Reference;
21 22
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
22 23
import eu.etaxonomy.cdm.model.reference.ReferenceType;
24
import eu.etaxonomy.taxeditor.model.AbstractUtility;
25
import eu.etaxonomy.taxeditor.preference.Resources;
23 26
import eu.etaxonomy.taxeditor.store.StoreUtil;
24 27
import eu.etaxonomy.taxeditor.ui.combo.EnumComboElement;
25 28
import eu.etaxonomy.taxeditor.ui.element.CacheRelevance;
......
29 32
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
30 33
import eu.etaxonomy.taxeditor.ui.element.IErrorIntolerableElement;
31 34
import eu.etaxonomy.taxeditor.ui.element.IExceptionHandler;
35
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
32 36
import eu.etaxonomy.taxeditor.ui.element.LsidWithExceptionLabelElement;
33 37
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
34 38
import eu.etaxonomy.taxeditor.ui.element.ToggleableTextElement;
......
170 174

  
171 175
		createUri(this, entity, SWT.NULL);
172 176

  
173
//		externalLinks = formFactory.createExternalLinksSection(getConversationHolder(), formElement, StoreUtil.getSectionStyle(ExternalLinksSection.class, DescriptionElementSource.class.getCanonicalName()));
174
//        externalLinks.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 3));
175
//        externalLinks.setEntity(entity);
176
//        externalLinks.setFont(AbstractUtility.getFont(Resources.COLOR_FONT_DEFAULT));
177
//        externalLinks.setEmptySectionString("No links yet.");
177
		externalLinks = formFactory.createExternalLinksSection(getConversationHolder(), formElement, StoreUtil.getSectionStyle(ExternalLinksSection.class, DescriptionElementSource.class.getCanonicalName()));
178
        externalLinks.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 3));
179
        externalLinks.setEntity(entity);
180
        externalLinks.setFont(AbstractUtility.getFont(Resources.COLOR_FONT_DEFAULT));
181
        externalLinks.setEmptySectionString("No links yet.");
178 182

  
179 183
		if(referenceType != null && (!referenceType.equals(ReferenceType.Journal) && !referenceType.equals(ReferenceType.PrintSeries) && !referenceType.equals(ReferenceType.PersonalCommunication))) {
180 184
            text_doi = formFactory.createDoiWithLabelElement(formElement, "DOI", entity.getDoi(), style);
......
205 209
		super.updateContent();
206 210

  
207 211
		// enable elements according to state of cache protection
208
		toggleable_cache.setEnabled(getEntity().isProtectedTitleCache());
209
		toggleableAbbrevCache.setEnabled(getEntity().isProtectedAbbrevTitleCache());
212
		toggleable_cache.setCacheEnabled(getEntity().isProtectedTitleCache());
213
		toggleableAbbrevCache.setCacheEnabled(getEntity().isProtectedAbbrevTitleCache());
210 214
	}
211 215

  
212 216
	/**
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/taxon/TaxonBaseDetailElement.java
75 75
	            secElement.setEntity(entity.getSecSource());
76 76
	        }
77 77

  
78
//		selection_secundum = formFactory.createSelectionElement(Reference.class,
79
//				 formElement, "Secundum",
80
//				entity.getSec(), EntitySelectionElement.ALL,
81
//				style);
82 78
		if (config != null && !config.isSecEnabled()){
83 79
		    secElement.setEnabled(false);
84 80
		}
......
93 89
		checkbox_published = formFactory.createCheckbox(formElement,
94 90
		        entity.getClass().getSimpleName()+" is published", entity.isPublish(), style);
95 91

  
96
		if(entity instanceof Synonym){
97
		    //#6198 removed type as it is currently not handled correctly in the editor
98
//		    combo_relationshipType = formFactory.createDefinedTermComboElement(TermType.SynonymType, formElement, "Synonym Type", ((Synonym) entity).getType(), style);
99
		}
100 92

  
101 93
	    //cache relevance
102 94
        registerCacheRelevance(checkbox_doubtful);
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/taxon/TaxonOfRelationshipElement.java
57 57
	@Override
58 58
	protected void updateContent() {
59 59
		super.updateContent();
60
		toggleable_cache.setEnabled(getEntity().isProtectedTitleCache());
60
		toggleable_cache.setCacheEnabled(getEntity().isProtectedTitleCache());
61 61
		updateCacheRelevance();
62 62
		firePropertyChangeEvent(getEntity());
63 63
	}

Also available in: Unified diff