Project

General

Profile

« Previous | Next » 

Revision aa744c3b

Added by Katja Luther over 6 years ago

add distinction between misapplied name and other concept relationships

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/taxon/TaxonRelationshipDetailElement.java
19 19
import eu.etaxonomy.cdm.model.taxon.SynonymType;
20 20
import eu.etaxonomy.cdm.model.taxon.Taxon;
21 21
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
22
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
22 23
import eu.etaxonomy.taxeditor.model.TaxonRelationshipTypeInverseContainer;
23 24
import eu.etaxonomy.taxeditor.store.StoreUtil;
24 25
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
......
40 41
 */
41 42
public class TaxonRelationshipDetailElement extends AbstractCdmDetailElement<TaxonRelationship> {
42 43

  
43
//	private TermComboElement<TaxonRelationshipTypeInverseContainer> combo_taxonRelationshipType;
44
//	
45
//	private EntitySelectionElement<Taxon> selection_relatedTaxon;
44
	private TermComboElement<TaxonRelationshipTypeInverseContainer> combo_taxonRelationshipType;
45
	
46
	private EntitySelectionElement<Taxon> selection_relatedTaxon;
47
	private CheckboxElement checkBoxDoubtful;
46 48
	 protected ToggleableTextElement toggleable_cache;
47 49
	private  EntitySelectionElement<Reference> secReference;
48 50
	private  EntitySelectionElement<Reference> sensuReference;
......
69 71
	@Override
70 72
	protected void createControls(ICdmFormElement formElement,
71 73
			TaxonRelationship entity, int style) {
72
//		combo_taxonRelationshipType = formFactory.createTermComboElement(
73
//				TaxonRelationshipTypeInverseContainer.class, 
74
//				formElement, "Relationship Type", 
75
//				getTaxonRelationshipTypeInverseContainer(), style);
76
//		combo_taxonRelationshipType.setEnabled(false);
77
//		selection_relatedTaxon = formFactory.createSelectionElement(
78
//				Taxon.class, getConversationHolder(), 
79
//				formElement, "Related Taxon", getRelatedTaxon(), 
80
//				EntitySelectionElement.SELECTABLE, style);
81
		taxon = entity.getFromTaxon();
82
		toggleable_cache = formFactory.createToggleableTextField(formElement,
83
				"Title Cache", taxon.getTitleCache(),
84
				taxon.isProtectedTitleCache(), style);
85

  
86
		text_appendedPhrase = formFactory.createTextWithLabelElement(
87
				formElement, "Appended Phrase", taxon.getAppendedPhrase(),
88
				SWT.WRAP);
89

  
90

  
91
		sensuReference = formFactory.createSelectionElement(Reference.class,
92
			getConversationHolder(), formElement, "Sensu",
93
			taxon.getSec(), EntitySelectionElement.ALL,
94
			style);
95

  
96
		text_sensu_microreference = formFactory.createTextWithLabelElement(
97
				formElement, "Detail",
98
				taxon.getSecMicroReference(),null,
99
				SWT.WRAP);
100

  
101
		
74
		if (!entity.getType().equals(TaxonRelationshipType.MISAPPLIED_NAME_FOR())){
75
			combo_taxonRelationshipType = formFactory.createTermComboElement(
76
					TaxonRelationshipTypeInverseContainer.class, 
77
					formElement, "Relationship Type", 
78
					getTaxonRelationshipTypeInverseContainer(), style);
79
			combo_taxonRelationshipType.setEnabled(false);
80
			selection_relatedTaxon = formFactory.createSelectionElement(
81
					Taxon.class, getConversationHolder(), 
82
					formElement, "Related Taxon", getRelatedTaxon(), 
83
					EntitySelectionElement.SELECTABLE, style);
84
			checkBoxDoubtful = formFactory.createCheckbox(formElement, "Relation is doubtful", entity.isDoubtful(), style);
85
		}else{
86
			taxon = entity.getFromTaxon();
87
			toggleable_cache = formFactory.createToggleableTextField(formElement,
88
					"Title Cache", taxon.getTitleCache(),
89
					taxon.isProtectedTitleCache(), style);
102 90
	
91
			text_appendedPhrase = formFactory.createTextWithLabelElement(
92
					formElement, "Appended Phrase", taxon.getAppendedPhrase(),
93
					SWT.WRAP);
103 94
	
104
		checkbox_published = formFactory.createCheckbox(formElement,
105
					"Published", taxon.isPublish(), style);
106
			
107
			
108
		secReference = formFactory.createSelectionElement(Reference.class,
109
				getConversationHolder(), formElement, "Misappl. Sec.",
110
				entity.getCitation(), EntitySelectionElement.ALL,
95
	
96
			sensuReference = formFactory.createSelectionElement(Reference.class,
97
				getConversationHolder(), formElement, "Sensu",
98
				taxon.getSec(), EntitySelectionElement.ALL,
111 99
				style);
112 100
	
113
		text_secundum_microreference = formFactory.createTextWithLabelElement(
114
	            formElement, "Detail",
115
	            entity.getCitationMicroReference(),null,
116
	            SWT.WRAP);
117
		checkbox_doubtful = formFactory.createCheckbox(formElement,
118
				"Misappl. Doubtful", entity.isDoubtful(), style);
119

  
101
			text_sensu_microreference = formFactory.createTextWithLabelElement(
102
					formElement, "Detail",
103
					taxon.getSecMicroReference(),null,
104
					SWT.WRAP);
105
	
106
			
107
		
108
		
109
			checkbox_published = formFactory.createCheckbox(formElement,
110
						"Published", taxon.isPublish(), style);
111
				
112
				
113
			secReference = formFactory.createSelectionElement(Reference.class,
114
					getConversationHolder(), formElement, "Misappl. Sec.",
115
					entity.getCitation(), EntitySelectionElement.ALL,
116
					style);
117
		
118
			text_secundum_microreference = formFactory.createTextWithLabelElement(
119
		            formElement, "Detail",
120
		            entity.getCitationMicroReference(),null,
121
		            SWT.WRAP);
122
			checkbox_doubtful = formFactory.createCheckbox(formElement,
123
					"Misappl. Doubtful", entity.isDoubtful(), style);
124
		}
120 125
		
121 126
	}
122 127
	
......
135 140

  
136 141
	@Override
137 142
	public void handleEvent(Object eventSource) {
138
		if (eventSource== toggleable_cache) {
139
		handleToggleableCacheField();
140
	} else if (eventSource == checkbox_doubtful) {
141
		taxon.setDoubtful(checkbox_doubtful.getSelection());
142
	}  else if (eventSource == secReference) {
143
		getEntity().setCitation(secReference.getSelection());
144
	} else if (eventSource == text_appendedPhrase) {
145
		taxon.setAppendedPhrase(text_appendedPhrase.getText());
146
	} else if (eventSource == text_secundum_microreference) {
147
		getEntity().setCitationMicroReference(text_secundum_microreference.getText());
148
	} else if (eventSource == checkbox_published) {
149
	    taxon.setPublish(checkbox_published.getSelection());
150
	} else if (eventSource == text_sensu_microreference) {
151
        taxon.setSecMicroReference(text_sensu_microreference.getText());
152
	}else if (eventSource == sensuReference) {
153
		taxon.setSec(sensuReference.getSelection());
154
	}
143
		if (getEntity().getType().equals(TaxonRelationshipType.MISAPPLIED_NAME_FOR())){
144
			if (eventSource== toggleable_cache) {
145
				handleToggleableCacheField();
146
			} else if (eventSource == checkbox_doubtful) {
147
				taxon.setDoubtful(checkbox_doubtful.getSelection());
148
			}  else if (eventSource == secReference) {
149
				getEntity().setCitation(secReference.getSelection());
150
			} else if (eventSource == text_appendedPhrase) {
151
				taxon.setAppendedPhrase(text_appendedPhrase.getText());
152
			} else if (eventSource == text_secundum_microreference) {
153
				getEntity().setCitationMicroReference(text_secundum_microreference.getText());
154
			} else if (eventSource == checkbox_published) {
155
			    taxon.setPublish(checkbox_published.getSelection());
156
			} else if (eventSource == text_sensu_microreference) {
157
		        taxon.setSecMicroReference(text_sensu_microreference.getText());
158
			}else if (eventSource == sensuReference) {
159
				taxon.setSec(sensuReference.getSelection());
160
			}
161
		}else{
162
			if (eventSource == selection_relatedTaxon){
163
				boolean inverse = getTaxonRelationshipTypeInverseContainer().isInverse();
164
				Taxon relatedTaxon = selection_relatedTaxon.getEntity();
165
				if(inverse){
166
					getEntity().setFromTaxon(relatedTaxon);
167
				}else{
168
					getEntity().setToTaxon(relatedTaxon);
169
				}
170
			}else if(eventSource==checkBoxDoubtful){
171
			    getEntity().setDoubtful(checkBoxDoubtful.getSelection());
172
			}
173
		}	
174
		firePropertyChangeEvent(new CdmPropertyChangeEvent(this, null));
155 175
	}
156 176
	
157 177
	protected void handleToggleableCacheField() {
......
163 183
    }
164 184
	
165 185
	 public void updateToggleableCacheField() {
186
		 if (getEntity().getType().equals(TaxonRelationshipType.MISAPPLIED_NAME_FOR())){
166 187
	        if (toggleable_cache != null){
167 188
	            if (!taxon.isProtectedTitleCache()) {
168 189
	                toggleable_cache.setText(taxon.generateTitle());
169 190
	            }
170 191
	        }
192
		 }
171 193
	    }
172 194
	 
173 195
	 @Override
174 196
		protected void updateContent() {
175
			super.updateContent();
197
		 super.updateContent();
198
		 if (getEntity().getType().equals(TaxonRelationshipType.MISAPPLIED_NAME_FOR())){
199
			
176 200
			toggleable_cache.setEnabled(taxon.isProtectedTitleCache());
177 201
			setIrrelevant(toggleable_cache.getState(),
178 202
					Arrays.asList(new Object[] { toggleable_cache, checkbox_published}));
203
		 }
179 204
		}
180 205
	 @Override
181 206
	    protected void updateControlStates() {
......
183 208
	       
184 209
	    }
185 210
	 @Override
186
		protected void handleTitleCacheRelevantChange(PropertyChangeEvent event) {
211
	 protected void handleTitleCacheRelevantChange(PropertyChangeEvent event) {
212
		 if (getEntity().getType().equals(TaxonRelationshipType.MISAPPLIED_NAME_FOR())){
187 213
			String title = taxon.generateTitle();
188 214
			taxon.setTitleCache(title);
189 215
			super.handleTitleCacheRelevantChange(event);
190
		}
216
		 }
217
	 }
191 218
	 
192 219
	@Override
193 220
	public void refresh(){
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/taxon/TaxonRelationshipDetailSection.java
35 35
	public TaxonRelationshipDetailSection(CdmFormFactory formFactory,
36 36
			ConversationHolder conversation, ICdmFormElement parentElement,
37 37
			ISelectionProvider selectionProvider, int style) {
38
		super(formFactory, conversation, parentElement, selectionProvider, style);
38
		super(formFactory, conversation, parentElement,  selectionProvider, style);
39 39
	}
40 40

  
41 41
	@Override
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/detail/DetailsViewer.java
46 46
import eu.etaxonomy.cdm.model.reference.Reference;
47 47
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
48 48
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
49
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
49 50
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
50 51
import eu.etaxonomy.taxeditor.model.AbstractUtility;
51 52
import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
......
66 67
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementMediaSection;
67 68
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementSourceSection;
68 69
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionSourceSection;
70
import eu.etaxonomy.taxeditor.ui.section.description.IntextReferenceSection;
69 71
import eu.etaxonomy.taxeditor.ui.section.description.MediaDetailsSection;
70 72
import eu.etaxonomy.taxeditor.ui.section.description.NaturalLanguageSection;
71 73
import eu.etaxonomy.taxeditor.ui.section.description.ScopeSection;
......
140 142

  
141 143
    @Override
142 144
    public void setInput(Object input) {
145
    	
143 146
        if(input instanceof TreeNode){
144 147
            input = ((TreeNode) input).getValue();
145 148
        }
......
187 190
        // Too much type checking to decide which detail view to display.
188 191
        // Need to build in a mechanism where navigators / editors are 'aware'
189 192
        // of the corresponding detail viewer.
193
    	
190 194
        Object input = getInput();
191 195

  
192 196
        destroySections();
......
307 311
            createUserSection(rootElement);
308 312
        } else if (input instanceof Group) {
309 313
            createGroupSection(rootElement);
310
        } else if (input instanceof TaxonRelationship) {
314
        } else if (input instanceof TaxonRelationship && ((TaxonRelationship)input).getType().equals(TaxonRelationshipType.MISAPPLIED_NAME_FOR())) {
315
            createMisappliedNameSection(rootElement);
316
        }else if (input instanceof TaxonRelationship ) {
311 317
            createTaxonRelationshipSection(rootElement);
312 318
        } else if (input instanceof TermVocabulary) {
313 319
            createTermVocabularySection(rootElement);
......
318 324
            createEmptySection(rootElement);
319 325
        }
320 326
        layout();
327
       
321 328
    }
322 329

  
323 330

  
......
350 357
    /** {@inheritDoc} */
351 358
    @Override
352 359
    public void setSelection(ISelection selection, boolean reveal) {
353
        this.selection = selection;
354
        if(this.selection!=null){
355
            SelectionChangedEvent selectionChangedEvent = new SelectionChangedEvent(this, selection);
356
            fireSelectionChanged(selectionChangedEvent);
357
        }
360
    	
361
    		this.selection = selection;
362
	      
363
	        if(this.selection!=null){
364
	            SelectionChangedEvent selectionChangedEvent = new SelectionChangedEvent(this, selection);
365
	            fireSelectionChanged(selectionChangedEvent);
366
	        }
367
    	
358 368
    }
359 369

  
360 370
    private void createTaxonSections(RootElement parent) {
......
485 495
        destroySections();
486 496

  
487 497
        DescriptionElementDetailSection descriptionElementDetailSection = formFactory.createDescriptionElementDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
488

  
498
        
499
      //  IntextReferenceSection intextReferenceSection = formFactory.createIntextReferenceSection(getConversationHolder(), parent,  ExpandableComposite.TWISTIE);
500
        
489 501
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
490 502

  
491 503
        DescriptionElementSourceSection descriptionElementSourceSection = formFactory.createDescriptionElementSourceSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
......
766 778
        addPart(groupByUserDetailSection);
767 779
    }
768 780

  
769
    private void createTaxonRelationshipSection(RootElement parent) {
781
    private void createMisappliedNameSection(RootElement parent) {
770 782
        destroySections();
771 783

  
772 784
        TaxonRelationshipDetailSection taxonRelationshipDetailSection = formFactory.createTaxonRelationshipDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
773 785

  
774 786
       // ReferencedEntityDetailSection referencedEntityBaseDetailSection = formFactory.createReferencedEntityDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
775 787
        addPart(taxonRelationshipDetailSection);
776
     //   addPart(referencedEntityBaseDetailSection);
788
        //addPart(referencedEntityBaseDetailSection);
789
       
777 790
        NonViralNameDetailSection nonViralNameSection = formFactory
778 791
                .createNonViralNameDetailSection(getConversationHolder(), parent, this, true,
779 792
                        ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
......
814 827
        //}
815 828
    }
816 829

  
830
    private void createTaxonRelationshipSection(RootElement parent) {
831
    	destroySections();
832

  
833
    	TaxonRelationshipDetailSection taxonRelationshipDetailSection = formFactory.createTaxonRelationshipDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
834

  
835
        ReferencedEntityDetailSection referencedEntityBaseDetailSection = formFactory.createReferencedEntityDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
836
        addPart(taxonRelationshipDetailSection);
837
        addPart(referencedEntityBaseDetailSection);
838
    }
817 839
    private void createTermVocabularySection(RootElement parent) {
818 840
        destroySections();
819 841

  

Also available in: Unified diff