</with>
</activeWhen>
</handler>
- <handler
- class="eu.etaxonomy.taxeditor.editor.handler.OpenChecklistEditorHandler"
- commandId="eu.etaxonomy.taxeditor.editor.handler.OpenChecklistEditorHandler">
- </handler>
<handler
class="eu.etaxonomy.taxeditor.editor.view.derivate.handler.DeleteDerivateHandler"
commandId="org.eclipse.ui.edit.delete">
</with>
</activeWhen>
</handler>
+ <handler
+ class="eu.etaxonomy.taxeditor.editor.handler.OpenChecklistEditorHandler"
+ commandId="eu.etaxonomy.taxeditor.editor.handler.OpenChecklistViewHandler">
+ <activeWhen>
+ <and>
+ <reference
+ definitionId="isChecklistEditorEnabled">
+ </reference>
+ <or>
+ <reference
+ definitionId="isTaxonNode">
+ </reference>
+ <reference
+ definitionId="isClassification">
+ </reference>
+ </or>
+ </and>
+ </activeWhen>
+ </handler>
</extension>
<extension
name="%extension.name"
name="%command.name.34">
</command>
<command
- defaultHandler="eu.etaxonomy.taxeditor.editor.handler.OpenChecklistEditorHandler"
id="eu.etaxonomy.taxeditor.editor.handler.OpenChecklistViewHandler"
name="%command.name.38">
+ <commandParameter
+ id="eu.etaxonomy.taxeditor.editor.handler.OpenChecklistViewHandler.uuid"
+ name="taxonNodeUuid"
+ optional="true"
+ typeId="eu.etaxonomy.taxeditor.uuidParameterType">
+ </commandParameter>
</command>
<command
categoryId="eu.etaxonomy.taxeditor.editor.new.category"
selection="eu.etaxonomy.cdm.model.taxon.TaxonNode"
viewerName="%viewCommandMapping.viewerName.SPECIMEN_EDITOR">
</viewCommandMapping>
+ <viewCommandMapping
+ commandId="eu.etaxonomy.taxeditor.editor.handler.OpenChecklistViewHandler"
+ selection="eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode"
+ viewerName="%viewCommandMapping.viewerName.CHECKLIST_EDITOR">
+ </viewCommandMapping>
</extension>
</plugin>
package eu.etaxonomy.taxeditor.editor.handler;
-import org.apache.log4j.Logger;
-import org.eclipse.core.commands.AbstractHandler;
+import java.util.UUID;
+
import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.handlers.HandlerUtil;
+import eu.etaxonomy.cdm.api.service.IClassificationService;
+import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
import eu.etaxonomy.cdm.model.taxon.Classification;
+import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
import eu.etaxonomy.taxeditor.editor.EditorUtil;
import eu.etaxonomy.taxeditor.editor.view.checklist.ChecklistEditorInput;
-import eu.etaxonomy.taxeditor.model.AbstractUtility;
+import eu.etaxonomy.taxeditor.handler.defaultHandler.DefaultOpenHandlerBase;
import eu.etaxonomy.taxeditor.model.MessagingUtils;
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
+import eu.etaxonomy.taxeditor.store.CdmStore;
-public class OpenChecklistEditorHandler extends AbstractHandler {
+public class OpenChecklistEditorHandler extends DefaultOpenHandlerBase<ITaxonTreeNode> {
- private static final Logger logger = Logger.getLogger(OpenChecklistEditorHandler.class);
+ @Override
+ protected ITaxonTreeNode getEntity(UUID uuid) {
+ ITaxonTreeNode taxonTreeNode = CdmStore.getService(ITaxonNodeService.class).load(uuid);
+ if(taxonTreeNode==null){
+ taxonTreeNode = CdmStore.getService(IClassificationService.class).load(uuid);
+ }
+ return taxonTreeNode;
+ }
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.
- * ExecutionEvent)
- */
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
- boolean isChecklistEditorActivated = PreferencesUtil.getPreferenceStore().getBoolean(
- IPreferenceKeys.DISTRIBUTION_AREA_PREFRENCES_ACTIVE);
- if (isChecklistEditorActivated) {
- ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
- if (currentSelection instanceof IStructuredSelection) {
- Object selectedElement = ((IStructuredSelection) currentSelection).getFirstElement();
- if (selectedElement instanceof Classification) {
- ChecklistEditorInput input = new ChecklistEditorInput(((Classification) selectedElement));
- try {
- EditorUtil.open(input);
- } catch (PartInitException e) {
- MessagingUtils.error(OpenChecklistEditorHandler.class, "Could not open ChecklistView", e);
- } catch (NullPointerException npe) {
- MessagingUtils.messageDialog("Failed to open Editor", OpenChecklistEditorHandler.class,
- "Could not open ChecklistView. The hierarchy is corrupted!", npe);
- }
- } else if (selectedElement instanceof TaxonNode) {
- ChecklistEditorInput input = new ChecklistEditorInput(((TaxonNode) selectedElement));
- try {
- EditorUtil.open(input);
- } catch (PartInitException e) {
- MessagingUtils.error(OpenChecklistEditorHandler.class, "Could not open ChecklistView", e);
- } catch (NullPointerException npe) {
- MessagingUtils.messageDialog("Failed to open Editor", OpenChecklistEditorHandler.class,
- "Could not open ChecklistView. The hierarchy is corrupted!", npe);
- }
- }
- }
- }
- return null;
- }
+ @Override
+ protected void open(ExecutionEvent event, ITaxonTreeNode entity) {
+ if (PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.DISTRIBUTION_AREA_PREFRENCES_ACTIVE)) {
+ if (entity instanceof Classification) {
+ ChecklistEditorInput input = new ChecklistEditorInput(((Classification) entity));
+ try {
+ EditorUtil.open(input);
+ } catch (PartInitException e) {
+ MessagingUtils.error(OpenChecklistEditorHandler.class, "Could not open ChecklistView", e);
+ } catch (NullPointerException npe) {
+ MessagingUtils.messageDialog("Failed to open Editor", OpenChecklistEditorHandler.class,
+ "Could not open ChecklistView. The hierarchy is corrupted!", npe);
+ }
+ } else if (entity instanceof TaxonNode) {
+ ChecklistEditorInput input = new ChecklistEditorInput((TaxonNode) entity);
+ try {
+ EditorUtil.open(input);
+ } catch (PartInitException e) {
+ MessagingUtils.error(OpenChecklistEditorHandler.class, "Could not open ChecklistView", e);
+ } catch (NullPointerException npe) {
+ MessagingUtils.messageDialog("Failed to open Editor", OpenChecklistEditorHandler.class,
+ "Could not open ChecklistView. The hierarchy is corrupted!", npe);
+ }
+ }
+ }
+ }
}