Revision 0122459a
Added by Katja Luther over 2 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/handler/defaultHandler/e4/DefaultOpenTaxonNodeWizardHandlerE4.java | ||
---|---|---|
66 | 66 |
WizardDialog dialog = new WizardDialog(shell, taxonNodeWizard); |
67 | 67 |
dialog.open(); |
68 | 68 |
EventUtility.postEvent(WorkbenchEventConstants.REFRESH_NAVIGATOR, entity); |
69 |
EventUtility.postEvent(WorkbenchEventConstants.REFRESH_NAME_EDITOR, entity.getTaxonUuid()); |
|
69 | 70 |
|
70 | 71 |
} |
71 | 72 |
|
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/CdmFormFactory.java | ||
---|---|---|
320 | 320 |
import eu.etaxonomy.taxeditor.ui.section.reference.NomenclaturalReferenceDetailElement; |
321 | 321 |
import eu.etaxonomy.taxeditor.ui.section.reference.NomenclaturalReferenceDetailSection; |
322 | 322 |
import eu.etaxonomy.taxeditor.ui.section.reference.OriginalSourceAdvancedSection; |
323 |
import eu.etaxonomy.taxeditor.ui.section.reference.OriginalSourceElement; |
|
323 | 324 |
import eu.etaxonomy.taxeditor.ui.section.reference.ReferenceDetailElement; |
324 | 325 |
import eu.etaxonomy.taxeditor.ui.section.reference.ReferenceDetailSection; |
325 | 326 |
import eu.etaxonomy.taxeditor.ui.section.reference.SingleSourceSection; |
... | ... | |
1854 | 1855 |
return section; |
1855 | 1856 |
} |
1856 | 1857 |
|
1857 |
public SingleSourceSection createSingleSourceSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){ |
|
1858 |
SingleSourceSection section = new SingleSourceSection(this, conversation, parentElement, selectionProvider, style); |
|
1858 |
public SingleSourceSection createSingleSourceSection(ConversationHolder conversation, ICdmFormElement parentElement, CdmBase cdmEntity, ISelectionProvider selectionProvider, int style){
|
|
1859 |
SingleSourceSection section = new SingleSourceSection(this, conversation, parentElement, cdmEntity, selectionProvider, style);
|
|
1859 | 1860 |
addAndAdaptSection(parentElement, section); |
1860 | 1861 |
return section; |
1861 | 1862 |
} |
... | ... | |
2204 | 2205 |
addAndAdaptElement(parentElement, element); |
2205 | 2206 |
return element; |
2206 | 2207 |
} |
2208 |
public OriginalSourceElement createOriginalSourceElement(ICdmFormElement parentElement, CdmBase cdmEntity){ |
|
2209 |
OriginalSourceElement element = new OriginalSourceElement(this, parentElement, cdmEntity); |
|
2210 |
addAndAdaptElement(parentElement, element); |
|
2211 |
return element; |
|
2212 |
} |
|
2207 | 2213 |
|
2208 | 2214 |
public TaxonRelationshipDetailElement createTaxonRelationshipDetailElement(ICdmFormElement parentElement){ |
2209 | 2215 |
TaxonRelationshipDetailElement element = new TaxonRelationshipDetailElement(this, parentElement); |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/classification/TaxonNodeDetailElement.java | ||
---|---|---|
9 | 9 |
|
10 | 10 |
package eu.etaxonomy.taxeditor.ui.section.classification; |
11 | 11 |
|
12 |
|
|
12 | 13 |
import java.util.ArrayList; |
13 | 14 |
import java.util.Collection; |
14 | 15 |
import java.util.HashMap; |
15 | 16 |
import java.util.Map; |
16 | 17 |
|
17 | 18 |
import org.apache.commons.lang.StringUtils; |
19 |
import org.eclipse.jface.resource.JFaceResources; |
|
18 | 20 |
import org.eclipse.swt.SWT; |
21 |
import org.eclipse.swt.graphics.Font; |
|
19 | 22 |
import org.eclipse.swt.widgets.Control; |
23 |
import org.eclipse.swt.widgets.Label; |
|
20 | 24 |
import org.eclipse.swt.widgets.Text; |
25 |
import org.eclipse.ui.forms.widgets.TableWrapData; |
|
21 | 26 |
|
22 | 27 |
import eu.etaxonomy.cdm.common.CdmUtils; |
23 | 28 |
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper; |
24 | 29 |
import eu.etaxonomy.cdm.model.common.Language; |
25 | 30 |
import eu.etaxonomy.cdm.model.common.LanguageString; |
31 |
import eu.etaxonomy.cdm.model.description.DescriptionElementSource; |
|
26 | 32 |
import eu.etaxonomy.cdm.model.metadata.CdmPreference; |
27 | 33 |
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate; |
28 | 34 |
import eu.etaxonomy.cdm.model.metadata.PublishEnum; |
... | ... | |
46 | 52 |
import eu.etaxonomy.taxeditor.ui.element.MultilanguageTextElement; |
47 | 53 |
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement; |
48 | 54 |
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement; |
55 |
import eu.etaxonomy.taxeditor.ui.section.reference.OriginalSourceElement; |
|
49 | 56 |
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement; |
50 | 57 |
import eu.etaxonomy.taxeditor.ui.selection.TaxonNodeSelectionElement; |
51 | 58 |
|
... | ... | |
61 | 68 |
private static final String REUSE_EXISTING_NAME = Messages.TaxonNodeWizardPage_REUSE_EXISTING_NAME; |
62 | 69 |
private static final String SECUNDUM_REFERENCE = Messages.TaxonNodeWizardPage_SECUNDUM_REFERENCE; |
63 | 70 |
|
71 |
private static final Font FONT_BOLD = JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT); |
|
72 |
|
|
64 | 73 |
private boolean createNew = false; |
65 | 74 |
private Classification classification; |
66 | 75 |
private TaxonNode parentNode; |
... | ... | |
73 | 82 |
private EntitySelectionElement<Taxon> selection_reuseExistingTaxon; |
74 | 83 |
private EntitySelectionElement<TaxonName> selection_reuseExistingName; |
75 | 84 |
private EntitySelectionElement<Reference> selection_SecRef; |
76 |
private EntitySelectionElement<Reference> selection_Ref; |
|
85 |
|
|
86 |
private OriginalSourceElement sourceSection; |
|
87 |
|
|
77 | 88 |
private TextWithLabelElement textTaxonSec; |
78 | 89 |
private TextWithLabelElement microReference; |
79 | 90 |
private TextWithLabelElement textNewTaxonName; |
... | ... | |
97 | 108 |
} |
98 | 109 |
|
99 | 110 |
public Reference getRef() { |
100 |
return selection_Ref.getEntity();
|
|
111 |
return sourceSection.getEntity().getCitation();
|
|
101 | 112 |
} |
102 | 113 |
public TaxonName getExistingName() { |
103 | 114 |
return selection_reuseExistingName.getEntity(); |
... | ... | |
110 | 121 |
protected void createControls(ICdmFormElement formElement, |
111 | 122 |
TaxonNode entity, int style) { |
112 | 123 |
// taxon = entity.getTaxon(); |
124 |
Label taxonTitle = new Label(getLayoutComposite(), SWT.NULL); |
|
125 |
taxonTitle.setText("Taxon Information"); |
|
126 |
TableWrapData tableWrap = LayoutConstants.FILL_HORIZONTALLY(2, 2); |
|
127 |
tableWrap.valign = SWT.TOP; |
|
128 |
taxonTitle.setLayoutData(tableWrap); |
|
129 |
taxonTitle.setFont(FONT_BOLD); |
|
113 | 130 |
|
114 | 131 |
if (isCreateNew()){ |
115 |
// setParentTreeNode(entity); |
|
116 |
selection_parentTaxonNode = formFactory |
|
117 |
.createTaxonNodeSelectionElement(getConversationHolder(), formElement, Messages.TaxonNodeWizardPage_PARENT, parentNode, |
|
118 |
EntitySelectionElement.DELETABLE, style, 100); |
|
119 |
|
|
120 |
selection_Ref = formFactory |
|
121 |
.createSelectionElement(Reference.class, |
|
122 |
formElement, Messages.TaxonNodeWizardPage_PLACEMENT_SOURCE, null, |
|
123 |
EntitySelectionElement.DELETABLE, style, 100); |
|
132 |
textNewTaxonName = formFactory.createTextWithLabelElement(formElement, |
|
133 |
Messages.TaxonNodeWizardPage_NEW_TAXON, "", style); |
|
134 |
textNewTaxonName.setFocus(); |
|
124 | 135 |
|
125 |
microReference = formFactory.createTextWithLabelElement(formElement, |
|
126 |
Messages.TaxonNodeWizardPage_PLACEMENT_SOURCE_DETAIL, "", style); |
|
127 |
microReference.setText(parentNode.getMicroReference()); |
|
128 |
|
|
129 |
selection_reuseExistingTaxon = formFactory |
|
130 |
.createSelectionElement(Taxon.class,//getConversationHolder(), |
|
131 |
formElement, |
|
132 |
REUSE_EXISTING_TAXON, null, |
|
133 |
EntitySelectionElement.DELETABLE, style); |
|
134 |
|
|
135 |
selection_reuseExistingName = formFactory |
|
136 |
.createSelectionElement(TaxonName.class,//getConversationHolder(), |
|
137 |
formElement, |
|
138 |
REUSE_EXISTING_NAME, taxon != null? taxon.getName(): null, |
|
139 |
EntitySelectionElement.DELETABLE, style); |
|
140 |
selection_SecRef = formFactory |
|
136 |
selection_reuseExistingTaxon = formFactory |
|
137 |
.createSelectionElement(Taxon.class,//getConversationHolder(), |
|
138 |
formElement, |
|
139 |
REUSE_EXISTING_TAXON, null, |
|
140 |
EntitySelectionElement.DELETABLE, style); |
|
141 |
|
|
142 |
selection_reuseExistingName = formFactory |
|
143 |
.createSelectionElement(TaxonName.class,//getConversationHolder(), |
|
144 |
formElement, |
|
145 |
REUSE_EXISTING_NAME, taxon != null? taxon.getName(): null, |
|
146 |
EntitySelectionElement.DELETABLE, style); |
|
147 |
selection_SecRef = formFactory |
|
141 | 148 |
.createSelectionElement(Reference.class,//getConversationHolder(), |
142 | 149 |
formElement, SECUNDUM_REFERENCE, taxon != null? taxon.getSec(): null, |
143 | 150 |
EntitySelectionElement.DELETABLE, style, 100); |
144 | 151 |
|
145 |
if (isCreateNew()){ |
|
146 |
textNewTaxonName = formFactory.createTextWithLabelElement(formElement, |
|
147 |
Messages.TaxonNodeWizardPage_NEW_TAXON, "", style); |
|
148 |
textNewTaxonName.setFocus(); |
|
149 |
} else{ |
|
150 |
textNewTaxonName = formFactory.createTextWithLabelElement(formElement, |
|
151 |
Messages.TaxonNodeWizardPage_TAXON, "", style); |
|
152 |
} |
|
153 |
}else{ |
|
154 |
taxon = getEntity().getTaxon(); |
|
155 |
if (entity.getParent().getTaxon() == null){ |
|
156 |
TextWithLabelElement textParent = formFactory.createTextWithLabelElement( |
|
157 |
formElement,CLASSIFICATION_STR, entity.getClassification().getTitleCache(), style); |
|
158 |
textParent.setEnabled(false); |
|
159 |
}else{ |
|
160 |
TextWithLabelElement textParent = formFactory.createTextWithLabelElement( |
|
161 |
formElement, Messages.TaxonNodeWizardPage_PARENT, entity.getParent().getTaxon().getTitleCache(), style); |
|
162 |
textParent.setEnabled(false); |
|
163 |
} |
|
152 |
checkbox_publish = formFactory.createCheckbox(formElement, |
|
153 |
"Taxon is published", true, style); |
|
154 |
|
|
155 |
checkbox_publish.setEnabled(isCreateNew()); |
|
156 |
Label seperator = new Label(getLayoutComposite(), SWT.HORIZONTAL | SWT.SEPARATOR); |
|
157 |
seperator.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 3)); |
|
158 |
Label nodeTitle = new Label(getLayoutComposite(), SWT.NULL); |
|
159 |
nodeTitle.setText("Taxon Node"); |
|
160 |
nodeTitle.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1)); |
|
161 |
nodeTitle.setFont(FONT_BOLD); |
|
164 | 162 |
|
165 |
selection_Ref = formFactory |
|
166 |
.createSelectionElement(Reference.class, |
|
167 |
formElement, Messages.TaxonNodeWizardPage_PLACEMENT_SOURCE, null, |
|
168 |
EntitySelectionElement.DELETABLE, style); |
|
169 | 163 |
|
164 |
// microReference = formFactory.createTextWithLabelElement(formElement, |
|
165 |
// Messages.TaxonNodeWizardPage_PLACEMENT_SOURCE_DETAIL, "", style); |
|
166 |
// microReference.setText(parentNode.getMicroReference()); |
|
167 |
selection_parentTaxonNode = formFactory |
|
168 |
.createTaxonNodeSelectionElement(getConversationHolder(), formElement, Messages.TaxonNodeWizardPage_PARENT, parentNode, |
|
169 |
EntitySelectionElement.DELETABLE, style, 100); |
|
170 |
|
|
171 |
|
|
172 |
|
|
173 |
}else{ |
|
174 |
taxon = getEntity().getTaxon(); |
|
170 | 175 |
selection_reuseExistingTaxon = formFactory |
171 | 176 |
.createSelectionElement(Taxon.class,//getConversationHolder(), |
172 | 177 |
formElement, |
... | ... | |
174 | 179 |
EntitySelectionElement.DELETABLE, style); |
175 | 180 |
|
176 | 181 |
textTaxonSec = formFactory.createTextWithLabelElement(formElement,SECUNDUM_REFERENCE, "", style); |
182 |
|
|
177 | 183 |
if (entity.getTaxon().getSec() != null){ |
178 | 184 |
textTaxonSec.setText(taxon.getSec().getTitleCache()); |
179 | 185 |
} |
180 | 186 |
textTaxonSec.setEnabled(false); |
181 |
} |
|
182 | 187 |
|
183 |
if (!isCreateNew()){ |
|
184 |
if (entity.getReference() != null){ |
|
185 |
selection_Ref.setEntity(entity.getReference()); |
|
186 |
} |
|
187 |
} |
|
188 |
Label nodeTitle = new Label(getLayoutComposite(), SWT.NULL); |
|
189 |
nodeTitle.setText("Taxon Node"); |
|
190 |
nodeTitle.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1)); |
|
191 |
nodeTitle.setFont(FONT_BOLD); |
|
188 | 192 |
|
189 |
Taxon tax = null; |
|
190 |
if (entity.getTaxon() != null){ |
|
191 |
tax = entity.getTaxon(); |
|
192 |
} |
|
193 |
checkbox_publish = formFactory.createCheckbox(formElement, |
|
194 |
"Taxon is published", tax != null? tax.isPublish(): true, style); |
|
193 |
if (entity.getParent().getTaxon() == null){ |
|
194 |
TextWithLabelElement textParent = formFactory.createTextWithLabelElement( |
|
195 |
formElement,CLASSIFICATION_STR, entity.getClassification().getTitleCache(), style); |
|
196 |
textParent.setEnabled(false); |
|
197 |
}else{ |
|
198 |
TextWithLabelElement textParent = formFactory.createTextWithLabelElement( |
|
199 |
formElement, Messages.TaxonNodeWizardPage_PARENT, entity.getParent().getTaxon().getTitleCache(), style); |
|
200 |
textParent.setEnabled(false); |
|
201 |
} |
|
202 |
// sourceSection = formFactory.createOriginalSourceElement(formElement, entity); |
|
195 | 203 |
|
196 |
checkbox_publish.setEnabled(isCreateNew()); |
|
197 | 204 |
|
205 |
} |
|
206 |
Label spacer = new Label(getLayoutComposite(), SWT.NULL); |
|
207 |
spacer.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1)); |
|
198 | 208 |
combo_status = formFactory.createEnumComboElement(TaxonNodeStatus.class, formElement, style, true); |
199 | 209 |
if (!isCreateNew()){ |
200 | 210 |
combo_status.setSelection(entity.getStatus()); |
... | ... | |
231 | 241 |
|
232 | 242 |
if (!isCreateNew()){ |
233 | 243 |
selectionNodeAgentRelation = formFactory.createTaxonNodeAgentRelationCollectionSection(formElement, getConversationHolder(), StoreUtil.getSectionStyle(TaxonNodeAgentRelationCollectionSection.class, entity.getClass().getCanonicalName())); |
234 |
selectionNodeAgentRelation.setEntity(entity); |
|
244 |
|
|
235 | 245 |
selectionNodeAgentRelation.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1)); |
246 |
selectionNodeAgentRelation.setEntity(entity); |
|
247 |
} |
|
248 |
|
|
249 |
sourceSection = formFactory.createOriginalSourceElement(formElement, entity); |
|
250 |
if (isCreateNew()){ |
|
251 |
sourceSection.setEntity(null); |
|
252 |
}else{ |
|
253 |
sourceSection.setEntity(entity.getSource()); |
|
236 | 254 |
} |
255 |
|
|
256 |
|
|
237 | 257 |
} |
238 | 258 |
|
239 | 259 |
private void preFillTaxonName() { |
... | ... | |
304 | 324 |
complete = !textNewTaxonName.getText().isEmpty(); |
305 | 325 |
} |
306 | 326 |
|
307 |
if (eventSource == selection_Ref) {
|
|
327 |
if (eventSource == sourceSection) {
|
|
308 | 328 |
if(!isCreateNew()){ |
309 |
getEntity().setReference(selection_Ref.getEntity());
|
|
329 |
getEntity().setSource((DescriptionElementSource)sourceSection.getEntity());
|
|
310 | 330 |
} |
311 | 331 |
}else if (eventSource == selection_SecRef) { |
312 | 332 |
if (taxon != null){ |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/reference/AdvancedSourceElement.java | ||
---|---|---|
12 | 12 |
import org.eclipse.swt.graphics.Color; |
13 | 13 |
import org.eclipse.swt.widgets.Display; |
14 | 14 |
|
15 |
import eu.etaxonomy.cdm.model.media.ExternalLink; |
|
15 |
import eu.etaxonomy.cdm.model.common.ReferencedEntityBase; |
|
16 |
import eu.etaxonomy.cdm.model.description.DescriptionElementSource; |
|
16 | 17 |
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate; |
17 | 18 |
import eu.etaxonomy.cdm.model.reference.OriginalSourceBase; |
18 | 19 |
import eu.etaxonomy.taxeditor.preference.PreferencesUtil; |
... | ... | |
28 | 29 |
* @author k.luther |
29 | 30 |
* @since Jul 2, 2020 |
30 | 31 |
*/ |
31 |
public class AdvancedSourceElement extends AbstractCdmDetailElement<OriginalSourceBase> {
|
|
32 |
public class AdvancedSourceElement extends AbstractCdmDetailElement<ReferencedEntityBase > {
|
|
32 | 33 |
|
33 | 34 |
protected TextWithLabelElement text_idInSource; |
34 | 35 |
protected TextWithLabelElement text_idNamespace; |
... | ... | |
45 | 46 |
|
46 | 47 |
|
47 | 48 |
@Override |
48 |
protected void createControls(ICdmFormElement formElement, OriginalSourceBase entity, int style) {
|
|
49 |
protected void createControls(ICdmFormElement formElement, ReferencedEntityBase entity, int style) {
|
|
49 | 50 |
Display display = Display.getCurrent(); |
50 | 51 |
Color background = display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND); |
51 | 52 |
|
52 | 53 |
if (PreferencesUtil.getBooleanValue(PreferencePredicate.ShowIdInSource.getKey())){ |
53 |
text_idInSource = formFactory.createTextWithLabelElement(formElement, "ID in Source", entity != null?entity.getIdInSource():null, style); |
|
54 |
|
|
55 |
text_idInSource = formFactory.createTextWithLabelElement(formElement, "ID in Source", entity != null?((OriginalSourceBase)entity).getIdInSource():null, style); |
|
54 | 56 |
text_idInSource.setBackground(background); |
55 | 57 |
} |
56 | 58 |
if (PreferencesUtil.getBooleanValue(PreferencePredicate.ShowNamespaceInSource.getKey())){ |
57 |
text_idNamespace = formFactory.createTextWithLabelElement(formElement, "ID Namespace", entity != null?entity.getIdNamespace():null, style);
|
|
59 |
text_idNamespace = formFactory.createTextWithLabelElement(formElement, "ID Namespace", entity != null?((OriginalSourceBase)entity).getIdNamespace():null, style);
|
|
58 | 60 |
text_idNamespace.setBackground(background); |
59 | 61 |
} |
60 | 62 |
text_originaleNameString = formFactory.createTextWithLabelElement( |
... | ... | |
63 | 65 |
text_originaleNameString.setBackground(background); |
64 | 66 |
// text_cdmsource = formFactory.createTextWithLabelElement( |
65 | 67 |
// formElement, "CDM Source", entity != null?entity.getCdmSource():null, SWT.NULL); |
66 |
externalLinks = formFactory.createExternalLinksSection(getConversationHolder(), formElement, StoreUtil.getSectionStyle(ExternalLinksSection.class, ExternalLink.class.getCanonicalName()));
|
|
67 |
externalLinks.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
|
68 |
externalLinks.setEntity(entity);
|
|
68 |
externalLinks = formFactory.createExternalLinksSection(getConversationHolder(), formElement, StoreUtil.getSectionStyle(ExternalLinksSection.class, DescriptionElementSource.class.getCanonicalName()));
|
|
69 |
externalLinks.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 3));
|
|
70 |
externalLinks.setEntity( ((OriginalSourceBase)entity));
|
|
69 | 71 |
addControl(externalLinks); |
70 | 72 |
addElement(externalLinks); |
71 | 73 |
|
72 | 74 |
|
73 | 75 |
} |
74 | 76 |
|
77 |
@Override |
|
78 |
public void setEntity(ReferencedEntityBase entity) { |
|
79 |
super.setEntity(entity); |
|
80 |
externalLinks.setEntity((OriginalSourceBase)entity); |
|
81 |
} |
|
82 |
|
|
75 | 83 |
@Override |
76 | 84 |
public void handleEvent(Object eventSource) { |
77 | 85 |
if (eventSource.equals(text_idInSource)){ |
78 |
getEntity().setIdInSource(text_idInSource.getText());
|
|
86 |
((OriginalSourceBase)getEntity()).setIdInSource(text_idInSource.getText());
|
|
79 | 87 |
}else if (eventSource.equals(text_idNamespace)){ |
80 |
getEntity().setIdNamespace(text_idNamespace.getText());
|
|
88 |
((OriginalSourceBase)getEntity()).setIdNamespace(text_idNamespace.getText());
|
|
81 | 89 |
}else if (eventSource.equals(text_originaleNameString)){ |
82 |
getEntity().setOriginalNameString(text_originaleNameString.getText());
|
|
90 |
((OriginalSourceBase)getEntity()).setOriginalNameString(text_originaleNameString.getText());
|
|
83 | 91 |
} |
84 | 92 |
|
85 | 93 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/reference/OriginalSourceElement.java | ||
---|---|---|
10 | 10 |
|
11 | 11 |
import org.eclipse.jface.util.IPropertyChangeListener; |
12 | 12 |
|
13 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
|
14 |
import eu.etaxonomy.cdm.model.common.ReferencedEntityBase; |
|
15 |
import eu.etaxonomy.cdm.model.description.DescriptionElementSource; |
|
13 | 16 |
import eu.etaxonomy.cdm.model.reference.INomenclaturalReference; |
14 |
import eu.etaxonomy.cdm.model.reference.OriginalSourceBase; |
|
15 | 17 |
import eu.etaxonomy.cdm.model.reference.Reference; |
18 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode; |
|
16 | 19 |
import eu.etaxonomy.taxeditor.l10n.Messages; |
17 | 20 |
import eu.etaxonomy.taxeditor.store.StoreUtil; |
18 | 21 |
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory; |
... | ... | |
25 | 28 |
* @author k.luther |
26 | 29 |
* @since Jul 1, 2020 |
27 | 30 |
*/ |
28 |
public class OriginalSourceElement extends AbstractCdmDetailElement<OriginalSourceBase> implements IPropertyChangeListener{
|
|
31 |
public class OriginalSourceElement extends AbstractCdmDetailElement<ReferencedEntityBase> implements IPropertyChangeListener{
|
|
29 | 32 |
|
30 | 33 |
// protected EnumComboElement<OriginalSourceType> combo_origsourcetype; |
31 | 34 |
|
32 | 35 |
private EntitySelectionElement<Reference> selection_Ref; |
33 | 36 |
private OriginalSourceAdvancedSection advancedSection; |
34 | 37 |
|
38 |
private CdmBase cdmEntity; |
|
39 |
|
|
35 | 40 |
|
36 | 41 |
// protected EntitySelectionElement<Reference> selection_reference; |
37 | 42 |
// protected TextWithLabelElement text_referenceDetail; |
38 | 43 |
|
39 | 44 |
|
40 |
public OriginalSourceElement(CdmFormFactory formFactory, ICdmFormElement formElement) { |
|
45 |
public OriginalSourceElement(CdmFormFactory formFactory, ICdmFormElement formElement, CdmBase cdmEntity) {
|
|
41 | 46 |
super(formFactory, formElement); |
47 |
this.cdmEntity = cdmEntity; |
|
42 | 48 |
// selectionArbitrator = formFactory.createSelectionArbitrator(this); |
43 | 49 |
} |
44 | 50 |
|
45 | 51 |
@Override |
46 |
protected void createControls(ICdmFormElement formElement, OriginalSourceBase entity, int style) {
|
|
52 |
protected void createControls(ICdmFormElement formElement, ReferencedEntityBase entity, int style) {
|
|
47 | 53 |
|
48 | 54 |
selection_Ref = formFactory.createSelectionElement(Reference.class, |
49 | 55 |
formElement, Messages.TaxonNodeWizardPage_PLACEMENT_SOURCE, null, |
... | ... | |
69 | 75 |
@Override |
70 | 76 |
public void handleEvent(Object eventSource) { |
71 | 77 |
if (eventSource.equals(selection_Ref)){ |
78 |
|
|
79 |
if (getEntity() == null){ |
|
80 |
Reference ref = selection_Ref.getEntity(); |
|
81 |
DescriptionElementSource source = DescriptionElementSource.NewPrimarySourceInstance(null, null); |
|
82 |
setEntity(source); |
|
83 |
selection_Ref.setEntity(ref); |
|
84 |
if (cdmEntity != null && cdmEntity instanceof TaxonNode){ |
|
85 |
((TaxonNode)cdmEntity).setSource(source); |
|
86 |
} |
|
87 |
} |
|
88 |
//TODO: why is this null????ß |
|
72 | 89 |
getEntity().setCitation(selection_Ref.getEntity()); |
90 |
|
|
73 | 91 |
} |
74 | 92 |
|
75 | 93 |
} |
76 | 94 |
|
95 |
/** |
|
96 |
* @param cdmEntity2 |
|
97 |
*/ |
|
98 |
public void setCdmEntity(CdmBase cdmEntity) { |
|
99 |
this.cdmEntity = cdmEntity; |
|
100 |
|
|
101 |
} |
|
102 |
|
|
77 | 103 |
|
78 | 104 |
|
79 | 105 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/reference/SingleSourceSection.java | ||
---|---|---|
11 | 11 |
import org.eclipse.jface.viewers.ISelectionProvider; |
12 | 12 |
|
13 | 13 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
14 |
import eu.etaxonomy.cdm.model.reference.OriginalSourceBase; |
|
14 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
|
15 |
import eu.etaxonomy.cdm.model.common.ReferencedEntityBase; |
|
15 | 16 |
import eu.etaxonomy.cdm.model.reference.Reference; |
16 | 17 |
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory; |
17 | 18 |
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement; |
... | ... | |
22 | 23 |
* @author k.luther |
23 | 24 |
* @since Jul 2, 2020 |
24 | 25 |
*/ |
25 |
public class SingleSourceSection extends AbstractCdmDetailSection<OriginalSourceBase> { |
|
26 |
public class SingleSourceSection extends AbstractCdmDetailSection<ReferencedEntityBase> { |
|
27 |
|
|
28 |
CdmBase cdmEntity; |
|
26 | 29 |
/** |
27 | 30 |
* @param formFactory |
28 | 31 |
* @param conversation |
... | ... | |
31 | 34 |
* @param style |
32 | 35 |
*/ |
33 | 36 |
public SingleSourceSection(CdmFormFactory formFactory, ConversationHolder conversation, |
34 |
ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) { |
|
37 |
ICdmFormElement parentElement, CdmBase cdmEntity, ISelectionProvider selectionProvider, int style) {
|
|
35 | 38 |
super(formFactory, conversation, parentElement, selectionProvider, style); |
36 |
|
|
39 |
this.cdmEntity = cdmEntity; |
|
40 |
((OriginalSourceElement)this.detailElement).setCdmEntity(cdmEntity); |
|
37 | 41 |
|
38 | 42 |
} |
39 | 43 |
|
40 | 44 |
@Override |
41 |
protected AbstractCdmDetailElement<OriginalSourceBase> createCdmDetailElement(
|
|
42 |
AbstractCdmDetailSection<OriginalSourceBase> parentElement, int style) {
|
|
45 |
protected AbstractCdmDetailElement<ReferencedEntityBase> createCdmDetailElement(
|
|
46 |
AbstractCdmDetailSection<ReferencedEntityBase> parentElement, int style) {
|
|
43 | 47 |
|
44 |
return new OriginalSourceElement(getFormFactory(), parentElement); |
|
48 |
return new OriginalSourceElement(getFormFactory(), parentElement, cdmEntity);
|
|
45 | 49 |
} |
46 | 50 |
|
47 | 51 |
@Override |
... | ... | |
51 | 55 |
} |
52 | 56 |
|
53 | 57 |
public Reference getRef() { |
54 |
return ((OriginalSourceElement)detailElement).getEntity().getCitation();
|
|
58 |
return detailElement.getEntity().getCitation();
|
|
55 | 59 |
} |
56 | 60 |
} |
Also available in: Unified diff
ref #9116: add single source element to taxon node details and restructure the wizard