Revision 50e9235a
Added by Niels Hoffmann over 12 years ago
.gitattributes | ||
---|---|---|
913 | 913 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/NomenclaturalCodeHelper.java -text |
914 | 914 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/PolytomousKeyRelationship.java -text |
915 | 915 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/TaxeditorPartService.java -text |
916 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/TaxonRelationshipTypeInverseContainer.java -text |
|
916 | 917 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/TaxonTransfer.java -text |
917 | 918 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/TextHelper.java -text |
918 | 919 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/TimeHelper.java -text |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/ConceptLabelProvider.java | ||
---|---|---|
70 | 70 |
TaxonRelationshipType type = relationship.getType(); |
71 | 71 |
Representation representation = inverse ? type.getInverseRepresentation(Language.ENGLISH()) : type.getRepresentation(Language.ENGLISH()); |
72 | 72 |
|
73 |
Taxon relatedTaxon = inverse ? relationship.getToTaxon() : relationship.getFromTaxon();
|
|
73 |
Taxon relatedTaxon = inverse ? relationship.getFromTaxon() : relationship.getToTaxon();
|
|
74 | 74 |
|
75 | 75 |
String symbol = representation.getAbbreviatedLabel(); |
76 | 76 |
|
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/handler/AbstractDynamicConceptRelationMenu.java | ||
---|---|---|
3 | 3 |
*/ |
4 | 4 |
package eu.etaxonomy.taxeditor.editor.view.concept.handler; |
5 | 5 |
|
6 |
import java.util.ArrayList; |
|
6 | 7 |
import java.util.Arrays; |
7 | 8 |
import java.util.List; |
8 | 9 |
|
... | ... | |
14 | 15 |
import org.eclipse.swt.widgets.MenuItem; |
15 | 16 |
import org.eclipse.ui.handlers.IHandlerService; |
16 | 17 |
|
18 |
import eu.etaxonomy.cdm.model.common.Language; |
|
17 | 19 |
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType; |
18 | 20 |
import eu.etaxonomy.taxeditor.editor.EditorUtil; |
19 | 21 |
import eu.etaxonomy.taxeditor.editor.internal.TaxeditorEditorPlugin; |
22 |
import eu.etaxonomy.taxeditor.model.TaxonRelationshipTypeInverseContainer; |
|
20 | 23 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
21 | 24 |
|
22 | 25 |
/** |
... | ... | |
42 | 45 |
@Override |
43 | 46 |
public void fill(Menu menu, int index){ |
44 | 47 |
final IHandlerService handlerService = (IHandlerService) TaxeditorEditorPlugin.getDefault().getWorkbench().getService(IHandlerService.class); |
45 |
|
|
46 |
List<TaxonRelationshipType> relationshipTypes = CdmStore.getTermManager().getPreferredTaxonRelationshipTypes(); |
|
47 |
|
|
48 |
relationshipTypes.removeAll(excludeRelationshipTypes); |
|
49 | 48 |
|
50 |
for(final TaxonRelationshipType type : relationshipTypes){
|
|
49 |
for(final TaxonRelationshipTypeInverseContainer container : getRelationshipTypesWithInverses()){
|
|
51 | 50 |
MenuItem menuItem = new MenuItem(menu, -1); |
52 |
menuItem.setText(type.getLabel());
|
|
53 |
menuItem.setData(type);
|
|
51 |
menuItem.setText(formatLabelText(container));
|
|
52 |
menuItem.setData(container);
|
|
54 | 53 |
menuItem.addSelectionListener(new SelectionListener(){ |
55 | 54 |
|
56 | 55 |
public void widgetDefaultSelected(SelectionEvent e) {} |
57 | 56 |
|
58 | 57 |
public void widgetSelected(SelectionEvent ev) { |
59 | 58 |
Event event = new Event(); |
60 |
event.data = type;
|
|
59 |
event.data = container;
|
|
61 | 60 |
try { |
62 | 61 |
handlerService.executeCommand(getCommandName(), event); |
63 | 62 |
} catch (Exception e) { |
... | ... | |
68 | 67 |
} |
69 | 68 |
} |
70 | 69 |
|
70 |
private String formatLabelText(TaxonRelationshipTypeInverseContainer container){ |
|
71 |
Language language = Language.ENGLISH(); |
|
72 |
String formattedString = String.format("%s (%s)", container.getLabel(language), container.getAbbreviatedLabel(language)); |
|
73 |
|
|
74 |
return formattedString; |
|
75 |
} |
|
76 |
|
|
77 |
private List<TaxonRelationshipTypeInverseContainer> getRelationshipTypesWithInverses(){ |
|
78 |
List<TaxonRelationshipTypeInverseContainer> relationshipTypeInverseContainers = new ArrayList<TaxonRelationshipTypeInverseContainer>(); |
|
79 |
|
|
80 |
List<TaxonRelationshipType> relationshipTypes = CdmStore.getTermManager().getPreferredTaxonRelationshipTypes(); |
|
81 |
|
|
82 |
relationshipTypes.removeAll(excludeRelationshipTypes); |
|
83 |
|
|
84 |
for (TaxonRelationshipType relationshipType : relationshipTypes){ |
|
85 |
if(!relationshipType.isSymmetric()){ |
|
86 |
TaxonRelationshipTypeInverseContainer inverseContainer = new TaxonRelationshipTypeInverseContainer(relationshipType, true); |
|
87 |
relationshipTypeInverseContainers.add(inverseContainer); |
|
88 |
} |
|
89 |
TaxonRelationshipTypeInverseContainer container = new TaxonRelationshipTypeInverseContainer(relationshipType, false); |
|
90 |
relationshipTypeInverseContainers.add(container); |
|
91 |
} |
|
92 |
|
|
93 |
return relationshipTypeInverseContainers; |
|
94 |
} |
|
95 |
|
|
71 | 96 |
/** |
72 | 97 |
* <p>getCommandName</p> |
73 | 98 |
* |
74 | 99 |
* @return a {@link java.lang.String} object. |
75 | 100 |
*/ |
76 | 101 |
public abstract String getCommandName(); |
102 |
|
|
77 | 103 |
} |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/handler/CreateConceptRelationHandler.java | ||
---|---|---|
27 | 27 |
import eu.etaxonomy.taxeditor.editor.Page; |
28 | 28 |
import eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor; |
29 | 29 |
import eu.etaxonomy.taxeditor.editor.view.concept.operation.CreateConceptRelationOperation; |
30 |
import eu.etaxonomy.taxeditor.model.TaxonRelationshipTypeInverseContainer; |
|
30 | 31 |
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation; |
31 | 32 |
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled; |
32 | 33 |
import eu.etaxonomy.taxeditor.parser.ParseHandler; |
... | ... | |
53 | 54 |
|
54 | 55 |
Taxon relatedConcept = TaxonBaseSelectionDialog.selectTaxon(HandlerUtil.getActiveShell(event), editor.getConversationHolder()); |
55 | 56 |
|
56 |
TaxonRelationshipType type = (TaxonRelationshipType) ((Event)event.getTrigger()).data;
|
|
57 |
TaxonRelationshipTypeInverseContainer typeInverseContainer = (TaxonRelationshipTypeInverseContainer) ((Event)event.getTrigger()).data;
|
|
57 | 58 |
|
58 | 59 |
IWorkbenchPart activePart = HandlerUtil.getActivePart(event); |
59 | 60 |
IPostOperationEnabled postOperationEnabled = (activePart instanceof IPostOperationEnabled) ? (IPostOperationEnabled) activePart : null; |
60 | 61 |
|
61 | 62 |
try { |
62 | 63 |
AbstractPostOperation operation = new CreateConceptRelationOperation(event.getCommand().getName(), |
63 |
editor.getUndoContext(), editor.getTaxon(), relatedConcept, type, postOperationEnabled); |
|
64 |
editor.getUndoContext(), editor.getTaxon(), relatedConcept, typeInverseContainer, postOperationEnabled);
|
|
64 | 65 |
EditorUtil.executeOperation(operation); |
65 | 66 |
} catch (NotDefinedException e) { |
66 |
logger.warn("Command name not set");
|
|
67 |
EditorUtil.warn(getClass(), "Command name not set");
|
|
67 | 68 |
} |
68 | 69 |
|
69 | 70 |
return null; |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/operation/CreateConceptRelationOperation.java | ||
---|---|---|
17 | 17 |
|
18 | 18 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
19 | 19 |
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType; |
20 |
import eu.etaxonomy.taxeditor.model.TaxonRelationshipTypeInverseContainer; |
|
20 | 21 |
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation; |
21 | 22 |
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled; |
22 | 23 |
|
... | ... | |
31 | 32 |
public class CreateConceptRelationOperation extends AbstractPostOperation { |
32 | 33 |
|
33 | 34 |
private Taxon concept; |
34 |
private TaxonRelationshipType taxonRelationshipType;
|
|
35 |
private TaxonRelationshipTypeInverseContainer taxonRelationshipTypeInverseContainer;
|
|
35 | 36 |
|
36 | 37 |
/** |
37 | 38 |
* <p>Constructor for CreateConceptRelationOperation.</p> |
... | ... | |
44 | 45 |
* @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object. |
45 | 46 |
*/ |
46 | 47 |
public CreateConceptRelationOperation(String label, |
47 |
IUndoContext undoContext, Taxon taxon, Taxon concept, TaxonRelationshipType taxonRelationshipType
|
|
48 |
IUndoContext undoContext, Taxon taxon, Taxon concept, TaxonRelationshipTypeInverseContainer taxonRelationshipTypeInverseContainer
|
|
48 | 49 |
, IPostOperationEnabled postOperationEnabled) { |
49 | 50 |
super(label, undoContext, taxon, postOperationEnabled); |
50 | 51 |
this.concept = concept; |
51 |
this.taxonRelationshipType = taxonRelationshipType; |
|
52 |
this.taxonRelationshipTypeInverseContainer = taxonRelationshipTypeInverseContainer; |
|
53 |
} |
|
54 |
|
|
55 |
public CreateConceptRelationOperation(String label, |
|
56 |
IUndoContext undoContext, Taxon taxon, Taxon concept, TaxonRelationshipType taxonRelationshipType |
|
57 |
, IPostOperationEnabled postOperationEnabled) { |
|
58 |
this(label, undoContext, taxon, concept, new TaxonRelationshipTypeInverseContainer(taxonRelationshipType, false), postOperationEnabled); |
|
52 | 59 |
} |
53 | 60 |
|
54 | 61 |
/* (non-Javadoc) |
... | ... | |
61 | 68 |
|
62 | 69 |
monitor.worked(20); |
63 | 70 |
// add concept to taxon |
64 |
taxon.addTaxonRelation(concept, taxonRelationshipType, null, null); |
|
71 |
if(taxonRelationshipTypeInverseContainer.isInverse()){ |
|
72 |
concept.addTaxonRelation(taxon, taxonRelationshipTypeInverseContainer.getType(), null, null); |
|
73 |
} else { |
|
74 |
taxon.addTaxonRelation(concept, taxonRelationshipTypeInverseContainer.getType(), null, null); |
|
75 |
} |
|
65 | 76 |
monitor.worked(40); |
66 | 77 |
|
67 | 78 |
// redraw editor if exists |
... | ... | |
86 | 97 |
public IStatus undo(IProgressMonitor monitor, IAdaptable info) |
87 | 98 |
throws ExecutionException { |
88 | 99 |
|
89 |
taxon.removeTaxon(concept, taxonRelationshipType); |
|
100 |
taxon.removeTaxon(concept, taxonRelationshipTypeInverseContainer.getType());
|
|
90 | 101 |
|
91 | 102 |
// redraw editor if exists |
92 | 103 |
return postExecute(null); |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/TaxonRelationshipTypeInverseContainer.java | ||
---|---|---|
1 |
/** |
|
2 |
* |
|
3 |
*/ |
|
4 |
package eu.etaxonomy.taxeditor.model; |
|
5 |
|
|
6 |
import eu.etaxonomy.cdm.model.common.Language; |
|
7 |
import eu.etaxonomy.cdm.model.common.Representation; |
|
8 |
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType; |
|
9 |
|
|
10 |
/** |
|
11 |
* @author n.hoffmann |
|
12 |
* @created Nov 30, 2011 |
|
13 |
* @version 1.0 |
|
14 |
* |
|
15 |
*/ |
|
16 |
public class TaxonRelationshipTypeInverseContainer { |
|
17 |
|
|
18 |
private boolean inverse; |
|
19 |
private TaxonRelationshipType type; |
|
20 |
|
|
21 |
public TaxonRelationshipTypeInverseContainer(TaxonRelationshipType type, boolean inverse){ |
|
22 |
this.inverse = inverse; |
|
23 |
this.setType(type); |
|
24 |
} |
|
25 |
|
|
26 |
public boolean isInverse() { |
|
27 |
return inverse; |
|
28 |
} |
|
29 |
|
|
30 |
public Representation getRepresentation(Language language){ |
|
31 |
return inverse ? type.getInverseRepresentation(language) : type.getRepresentation(language); |
|
32 |
} |
|
33 |
|
|
34 |
public String getLabel(Language language){ |
|
35 |
return getRepresentation(language).getLabel(); |
|
36 |
} |
|
37 |
|
|
38 |
public String getDescription(Language language){ |
|
39 |
return getRepresentation(language).getDescription(); |
|
40 |
} |
|
41 |
|
|
42 |
public String getAbbreviatedLabel(Language language){ |
|
43 |
return getRepresentation(language).getAbbreviatedLabel(); |
|
44 |
} |
|
45 |
|
|
46 |
public void setInverse(boolean inverse) { |
|
47 |
this.inverse = inverse; |
|
48 |
} |
|
49 |
|
|
50 |
public TaxonRelationshipType getType() { |
|
51 |
return type; |
|
52 |
} |
|
53 |
|
|
54 |
public void setType(TaxonRelationshipType type) { |
|
55 |
this.type = type; |
|
56 |
} |
|
57 |
|
|
58 |
|
|
59 |
|
|
60 |
} |
Also available in: Unified diff
Showing the correct label and improving the mneu