Revision e6aba306
Added by Patrick Plitzner over 5 years ago
eu.etaxonomy.taxeditor.editor/fragment.e4xmi | ||
---|---|---|
63 | 63 |
</elements> |
64 | 64 |
<elements xsi:type="basic:PartDescriptor" xmi:id="_7GbckIDLEeeBD7P1FZoD-g" elementId="eu.etaxonomy.taxeditor.editor.view.media.e4.MediaViewPartE4" label="%view.name.1" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.editor/icons/camera-photo.png" closeable="true" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.view.media.e4.MediaViewPartE4"> |
65 | 65 |
<handlers xmi:id="_k638MIDSEeeBD7P1FZoD-g" elementId="eu.etaxonomy.taxeditor.editor.view.media.handler.AddImageGalleryHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.view.media.handler.AddImageGalleryHandler" command="_fIAlsIDSEeeBD7P1FZoD-g"/> |
66 |
<handlers xmi:id="_cedukIDoEeeBD7P1FZoD-g" elementId="eu.etaxonomy.taxeditor.editor.view.media.handler.CreateMediaHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.view.media.handler.CreateMediaHandler" command="_VZ6twIDoEeeBD7P1FZoD-g"/> |
|
67 |
<handlers xmi:id="_-rEh0IDoEeeBD7P1FZoD-g" elementId="eu.etaxonomy.taxeditor.editor.view.media.handler.MoveImageUpInListHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.view.media.handler.MoveImageUpInListHandler" command="_459e0IDoEeeBD7P1FZoD-g"/> |
|
68 |
<handlers xmi:id="_F_VZoIDpEeeBD7P1FZoD-g" elementId="eu.etaxonomy.taxeditor.editor.view.media.handler.MoveImageDownInListHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.view.media.handler.MoveImageDownInListHandler" command="_7tiZsIDoEeeBD7P1FZoD-g"/> |
|
69 |
<handlers xmi:id="_1LMfUIDuEeeBD7P1FZoD-g" elementId="eu.etaxonomy.taxeditor.editor.view.media.handler.AddExistingMediaHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.view.media.handler.AddExistingMediaHandler" command="_0eupoIDoEeeBD7P1FZoD-g"/> |
|
70 |
<handlers xmi:id="_vFCaIIGCEee6OIMIZFL1jw" elementId="eu.etaxonomy.taxeditor.editor.view.descriptive.handler.DeleteHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.view.descriptive.handler.DeleteHandler" command="_jWmdEIGCEee6OIMIZFL1jw"/> |
|
66 | 71 |
<menus xsi:type="menu:PopupMenu" xmi:id="_UwO5kIDSEeeBD7P1FZoD-g" elementId="eu.etaxonomy.taxeditor.editor.popupmenu.mediaview"> |
67 |
<children xsi:type="menu:HandledMenuItem" xmi:id="_XhTTAIDSEeeBD7P1FZoD-g" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.commandlabel37" label="%command.label.37" iconURI="" command="_fIAlsIDSEeeBD7P1FZoD-g"/> |
|
72 |
<visibleWhen xsi:type="ui:CoreExpression" xmi:id="_Z2OaYIF_Eee6OIMIZFL1jw" coreExpressionId="isCdmStoreConnected"/> |
|
73 |
<children xsi:type="menu:HandledMenuItem" xmi:id="_XhTTAIDSEeeBD7P1FZoD-g" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.newImageGallery" label="%command.name.20" iconURI="" command="_fIAlsIDSEeeBD7P1FZoD-g"/> |
|
74 |
<children xsi:type="menu:MenuSeparator" xmi:id="_0Z-zoIGEEee6OIMIZFL1jw" elementId="eu.etaxonomy.taxeditor.editor.menuseparator.7"/> |
|
75 |
<children xsi:type="menu:HandledMenuItem" xmi:id="_gljfwIDoEeeBD7P1FZoD-g" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.newImage" label="%command.name.21" command="_VZ6twIDoEeeBD7P1FZoD-g"> |
|
76 |
<visibleWhen xsi:type="ui:CoreExpression" xmi:id="_sHDNAIDoEeeBD7P1FZoD-g" coreExpressionId="isImageGallery"/> |
|
77 |
</children> |
|
78 |
<children xsi:type="menu:HandledMenuItem" xmi:id="_6amuAIDvEeeBD7P1FZoD-g" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.addExistingImage" label="%command.name.37" command="_0eupoIDoEeeBD7P1FZoD-g"> |
|
79 |
<visibleWhen xsi:type="ui:CoreExpression" xmi:id="_NQtSEIGEEee6OIMIZFL1jw" coreExpressionId="isImageGallery"/> |
|
80 |
</children> |
|
81 |
<children xsi:type="menu:MenuSeparator" xmi:id="_Xeq6IIDwEeeBD7P1FZoD-g" elementId="eu.etaxonomy.taxeditor.editor.menuseparator.6"/> |
|
82 |
<children xsi:type="menu:HandledMenuItem" xmi:id="_o4rk0IDuEeeBD7P1FZoD-g" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.moveImageUp" label="%command.name.22" command="_459e0IDoEeeBD7P1FZoD-g"> |
|
83 |
<visibleWhen xsi:type="ui:CoreExpression" xmi:id="_SXwqsIDwEeeBD7P1FZoD-g" coreExpressionId="isMedia"/> |
|
84 |
</children> |
|
85 |
<children xsi:type="menu:HandledMenuItem" xmi:id="_Akju0IDwEeeBD7P1FZoD-g" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.moveImageDown" label="%command.name.19" command="_7tiZsIDoEeeBD7P1FZoD-g"> |
|
86 |
<visibleWhen xsi:type="ui:CoreExpression" xmi:id="_wJU2wIGEEee6OIMIZFL1jw" coreExpressionId="isMedia"/> |
|
87 |
</children> |
|
88 |
<children xsi:type="menu:MenuSeparator" xmi:id="_W3Gj0IDwEeeBD7P1FZoD-g" elementId="eu.etaxonomy.taxeditor.editor.menuseparator.3"/> |
|
89 |
<children xsi:type="menu:HandledMenuItem" xmi:id="_y6pZwIGCEee6OIMIZFL1jw" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.deleteMedia" label="%command.label.41" command="_jWmdEIGCEee6OIMIZFL1jw"/> |
|
68 | 90 |
</menus> |
69 | 91 |
</elements> |
70 | 92 |
</fragments> |
... | ... | |
83 | 105 |
<elements xsi:type="commands:Command" xmi:id="_K4DxEDumEeeOtqC_3qh40A" elementId="eu.etaxonomy.taxeditor.editor.derivative.removeSingleReadFromSequence" commandName="%command.name.REMOVE_SINGLE_READ"/> |
84 | 106 |
<elements xsi:type="commands:Command" xmi:id="_N0wLsDumEeeOtqC_3qh40A" elementId="eu.etaxonomy.taxeditor.editor.derivative.copySingleReadToClipBoard" commandName="%command.name.COPY_SINGLE_READ_TO_CLIPBOARD"/> |
85 | 107 |
<elements xsi:type="commands:Command" xmi:id="_YPp1wDvREeeOtqC_3qh40A" elementId="eu.etaxonomy.taxeditor.editor.derivate.delete" commandName="Delete"/> |
86 |
<elements xsi:type="commands:Command" xmi:id="_fIAlsIDSEeeBD7P1FZoD-g" elementId="eu.etaxonomy.taxeditor.editor.media.command.newimagegallery" commandName="%command.label.37"/> |
|
108 |
<elements xsi:type="commands:Command" xmi:id="_fIAlsIDSEeeBD7P1FZoD-g" elementId="eu.etaxonomy.taxeditor.editor.media.command.newimagegallery" commandName="%command.name.20"/> |
|
109 |
<elements xsi:type="commands:Command" xmi:id="_VZ6twIDoEeeBD7P1FZoD-g" elementId="eu.etaxonomy.taxeditor.editor.media.command.newimage" commandName="%command.name.21"/> |
|
110 |
<elements xsi:type="commands:Command" xmi:id="_0eupoIDoEeeBD7P1FZoD-g" elementId="eu.etaxonomy.taxeditor.editor.media.command.useExistingImage" commandName="%command.name.37"/> |
|
111 |
<elements xsi:type="commands:Command" xmi:id="_459e0IDoEeeBD7P1FZoD-g" elementId="eu.etaxonomy.taxeditor.editor.media.command.moveimgup" commandName="%command.name.22"/> |
|
112 |
<elements xsi:type="commands:Command" xmi:id="_7tiZsIDoEeeBD7P1FZoD-g" elementId="eu.etaxonomy.taxeditor.editor.media.command.moveimgdown" commandName="%command.name.19"/> |
|
113 |
<elements xsi:type="commands:Command" xmi:id="_jWmdEIGCEee6OIMIZFL1jw" elementId="eu.etaxonomy.taxeditor.editor.media.command.delete" commandName="Delete Media"/> |
|
87 | 114 |
</fragments> |
88 | 115 |
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_pZmusEalEeeXMc6kSYO7Xg" featurename="children" parentElementId="eu.etaxonomy.taxeditor.menu.showView"> |
89 | 116 |
<elements xsi:type="menu:HandledMenuItem" xmi:id="_tvph4EalEeeXMc6kSYO7Xg" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.featuretreeeditor" label="Character Editor" command="_WPjpoDSnEeek0dKsFNy--Q"> |
eu.etaxonomy.taxeditor.editor/plugin.xml | ||
---|---|---|
862 | 862 |
|
863 | 863 |
|
864 | 864 |
|
865 |
<menuContribution |
|
866 |
locationURI="popup:eu.etaxonomy.taxeditor.editor.view.media"> |
|
867 |
<command |
|
868 |
commandId="eu.etaxonomy.taxeditor.editor.media.command.newimage" |
|
869 |
label="%command.label.38" |
|
870 |
style="push"> |
|
871 |
<visibleWhen> |
|
872 |
<reference |
|
873 |
definitionId="isImageGallery"> |
|
874 |
</reference> |
|
875 |
</visibleWhen> |
|
876 |
</command> |
|
877 |
<command |
|
878 |
commandId="eu.etaxonomy.taxeditor.editor.media.command.useExistingImage" |
|
879 |
label="%command.label.50" |
|
880 |
style="push"> |
|
881 |
<visibleWhen> |
|
882 |
<reference |
|
883 |
definitionId="isImageGallery"> |
|
884 |
</reference> |
|
885 |
</visibleWhen> |
|
886 |
</command> |
|
887 |
<command |
|
888 |
commandId="eu.etaxonomy.taxeditor.editor.media.command.moveimgdown" |
|
889 |
label="%command.label.39" |
|
890 |
style="push"> |
|
891 |
<visibleWhen> |
|
892 |
<reference |
|
893 |
definitionId="isMedia"> |
|
894 |
</reference> |
|
895 |
</visibleWhen> |
|
896 |
</command> |
|
897 |
<command |
|
898 |
commandId="eu.etaxonomy.taxeditor.editor.media.command.moveimgup" |
|
899 |
label="%command.label.40" |
|
900 |
style="push"> |
|
901 |
<visibleWhen> |
|
902 |
<reference |
|
903 |
definitionId="isMedia"> |
|
904 |
</reference> |
|
905 |
</visibleWhen> |
|
906 |
</command> |
|
907 |
<separator |
|
908 |
name="taxeditor-editor.separator2" |
|
909 |
visible="true"> |
|
910 |
</separator> |
|
911 |
<command |
|
912 |
commandId="eu.etaxonomy.taxeditor.editor.media.command.delete" |
|
913 |
label="%command.label.41" |
|
914 |
style="push"> |
|
915 |
</command> |
|
916 |
<command |
|
917 |
commandId="org.eclipse.ui.file.save" |
|
918 |
label="%command.label.42" |
|
919 |
style="push"> |
|
920 |
</command> |
|
921 |
</menuContribution> |
|
922 | 865 |
<menuContribution |
923 | 866 |
locationURI="popup:eu.etaxonomy.taxeditor.editor.view.concept"> |
924 | 867 |
<menu |
... | ... | |
1371 | 1314 |
id="eu.etaxonomy.taxeditor.editor.media.category" |
1372 | 1315 |
name="%category.name.3"> |
1373 | 1316 |
</category> |
1374 |
<command |
|
1375 |
categoryId="eu.etaxonomy.taxeditor.editor.media.category" |
|
1376 |
defaultHandler="eu.etaxonomy.taxeditor.editor.view.media.handler.MoveImageDownInListHandler" |
|
1377 |
id="eu.etaxonomy.taxeditor.editor.media.command.moveimgdown" |
|
1378 |
name="%command.name.19"> |
|
1379 |
</command> |
|
1380 |
<command |
|
1381 |
categoryId="eu.etaxonomy.taxeditor.editor.media.category" |
|
1382 |
defaultHandler="eu.etaxonomy.taxeditor.editor.view.media.handler.CreateMediaHandler" |
|
1383 |
id="eu.etaxonomy.taxeditor.editor.media.command.newimage" |
|
1384 |
name="%command.name.21"> |
|
1385 |
</command> |
|
1386 |
<command |
|
1387 |
categoryId="eu.etaxonomy.taxeditor.editor.media.category" |
|
1388 |
defaultHandler="eu.etaxonomy.taxeditor.editor.view.media.handler.AddExistingMediaHandler" |
|
1389 |
id="eu.etaxonomy.taxeditor.editor.media.command.useExistingImage" |
|
1390 |
name="%command.name.37"> |
|
1391 |
</command> |
|
1392 |
<command |
|
1393 |
categoryId="eu.etaxonomy.taxeditor.editor.media.category" |
|
1394 |
defaultHandler="eu.etaxonomy.taxeditor.editor.view.media.handler.MoveImageUpInListHandler" |
|
1395 |
id="eu.etaxonomy.taxeditor.editor.media.command.moveimgup" |
|
1396 |
name="%command.name.22"> |
|
1397 |
</command> |
|
1398 |
<command |
|
1399 |
categoryId="eu.etaxonomy.taxeditor.editor.media.category" |
|
1400 |
defaultHandler="eu.etaxonomy.taxeditor.editor.view.descriptive.handler.DeleteHandler" |
|
1401 |
id="eu.etaxonomy.taxeditor.editor.media.command.delete" |
|
1402 |
name="%command.name.49"> |
|
1403 |
</command> |
|
1404 | 1317 |
|
1405 | 1318 |
<category |
1406 | 1319 |
id="eu.etaxonomy.taxeditor.editor.new.category" |
... | ... | |
1849 | 1762 |
id="eu.etaxonomy.taxeditor.descriptions.propertyTester" |
1850 | 1763 |
namespace="eu.etaxonomy.taxeditor.descriptions.propertyTester" |
1851 | 1764 |
properties="isMedia,isDescription,isDescriptionElement,isDeletable,isFeatureNodeContainer,isImageGallery,isTaxonEditor,isBulkEditor,isDerivateEditor, isIndividualsAssociation" |
1852 |
type="org.eclipse.jface.viewers.TreeSelection">
|
|
1765 |
type="java.lang.Object">
|
|
1853 | 1766 |
</propertyTester> |
1854 | 1767 |
<propertyTester |
1855 | 1768 |
class="eu.etaxonomy.taxeditor.editor.handler.SpecimenPropertyTester" |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/e4/MediaViewPartE4.java | ||
---|---|---|
166 | 166 |
*/ |
167 | 167 |
@Override |
168 | 168 |
public boolean postOperation(CdmBase objectAffectedByOperation) { |
169 |
changed(objectAffectedByOperation); |
|
169 | 170 |
return true; |
170 | 171 |
} |
171 | 172 |
|
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/handler/AddExistingMediaHandler.java | ||
---|---|---|
1 | 1 |
package eu.etaxonomy.taxeditor.editor.view.media.handler; |
2 | 2 |
|
3 |
import org.eclipse.core.commands.ExecutionEvent; |
|
4 |
import org.eclipse.core.commands.common.NotDefinedException; |
|
3 |
import javax.inject.Named; |
|
4 |
|
|
5 |
import org.eclipse.e4.core.di.annotations.CanExecute; |
|
6 |
import org.eclipse.e4.core.di.annotations.Execute; |
|
7 |
import org.eclipse.e4.core.di.annotations.Optional; |
|
8 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
|
9 |
import org.eclipse.e4.ui.model.application.ui.menu.MMenuItem; |
|
10 |
import org.eclipse.e4.ui.services.IServiceConstants; |
|
5 | 11 |
|
6 | 12 |
import eu.etaxonomy.cdm.model.description.DescriptionBase; |
7 | 13 |
import eu.etaxonomy.cdm.model.media.Media; |
8 | 14 |
import eu.etaxonomy.taxeditor.editor.EditorUtil; |
15 |
import eu.etaxonomy.taxeditor.editor.view.media.e4.MediaViewPartE4; |
|
9 | 16 |
import eu.etaxonomy.taxeditor.editor.view.media.operation.AddExistingMediaToImageGalleryOperation; |
10 | 17 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
11 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
|
12 | 18 |
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation; |
13 |
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled; |
|
14 | 19 |
import eu.etaxonomy.taxeditor.ui.dialog.selection.MediaSelectionDialog; |
15 | 20 |
|
16 |
public class AddExistingMediaHandler extends CreateMediaHandler { |
|
17 |
|
|
18 |
/** |
|
19 |
* @param event |
|
20 |
* @param postOperationEnabled |
|
21 |
* @param description |
|
22 |
*/ |
|
23 |
@Override |
|
24 |
protected void executeOperation(ExecutionEvent event, IPostOperationEnabled postOperationEnabled, |
|
25 |
DescriptionBase description) { |
|
26 |
AbstractPostOperation operation = null; |
|
27 |
try { |
|
21 |
public class AddExistingMediaHandler { |
|
22 |
|
|
23 |
@Execute |
|
24 |
public void execute(@Named(IServiceConstants.ACTIVE_PART) MPart activePart, |
|
25 |
@Optional@Named(IServiceConstants.ACTIVE_SELECTION) DescriptionBase description, MMenuItem menuItem) { |
|
26 |
|
|
27 |
MediaViewPartE4 mediaView = (MediaViewPartE4) activePart.getObject(); |
|
28 |
|
|
29 |
if(description != null){ |
|
30 |
AbstractPostOperation operation = null; |
|
28 | 31 |
//select media |
29 | 32 |
Media media = MediaSelectionDialog.select(AbstractUtility.getShell(), null, null); |
30 | 33 |
if(media!=null){ |
31 | 34 |
// TODO use undo context specific to editor |
32 |
operation = new AddExistingMediaToImageGalleryOperation(media, event.getCommand().getName(),
|
|
33 |
EditorUtil.getUndoContext(), description, postOperationEnabled);
|
|
35 |
operation = new AddExistingMediaToImageGalleryOperation(media, menuItem.getLocalizedLabel(),
|
|
36 |
EditorUtil.getUndoContext(), description, mediaView);
|
|
34 | 37 |
AbstractUtility.executeOperation(operation); |
35 | 38 |
} |
36 |
} catch (NotDefinedException e) { |
|
37 |
MessagingUtils.warn(getClass(), "Command name not set."); //$NON-NLS-1$ |
|
38 | 39 |
} |
39 | 40 |
} |
40 | 41 |
|
42 |
@CanExecute |
|
43 |
private boolean canExecute(){ |
|
44 |
return true; |
|
45 |
} |
|
46 |
|
|
41 | 47 |
} |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/handler/CreateMediaHandler.java | ||
---|---|---|
3 | 3 |
*/ |
4 | 4 |
package eu.etaxonomy.taxeditor.editor.view.media.handler; |
5 | 5 |
|
6 |
import org.eclipse.core.commands.AbstractHandler; |
|
7 |
import org.eclipse.core.commands.ExecutionEvent; |
|
8 |
import org.eclipse.core.commands.ExecutionException; |
|
9 |
import org.eclipse.core.commands.common.NotDefinedException; |
|
10 |
import org.eclipse.jface.viewers.ISelection; |
|
11 |
import org.eclipse.jface.viewers.TreePath; |
|
12 |
import org.eclipse.jface.viewers.TreeSelection; |
|
13 |
import org.eclipse.ui.IEditorPart; |
|
14 |
import org.eclipse.ui.IWorkbenchPart; |
|
15 |
import org.eclipse.ui.forms.editor.FormEditor; |
|
16 |
import org.eclipse.ui.handlers.HandlerUtil; |
|
6 |
import javax.inject.Named; |
|
7 |
|
|
8 |
import org.eclipse.e4.core.di.annotations.Execute; |
|
9 |
import org.eclipse.e4.core.di.annotations.Optional; |
|
10 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
|
11 |
import org.eclipse.e4.ui.model.application.ui.menu.MMenuItem; |
|
12 |
import org.eclipse.e4.ui.services.IServiceConstants; |
|
17 | 13 |
|
18 | 14 |
import eu.etaxonomy.cdm.model.description.DescriptionBase; |
19 | 15 |
import eu.etaxonomy.taxeditor.editor.EditorUtil; |
16 |
import eu.etaxonomy.taxeditor.editor.view.media.e4.MediaViewPartE4; |
|
20 | 17 |
import eu.etaxonomy.taxeditor.editor.view.media.operation.AddMediaToImageGalleryOperation; |
21 | 18 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
22 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
|
23 | 19 |
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation; |
24 |
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled; |
|
25 | 20 |
|
26 | 21 |
/** |
27 |
* <p>CreateMediaHandler class.</p> |
|
28 | 22 |
* |
29 |
* @author p.ciardelli |
|
30 |
* @version $Id: $ |
|
23 |
* @author pplitzner |
|
24 |
* @since Aug 14, 2017 |
|
25 |
* |
|
31 | 26 |
*/ |
32 |
public class CreateMediaHandler extends AbstractHandler { |
|
33 |
|
|
34 |
/* (non-Javadoc) |
|
35 |
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) |
|
36 |
*/ |
|
37 |
/** {@inheritDoc} */ |
|
38 |
@Override |
|
39 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
|
40 |
IWorkbenchPart part = HandlerUtil.getActivePart(event); |
|
41 |
IPostOperationEnabled postOperationEnabled = (part instanceof IPostOperationEnabled) ? (IPostOperationEnabled) part : null; |
|
42 |
|
|
43 |
|
|
44 |
DescriptionBase description = null; |
|
27 |
public class CreateMediaHandler { |
|
45 | 28 |
|
46 |
IEditorPart editor = HandlerUtil.getActiveEditor(event); |
|
47 |
if (editor instanceof FormEditor) { |
|
48 |
editor = ((FormEditor) editor).getActiveEditor(); |
|
49 |
} |
|
50 |
|
|
51 |
ISelection selection = HandlerUtil.getCurrentSelection(event); |
|
52 |
if (selection instanceof TreeSelection) { |
|
53 |
TreePath[] paths = ((TreeSelection) selection).getPaths(); |
|
29 |
@Execute |
|
30 |
public Object execute(@Named(IServiceConstants.ACTIVE_PART) MPart activePart, |
|
31 |
@Optional@Named(IServiceConstants.ACTIVE_SELECTION) DescriptionBase description, MMenuItem menuItem) { |
|
54 | 32 |
|
55 |
int count = paths[0].getSegmentCount(); |
|
56 |
|
|
57 |
for (int i = 0; i < count; i++ ) { |
|
58 |
if (paths[0].getSegment(i) instanceof DescriptionBase) { |
|
59 |
description = (DescriptionBase) paths[0].getSegment(i); |
|
60 |
break; |
|
61 |
} |
|
62 |
} |
|
63 |
} |
|
33 |
MediaViewPartE4 mediaView = (MediaViewPartE4) activePart.getObject(); |
|
64 | 34 |
|
65 | 35 |
if(description != null){ |
66 |
executeOperation(event, postOperationEnabled, description); |
|
36 |
AbstractPostOperation operation = null; |
|
37 |
// TODO use undo context specific to editor |
|
38 |
operation = new AddMediaToImageGalleryOperation(menuItem.getLocalizedLabel(), |
|
39 |
EditorUtil.getUndoContext(), description, mediaView); |
|
40 |
AbstractUtility.executeOperation(operation); |
|
67 | 41 |
} |
68 | 42 |
|
69 | 43 |
return null; |
70 | 44 |
} |
71 | 45 |
|
72 |
/** |
|
73 |
* @param event |
|
74 |
* @param postOperationEnabled |
|
75 |
* @param description |
|
76 |
*/ |
|
77 |
protected void executeOperation(ExecutionEvent event, IPostOperationEnabled postOperationEnabled, |
|
78 |
DescriptionBase description) { |
|
79 |
AbstractPostOperation operation = null; |
|
80 |
try { |
|
81 |
// TODO use undo context specific to editor |
|
82 |
operation = new AddMediaToImageGalleryOperation(event.getCommand().getName(), |
|
83 |
EditorUtil.getUndoContext(), description, postOperationEnabled); |
|
84 |
AbstractUtility.executeOperation(operation); |
|
85 |
} catch (NotDefinedException e) { |
|
86 |
MessagingUtils.warn(getClass(), "Command name not set."); //$NON-NLS-1$ |
|
87 |
} |
|
88 |
} |
|
89 |
|
|
90 | 46 |
} |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/handler/DeleteMediaHandler.java | ||
---|---|---|
3 | 3 |
*/ |
4 | 4 |
package eu.etaxonomy.taxeditor.editor.view.media.handler; |
5 | 5 |
|
6 |
import org.eclipse.core.commands.AbstractHandler; |
|
7 |
import org.eclipse.core.commands.ExecutionEvent; |
|
8 |
import org.eclipse.core.commands.ExecutionException; |
|
9 |
import org.eclipse.core.runtime.Status; |
|
6 |
import javax.inject.Named; |
|
7 |
|
|
8 |
import org.eclipse.core.runtime.IStatus; |
|
9 |
import org.eclipse.e4.core.di.annotations.Execute; |
|
10 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
|
11 |
import org.eclipse.e4.ui.model.application.ui.menu.MMenuItem; |
|
12 |
import org.eclipse.e4.ui.services.IServiceConstants; |
|
10 | 13 |
import org.eclipse.jface.dialogs.MessageDialog; |
11 | 14 |
import org.eclipse.jface.viewers.ISelection; |
12 | 15 |
import org.eclipse.jface.viewers.TreePath; |
13 | 16 |
import org.eclipse.jface.viewers.TreeSelection; |
17 |
import org.eclipse.swt.widgets.Shell; |
|
14 | 18 |
import org.eclipse.ui.IEditorInput; |
15 | 19 |
import org.eclipse.ui.IEditorPart; |
16 |
import org.eclipse.ui.IWorkbenchPart; |
|
17 | 20 |
import org.eclipse.ui.forms.editor.FormEditor; |
18 |
import org.eclipse.ui.handlers.HandlerUtil; |
|
19 | 21 |
|
20 | 22 |
import eu.etaxonomy.cdm.api.service.config.MediaDeletionConfigurator; |
21 |
import eu.etaxonomy.cdm.model.description.DescriptionElementBase; |
|
22 |
import eu.etaxonomy.cdm.model.media.ImageFile; |
|
23 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
|
23 |
import eu.etaxonomy.cdm.model.description.DescriptionBase; |
|
24 |
import eu.etaxonomy.cdm.model.media.Media; |
|
24 | 25 |
import eu.etaxonomy.taxeditor.editor.EditorUtil; |
25 | 26 |
import eu.etaxonomy.taxeditor.editor.TaxonEditorInput; |
26 | 27 |
import eu.etaxonomy.taxeditor.editor.l10n.Messages; |
28 |
import eu.etaxonomy.taxeditor.editor.view.media.e4.MediaViewPartE4; |
|
29 |
import eu.etaxonomy.taxeditor.editor.view.media.operation.DeleteMediaOperation; |
|
30 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
|
27 | 31 |
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation; |
28 |
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled; |
|
29 | 32 |
import eu.etaxonomy.taxeditor.ui.dialog.configurator.deleteConfigurator.DeleteConfiguratorDialog; |
33 |
import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility; |
|
30 | 34 |
|
31 | 35 |
/** |
32 |
* <p>DeleteMediaHandler class.</p> |
|
33 | 36 |
* |
34 |
* @author p.ciardelli |
|
35 |
* @version $Id: $ |
|
37 |
* @author pplitzner |
|
38 |
* @since Aug 15, 2017 |
|
39 |
* |
|
36 | 40 |
*/ |
37 |
public class DeleteMediaHandler extends AbstractHandler { |
|
38 |
|
|
39 |
/* (non-Javadoc) |
|
40 |
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) |
|
41 |
*/ |
|
42 |
/** {@inheritDoc} */ |
|
43 |
@Override |
|
44 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
|
45 |
IWorkbenchPart part = HandlerUtil.getActivePart(event); |
|
46 |
IPostOperationEnabled postOperationEnabled = (part instanceof IPostOperationEnabled) ? (IPostOperationEnabled) part : null; |
|
41 |
public class DeleteMediaHandler { |
|
47 | 42 |
|
48 |
IEditorPart editor = HandlerUtil.getActiveEditor(event); |
|
49 |
if (editor instanceof FormEditor) { |
|
50 |
editor = ((FormEditor) editor).getActiveEditor(); |
|
51 |
} |
|
52 |
IEditorInput input = editor.getEditorInput(); |
|
53 |
if (input instanceof TaxonEditorInput) { |
|
54 |
Taxon taxon = ((TaxonEditorInput) input).getTaxon(); |
|
43 |
@Execute |
|
44 |
public void execute(@Named(IServiceConstants.ACTIVE_PART) MPart activePart, |
|
45 |
@Named(IServiceConstants.ACTIVE_SELECTION) Media media, |
|
46 |
@Named(IServiceConstants.ACTIVE_SHELL)Shell shell, |
|
47 |
MMenuItem menuItem) { |
|
55 | 48 |
|
56 |
ISelection selection = HandlerUtil.getCurrentSelection(event); |
|
57 |
if (selection instanceof TreeSelection) { |
|
58 |
TreePath[] paths = ((TreeSelection) selection).getPaths(); |
|
49 |
MediaViewPartE4 mediaView = (MediaViewPartE4) activePart.getObject(); |
|
59 | 50 |
|
60 |
int count = paths[0].getSegmentCount(); |
|
61 |
DescriptionElementBase element = null; |
|
62 |
for (int i = 0; i < count; i++ ) { |
|
63 |
if (paths[0].getSegment(i) instanceof DescriptionElementBase) { |
|
64 |
element = (DescriptionElementBase) paths[0].getSegment(i); |
|
65 |
break; |
|
66 |
} |
|
67 |
} |
|
68 |
ImageFile image = (ImageFile) paths[0].getLastSegment(); |
|
51 |
IEditorPart editor = null; |
|
52 |
Object e4WrappedPart = WorkbenchUtility.getE4WrappedPart(mediaView.getSelectionProvidingPart()); |
|
53 |
if (e4WrappedPart instanceof FormEditor) { |
|
54 |
editor = (FormEditor) e4WrappedPart; |
|
55 |
IEditorInput input = editor.getEditorInput(); |
|
56 |
if (input instanceof TaxonEditorInput) { |
|
57 |
ISelection selection = mediaView.getViewer().getSelection(); |
|
58 |
if (selection instanceof TreeSelection) { |
|
59 |
TreePath[] paths = ((TreeSelection) selection).getPaths(); |
|
60 |
int count = paths[0].getSegmentCount(); |
|
61 |
DescriptionBase description = null; |
|
62 |
for (int i = 0; i < count; i++ ) { |
|
63 |
if (paths[0].getSegment(i) instanceof DescriptionBase) { |
|
64 |
description = (DescriptionBase) paths[0].getSegment(i); |
|
65 |
break; |
|
66 |
} |
|
67 |
} |
|
68 |
// TODO use undo context specific to editor |
|
69 |
MediaDeletionConfigurator config = new MediaDeletionConfigurator(); |
|
70 |
AbstractPostOperation<?> operation = new DeleteMediaOperation(menuItem.getLocalizedLabel(), EditorUtil.getUndoContext(), description, media, config, mediaView); |
|
69 | 71 |
|
70 |
AbstractPostOperation<?> operation = null; |
|
71 |
// TODO use undo context specific to editor |
|
72 |
MediaDeletionConfigurator config = new MediaDeletionConfigurator(); |
|
72 |
DeleteConfiguratorDialog dialog; |
|
73 |
dialog = new DeleteConfiguratorDialog(config, shell, Messages.DeleteMediaHandler_CONFIRM, null, Messages.DeleteMediaHandler_CONFIRM_MESSAGE, MessageDialog.WARNING, new String[] { Messages.DeleteMediaHandler_DELETE, Messages.DeleteMediaHandler_SKIP }, 0); |
|
74 |
int result_dialog= dialog.open(); |
|
75 |
if (result_dialog != IStatus.OK){ |
|
76 |
return; |
|
77 |
} |
|
73 | 78 |
|
74 |
DeleteConfiguratorDialog dialog; |
|
75 |
dialog = new DeleteConfiguratorDialog(config, HandlerUtil.getActiveShell(event), Messages.DeleteMediaHandler_CONFIRM, null, Messages.DeleteMediaHandler_CONFIRM_MESSAGE, MessageDialog.WARNING, new String[] { Messages.DeleteMediaHandler_DELETE, Messages.DeleteMediaHandler_SKIP }, 0); |
|
76 |
int result_dialog= dialog.open(); |
|
77 |
if (result_dialog != Status.OK){ |
|
78 |
return null; |
|
79 |
AbstractUtility.executeOperation(operation); |
|
79 | 80 |
} |
81 |
} |
|
82 |
} |
|
80 | 83 |
|
81 |
|
|
82 |
// |
|
83 |
// if (config.isOnlyRemoveFromGallery()){ |
|
84 |
// operation = new RemoveImageFromDescriptionElementOperation(event.getCommand().getName(), EditorUtil.getUndoContext(), taxon, image, element, postOperationEnabled); |
|
85 |
// }else{ |
|
86 |
// operation = new DeleteMediaOperation(event.getCommand().getName(), EditorUtil.getUndoContext(), element, image, config, postOperationEnabled); |
|
87 |
// } |
|
88 |
|
|
89 |
EditorUtil.executeOperation(operation); |
|
90 |
} |
|
91 |
} |
|
92 |
return null; |
|
93 |
} |
|
94 |
|
|
95 |
} |
|
84 |
} |
|
85 |
} |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/handler/MoveImageDownInListHandler.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 |
package eu.etaxonomy.taxeditor.editor.view.media.handler; |
10 |
import org.eclipse.core.commands.AbstractHandler; |
|
11 |
import org.eclipse.core.commands.ExecutionEvent; |
|
12 |
import org.eclipse.core.commands.ExecutionException; |
|
13 |
import org.eclipse.core.commands.common.NotDefinedException; |
|
10 |
import javax.inject.Named; |
|
11 |
|
|
12 |
import org.eclipse.e4.core.di.annotations.Execute; |
|
13 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
|
14 |
import org.eclipse.e4.ui.model.application.ui.menu.MMenuItem; |
|
15 |
import org.eclipse.e4.ui.services.IServiceConstants; |
|
14 | 16 |
import org.eclipse.jface.viewers.ISelection; |
15 | 17 |
import org.eclipse.jface.viewers.TreePath; |
16 | 18 |
import org.eclipse.jface.viewers.TreeSelection; |
17 | 19 |
import org.eclipse.ui.IEditorInput; |
18 | 20 |
import org.eclipse.ui.IEditorPart; |
19 |
import org.eclipse.ui.IWorkbenchPart; |
|
20 | 21 |
import org.eclipse.ui.forms.editor.FormEditor; |
21 |
import org.eclipse.ui.handlers.HandlerUtil; |
|
22 | 22 |
|
23 | 23 |
import eu.etaxonomy.cdm.model.description.DescriptionBase; |
24 | 24 |
import eu.etaxonomy.cdm.model.media.Media; |
25 | 25 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
26 | 26 |
import eu.etaxonomy.taxeditor.editor.EditorUtil; |
27 | 27 |
import eu.etaxonomy.taxeditor.editor.TaxonEditorInput; |
28 |
import eu.etaxonomy.taxeditor.editor.view.media.e4.MediaViewPartE4; |
|
28 | 29 |
import eu.etaxonomy.taxeditor.editor.view.media.operation.MoveMediaInListOperation; |
29 |
import eu.etaxonomy.taxeditor.model.MessagingUtils;
|
|
30 |
import eu.etaxonomy.taxeditor.model.AbstractUtility;
|
|
30 | 31 |
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation; |
31 |
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
|
|
32 |
import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility;
|
|
32 | 33 |
|
33 | 34 |
/** |
34 |
* <p>MoveImageDownInListHandler class.</p> |
|
35 | 35 |
* |
36 | 36 |
* @author p.ciardelli |
37 | 37 |
* @created 11.08.2009 |
38 | 38 |
* @version 1.0 |
39 | 39 |
*/ |
40 |
public class MoveImageDownInListHandler extends AbstractHandler { |
|
40 |
public class MoveImageDownInListHandler { |
|
41 |
|
|
42 |
@Execute |
|
43 |
public void execute(@Named(IServiceConstants.ACTIVE_PART) MPart activePart, |
|
44 |
@Named(IServiceConstants.ACTIVE_SELECTION) Media media, |
|
45 |
MMenuItem menuItem) { |
|
46 |
|
|
47 |
MediaViewPartE4 mediaView = (MediaViewPartE4) activePart.getObject(); |
|
48 |
|
|
49 |
IEditorPart editor = null; |
|
50 |
Object e4WrappedPart = WorkbenchUtility.getE4WrappedPart(mediaView.getSelectionProvidingPart()); |
|
51 |
if (e4WrappedPart instanceof FormEditor) { |
|
52 |
editor = (FormEditor) e4WrappedPart; |
|
53 |
IEditorInput input = editor.getEditorInput(); |
|
54 |
if (input instanceof TaxonEditorInput) { |
|
55 |
Taxon taxon = ((TaxonEditorInput) input).getTaxon(); |
|
41 | 56 |
|
42 |
/* (non-Javadoc) |
|
43 |
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) |
|
44 |
*/ |
|
45 |
/** {@inheritDoc} */ |
|
46 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
|
47 |
IWorkbenchPart part = HandlerUtil.getActivePart(event); |
|
48 |
IPostOperationEnabled postOperationEnabled = (part instanceof IPostOperationEnabled) ? (IPostOperationEnabled) part : null; |
|
49 |
|
|
50 |
IEditorPart editor = HandlerUtil.getActiveEditor(event); |
|
51 |
if (editor instanceof FormEditor) { |
|
52 |
editor = ((FormEditor) editor).getActiveEditor(); |
|
53 |
} |
|
54 |
IEditorInput input = editor.getEditorInput(); |
|
55 |
if (input instanceof TaxonEditorInput) { |
|
56 |
Taxon taxon = ((TaxonEditorInput) input).getTaxon(); |
|
57 |
|
|
58 |
ISelection selection = HandlerUtil.getCurrentSelection(event); |
|
59 |
|
|
60 |
if (selection instanceof TreeSelection) { |
|
61 |
TreePath[] paths = ((TreeSelection) selection).getPaths(); |
|
62 |
int count = paths[0].getSegmentCount(); |
|
63 |
DescriptionBase description = null; |
|
64 |
for (int i = 0; i < count; i++ ) { |
|
65 |
if (paths[0].getSegment(i) instanceof DescriptionBase) { |
|
66 |
description = (DescriptionBase) paths[0].getSegment(i); |
|
67 |
break; |
|
68 |
} |
|
69 |
} |
|
70 |
Media media = (Media) paths[0].getLastSegment(); |
|
71 |
AbstractPostOperation operation = null; |
|
72 |
try { |
|
73 |
// TODO use undo context specific to editor |
|
74 |
operation = new MoveMediaInListOperation(event.getCommand().getName(), |
|
75 |
EditorUtil.getUndoContext(), taxon, description, media, MoveMediaInListOperation.DOWN, postOperationEnabled); |
|
76 |
EditorUtil.executeOperation(operation); |
|
77 |
} catch (NotDefinedException e) { |
|
78 |
MessagingUtils.warn(getClass(), "Command name not set."); //$NON-NLS-1$ |
|
79 |
} |
|
80 |
} |
|
81 |
} |
|
82 |
return null; |
|
57 |
ISelection selection = mediaView.getViewer().getSelection(); |
|
58 |
if (selection instanceof TreeSelection) { |
|
59 |
TreePath[] paths = ((TreeSelection) selection).getPaths(); |
|
60 |
int count = paths[0].getSegmentCount(); |
|
61 |
DescriptionBase description = null; |
|
62 |
for (int i = 0; i < count; i++ ) { |
|
63 |
if (paths[0].getSegment(i) instanceof DescriptionBase) { |
|
64 |
description = (DescriptionBase) paths[0].getSegment(i); |
|
65 |
break; |
|
66 |
} |
|
67 |
} |
|
68 |
AbstractPostOperation operation = null; |
|
69 |
// TODO use undo context specific to editor |
|
70 |
operation = new MoveMediaInListOperation(menuItem.getLocalizedLabel(), |
|
71 |
EditorUtil.getUndoContext(), taxon, description, media, MoveMediaInListOperation.DOWN, mediaView); |
|
72 |
AbstractUtility.executeOperation(operation); |
|
73 |
} |
|
74 |
} |
|
75 |
} |
|
83 | 76 |
} |
84 | 77 |
|
85 | 78 |
} |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/handler/MoveImageUpInListHandler.java | ||
---|---|---|
1 | 1 |
/** |
2 |
* Copyright (C) 2007 EDIT |
|
3 |
* European Distributed Institute of Taxonomy
|
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
*
|
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
2 |
* Copyright (C) 2007 EDIT
|
|
3 |
* European Distributed Institute of Taxonomy
|
|
4 |
* http://www.e-taxonomy.eu
|
|
5 |
*
|
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms.
|
|
8 |
*/
|
|
9 | 9 |
package eu.etaxonomy.taxeditor.editor.view.media.handler; |
10 |
import org.eclipse.core.commands.AbstractHandler; |
|
11 |
import org.eclipse.core.commands.ExecutionEvent; |
|
12 |
import org.eclipse.core.commands.ExecutionException; |
|
13 |
import org.eclipse.core.commands.common.NotDefinedException; |
|
10 |
import javax.inject.Named; |
|
11 |
|
|
12 |
import org.eclipse.e4.core.di.annotations.Execute; |
|
13 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
|
14 |
import org.eclipse.e4.ui.model.application.ui.menu.MMenuItem; |
|
15 |
import org.eclipse.e4.ui.services.IServiceConstants; |
|
14 | 16 |
import org.eclipse.jface.viewers.ISelection; |
15 | 17 |
import org.eclipse.jface.viewers.TreePath; |
16 | 18 |
import org.eclipse.jface.viewers.TreeSelection; |
17 | 19 |
import org.eclipse.ui.IEditorInput; |
18 | 20 |
import org.eclipse.ui.IEditorPart; |
19 |
import org.eclipse.ui.IWorkbenchPart; |
|
20 | 21 |
import org.eclipse.ui.forms.editor.FormEditor; |
21 |
import org.eclipse.ui.handlers.HandlerUtil; |
|
22 | 22 |
|
23 | 23 |
import eu.etaxonomy.cdm.model.description.DescriptionBase; |
24 | 24 |
import eu.etaxonomy.cdm.model.media.Media; |
25 | 25 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
26 | 26 |
import eu.etaxonomy.taxeditor.editor.EditorUtil; |
27 | 27 |
import eu.etaxonomy.taxeditor.editor.TaxonEditorInput; |
28 |
import eu.etaxonomy.taxeditor.editor.view.media.e4.MediaViewPartE4; |
|
28 | 29 |
import eu.etaxonomy.taxeditor.editor.view.media.operation.MoveMediaInListOperation; |
29 |
import eu.etaxonomy.taxeditor.model.MessagingUtils;
|
|
30 |
import eu.etaxonomy.taxeditor.model.AbstractUtility;
|
|
30 | 31 |
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation; |
31 |
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
|
|
32 |
import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility;
|
|
32 | 33 |
|
33 | 34 |
/** |
34 |
* <p>MoveImageUpInListHandler class.</p> |
|
35 | 35 |
* |
36 | 36 |
* @author p.ciardelli |
37 | 37 |
* @created 11.08.2009 |
38 | 38 |
* @version 1.0 |
39 | 39 |
*/ |
40 |
public class MoveImageUpInListHandler extends AbstractHandler { |
|
40 |
public class MoveImageUpInListHandler { |
|
41 |
|
|
42 |
@Execute |
|
43 |
public void execute(@Named(IServiceConstants.ACTIVE_PART) MPart activePart, |
|
44 |
@Named(IServiceConstants.ACTIVE_SELECTION) Media media, |
|
45 |
MMenuItem menuItem) { |
|
46 |
|
|
47 |
MediaViewPartE4 mediaView = (MediaViewPartE4) activePart.getObject(); |
|
48 |
|
|
49 |
IEditorPart editor = null; |
|
50 |
Object e4WrappedPart = WorkbenchUtility.getE4WrappedPart(mediaView.getSelectionProvidingPart()); |
|
51 |
if (e4WrappedPart instanceof FormEditor) { |
|
52 |
editor = (FormEditor) e4WrappedPart; |
|
53 |
IEditorInput input = editor.getEditorInput(); |
|
54 |
if (input instanceof TaxonEditorInput) { |
|
55 |
Taxon taxon = ((TaxonEditorInput) input).getTaxon(); |
|
41 | 56 |
|
42 |
/* (non-Javadoc) |
|
43 |
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) |
|
44 |
*/ |
|
45 |
/** {@inheritDoc} */ |
|
46 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
|
47 |
IWorkbenchPart part = HandlerUtil.getActivePart(event); |
|
48 |
IPostOperationEnabled postOperationEnabled = (part instanceof IPostOperationEnabled) ? (IPostOperationEnabled) part : null; |
|
49 |
|
|
50 |
IEditorPart editor = HandlerUtil.getActiveEditor(event); |
|
51 |
if (editor instanceof FormEditor) { |
|
52 |
editor = ((FormEditor) editor).getActiveEditor(); |
|
53 |
} |
|
54 |
IEditorInput input = editor.getEditorInput(); |
|
55 |
if (input instanceof TaxonEditorInput) { |
|
56 |
Taxon taxon = ((TaxonEditorInput) input).getTaxon(); |
|
57 |
|
|
58 |
ISelection selection = HandlerUtil.getCurrentSelection(event); |
|
59 |
if (selection instanceof TreeSelection) { |
|
60 |
TreePath[] paths = ((TreeSelection) selection).getPaths(); |
|
61 |
int count = paths[0].getSegmentCount(); |
|
62 |
DescriptionBase element = null; |
|
63 |
for (int i = 0; i < count; i++ ) { |
|
64 |
if (paths[0].getSegment(i) instanceof DescriptionBase) { |
|
65 |
element = (DescriptionBase) paths[0].getSegment(i); |
|
66 |
break; |
|
67 |
} |
|
68 |
} |
|
69 |
Media media = (Media) paths[0].getLastSegment(); |
|
70 |
AbstractPostOperation operation = null; |
|
71 |
try { |
|
72 |
// TODO use undo context specific to editor |
|
73 |
operation = new MoveMediaInListOperation(event.getCommand().getName(), |
|
74 |
EditorUtil.getUndoContext(), taxon, element, media, MoveMediaInListOperation.UP, postOperationEnabled); |
|
75 |
EditorUtil.executeOperation(operation); |
|
76 |
} catch (NotDefinedException e) { |
|
77 |
MessagingUtils.warn(getClass(), "Command name not set."); //$NON-NLS-1$ |
|
78 |
} |
|
79 |
} |
|
80 |
} |
|
81 |
return null; |
|
82 |
} |
|
57 |
ISelection selection = mediaView.getViewer().getSelection(); |
|
58 |
if (selection instanceof TreeSelection) { |
|
59 |
TreePath[] paths = ((TreeSelection) selection).getPaths(); |
|
60 |
int count = paths[0].getSegmentCount(); |
|
61 |
DescriptionBase element = null; |
|
62 |
for (int i = 0; i < count; i++ ) { |
|
63 |
if (paths[0].getSegment(i) instanceof DescriptionBase) { |
|
64 |
element = (DescriptionBase) paths[0].getSegment(i); |
|
65 |
break; |
|
66 |
} |
|
67 |
} |
|
68 |
AbstractPostOperation operation = null; |
|
69 |
// TODO use undo context specific to editor |
|
70 |
operation = new MoveMediaInListOperation(menuItem.getLocalizedLabel(), |
|
71 |
EditorUtil.getUndoContext(), taxon, element, media, MoveMediaInListOperation.UP, mediaView); |
|
72 |
AbstractUtility.executeOperation(operation); |
|
73 |
} |
|
74 |
} |
|
75 |
} |
|
76 |
} |
|
83 | 77 |
|
84 | 78 |
} |
Also available in: Unified diff
ref #6906 Migrate media view context menu