Revision c2b6c2d3
fix details view for misapplied names and add choosable taxon for misapplied name relationsip
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/taxon/TaxonRelationshipDetailSection.java | ||
---|---|---|
9 | 9 |
package eu.etaxonomy.taxeditor.ui.section.taxon; |
10 | 10 |
|
11 | 11 |
import org.apache.commons.lang.StringUtils; |
12 |
import org.eclipse.jface.action.Action; |
|
13 |
import org.eclipse.jface.action.IAction; |
|
14 |
import org.eclipse.jface.action.ToolBarManager; |
|
12 | 15 |
import org.eclipse.jface.viewers.ISelectionProvider; |
16 |
import org.eclipse.swt.SWT; |
|
17 |
import org.eclipse.swt.widgets.Control; |
|
13 | 18 |
|
14 | 19 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
15 | 20 |
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper; |
... | ... | |
17 | 22 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
18 | 23 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
19 | 24 |
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship; |
25 |
import eu.etaxonomy.taxeditor.model.ImageResources; |
|
26 |
import eu.etaxonomy.taxeditor.ui.dialog.selection.NameSelectionDialog; |
|
27 |
import eu.etaxonomy.taxeditor.ui.dialog.selection.TaxonBaseSelectionDialog; |
|
20 | 28 |
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory; |
21 | 29 |
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement; |
22 | 30 |
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement; |
23 | 31 |
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection; |
24 | 32 |
import eu.etaxonomy.taxeditor.ui.section.ITaxonBaseDetailSection; |
33 |
import eu.etaxonomy.taxeditor.ui.section.name.NonViralNameDetailSection; |
|
25 | 34 |
|
26 | 35 |
/** |
27 | 36 |
* @author n.hoffmann |
... | ... | |
31 | 40 |
public class TaxonRelationshipDetailSection extends AbstractCdmDetailSection<TaxonRelationship> implements ITaxonBaseDetailSection { |
32 | 41 |
Taxon taxon; |
33 | 42 |
TaxonName name; |
43 |
boolean taxonChoosable = false; |
|
34 | 44 |
|
35 | 45 |
public TaxonRelationshipDetailSection(CdmFormFactory formFactory, |
36 | 46 |
ConversationHolder conversation, ICdmFormElement parentElement, |
37 |
ISelectionProvider selectionProvider, int style) { |
|
47 |
ISelectionProvider selectionProvider, int style, boolean taxonChoosable) {
|
|
38 | 48 |
super(formFactory, conversation, parentElement, selectionProvider, style); |
49 |
this.taxonChoosable = taxonChoosable; |
|
39 | 50 |
} |
40 | 51 |
|
41 | 52 |
@Override |
... | ... | |
68 | 79 |
private void setName(TaxonName name){ |
69 | 80 |
this.name = name; |
70 | 81 |
} |
82 |
|
|
83 |
@Override |
|
84 |
protected Control createToolbar() { |
|
85 |
ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT); |
|
86 |
|
|
87 |
if(taxonChoosable){ |
|
88 |
//choose name |
|
89 |
Action chooseTaxonAction = new Action("Choose Taxon", IAction.AS_PUSH_BUTTON){ |
|
90 |
@Override |
|
91 |
public void run() { |
|
92 |
Taxon taxon = TaxonBaseSelectionDialog.selectTaxon(getShell(), getConversationHolder(), getEntity().getFromTaxon()); |
|
93 |
if(taxon!=null){ |
|
94 |
taxon = HibernateProxyHelper.deproxy(taxon); |
|
95 |
name = taxon.getName(); |
|
96 |
TaxonRelationship rel = getEntity(); |
|
97 |
rel.setFromTaxon(taxon); |
|
98 |
setEntity(rel); |
|
99 |
// taxonBase.getTitleCache(); |
|
100 |
|
|
101 |
firePropertyChangeEvent(TaxonRelationshipDetailSection.this); |
|
102 |
} |
|
103 |
} |
|
104 |
}; |
|
105 |
chooseTaxonAction.setToolTipText("Choose taxon for this Relationship"); |
|
106 |
chooseTaxonAction.setImageDescriptor(ImageResources.getImageDescriptor(ImageResources.BROWSE_ICON)); |
|
107 |
|
|
108 |
toolBarManager.add(chooseTaxonAction); |
|
109 |
} |
|
110 |
return toolBarManager.createControl(this); |
|
111 |
} |
|
71 | 112 |
|
72 | 113 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/AbstractCdmEditorPartE4.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.taxeditor.view.e4; |
10 | 10 |
|
11 |
import java.util.Set; |
|
12 |
|
|
11 | 13 |
import javax.annotation.PreDestroy; |
12 | 14 |
|
13 | 15 |
import org.eclipse.e4.ui.di.PersistState; |
... | ... | |
19 | 21 |
|
20 | 22 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
21 | 23 |
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled; |
24 |
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper; |
|
22 | 25 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
26 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
|
27 |
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship; |
|
28 |
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType; |
|
23 | 29 |
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap; |
30 |
import eu.etaxonomy.taxeditor.editor.ITaxonEditor; |
|
31 |
|
|
24 | 32 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
25 | 33 |
import eu.etaxonomy.taxeditor.model.IDirtyMarkable; |
26 | 34 |
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled; |
... | ... | |
60 | 68 |
if(viewer!=null){ |
61 | 69 |
Object element = selection.getFirstElement(); |
62 | 70 |
if(selection.getFirstElement()!=null){ |
63 |
viewer.setInput(element); |
|
71 |
if (element instanceof Taxon){ |
|
72 |
Taxon taxon = HibernateProxyHelper.deproxy(element, Taxon.class); |
|
73 |
if (taxon.isMisapplication()){ |
|
74 |
Object part = createPartObject(activePart); |
|
75 |
if(part instanceof ITaxonEditor){ |
|
76 |
Taxon accepted = ((ITaxonEditor) part).getTaxon(); |
|
77 |
|
|
78 |
// Taxon accepted= ((ITaxonEditor)activePart).getTaxon(); |
|
79 |
Set<TaxonRelationship> rels = taxon.getTaxonRelations(accepted); |
|
80 |
|
|
81 |
if (rels.iterator().hasNext()){ |
|
82 |
TaxonRelationship rel = rels.iterator().next(); |
|
83 |
if (rel.getType().equals(TaxonRelationshipType.MISAPPLIED_NAME_FOR())){ |
|
84 |
viewer.setInput(rel); |
|
85 |
|
|
86 |
return; |
|
87 |
} |
|
88 |
} |
|
89 |
} |
|
90 |
|
|
91 |
|
|
92 |
} |
|
93 |
} |
|
94 |
viewer.setInput(element); |
|
95 |
|
|
96 |
|
|
64 | 97 |
} |
65 | 98 |
selectionProvidingPart = activePart; |
66 | 99 |
} |
Also available in: Unified diff