Revision b5b429af
Added by Patrick Plitzner over 6 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/handler/DeleteMediaHandler.java | ||
---|---|---|
7 | 7 |
|
8 | 8 |
import org.eclipse.core.runtime.IStatus; |
9 | 9 |
import org.eclipse.e4.core.di.annotations.Execute; |
10 |
import org.eclipse.e4.ui.di.UISynchronize; |
|
10 | 11 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
11 | 12 |
import org.eclipse.e4.ui.model.application.ui.menu.MMenuItem; |
12 | 13 |
import org.eclipse.e4.ui.services.IServiceConstants; |
... | ... | |
27 | 28 |
import eu.etaxonomy.cdm.model.media.Media; |
28 | 29 |
import eu.etaxonomy.taxeditor.editor.CdmEntitySessionInput; |
29 | 30 |
import eu.etaxonomy.taxeditor.editor.EditorUtil; |
30 |
import eu.etaxonomy.taxeditor.editor.TaxonEditorInput; |
|
31 | 31 |
import eu.etaxonomy.taxeditor.editor.l10n.Messages; |
32 | 32 |
import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView; |
33 | 33 |
import eu.etaxonomy.taxeditor.editor.view.media.e4.MediaViewPartE4; |
... | ... | |
49 | 49 |
public void execute(@Named(IServiceConstants.ACTIVE_PART) MPart activePart, |
50 | 50 |
@Named(IServiceConstants.ACTIVE_SELECTION) Media media, |
51 | 51 |
@Named(IServiceConstants.ACTIVE_SHELL)Shell shell, |
52 |
MMenuItem menuItem) { |
|
52 |
MMenuItem menuItem, |
|
53 |
UISynchronize sync) { |
|
53 | 54 |
|
54 | 55 |
MediaViewPartE4 mediaView = (MediaViewPartE4) activePart.getObject(); |
55 | 56 |
|
56 |
|
|
57 |
|
|
57 | 58 |
Object e4WrappedPart = WorkbenchUtility.getE4WrappedPart(mediaView.getSelectionProvidingPart()); |
58 | 59 |
if (e4WrappedPart instanceof FormEditor) { |
59 | 60 |
IEditorPart editor = null; |
... | ... | |
73 | 74 |
} |
74 | 75 |
// TODO use undo context specific to editor |
75 | 76 |
MediaDeletionConfigurator config = new MediaDeletionConfigurator(); |
76 |
|
|
77 |
|
|
77 | 78 |
config.setDeleteFromDescription(true); |
78 | 79 |
config.setOnlyRemoveFromGallery(false); |
79 |
|
|
80 |
|
|
80 | 81 |
if (description instanceof SpecimenDescription){ |
81 | 82 |
config.setDeleteFrom(((SpecimenDescription)description).getDescribedSpecimenOrObservation()); |
82 | 83 |
} else if (description instanceof TaxonDescription){ |
... | ... | |
84 | 85 |
}else if (description instanceof TaxonNameDescription){ |
85 | 86 |
config.setDeleteFrom(((TaxonNameDescription)description).getTaxonName()); |
86 | 87 |
} |
87 |
|
|
88 |
|
|
88 | 89 |
|
89 | 90 |
DeleteConfiguratorDialog dialog; |
90 | 91 |
dialog = new DeleteConfiguratorDialog(config, shell, Messages.DeleteMediaHandler_CONFIRM, null, Messages.DeleteMediaHandler_CONFIRM_MESSAGE, MessageDialog.WARNING, new String[] { Messages.DeleteMediaHandler_DELETE, Messages.DeleteMediaHandler_SKIP }, 0); |
... | ... | |
93 | 94 |
return; |
94 | 95 |
} |
95 | 96 |
AbstractPostOperation<?> operation = new DeleteMediaOperation(menuItem.getLocalizedLabel(), EditorUtil.getUndoContext(), description, media, config, mediaView); |
96 |
AbstractUtility.executeOperation(operation); |
|
97 |
|
|
97 |
AbstractUtility.executeOperation(operation, sync);
|
|
98 |
|
|
98 | 99 |
} |
99 | 100 |
} |
100 | 101 |
} else if (e4WrappedPart instanceof DerivateView){ |
101 | 102 |
DerivateView view = (DerivateView) e4WrappedPart; |
102 |
|
|
103 |
|
|
103 | 104 |
ISelection selection = mediaView.getViewer().getSelection(); |
104 | 105 |
if (selection instanceof TreeSelection) { |
105 | 106 |
TreePath[] paths = ((TreeSelection) selection).getPaths(); |
... | ... | |
113 | 114 |
} |
114 | 115 |
// TODO use undo context specific to editor |
115 | 116 |
MediaDeletionConfigurator config = new MediaDeletionConfigurator(); |
116 |
|
|
117 |
|
|
117 | 118 |
config.setDeleteFromDescription(true); |
118 | 119 |
config.setOnlyRemoveFromGallery(false); |
119 |
|
|
120 |
|
|
120 | 121 |
if (description instanceof SpecimenDescription){ |
121 | 122 |
config.setDeleteFrom(((SpecimenDescription)description).getDescribedSpecimenOrObservation()); |
122 | 123 |
} else if (description instanceof TaxonDescription){ |
... | ... | |
124 | 125 |
}else if (description instanceof TaxonNameDescription){ |
125 | 126 |
config.setDeleteFrom(((TaxonNameDescription)description).getTaxonName()); |
126 | 127 |
} |
127 |
|
|
128 |
|
|
128 | 129 |
|
129 | 130 |
DeleteConfiguratorDialog dialog; |
130 | 131 |
dialog = new DeleteConfiguratorDialog(config, shell, Messages.DeleteMediaHandler_CONFIRM, null, Messages.DeleteMediaHandler_CONFIRM_MESSAGE, MessageDialog.WARNING, new String[] { Messages.DeleteMediaHandler_DELETE, Messages.DeleteMediaHandler_SKIP }, 0); |
... | ... | |
133 | 134 |
return; |
134 | 135 |
} |
135 | 136 |
AbstractPostOperation<?> operation = new DeleteMediaOperation(menuItem.getLocalizedLabel(), EditorUtil.getUndoContext(), description, media, config, mediaView); |
136 |
AbstractUtility.executeOperation(operation); |
|
137 |
|
|
137 |
AbstractUtility.executeOperation(operation, sync);
|
|
138 |
|
|
138 | 139 |
} |
139 | 140 |
} |
140 | 141 |
} |
141 | 142 |
|
142 |
|
|
143 |
|
|
143 | 144 |
} |
Also available in: Unified diff
ref #6925 Inject context into operations to allow sync/async execution