Revision 8e4eddeb
Added by Katja Luther over 5 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/checklist/e4/handler/OpenChecklistEditorHandlerE4.java | ||
---|---|---|
4 | 4 |
|
5 | 5 |
import javax.inject.Inject; |
6 | 6 |
|
7 |
import org.apache.commons.lang.StringUtils; |
|
8 | 7 |
import org.eclipse.e4.core.services.log.Logger; |
9 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
|
10 |
import org.eclipse.e4.ui.model.application.ui.basic.MPartStack; |
|
11 | 8 |
import org.eclipse.e4.ui.workbench.modeling.EPartService; |
12 |
import org.eclipse.e4.ui.workbench.modeling.EPartService.PartState; |
|
13 | 9 |
import org.eclipse.swt.widgets.Shell; |
14 | 10 |
|
15 | 11 |
import eu.etaxonomy.cdm.api.service.IClassificationService; |
16 | 12 |
import eu.etaxonomy.cdm.api.service.ITaxonNodeService; |
17 |
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate; |
|
18 |
import eu.etaxonomy.cdm.model.taxon.Classification; |
|
19 | 13 |
import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode; |
20 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode; |
|
21 | 14 |
import eu.etaxonomy.taxeditor.editor.AppModelId; |
15 |
import eu.etaxonomy.taxeditor.editor.EditorUtil; |
|
22 | 16 |
import eu.etaxonomy.taxeditor.editor.l10n.Messages; |
23 |
import eu.etaxonomy.taxeditor.editor.view.checklist.ChecklistEditorInput; |
|
24 |
import eu.etaxonomy.taxeditor.editor.view.checklist.e4.ChecklistEditorE4; |
|
25 | 17 |
import eu.etaxonomy.taxeditor.handler.defaultHandler.e4.DefaultOpenHandlerBaseE4; |
26 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
|
27 | 18 |
import eu.etaxonomy.taxeditor.preference.EditorPreferencePredicate; |
28 | 19 |
import eu.etaxonomy.taxeditor.preference.PreferencesUtil; |
29 | 20 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
30 |
import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility; |
|
31 | 21 |
|
32 | 22 |
public class OpenChecklistEditorHandlerE4 extends DefaultOpenHandlerBaseE4<ITaxonTreeNode> { |
33 | 23 |
@Inject |
... | ... | |
47 | 37 |
@Override |
48 | 38 |
protected void open(ITaxonTreeNode entity, Shell shell, EPartService partService) { |
49 | 39 |
|
50 |
if (PreferencesUtil.getBooleanValue(EditorPreferencePredicate.DistributionEditorActivated.getKey())) { |
|
51 |
if (StringUtils.isBlank(PreferencesUtil.getStringValue(PreferencePredicate.AvailableDistributionAreaVocabularies.getKey()) )){ |
|
40 |
// if (PreferencesUtil.getBooleanValue(EditorPreferencePredicate.DistributionEditorActivated.getKey())) { |
|
41 |
// if (StringUtils.isBlank(PreferencesUtil.getStringValue(PreferencePredicate.AvailableDistributionAreaVocabularies.getKey()) )){ |
|
42 |
// |
|
43 |
// MessagingUtils.informationDialog(Messages.OpenChecklistEditorHandler_NO_AREAS, Messages.OpenChecklistEditorHandler_CHOOSE_AREA |
|
44 |
// + Messages.OpenChecklistEditorHandler_GOTO_PREFERENCES); |
|
45 |
// return; |
|
46 |
// } |
|
47 |
// if (entity instanceof Classification) { |
|
48 |
// ChecklistEditorInput input = new ChecklistEditorInput(((Classification) entity)); |
|
49 |
// try { |
|
50 |
// openChecklistEditor(input, partService); |
|
51 |
// } catch (NullPointerException npe) { |
|
52 |
// MessagingUtils.messageDialog(COULD_NOT_OPEN_DISTRIBUTION_EDITOR, OpenChecklistEditorHandlerE4.class, |
|
53 |
// COULD_NOT_OPEN_DISTRIBUTION_EDITOR_THE_HIERARCHY_IS_CORRUPTED, npe); |
|
54 |
// } |
|
55 |
// } else if (entity instanceof TaxonNode) { |
|
56 |
// ChecklistEditorInput input = new ChecklistEditorInput((TaxonNode) entity); |
|
57 |
// try { |
|
58 |
// openChecklistEditor(input, partService); |
|
59 |
// } catch (NullPointerException npe) { |
|
60 |
// MessagingUtils.messageDialog(COULD_NOT_OPEN_DISTRIBUTION_EDITOR, OpenChecklistEditorHandlerE4.class, |
|
61 |
// COULD_NOT_OPEN_DISTRIBUTION_EDITOR_THE_HIERARCHY_IS_CORRUPTED, npe); |
|
62 |
// } |
|
63 |
// } |
|
64 |
// } |
|
52 | 65 |
|
53 |
MessagingUtils.informationDialog(Messages.OpenChecklistEditorHandler_NO_AREAS, Messages.OpenChecklistEditorHandler_CHOOSE_AREA |
|
54 |
+ Messages.OpenChecklistEditorHandler_GOTO_PREFERENCES); |
|
55 |
return; |
|
56 |
} |
|
57 |
if (entity instanceof Classification) { |
|
58 |
ChecklistEditorInput input = new ChecklistEditorInput(((Classification) entity)); |
|
59 |
try { |
|
60 |
openChecklistEditor(input, partService); |
|
61 |
} catch (NullPointerException npe) { |
|
62 |
MessagingUtils.messageDialog(COULD_NOT_OPEN_DISTRIBUTION_EDITOR, OpenChecklistEditorHandlerE4.class, |
|
63 |
COULD_NOT_OPEN_DISTRIBUTION_EDITOR_THE_HIERARCHY_IS_CORRUPTED, npe); |
|
64 |
} |
|
65 |
} else if (entity instanceof TaxonNode) { |
|
66 |
ChecklistEditorInput input = new ChecklistEditorInput((TaxonNode) entity); |
|
67 |
try { |
|
68 |
openChecklistEditor(input, partService); |
|
69 |
} catch (NullPointerException npe) { |
|
70 |
MessagingUtils.messageDialog(COULD_NOT_OPEN_DISTRIBUTION_EDITOR, OpenChecklistEditorHandlerE4.class, |
|
71 |
COULD_NOT_OPEN_DISTRIBUTION_EDITOR_THE_HIERARCHY_IS_CORRUPTED, npe); |
|
72 |
} |
|
73 |
} |
|
74 |
} |
|
66 |
EditorUtil.openDistributionEditor(entity.getUuid(), modelService, partService, application); |
|
75 | 67 |
} |
76 | 68 |
|
77 |
private void openChecklistEditor(ChecklistEditorInput input, EPartService partService) { |
|
78 |
MPart part = partService.createPart(AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_CHECKLIST_E4_CHECKLISTEDITORE4); |
|
79 |
MPartStack editorAreaPartStack = WorkbenchUtility.getEditorAreaPartStack(application, modelService); |
|
80 |
if(editorAreaPartStack!=null){ |
|
81 |
editorAreaPartStack.getChildren().add(part); |
|
82 |
} |
|
83 |
part = partService.showPart(part, PartState.ACTIVATE); |
|
84 |
ChecklistEditorE4 checklistEditor = (ChecklistEditorE4) part.getObject(); |
|
85 |
if (checklistEditor != null){ |
|
86 |
checklistEditor.init(input); |
|
87 |
}else{ |
|
88 |
logger.debug("Editor is null"); |
|
89 |
} |
|
90 |
} |
|
69 |
// private void openChecklistEditor(ChecklistEditorInput input, EPartService partService) {
|
|
70 |
// MPart part = partService.createPart(AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_CHECKLIST_E4_CHECKLISTEDITORE4);
|
|
71 |
// MPartStack editorAreaPartStack = WorkbenchUtility.getEditorAreaPartStack(application, modelService);
|
|
72 |
// if(editorAreaPartStack!=null){
|
|
73 |
// editorAreaPartStack.getChildren().add(part);
|
|
74 |
// }
|
|
75 |
// part = partService.showPart(part, PartState.ACTIVATE);
|
|
76 |
// ChecklistEditorE4 checklistEditor = (ChecklistEditorE4) part.getObject();
|
|
77 |
// if (checklistEditor != null){
|
|
78 |
// checklistEditor.init(input);
|
|
79 |
// }else{
|
|
80 |
// logger.debug("Editor is null");
|
|
81 |
// }
|
|
82 |
// }
|
|
91 | 83 |
|
92 | 84 |
/** |
93 | 85 |
* {@inheritDoc} |
... | ... | |
99 | 91 |
|
100 | 92 |
@Override |
101 | 93 |
protected String getPartId() { |
102 |
return AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_CHECKLIST_E4_CHECKLISTEDITORE4;
|
|
94 |
return AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_CHECKLIST_E4_DISTRIBUTIONEDITORPART;
|
|
103 | 95 |
} |
104 | 96 |
} |
Also available in: Unified diff
build layers for distribution editor