Revision 9c4b5905
Added by Katja Luther over 6 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/OpenChecklistEditorHandler.java | ||
---|---|---|
4 | 4 |
|
5 | 5 |
import org.apache.commons.lang.StringUtils; |
6 | 6 |
import org.eclipse.core.commands.ExecutionEvent; |
7 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
|
8 |
import org.eclipse.e4.ui.workbench.modeling.EPartService; |
|
9 |
import org.eclipse.e4.ui.workbench.modeling.EPartService.PartState; |
|
7 | 10 |
import org.eclipse.ui.PartInitException; |
8 | 11 |
|
9 | 12 |
import eu.etaxonomy.cdm.api.service.IClassificationService; |
... | ... | |
11 | 14 |
import eu.etaxonomy.cdm.model.taxon.Classification; |
12 | 15 |
import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode; |
13 | 16 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode; |
17 |
import eu.etaxonomy.taxeditor.editor.AppModelId; |
|
14 | 18 |
import eu.etaxonomy.taxeditor.editor.EditorUtil; |
19 |
import eu.etaxonomy.taxeditor.editor.internal.TaxeditorEditorPlugin; |
|
15 | 20 |
import eu.etaxonomy.taxeditor.editor.l10n.Messages; |
16 | 21 |
import eu.etaxonomy.taxeditor.editor.view.checklist.ChecklistEditorInput; |
22 |
import eu.etaxonomy.taxeditor.editor.view.checklist.e4.ChecklistEditorE4; |
|
23 |
import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView; |
|
24 |
import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateViewEditorInput; |
|
17 | 25 |
import eu.etaxonomy.taxeditor.handler.defaultHandler.DefaultOpenHandlerBase; |
18 | 26 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
19 | 27 |
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys; |
20 | 28 |
import eu.etaxonomy.taxeditor.preference.PreferencesUtil; |
21 | 29 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
30 |
import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin; |
|
22 | 31 |
|
23 | 32 |
public class OpenChecklistEditorHandler extends DefaultOpenHandlerBase<ITaxonTreeNode> { |
24 | 33 |
|
... | ... | |
47 | 56 |
if (entity instanceof Classification) { |
48 | 57 |
ChecklistEditorInput input = new ChecklistEditorInput(((Classification) entity)); |
49 | 58 |
try { |
50 |
EditorUtil.open(input); |
|
51 |
} catch (PartInitException e) { |
|
52 |
MessagingUtils.error(OpenChecklistEditorHandler.class, COULD_NOT_OPEN_DISTRIBUTION_EDITOR, e); |
|
59 |
openChecklistEditor(input); |
|
53 | 60 |
} catch (NullPointerException npe) { |
54 | 61 |
MessagingUtils.messageDialog(FAILED_TO_OPEN_EDITOR, OpenChecklistEditorHandler.class, |
55 | 62 |
COULD_NOT_OPEN_DISTRIBUTION_EDITOR_THE_HIERARCHY_IS_CORRUPTED, npe); |
... | ... | |
57 | 64 |
} else if (entity instanceof TaxonNode) { |
58 | 65 |
ChecklistEditorInput input = new ChecklistEditorInput((TaxonNode) entity); |
59 | 66 |
try { |
60 |
EditorUtil.open(input); |
|
61 |
} catch (PartInitException e) { |
|
62 |
MessagingUtils.error(OpenChecklistEditorHandler.class, COULD_NOT_OPEN_DISTRIBUTION_EDITOR, e); |
|
67 |
openChecklistEditor(input); |
|
63 | 68 |
} catch (NullPointerException npe) { |
64 | 69 |
MessagingUtils.messageDialog(FAILED_TO_OPEN_EDITOR, OpenChecklistEditorHandler.class, |
65 | 70 |
COULD_NOT_OPEN_DISTRIBUTION_EDITOR_THE_HIERARCHY_IS_CORRUPTED, npe); |
... | ... | |
67 | 72 |
} |
68 | 73 |
} |
69 | 74 |
} |
75 |
|
|
76 |
private void openChecklistEditor(ChecklistEditorInput input) { |
|
77 |
EPartService partService = TaxeditorEditorPlugin.getDefault().getWorkbench().getService(EPartService.class); |
|
78 |
MPart part = partService.createPart("eu.etaxonomy.taxeditor.editor.view.checklist.e4.ChecklistEditorE4"); |
|
79 |
partService.showPart(part, PartState.ACTIVATE); |
|
80 |
ChecklistEditorE4 checklistEditor = (ChecklistEditorE4) part.getObject(); |
|
81 |
if (checklistEditor != null){ |
|
82 |
checklistEditor.init(input); |
|
83 |
}else{ |
|
84 |
System.err.println("Editor is null"); |
|
85 |
} |
|
86 |
} |
|
70 | 87 |
} |
Also available in: Unified diff
minor