eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/group/authority/CdmAuthorityEditorInput.java -text
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/group/authority/handler/EditCdmAuthoritiesHandler.java -text
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/EditNewTaxonHandler.java -text
+eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/FixClassificationHierarchyHandler.java -text
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/OpenChecklistEditorHandler.java -text
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/OpenDerivateViewHandler.java -text
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/OpenParentHandler.java -text
class="eu.etaxonomy.taxeditor.editor.view.descriptive.handler.ToggleShowOnlyIndividualAssociationsHandler"
commandId="eu.etaxonomy.taxeditor.editor.handler.showOnlyIndividualAssociations">
</handler>
+ <handler
+ class="eu.etaxonomy.taxeditor.editor.handler.FixClassificationHierarchyHandler"
+ commandId="eu.etaxonomy.taxeditor.editor.handler.FixClassificationHierarchyHandler">
+ </handler>
</extension>
<extension
name="%extension.name"
id="eu.etaxonomy.taxeditor.editor.derivate.deepDelete"
name="Deep Delete">
</command>
+ <command
+ defaultHandler="eu.etaxonomy.taxeditor.editor.handler.FixClassificationHierarchyHandler"
+ id="eu.etaxonomy.taxeditor.editor.handler.OpenFixClassificationHierarchyHandler"
+ name="Fix Classification Hierarchy">
+ </command>
</extension>
<extension
point="org.eclipse.core.expressions.definitions">
--- /dev/null
+package eu.etaxonomy.taxeditor.editor.handler;
+
+import org.apache.log4j.Logger;
+import org.eclipse.core.commands.AbstractHandler;
+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.handlers.HandlerUtil;
+
+import eu.etaxonomy.cdm.api.service.IClassificationService;
+import eu.etaxonomy.cdm.model.taxon.Classification;
+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 FixClassificationHierarchyHandler extends AbstractHandler {
+
+ private static final Logger logger = Logger.getLogger(FixClassificationHierarchyHandler.class);
+
+ /*
+ * (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) {
+
+ Classification classification = (Classification) selectedElement;
+ try {
+ IClassificationService service = CdmStore.getService(IClassificationService.class);
+
+ // Map<String, List<TaxonNode>> sortedGenusList =
+ // service.getSortedGenusList(classification.getAllNodes());
+
+ Classification newClassification = service.createHierarchyInClassification(classification, null);
+
+ MessagingUtils.messageDialog("Fix Hierarchy successful",
+ FixClassificationHierarchyHandler.class, "Operation 'Fix Hierarchy' was successful. New classification is " + newClassification.getTitleCache());
+
+ } catch (Exception e) {
+ MessagingUtils.messageDialog("Failed to open Editor", FixClassificationHierarchyHandler.class,
+ "Could not open ChecklistView. The hierarchy is corrupted!", e);
+ }
+ }
+ }
+ }
+ return null;
+ }
+}
</and>
</visibleWhen>
</command>
+ <command
+ commandId="eu.etaxonomy.taxeditor.editor.handler.OpenFixClassificationHierarchyHandler"
+ label="Fix Classification Hierarchy"
+ style="push">
+ <visibleWhen
+ checkEnabled="true">
+ <and>
+ <reference
+ definitionId="isShowExperimentalFeatures">
+ </reference>
+ <reference
+ definitionId="isClassification">
+ </reference>
+ </and>
+ </visibleWhen>
+ </command>
<separator
name="taxeditor-navigation.separator1"
visible="true">
properties="isCdmStoreConnected"
type="org.eclipse.jface.viewers.IStructuredSelection">
</propertyTester>
+ <propertyTester
+ class="eu.etaxonomy.taxeditor.preference.PreferencePropertyTester"
+ id="eu.etaxonomy.taxeditor.preferences.propertyTester"
+ namespace="eu.etaxonomy.taxeditor.preferences.propertyTester"
+ properties="isShowExperimentalFeatures"
+ type="org.eclipse.jface.viewers.IStructuredSelection">
+ </propertyTester>
</extension>
<extension
point="org.eclipse.core.expressions.definitions">
</test>
</with>
</definition>
+ <definition
+ id="isShowExperimentalFeatures">
+ <with
+ variable="selection">
+ <test
+ property="eu.etaxonomy.taxeditor.preferences.propertyTester.isShowExperimentalFeatures">
+ </test>
+ </with>
+ </definition>
</extension>
</plugin>