1 |
1 |
package eu.etaxonomy.taxeditor.editor.view.checklist.e4.handler;
|
2 |
2 |
|
3 |
3 |
import java.util.List;
|
4 |
|
import java.util.UUID;
|
5 |
4 |
|
6 |
5 |
import javax.inject.Inject;
|
|
6 |
import javax.inject.Named;
|
7 |
7 |
|
|
8 |
import org.eclipse.e4.core.di.annotations.CanExecute;
|
8 |
9 |
import org.eclipse.e4.core.services.log.Logger;
|
|
10 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
|
|
11 |
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
|
|
12 |
import org.eclipse.e4.ui.services.IServiceConstants;
|
9 |
13 |
import org.eclipse.e4.ui.workbench.modeling.EPartService;
|
|
14 |
import org.eclipse.jface.viewers.IStructuredSelection;
|
10 |
15 |
import org.eclipse.swt.widgets.Shell;
|
11 |
16 |
|
12 |
|
import eu.etaxonomy.cdm.api.service.IClassificationService;
|
13 |
|
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
|
14 |
17 |
import eu.etaxonomy.cdm.model.description.Distribution;
|
15 |
18 |
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
|
16 |
19 |
import eu.etaxonomy.cdm.model.permission.Operation;
|
17 |
|
import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
|
18 |
20 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
|
|
21 |
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
|
19 |
22 |
import eu.etaxonomy.taxeditor.editor.AppModelId;
|
20 |
23 |
import eu.etaxonomy.taxeditor.editor.EditorUtil;
|
21 |
24 |
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
|
22 |
|
import eu.etaxonomy.taxeditor.handler.defaultHandler.e4.DefaultOpenHandlerBaseE4;
|
|
25 |
import eu.etaxonomy.taxeditor.handler.defaultHandler.e4.DefaultOpenSetBaseHandler;
|
23 |
26 |
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
|
24 |
27 |
import eu.etaxonomy.taxeditor.security.RequiredPermissions;
|
25 |
28 |
import eu.etaxonomy.taxeditor.store.CdmStore;
|
26 |
29 |
|
27 |
|
public class OpenChecklistEditorHandlerE4 extends DefaultOpenHandlerBaseE4<ITaxonTreeNode> {
|
|
30 |
public class OpenChecklistEditorHandlerE4 extends DefaultOpenSetBaseHandler<List<UuidAndTitleCache>> {
|
28 |
31 |
@Inject
|
29 |
32 |
private Logger logger;
|
30 |
33 |
private static final String COULD_NOT_OPEN_DISTRIBUTION_EDITOR_THE_HIERARCHY_IS_CORRUPTED = Messages.OpenChecklistEditorHandler_COULD_NOT_OPEN_MESSAGE;
|
31 |
34 |
private static final String COULD_NOT_OPEN_DISTRIBUTION_EDITOR = Messages.OpenChecklistEditorHandler_COULD_NOT_OPEN_TITLE;
|
32 |
35 |
|
33 |
|
@Override
|
34 |
|
protected ITaxonTreeNode getEntity(UUID uuid) {
|
35 |
|
ITaxonTreeNode taxonTreeNode = CdmStore.getService(ITaxonNodeService.class).load(uuid);
|
36 |
|
if(taxonTreeNode==null){
|
37 |
|
taxonTreeNode = CdmStore.getService(IClassificationService.class).load(uuid);
|
38 |
|
}
|
39 |
|
return taxonTreeNode;
|
40 |
|
}
|
|
36 |
|
41 |
37 |
|
42 |
38 |
@Override
|
43 |
|
protected void open(ITaxonTreeNode entity, Shell shell, EPartService partService) {
|
44 |
|
|
45 |
|
// if (PreferencesUtil.getBooleanValue(EditorPreferencePredicate.DistributionEditorActivated.getKey())) {
|
46 |
|
// if (StringUtils.isBlank(PreferencesUtil.getStringValue(PreferencePredicate.AvailableDistributionAreaVocabularies.getKey()) )){
|
47 |
|
//
|
48 |
|
// MessagingUtils.informationDialog(Messages.OpenChecklistEditorHandler_NO_AREAS, Messages.OpenChecklistEditorHandler_CHOOSE_AREA
|
49 |
|
// + Messages.OpenChecklistEditorHandler_GOTO_PREFERENCES);
|
50 |
|
// return;
|
51 |
|
// }
|
52 |
|
// if (entity instanceof Classification) {
|
53 |
|
// ChecklistEditorInput input = new ChecklistEditorInput(((Classification) entity));
|
54 |
|
// try {
|
55 |
|
// openChecklistEditor(input, partService);
|
56 |
|
// } catch (NullPointerException npe) {
|
57 |
|
// MessagingUtils.messageDialog(COULD_NOT_OPEN_DISTRIBUTION_EDITOR, OpenChecklistEditorHandlerE4.class,
|
58 |
|
// COULD_NOT_OPEN_DISTRIBUTION_EDITOR_THE_HIERARCHY_IS_CORRUPTED, npe);
|
59 |
|
// }
|
60 |
|
// } else if (entity instanceof TaxonNode) {
|
61 |
|
// ChecklistEditorInput input = new ChecklistEditorInput((TaxonNode) entity);
|
62 |
|
// try {
|
63 |
|
// openChecklistEditor(input, partService);
|
64 |
|
// } catch (NullPointerException npe) {
|
65 |
|
// MessagingUtils.messageDialog(COULD_NOT_OPEN_DISTRIBUTION_EDITOR, OpenChecklistEditorHandlerE4.class,
|
66 |
|
// COULD_NOT_OPEN_DISTRIBUTION_EDITOR_THE_HIERARCHY_IS_CORRUPTED, npe);
|
67 |
|
// }
|
68 |
|
// }
|
69 |
|
// }
|
70 |
|
|
71 |
|
EditorUtil.openDistributionEditor(entity.getUuid(), modelService, partService, application);
|
|
39 |
protected void open(List<UuidAndTitleCache> entities, Shell shell, EPartService partService) {
|
|
40 |
|
|
41 |
EditorUtil.openDistributionEditor(entities, modelService, partService, application);
|
72 |
42 |
}
|
73 |
43 |
|
74 |
|
// private void openChecklistEditor(ChecklistEditorInput input, EPartService partService) {
|
75 |
|
// MPart part = partService.createPart(AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_CHECKLIST_E4_CHECKLISTEDITORE4);
|
76 |
|
// MPartStack editorAreaPartStack = WorkbenchUtility.getEditorAreaPartStack(application, modelService);
|
77 |
|
// if(editorAreaPartStack!=null){
|
78 |
|
// editorAreaPartStack.getChildren().add(part);
|
79 |
|
// }
|
80 |
|
// part = partService.showPart(part, PartState.ACTIVATE);
|
81 |
|
// ChecklistEditorE4 checklistEditor = (ChecklistEditorE4) part.getObject();
|
82 |
|
// if (checklistEditor != null){
|
83 |
|
// checklistEditor.init(input);
|
84 |
|
// }else{
|
85 |
|
// logger.debug("Editor is null");
|
86 |
|
// }
|
87 |
|
// }
|
|
44 |
|
88 |
45 |
|
89 |
46 |
/**
|
90 |
47 |
* {@inheritDoc}
|
91 |
48 |
*/
|
|
49 |
@CanExecute
|
92 |
50 |
@Override
|
93 |
|
protected boolean canExecute(ITaxonTreeNode entity) {
|
|
51 |
public boolean canExecute(MHandledMenuItem menuItem,
|
|
52 |
@Named(IServiceConstants.ACTIVE_PART) MPart activePart) {
|
94 |
53 |
|
95 |
54 |
Distribution instance = Distribution.NewInstance();
|
96 |
55 |
boolean hasDescriptionPermission = CdmStore.currentAuthentiationHasPermission(instance, Operation.ALL);
|
... | ... | |
123 |
82 |
}
|
124 |
83 |
return result;
|
125 |
84 |
}
|
|
85 |
|
|
86 |
|
|
87 |
|
|
88 |
@Override
|
|
89 |
protected boolean canExecute(IStructuredSelection entity) {
|
|
90 |
// TODO Auto-generated method stub
|
|
91 |
return true;
|
|
92 |
}
|
|
93 |
|
|
94 |
|
126 |
95 |
}
|
ref #8047: improve handling of factual data view when switching views