Revision 324d38f7
Added by Alex Theys about 12 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/handler/DeleteUseHandler.java | ||
---|---|---|
9 | 9 |
import org.eclipse.core.commands.common.NotDefinedException; |
10 | 10 |
import org.eclipse.core.commands.operations.IUndoContext; |
11 | 11 |
import org.eclipse.jface.viewers.IStructuredSelection; |
12 |
import org.eclipse.jface.viewers.TreePath; |
|
13 |
import org.eclipse.jface.viewers.TreeSelection; |
|
14 | 12 |
import org.eclipse.ui.IWorkbenchPart; |
15 | 13 |
import org.eclipse.ui.handlers.HandlerUtil; |
16 | 14 |
|
17 | 15 |
import eu.etaxonomy.cdm.model.description.DescriptionElementBase; |
18 | 16 |
import eu.etaxonomy.cdm.model.description.TaxonDescription; |
19 |
import eu.etaxonomy.cdm.model.media.Media; |
|
20 | 17 |
import eu.etaxonomy.taxeditor.editor.EditorUtil; |
21 |
import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.DeleteDescriptionElementOperation; |
|
22 |
import eu.etaxonomy.taxeditor.editor.view.media.operation.DeleteMediaOperation; |
|
23 | 18 |
import eu.etaxonomy.taxeditor.editor.view.uses.operation.DeleteTaxonUseOperation; |
24 | 19 |
import eu.etaxonomy.taxeditor.editor.view.uses.operation.DeleteUseRecordOperation; |
25 | 20 |
import eu.etaxonomy.taxeditor.model.FeatureNodeContainer; |
26 | 21 |
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation; |
27 | 22 |
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled; |
28 | 23 |
|
24 |
/** |
|
25 |
* The context manager mediates context start/stop and workbench shutdowns to all registered listeners. |
|
26 |
* |
|
27 |
* @author a.theys |
|
28 |
* @created mar 13, 2012 |
|
29 |
* @version 1.0 |
|
30 |
*/ |
|
29 | 31 |
public class DeleteUseHandler extends AbstractHandler { |
30 | 32 |
|
31 | 33 |
/* |
... | ... | |
53 | 55 |
|
54 | 56 |
for (Object object : selection.toArray()) { |
55 | 57 |
|
56 |
AbstractPostOperation operation = null; |
|
57 |
|
|
58 | 58 |
// TaxonDescription |
59 | 59 |
if (object instanceof TaxonDescription) { |
60 | 60 |
operations.add(new DeleteTaxonUseOperation(label, |
... | ... | |
76 | 76 |
postOperationEnabled)); |
77 | 77 |
} |
78 | 78 |
} |
79 |
// Media |
|
80 |
else if (object instanceof Media) { |
|
81 |
TreeSelection treeSelection = (TreeSelection) selection; |
|
82 |
|
|
83 |
TreePath[] path = treeSelection.getPathsFor(object); |
|
84 |
|
|
85 |
TaxonDescription imageGallery = (TaxonDescription) path[0] |
|
86 |
.getFirstSegment(); |
|
87 |
|
|
88 |
operations |
|
89 |
.add(new DeleteMediaOperation(label, undoContext, |
|
90 |
imageGallery, (Media) object, |
|
91 |
postOperationEnabled)); |
|
92 |
} else { |
|
79 |
else { |
|
93 | 80 |
EditorUtil.error(getClass(), |
94 | 81 |
"Selection is not valid for this delete handler", |
95 | 82 |
null); |
Also available in: Unified diff
AT: committing latest changes to the Tax Editor after a first round of Code review