Revision 15d18885
Added by Alex Theys almost 12 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/handler/CreateUseHandler.java | ||
---|---|---|
13 | 13 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
14 | 14 |
import eu.etaxonomy.taxeditor.editor.EditorUtil; |
15 | 15 |
import eu.etaxonomy.taxeditor.editor.TaxonEditorInput; |
16 |
import eu.etaxonomy.taxeditor.editor.view.descriptive.handler.CreateDescriptionHandler; |
|
17 |
import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.CreateTaxonDescriptionOperation; |
|
16 | 18 |
import eu.etaxonomy.taxeditor.editor.view.uses.operation.CreateTaxonUseOperation; |
17 | 19 |
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation; |
18 | 20 |
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled; |
... | ... | |
24 | 26 |
* @created mar 13, 2012 |
25 | 27 |
* @version 1.0 |
26 | 28 |
*/ |
27 |
public class CreateUseHandler extends AbstractHandler {
|
|
29 |
public class CreateUseHandler extends CreateDescriptionHandler {
|
|
28 | 30 |
/* (non-Javadoc) |
29 | 31 |
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) |
30 | 32 |
*/ |
31 | 33 |
/** {@inheritDoc} */ |
32 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
|
33 |
IWorkbenchPart part = HandlerUtil.getActivePart(event); |
|
34 |
IPostOperationEnabled postOperationEnabled = (part instanceof IPostOperationEnabled) ? (IPostOperationEnabled) part : null; |
|
35 |
|
|
36 |
|
|
37 |
IEditorPart editor = HandlerUtil.getActiveEditor(event); |
|
38 |
if (editor instanceof FormEditor) { |
|
39 |
editor = ((FormEditor) editor).getActiveEditor(); |
|
40 |
} |
|
41 |
IEditorInput input = editor.getEditorInput(); |
|
42 |
if (input instanceof TaxonEditorInput) { |
|
43 |
Taxon taxon = ((TaxonEditorInput) input).getTaxon(); |
|
44 |
AbstractPostOperation operation; |
|
45 |
try { |
|
46 |
operation = new CreateTaxonUseOperation(event.getCommand().getName(), |
|
47 |
EditorUtil.getUndoContext(), taxon, postOperationEnabled); |
|
48 |
EditorUtil.executeOperation(operation); |
|
49 |
} catch (NotDefinedException e) { |
|
50 |
EditorUtil.warn(getClass(), "Command name not set."); |
|
51 |
} |
|
52 |
} |
|
53 |
return null; |
|
34 |
@Override |
|
35 |
protected AbstractPostOperation createOperationInstance(String eventLabel, Taxon taxon, IPostOperationEnabled postOperationEnabled) { |
|
36 |
return new CreateTaxonUseOperation(eventLabel, EditorUtil.getUndoContext(), taxon, postOperationEnabled); |
|
54 | 37 |
} |
55 | 38 |
} |
Also available in: Unified diff
AT: committing changes to the TaxEditor Post first round of code review