Revision fb019605
Added by Patrick Plitzner over 6 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/handler/MoveImageDownInListHandler.java | ||
---|---|---|
17 | 17 |
import org.eclipse.jface.viewers.ISelection; |
18 | 18 |
import org.eclipse.jface.viewers.TreePath; |
19 | 19 |
import org.eclipse.jface.viewers.TreeSelection; |
20 |
import org.eclipse.ui.IEditorInput; |
|
21 |
import org.eclipse.ui.IEditorPart; |
|
22 |
import org.eclipse.ui.forms.editor.FormEditor; |
|
23 | 20 |
|
24 | 21 |
import eu.etaxonomy.cdm.model.description.DescriptionBase; |
25 | 22 |
import eu.etaxonomy.cdm.model.media.Media; |
26 | 23 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
27 | 24 |
import eu.etaxonomy.taxeditor.editor.EditorUtil; |
28 |
import eu.etaxonomy.taxeditor.editor.TaxonEditorInput; |
|
25 |
import eu.etaxonomy.taxeditor.editor.e4.TaxonEditorInputE4; |
|
26 |
import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4; |
|
29 | 27 |
import eu.etaxonomy.taxeditor.editor.view.media.e4.MediaViewPartE4; |
30 | 28 |
import eu.etaxonomy.taxeditor.editor.view.media.operation.MoveMediaInListOperation; |
31 | 29 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
... | ... | |
48 | 46 |
|
49 | 47 |
MediaViewPartE4 mediaView = (MediaViewPartE4) activePart.getObject(); |
50 | 48 |
|
51 |
IEditorPart editor = null;
|
|
49 |
TaxonNameEditorE4 editor = null;
|
|
52 | 50 |
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 |
Taxon taxon = ((TaxonEditorInput) input).getTaxon(); |
|
51 |
if (e4WrappedPart instanceof TaxonNameEditorE4) { |
|
52 |
editor = (TaxonNameEditorE4) e4WrappedPart; |
|
53 |
TaxonEditorInputE4 input = editor.getEditorInput(); |
|
54 |
Taxon taxon = input.getTaxon(); |
|
58 | 55 |
|
59 |
ISelection selection = mediaView.getViewer().getSelection(); |
|
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 |
} |
|
56 |
ISelection selection = mediaView.getViewer().getSelection(); |
|
57 |
if (selection instanceof TreeSelection) { |
|
58 |
TreePath[] paths = ((TreeSelection) selection).getPaths(); |
|
59 |
int count = paths[0].getSegmentCount(); |
|
60 |
DescriptionBase description = null; |
|
61 |
for (int i = 0; i < count; i++ ) { |
|
62 |
if (paths[0].getSegment(i) instanceof DescriptionBase) { |
|
63 |
description = (DescriptionBase) paths[0].getSegment(i); |
|
64 |
break; |
|
69 | 65 |
} |
70 |
AbstractPostOperation operation = null; |
|
71 |
// TODO use undo context specific to editor |
|
72 |
operation = new MoveMediaInListOperation(menuItem.getLocalizedLabel(), |
|
73 |
EditorUtil.getUndoContext(), taxon, description, media, MoveMediaInListOperation.DOWN, mediaView); |
|
74 |
AbstractUtility.executeOperation(operation, sync); |
|
75 | 66 |
} |
67 |
AbstractPostOperation operation = null; |
|
68 |
// TODO use undo context specific to editor |
|
69 |
operation = new MoveMediaInListOperation(menuItem.getLocalizedLabel(), |
|
70 |
EditorUtil.getUndoContext(), taxon, description, media, MoveMediaInListOperation.DOWN, mediaView); |
|
71 |
AbstractUtility.executeOperation(operation, sync); |
|
76 | 72 |
} |
77 | 73 |
} |
78 |
}
|
|
74 |
}
|
|
79 | 75 |
|
80 | 76 |
} |
Also available in: Unified diff
ref #6906 Fix Delete and move handler for media view