25 |
25 |
import eu.etaxonomy.cdm.model.description.TaxonDescription;
|
26 |
26 |
import eu.etaxonomy.cdm.model.description.TaxonNameDescription;
|
27 |
27 |
import eu.etaxonomy.cdm.model.media.Media;
|
|
28 |
import eu.etaxonomy.taxeditor.editor.CdmEntitySessionInput;
|
28 |
29 |
import eu.etaxonomy.taxeditor.editor.EditorUtil;
|
29 |
30 |
import eu.etaxonomy.taxeditor.editor.TaxonEditorInput;
|
30 |
31 |
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
|
|
32 |
import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView;
|
31 |
33 |
import eu.etaxonomy.taxeditor.editor.view.media.e4.MediaViewPartE4;
|
32 |
34 |
import eu.etaxonomy.taxeditor.editor.view.media.operation.DeleteMediaOperation;
|
33 |
35 |
import eu.etaxonomy.taxeditor.model.AbstractUtility;
|
... | ... | |
51 |
53 |
|
52 |
54 |
MediaViewPartE4 mediaView = (MediaViewPartE4) activePart.getObject();
|
53 |
55 |
|
54 |
|
IEditorPart editor = null;
|
|
56 |
|
55 |
57 |
Object e4WrappedPart = WorkbenchUtility.getE4WrappedPart(mediaView.getSelectionProvidingPart());
|
56 |
58 |
if (e4WrappedPart instanceof FormEditor) {
|
|
59 |
IEditorPart editor = null;
|
57 |
60 |
editor = (FormEditor) e4WrappedPart;
|
58 |
61 |
IEditorInput input = editor.getEditorInput();
|
59 |
|
if (input instanceof TaxonEditorInput) {
|
|
62 |
if (input instanceof CdmEntitySessionInput) {
|
60 |
63 |
ISelection selection = mediaView.getViewer().getSelection();
|
61 |
64 |
if (selection instanceof TreeSelection) {
|
62 |
65 |
TreePath[] paths = ((TreeSelection) selection).getPaths();
|
... | ... | |
91 |
94 |
}
|
92 |
95 |
AbstractPostOperation<?> operation = new DeleteMediaOperation(menuItem.getLocalizedLabel(), EditorUtil.getUndoContext(), description, media, config, mediaView);
|
93 |
96 |
AbstractUtility.executeOperation(operation);
|
|
97 |
|
94 |
98 |
}
|
95 |
99 |
}
|
|
100 |
} else if (e4WrappedPart instanceof DerivateView){
|
|
101 |
DerivateView view = (DerivateView) e4WrappedPart;
|
|
102 |
|
|
103 |
ISelection selection = mediaView.getViewer().getSelection();
|
|
104 |
if (selection instanceof TreeSelection) {
|
|
105 |
TreePath[] paths = ((TreeSelection) selection).getPaths();
|
|
106 |
int count = paths[0].getSegmentCount();
|
|
107 |
DescriptionBase description = null;
|
|
108 |
for (int i = 0; i < count; i++ ) {
|
|
109 |
if (paths[0].getSegment(i) instanceof DescriptionBase) {
|
|
110 |
description = (DescriptionBase) paths[0].getSegment(i);
|
|
111 |
break;
|
|
112 |
}
|
|
113 |
}
|
|
114 |
// TODO use undo context specific to editor
|
|
115 |
MediaDeletionConfigurator config = new MediaDeletionConfigurator();
|
|
116 |
|
|
117 |
config.setDeleteFromDescription(true);
|
|
118 |
config.setOnlyRemoveFromGallery(false);
|
|
119 |
|
|
120 |
if (description instanceof SpecimenDescription){
|
|
121 |
config.setDeleteFrom(((SpecimenDescription)description).getDescribedSpecimenOrObservation());
|
|
122 |
} else if (description instanceof TaxonDescription){
|
|
123 |
config.setDeleteFrom(((TaxonDescription)description).getTaxon());
|
|
124 |
}else if (description instanceof TaxonNameDescription){
|
|
125 |
config.setDeleteFrom(((TaxonNameDescription)description).getTaxonName());
|
|
126 |
}
|
|
127 |
|
|
128 |
|
|
129 |
DeleteConfiguratorDialog dialog;
|
|
130 |
dialog = new DeleteConfiguratorDialog(config, shell, Messages.DeleteMediaHandler_CONFIRM, null, Messages.DeleteMediaHandler_CONFIRM_MESSAGE, MessageDialog.WARNING, new String[] { Messages.DeleteMediaHandler_DELETE, Messages.DeleteMediaHandler_SKIP }, 0);
|
|
131 |
int result_dialog= dialog.open();
|
|
132 |
if (result_dialog != IStatus.OK){
|
|
133 |
return;
|
|
134 |
}
|
|
135 |
AbstractPostOperation<?> operation = new DeleteMediaOperation(menuItem.getLocalizedLabel(), EditorUtil.getUndoContext(), description, media, config, mediaView);
|
|
136 |
AbstractUtility.executeOperation(operation);
|
|
137 |
|
|
138 |
}
|
|
139 |
}
|
96 |
140 |
}
|
97 |
141 |
|
98 |
|
}
|
|
142 |
|
99 |
143 |
}
|
adapt media delete handler to e4 migration