Project

General

Profile

« Previous | Next » 

Revision 32103a77

Added by Alexander Oppermann about 9 years ago

Added Create Hierarchy Service for Editor as a experimental feature

View differences:

.gitattributes
391 391
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/group/authority/CdmAuthorityEditorInput.java -text
392 392
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/group/authority/handler/EditCdmAuthoritiesHandler.java -text
393 393
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/EditNewTaxonHandler.java -text
394
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/FixClassificationHierarchyHandler.java -text
394 395
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/OpenChecklistEditorHandler.java -text
395 396
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/OpenDerivateViewHandler.java -text
396 397
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/OpenParentHandler.java -text
eu.etaxonomy.taxeditor.editor/plugin.xml
1103 1103
            class="eu.etaxonomy.taxeditor.editor.view.descriptive.handler.ToggleShowOnlyIndividualAssociationsHandler"
1104 1104
            commandId="eu.etaxonomy.taxeditor.editor.handler.showOnlyIndividualAssociations">
1105 1105
      </handler>
1106
      <handler
1107
            class="eu.etaxonomy.taxeditor.editor.handler.FixClassificationHierarchyHandler"
1108
            commandId="eu.etaxonomy.taxeditor.editor.handler.FixClassificationHierarchyHandler">
1109
      </handler>
1106 1110
   </extension>
1107 1111
   <extension
1108 1112
         name="%extension.name"
......
1412 1416
            id="eu.etaxonomy.taxeditor.editor.derivate.deepDelete"
1413 1417
            name="Deep Delete">
1414 1418
      </command>
1419
      <command
1420
            defaultHandler="eu.etaxonomy.taxeditor.editor.handler.FixClassificationHierarchyHandler"
1421
            id="eu.etaxonomy.taxeditor.editor.handler.OpenFixClassificationHierarchyHandler"
1422
            name="Fix Classification Hierarchy">
1423
      </command>
1415 1424
   </extension>
1416 1425
   <extension
1417 1426
         point="org.eclipse.core.expressions.definitions">
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/FixClassificationHierarchyHandler.java
1
package eu.etaxonomy.taxeditor.editor.handler;
2

  
3
import org.apache.log4j.Logger;
4
import org.eclipse.core.commands.AbstractHandler;
5
import org.eclipse.core.commands.ExecutionEvent;
6
import org.eclipse.core.commands.ExecutionException;
7
import org.eclipse.jface.viewers.ISelection;
8
import org.eclipse.jface.viewers.IStructuredSelection;
9
import org.eclipse.ui.handlers.HandlerUtil;
10

  
11
import eu.etaxonomy.cdm.api.service.IClassificationService;
12
import eu.etaxonomy.cdm.model.taxon.Classification;
13
import eu.etaxonomy.taxeditor.model.MessagingUtils;
14
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
15
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
16
import eu.etaxonomy.taxeditor.store.CdmStore;
17

  
18
public class FixClassificationHierarchyHandler extends AbstractHandler {
19

  
20
    private static final Logger logger = Logger.getLogger(FixClassificationHierarchyHandler.class);
21

  
22
    /*
23
     * (non-Javadoc)
24
     *
25
     * @see
26
     * org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.
27
     * ExecutionEvent)
28
     */
29
    @Override
30
    public Object execute(ExecutionEvent event) throws ExecutionException {
31
        boolean isChecklistEditorActivated = PreferencesUtil.getPreferenceStore().getBoolean(
32
                IPreferenceKeys.DISTRIBUTION_AREA_PREFRENCES_ACTIVE);
33
        if (isChecklistEditorActivated) {
34
            ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
35
            if (currentSelection instanceof IStructuredSelection) {
36
                Object selectedElement = ((IStructuredSelection) currentSelection).getFirstElement();
37
                if (selectedElement instanceof Classification) {
38

  
39
                    Classification classification = (Classification) selectedElement;
40
                    try {
41
                        IClassificationService service = CdmStore.getService(IClassificationService.class);
42

  
43
                        // Map<String, List<TaxonNode>> sortedGenusList =
44
                        // service.getSortedGenusList(classification.getAllNodes());
45

  
46
                        Classification newClassification = service.createHierarchyInClassification(classification, null);
47

  
48
                        MessagingUtils.messageDialog("Fix Hierarchy successful",
49
                                FixClassificationHierarchyHandler.class, "Operation 'Fix Hierarchy' was successful. New classification is " + newClassification.getTitleCache());
50

  
51
                    } catch (Exception e) {
52
                        MessagingUtils.messageDialog("Failed to open Editor", FixClassificationHierarchyHandler.class,
53
                                "Could not open ChecklistView. The hierarchy is corrupted!", e);
54
                    }
55
                }
56
            }
57
        }
58
        return null;
59
    }
60
}
eu.etaxonomy.taxeditor.navigation/plugin.xml
127 127
              </and>
128 128
            </visibleWhen>
129 129
         </command>
130
         <command
131
               commandId="eu.etaxonomy.taxeditor.editor.handler.OpenFixClassificationHierarchyHandler"
132
               label="Fix Classification Hierarchy"
133
               style="push">
134
            <visibleWhen
135
                  checkEnabled="true">
136
               <and>
137
                  <reference
138
                        definitionId="isShowExperimentalFeatures">
139
                  </reference>
140
                  <reference
141
                        definitionId="isClassification">
142
                  </reference>
143
               </and>
144
            </visibleWhen>
145
         </command>
130 146
         <separator
131 147
               name="taxeditor-navigation.separator1"
132 148
               visible="true">
......
670 686
         properties="isCdmStoreConnected"
671 687
         type="org.eclipse.jface.viewers.IStructuredSelection">
672 688
   </propertyTester>
689
   <propertyTester
690
         class="eu.etaxonomy.taxeditor.preference.PreferencePropertyTester"
691
         id="eu.etaxonomy.taxeditor.preferences.propertyTester"
692
         namespace="eu.etaxonomy.taxeditor.preferences.propertyTester"
693
         properties="isShowExperimentalFeatures"
694
         type="org.eclipse.jface.viewers.IStructuredSelection">
695
   </propertyTester>
673 696
   </extension>
674 697
   <extension
675 698
         point="org.eclipse.core.expressions.definitions">
......
727 750
            </test>
728 751
         </with>
729 752
      </definition>
753
      <definition
754
            id="isShowExperimentalFeatures">
755
         <with
756
               variable="selection">
757
            <test
758
                  property="eu.etaxonomy.taxeditor.preferences.propertyTester.isShowExperimentalFeatures">
759
            </test>
760
         </with>
761
      </definition>
730 762
   </extension>
731 763
</plugin>

Also available in: Unified diff