Revision 9fcf0574
ref #5923 "Open in.." menu restructuring for conecpt view
- added "Open in" option for bulk editor and name editor coming from each of those
eu.etaxonomy.taxeditor.editor/plugin.xml | ||
---|---|---|
1080 | 1080 |
id="eu.etaxonomy.taxeditor.editor.view.concept.menus.new"> |
1081 | 1081 |
</dynamic> |
1082 | 1082 |
</menu> |
1083 |
<command |
|
1084 |
commandId="eu.etaxonomy.taxeditor.editor.view.concept.command.open" |
|
1085 |
label="%command.label.43" |
|
1086 |
style="push"> |
|
1087 |
</command> |
|
1083 |
<dynamic |
|
1084 |
class="eu.etaxonomy.taxeditor.view.CdmViewerContextMenu" |
|
1085 |
id="eu.etaxonomy.taxeditor.view.context.CdmViewerContextMenu"> |
|
1086 |
</dynamic> |
|
1088 | 1087 |
<separator |
1089 | 1088 |
name="eu.etaxonomy.taxeditor.editor.view.concept.menu.separator1" |
1090 | 1089 |
visible="true"> |
... | ... | |
1142 | 1141 |
</toolbar> |
1143 | 1142 |
</menuContribution> |
1144 | 1143 |
<menuContribution |
1145 |
allPopups="false" |
|
1146 | 1144 |
locationURI="menu:bulkeditor.menus.openmenu"> |
1147 | 1145 |
<command |
1148 | 1146 |
commandId="eu.etaxonomy.taxeditor.editor.openSpecimenEditorFromMenu" |
... | ... | |
1770 | 1768 |
id="eu.etaxonomy.taxeditor.openSpecimenEditorForTypeSpecimen" |
1771 | 1769 |
name="%command.name.OPEN_EDITOR_FOR_TYPE_SPECIMEN"> |
1772 | 1770 |
</command> |
1771 |
<command |
|
1772 |
defaultHandler="eu.etaxonomy.taxeditor.editor.view.concept.handler.OpenRelatedConceptInBulkEditorHandler" |
|
1773 |
id="eu.etaxonomy.taxeditor.editor.openBulkEditorForTaxonRelationship" |
|
1774 |
name="Open bulk editor for taxon relationship"> |
|
1775 |
</command> |
|
1773 | 1776 |
|
1774 | 1777 |
</extension> |
1775 | 1778 |
<extension |
... | ... | |
2106 | 2109 |
selection="eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation" |
2107 | 2110 |
viewerName="%viewCommandMapping.viewerName.SPECIMEN_EDITOR"> |
2108 | 2111 |
</viewCommandMapping> |
2112 |
<viewCommandMapping |
|
2113 |
commandId="eu.etaxonomy.taxeditor.editor.view.concept.command.open" |
|
2114 |
selection="eu.etaxonomy.cdm.model.taxon.TaxonRelationship" |
|
2115 |
viewerName="Name Editor"> |
|
2116 |
</viewCommandMapping> |
|
2117 |
<viewCommandMapping |
|
2118 |
commandId="eu.etaxonomy.taxeditor.editor.openBulkEditorForTaxonRelationship" |
|
2119 |
selection="eu.etaxonomy.cdm.model.taxon.TaxonRelationship" |
|
2120 |
viewerName="Bulk Editor"> |
|
2121 |
</viewCommandMapping> |
|
2109 | 2122 |
</extension> |
2110 | 2123 |
</plugin> |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/handler/OpenRelatedConceptHandler.java | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* Copyright (C) 2007 EDIT |
3 |
* European Distributed Institute of Taxonomy
|
|
3 |
* European Distributed Institute of Taxonomy |
|
4 | 4 |
* http://www.e-taxonomy.eu |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 | 8 |
*/ |
9 | 9 |
|
10 | 10 |
package eu.etaxonomy.taxeditor.editor.view.concept.handler; |
11 | 11 |
|
12 |
import java.util.Iterator; |
|
13 |
|
|
14 | 12 |
import org.eclipse.core.commands.AbstractHandler; |
15 | 13 |
import org.eclipse.core.commands.ExecutionEvent; |
16 | 14 |
import org.eclipse.core.commands.ExecutionException; |
17 | 15 |
import org.eclipse.jface.viewers.ISelection; |
18 | 16 |
import org.eclipse.jface.viewers.IStructuredSelection; |
17 |
import org.eclipse.ui.IEditorPart; |
|
19 | 18 |
import org.eclipse.ui.PartInitException; |
20 | 19 |
import org.eclipse.ui.handlers.HandlerUtil; |
21 | 20 |
|
22 | 21 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
22 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
|
23 | 23 |
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship; |
24 |
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditor; |
|
24 | 25 |
import eu.etaxonomy.taxeditor.editor.EditorUtil; |
25 | 26 |
import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor; |
26 | 27 |
import eu.etaxonomy.taxeditor.editor.l10n.Messages; |
28 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
|
29 |
import eu.etaxonomy.taxeditor.model.LineSelection; |
|
27 | 30 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
28 | 31 |
|
29 | 32 |
/** |
... | ... | |
33 | 36 |
*/ |
34 | 37 |
public class OpenRelatedConceptHandler extends AbstractHandler { |
35 | 38 |
|
36 |
/* (non-Javadoc) |
|
37 |
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) |
|
38 |
*/ |
|
39 | 39 |
@Override |
40 | 40 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
41 |
MultiPageTaxonEditor editor = EditorUtil.getActiveMultiPageTaxonEditor(); |
|
42 |
|
|
43 | 41 |
ISelection selection = HandlerUtil.getCurrentSelection(event); |
44 |
|
|
45 |
if(selection instanceof IStructuredSelection){ |
|
46 |
IStructuredSelection structuredSelection = (IStructuredSelection) selection; |
|
47 |
Iterator iterator = structuredSelection.iterator(); |
|
48 |
|
|
49 |
while (iterator.hasNext()){ |
|
50 |
Object element = iterator.next(); |
|
51 |
if(element instanceof TaxonRelationship){ |
|
52 |
Taxon relatedTaxon = getRelatedTaxon((TaxonRelationship) element, editor.getTaxon()); |
|
53 |
|
|
54 |
try { |
|
55 |
EditorUtil.openTaxonBase(relatedTaxon.getUuid()); |
|
56 |
} catch (PartInitException e) { |
|
57 |
MessagingUtils.messageDialog(Messages.OpenRelatedConceptHandler_COULD_NOT_OPEN, getClass(), |
|
58 |
String.format(Messages.OpenRelatedConceptHandler_COULD_NOT_OPEN_MESSAGE ,relatedTaxon), e); |
|
59 |
} |
|
60 |
} |
|
61 |
} |
|
42 |
TaxonBase<?> relatedTaxon = null; |
|
43 |
|
|
44 |
if(selection instanceof IStructuredSelection){ |
|
45 |
IStructuredSelection structuredSelection = (IStructuredSelection) selection; |
|
46 |
Object selectedElement = structuredSelection.getFirstElement(); |
|
47 |
|
|
48 |
if(selectedElement instanceof TaxonRelationship){ |
|
49 |
IEditorPart activeEditor = AbstractUtility.getActiveEditor(); |
|
50 |
if(activeEditor instanceof MultiPageTaxonEditor){ |
|
51 |
relatedTaxon = getRelatedTaxon((TaxonRelationship) selectedElement, ((MultiPageTaxonEditor) activeEditor).getTaxon()); |
|
52 |
} |
|
53 |
else if(activeEditor instanceof BulkEditor){ |
|
54 |
ISelection bulkSelection = ((BulkEditor)activeEditor).getSelectionProvider().getSelection(); |
|
55 |
if(bulkSelection instanceof LineSelection){ |
|
56 |
Object firstElement = ((LineSelection)bulkSelection).getFirstElement(); |
|
57 |
if(firstElement instanceof Taxon){ |
|
58 |
relatedTaxon = getRelatedTaxon((TaxonRelationship) selectedElement, (Taxon) firstElement); |
|
59 |
} |
|
60 |
} |
|
61 |
} |
|
62 |
} |
|
63 |
} |
|
64 |
|
|
65 |
if(relatedTaxon==null){ |
|
66 |
MessagingUtils.messageDialog(Messages.OpenRelatedConceptHandler_COULD_NOT_OPEN, getClass(), |
|
67 |
String.format(Messages.OpenRelatedConceptHandler_COULD_NOT_OPEN_MESSAGE ,relatedTaxon), null); |
|
62 | 68 |
} |
63 |
|
|
69 |
else{ |
|
70 |
openConcept(relatedTaxon); |
|
71 |
} |
|
72 |
|
|
64 | 73 |
return null; |
65 | 74 |
} |
66 | 75 |
|
67 |
|
|
76 |
/** |
|
77 |
* @param relatedTaxon |
|
78 |
*/ |
|
79 |
protected void openConcept(TaxonBase<?> relatedTaxon) { |
|
80 |
try { |
|
81 |
EditorUtil.openTaxonBase(relatedTaxon.getUuid()); |
|
82 |
} catch (PartInitException e) { |
|
83 |
MessagingUtils.messageDialog(Messages.OpenRelatedConceptHandler_COULD_NOT_OPEN, getClass(), |
|
84 |
String.format(Messages.OpenRelatedConceptHandler_COULD_NOT_OPEN_MESSAGE ,relatedTaxon), e); |
|
85 |
} |
|
86 |
} |
|
87 |
|
|
68 | 88 |
private Taxon getRelatedTaxon(TaxonRelationship relationship, Taxon taxon){ |
69 | 89 |
if (relationship.getFromTaxon().equals(taxon)){ |
70 | 90 |
return relationship.getToTaxon(); |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/handler/OpenRelatedConceptInBulkEditorHandler.java | ||
---|---|---|
1 |
package eu.etaxonomy.taxeditor.editor.view.concept.handler; |
|
2 |
|
|
3 |
import org.eclipse.ui.PartInitException; |
|
4 |
|
|
5 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
|
6 |
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditorUtil; |
|
7 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
|
8 |
|
|
9 |
public class OpenRelatedConceptInBulkEditorHandler extends OpenRelatedConceptHandler{ |
|
10 |
/** |
|
11 |
* {@inheritDoc} |
|
12 |
*/ |
|
13 |
@Override |
|
14 |
protected void openConcept(TaxonBase<?> relatedTaxon) { |
|
15 |
try { |
|
16 |
BulkEditorUtil.openEditor(relatedTaxon); |
|
17 |
} catch (PartInitException e) { |
|
18 |
MessagingUtils.error(this.getClass(), "Bulk Editor could not be opened for "+relatedTaxon, e); |
|
19 |
} |
|
20 |
} |
|
21 |
} |
Also available in: Unified diff