Revision f3065796
Added by Patrick Plitzner over 4 years ago
eu.etaxonomy.taxeditor.store/fragment.e4xmi | ||
---|---|---|
15 | 15 |
<handlers xmi:id="_hPTxMBezEeiXusClKZjycQ" elementId="eu.etaxonomy.taxeditor.featuretree.e4.handler.AddChildFeatureHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.featuretree.e4.handler.AddChildFeatureHandler" command="_aPYxsBezEeiXusClKZjycQ"/> |
16 | 16 |
<handlers xmi:id="_Bb0TwCFeEeiVXriJfxPIuA" elementId="eu.etaxonomy.taxeditor.featuretree.e4.handler.RemoveFeatureTreeHandlers" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.featuretree.e4.handler.RemoveFeatureTreeHandler" command="_3mqzkCFdEeiVXriJfxPIuA"/> |
17 | 17 |
<handlers xmi:id="_DYhGACHXEeiP8eNo0PEm1g" elementId="eu.etaxonomy.taxeditor.featuretree.e4.handler.CreateFeatureTreeHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.featuretree.e4.handler.CreateFeatureTreeHandler" command="_AJtnsCHXEeiP8eNo0PEm1g"/> |
18 |
<handlers xmi:id="_i-FlkNjyEeidDMMI9xTsbQ" elementId="eu.etaxonomy.taxeditor.featuretree.e4.handler.CopyFeatureHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.featuretree.e4.handler.CopyFeatureHandler" command="_cMyQ4NjyEeidDMMI9xTsbQ"/> |
|
19 |
<handlers xmi:id="_tzQ_YNjyEeidDMMI9xTsbQ" elementId="eu.etaxonomy.taxeditor.featuretree.e4.handler.PasteFeatureHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.featuretree.e4.handler.PasteFeatureHandler" command="_xDk5kNjyEeidDMMI9xTsbQ"/> |
|
18 | 20 |
<menus xsi:type="menu:PopupMenu" xmi:id="__Jwh4GceEee0qLTtA2ZpVQ" elementId="eu.etaxonomy.taxeditor.store.popupmenu.featureTreeEditor"> |
19 | 21 |
<children xsi:type="menu:HandledMenuItem" xmi:id="_GuuM0CHXEeiP8eNo0PEm1g" elementId="eu.etaxonomy.taxeditor.store.handledmenuitem.newfeaturetree" label="%handledmenuitem.label.1" iconURI="platform:/plugin/org.eclipse.ui/icons/full/etool16/new_wiz.png" command="_AJtnsCHXEeiP8eNo0PEm1g"/> |
20 | 22 |
<children xsi:type="menu:MenuSeparator" xmi:id="_eIB1kCHXEeiP8eNo0PEm1g" elementId="eu.etaxonomy.taxeditor.store.menuseparator.5"/> |
21 | 23 |
<children xsi:type="menu:HandledMenuItem" xmi:id="_jr4E0Be0EeiXusClKZjycQ" elementId="eu.etaxonomy.taxeditor.store.handledmenuitem.addchildfeature" label="%handledmenuitem.label.2" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.store/icons/add.gif" command="_aPYxsBezEeiXusClKZjycQ"/> |
22 | 24 |
<children xsi:type="menu:HandledMenuItem" xmi:id="_eWBz0GcjEee0qLTtA2ZpVQ" elementId="eu.etaxonomy.taxeditor.store.handledmenuitem.addFeature" label="%handledmenuitem.label.3" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.store/icons/add.gif" command="_oftL0GceEee0qLTtA2ZpVQ"/> |
25 |
<children xsi:type="menu:MenuSeparator" xmi:id="_XtPjcNjyEeidDMMI9xTsbQ" elementId="eu.etaxonomy.taxeditor.store.menuseparator.8"/> |
|
26 |
<children xsi:type="menu:HandledMenuItem" xmi:id="_G_IOENj3EeidDMMI9xTsbQ" elementId="eu.etaxonomy.taxeditor.store.handledmenuitem.paste" label="Paste" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.store/icons/paste_edit.png" command="_xDk5kNjyEeidDMMI9xTsbQ"/> |
|
27 |
<children xsi:type="menu:HandledMenuItem" xmi:id="_QXkWYNjyEeidDMMI9xTsbQ" elementId="eu.etaxonomy.taxeditor.store.handledmenuitem.copy" label="Copy" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.store/icons/copy_edit.png" command="_cMyQ4NjyEeidDMMI9xTsbQ"/> |
|
28 |
<children xsi:type="menu:MenuSeparator" xmi:id="_So5f0NjyEeidDMMI9xTsbQ" elementId="eu.etaxonomy.taxeditor.store.menuseparator.7"/> |
|
23 | 29 |
<children xsi:type="menu:HandledMenuItem" xmi:id="_7vaEcGcqEee0qLTtA2ZpVQ" elementId="eu.etaxonomy.taxeditor.store.handledmenuitem.exportFeatureTree" label="%handledmenuitem.label.4" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.store/icons/export.gif" command="_I_yx4GcqEee0qLTtA2ZpVQ"> |
24 | 30 |
<visibleWhen xsi:type="ui:CoreExpression" xmi:id="_-91IQGcqEee0qLTtA2ZpVQ" coreExpressionId="isShowExperimentalFeatures"/> |
25 | 31 |
</children> |
... | ... | |
135 | 141 |
<elements xsi:type="commands:Command" xmi:id="_tPtdwMiIEeiKErB3UVzQug" elementId="eu.etaxonomy.taxeditor.store.open.OpenDistributionStatusWizardAdminHandler" commandName="%command.name.111"/> |
136 | 142 |
<elements xsi:type="commands:Command" xmi:id="_tRsg8MrcEeiKErB3UVzQug" elementId="eu.etaxonomy.taxeditor.store.open.OpenCommonNameAreaWizardAdminHandler" commandName="%command.name.112"/> |
137 | 143 |
<elements xsi:type="commands:Command" xmi:id="_nP0XMNhHEeijwMElCRdOhg" elementId="org.eclipse.ui.file.restartWorkbench" commandName="%command.commandname.10"/> |
144 |
<elements xsi:type="commands:Command" xmi:id="_cMyQ4NjyEeidDMMI9xTsbQ" elementId="eu.etaxonomy.taxeditor.store.command.featureTree.copyFeature" commandName="Copy Feature"/> |
|
145 |
<elements xsi:type="commands:Command" xmi:id="_xDk5kNjyEeidDMMI9xTsbQ" elementId="eu.etaxonomy.taxeditor.store.command.featureTree.pasteFeature" commandName="Paste Feature"/> |
|
138 | 146 |
</fragments> |
139 | 147 |
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_swGH0GhvEee3K4uKJljEYg" featurename="handlers" parentElementId="xpath:/"> |
140 | 148 |
<elements xsi:type="commands:Handler" xmi:id="_rVEdIGcjEee0qLTtA2ZpVQ" elementId="eu.etaxonomy.taxeditor.featuretree.e4.handler.RemoveFeatureHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.featuretree.e4.handler.RemoveFeatureHandler" command="_fNBtQGcjEee0qLTtA2ZpVQ"/> |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/featuretree/e4/FeatureNodeDropAdapter.java | ||
---|---|---|
19 | 19 |
import org.eclipse.jface.viewers.TreeViewer; |
20 | 20 |
import org.eclipse.jface.viewers.Viewer; |
21 | 21 |
import org.eclipse.jface.viewers.ViewerDropAdapter; |
22 |
import org.eclipse.swt.dnd.DND; |
|
22 | 23 |
import org.eclipse.swt.dnd.TransferData; |
23 | 24 |
|
24 | 25 |
import eu.etaxonomy.cdm.api.service.IFeatureNodeService; |
... | ... | |
99 | 100 |
for (Object droppedObject : droppedObjects) { |
100 | 101 |
if(droppedObject instanceof FeatureNode){ |
101 | 102 |
FeatureNode droppedNode = (FeatureNode) droppedObject; |
102 |
CdmStore.getService(IFeatureNodeService.class).moveFeatureNode(droppedNode.getUuid(), target.getUuid(), position); |
|
103 |
//move operation |
|
104 |
if(getCurrentOperation()==DND.DROP_MOVE){ |
|
105 |
CdmStore.getService(IFeatureNodeService.class).moveFeatureNode(droppedNode.getUuid(), target.getUuid(), position); |
|
106 |
} |
|
107 |
//copy operation |
|
108 |
else if(getCurrentOperation()==DND.DROP_COPY){ |
|
109 |
CdmStore.getService(IFeatureNodeService.class).addChildFeatureNode(target.getUuid(), droppedNode.getFeature().getUuid()); |
|
110 |
} |
|
103 | 111 |
viewer.reveal(droppedNode); |
104 | 112 |
} |
105 | 113 |
else if(droppedObject instanceof Feature){ |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/featuretree/e4/handler/CopyFeatureHandler.java | ||
---|---|---|
1 |
|
|
2 |
package eu.etaxonomy.taxeditor.featuretree.e4.handler; |
|
3 |
|
|
4 |
import javax.inject.Named; |
|
5 |
|
|
6 |
import org.eclipse.e4.core.di.annotations.CanExecute; |
|
7 |
import org.eclipse.e4.core.di.annotations.Execute; |
|
8 |
import org.eclipse.e4.core.di.annotations.Optional; |
|
9 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
|
10 |
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem; |
|
11 |
import org.eclipse.e4.ui.services.IServiceConstants; |
|
12 |
import org.eclipse.jface.util.LocalSelectionTransfer; |
|
13 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
14 |
|
|
15 |
import eu.etaxonomy.cdm.model.description.FeatureNode; |
|
16 |
import eu.etaxonomy.taxeditor.featuretree.e4.FeatureTreeEditor; |
|
17 |
|
|
18 |
public class CopyFeatureHandler { |
|
19 |
|
|
20 |
@Execute |
|
21 |
public void execute(@Named(IServiceConstants.ACTIVE_PART) MPart part, |
|
22 |
@Named(IServiceConstants.ACTIVE_SELECTION) IStructuredSelection selection){ |
|
23 |
LocalSelectionTransfer.getTransfer().setSelection(selection); |
|
24 |
} |
|
25 |
|
|
26 |
@CanExecute |
|
27 |
public boolean canExecute(@Optional @Named(IServiceConstants.ACTIVE_SELECTION) IStructuredSelection selection, |
|
28 |
@Named(IServiceConstants.ACTIVE_PART) MPart part, |
|
29 |
MHandledMenuItem menuItem){ |
|
30 |
boolean canExecute = false; |
|
31 |
canExecute =part.getObject() instanceof FeatureTreeEditor |
|
32 |
&& selection!=null |
|
33 |
&& selection.size()==1 |
|
34 |
&& selection.getFirstElement() instanceof FeatureNode; |
|
35 |
menuItem.setVisible(canExecute); |
|
36 |
return canExecute; |
|
37 |
} |
|
38 |
|
|
39 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/featuretree/e4/handler/PasteFeatureHandler.java | ||
---|---|---|
1 |
|
|
2 |
package eu.etaxonomy.taxeditor.featuretree.e4.handler; |
|
3 |
|
|
4 |
import javax.inject.Named; |
|
5 |
|
|
6 |
import org.eclipse.e4.core.di.annotations.CanExecute; |
|
7 |
import org.eclipse.e4.core.di.annotations.Execute; |
|
8 |
import org.eclipse.e4.core.di.annotations.Optional; |
|
9 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
|
10 |
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem; |
|
11 |
import org.eclipse.e4.ui.services.IServiceConstants; |
|
12 |
import org.eclipse.jface.util.LocalSelectionTransfer; |
|
13 |
import org.eclipse.jface.viewers.ISelection; |
|
14 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
15 |
|
|
16 |
import eu.etaxonomy.cdm.api.service.IFeatureNodeService; |
|
17 |
import eu.etaxonomy.cdm.model.description.FeatureNode; |
|
18 |
import eu.etaxonomy.taxeditor.featuretree.e4.FeatureTreeEditor; |
|
19 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
20 |
|
|
21 |
public class PasteFeatureHandler { |
|
22 |
|
|
23 |
@Execute |
|
24 |
public void execute(@Named(IServiceConstants.ACTIVE_PART) MPart part, |
|
25 |
@Named(IServiceConstants.ACTIVE_SELECTION) IStructuredSelection selection){ |
|
26 |
ISelection clipBoardSelection = LocalSelectionTransfer.getTransfer().getSelection(); |
|
27 |
FeatureTreeEditor editor = (FeatureTreeEditor)part.getObject(); |
|
28 |
FeatureNode parentNode = (FeatureNode) selection.getFirstElement(); |
|
29 |
FeatureNode copiedNode = (FeatureNode) ((IStructuredSelection)clipBoardSelection).getFirstElement(); |
|
30 |
|
|
31 |
CdmStore.getService(IFeatureNodeService.class).addChildFeatureNode(parentNode.getUuid(), copiedNode.getFeature().getUuid()); |
|
32 |
|
|
33 |
editor.getViewer().reveal(copiedNode); |
|
34 |
editor.setDirty(true); |
|
35 |
editor.getViewer().refresh(); |
|
36 |
} |
|
37 |
|
|
38 |
@CanExecute |
|
39 |
public boolean canExecute(@Optional @Named(IServiceConstants.ACTIVE_SELECTION) IStructuredSelection selection, |
|
40 |
MHandledMenuItem menuItem){ |
|
41 |
boolean canExecute = false; |
|
42 |
ISelection transferSelection = LocalSelectionTransfer.getTransfer().getSelection(); |
|
43 |
canExecute = selection!=null |
|
44 |
&& selection.size()==1 |
|
45 |
&& selection.getFirstElement() instanceof FeatureNode |
|
46 |
&& transferSelection instanceof IStructuredSelection |
|
47 |
&& ((IStructuredSelection)transferSelection).size()==1 |
|
48 |
&& ((IStructuredSelection)transferSelection).getFirstElement() instanceof FeatureNode; |
|
49 |
menuItem.setVisible(canExecute); |
|
50 |
return canExecute; |
|
51 |
} |
|
52 |
|
|
53 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/ImageResources.java | ||
---|---|---|
51 | 51 |
ICONS |
52 | 52 |
************************************************************************************** */ |
53 | 53 |
/** Constant <code>ADD_ICON="add_icon"</code> */ |
54 |
public static final String COPY_ICON = "copy_icon"; |
|
55 |
public static final String PASTE_ICON = "paste_icon"; |
|
54 | 56 |
public static final String ADD_ICON = "add_icon"; |
55 | 57 |
public static final String ADD_ICON_GREEN = "add_icon_green"; |
56 | 58 |
public static final String MIN_ICON = "min_icon"; |
... | ... | |
280 | 282 |
* @param registry a {@link org.eclipse.jface.resource.ImageRegistry} object. |
281 | 283 |
*/ |
282 | 284 |
protected void initializeImageRegistry(ImageRegistry registry) { |
285 |
registerImage(registry, COPY_ICON, |
|
286 |
"copy_edit.png"); |
|
287 |
registerImage(registry, PASTE_ICON, |
|
288 |
"paste_edit.png"); |
|
283 | 289 |
registerImage(registry, ADD_ICON, |
284 | 290 |
"add_no_bg.gif"); |
285 | 291 |
registerImage(registry, ADD_ICON_GREEN, |
Also available in: Unified diff
fix #7873 Implement copy&paste for feature nodes in feature tree editor