Project

General

Profile

« Previous | Next » 

Revision 858305df

Added by Katja Luther almost 7 years ago

adapt propertyTester to navigator changes

View differences:

eu.etaxonomy.taxeditor.navigation/plugin.xml
144 144
                  <reference
145 145
                        definitionId="isShowExperimentalFeatures">
146 146
                  </reference>
147
                  <reference
148
                        definitionId="isClassification">
149
                  </reference>
147
                  <test
148
                        property="eu.etaxonomy.taxeditor.navigation.navigator.navigatorPropertyTester.isClassification">
149
                  </test>
150 150
               </and>
151 151
            </visibleWhen>
152 152
         </command>
......
160 160
                  <reference
161 161
                        definitionId="isShowExperimentalFeatures">
162 162
                  </reference>
163
                  <reference
164
                        definitionId="isClassification">
165
                  </reference>
163
                  <test
164
                        property="eu.etaxonomy.taxeditor.navigation.navigator.navigatorPropertyTester.isClassification">
165
                  </test>
166 166
               </and>
167 167
            </visibleWhen>
168 168
         </command>
......
183 183
                     <reference
184 184
                           definitionId="isTaxonNode">
185 185
                     </reference>
186
                     <not>
187
                     <test
188
                           property="eu.etaxonomy.taxeditor.navigation.navigator.navigatorPropertyTester.isClassification">
189
                     </test>
190
                     </not>
186 191
                  </and>
187 192
            </visibleWhen>
188 193
         </command>
......
205 210
               style="push">
206 211
            <visibleWhen
207 212
                  checkEnabled="true">
208
                  <reference
209
                        definitionId="isTaxonNode">
210
                  </reference>
213
                  <and>
214
	                  <reference
215
	                        definitionId="isTaxonNode">
216
	                  </reference>
217
	                  <not>
218
	                     <test
219
	                           property="eu.etaxonomy.taxeditor.navigation.navigator.navigatorPropertyTester.isClassification">
220
	                     </test>
221
	                  </not>
222
                  </and>
211 223
            </visibleWhen>
212 224
         </command>
213 225
         <command
......
223 235
                  <reference
224 236
                        definitionId="isTaxonNode">
225 237
                  </reference>
238
                  <not>
239
                     <test
240
                           property="eu.etaxonomy.taxeditor.navigation.navigator.navigatorPropertyTester.isClassification">
241
                     </test>
242
                  </not>
243
                     
226 244
               </and>
227 245
            </visibleWhen>
228 246
         </command>
......
693 711
            labelProvider="eu.etaxonomy.taxeditor.navigation.navigator.TaxonNodeLabelProvider"
694 712
            name="%navigatorContent.name.0">
695 713
         <triggerPoints>
696
            <or>
714
            
697 715
               <instanceof
698 716
                     value="eu.etaxonomy.cdm.model.taxon.TaxonNode">
699 717
               </instanceof>
700
               <and>
701
                  <instanceof
702
                     value="eu.etaxonomy.cdm.model.taxon.Classification">
703
                  </instanceof>
704
                  <test
705
                     forcePluginActivation="true"
706
                     property="eu.etaxonomy.taxeditor.propertytests.hasTaxa">
707
                  </test>
708
               </and>
709
            </or>
718
                
719
            
710 720
         </triggerPoints>
711 721
         <dropAssistant
712 722
               class="eu.etaxonomy.taxeditor.navigation.navigator.TreeNodeDropAdapterAssistant"
......
815 825
         point="org.eclipse.core.expressions.propertyTesters">
816 826
      <propertyTester
817 827
            class="eu.etaxonomy.taxeditor.navigation.navigator.TaxonNodePropertyTester"
818
            id="eu.etaxonomy.taxeditor.propertytests.navigatorPropertyTester"
819
            namespace="eu.etaxonomy.taxeditor.propertytests"
820
            properties="hasSynonyms"
821
            type="eu.etaxonomy.cdm.model.taxon.TaxonNode">
828
            id="eu.etaxonomy.taxeditor.navigation.navigator.navigatorPropertyTester"
829
            namespace="eu.etaxonomy.taxeditor.navigation.navigator.navigatorPropertyTester"
830
            properties="hasSynonyms, isClassification"
831
            type="java.lang.Object">
822 832
      </propertyTester>
823
      <propertyTester
824
            class="eu.etaxonomy.taxeditor.navigation.navigator.TaxonNodePropertyTester"
825
            id="eu.etaxonomy.taxeditor.propertytests.navigatorPropertyTester"
826
            namespace="eu.etaxonomy.taxeditor.propertytests"
833
      
834
     <propertyTester
835
             class="eu.etaxonomy.taxeditor.navigation.navigator.TaxonNodePropertyTester"
836
            id="eu.etaxonomy.taxeditor.navigation.navigator.navigatorPropertyTester"
837
            namespace="eu.etaxonomy.taxeditor.navigation.navigator.navigatorPropertyTester"
827 838
            properties="hasTaxa"
828 839
            type="eu.etaxonomy.cdm.model.taxon.TaxonomicTree">
829 840
      </propertyTester>
830 841
      <propertyTester
831
            class="eu.etaxonomy.taxeditor.navigation.navigator.TaxonNodePropertyTester"
832
            id="eu.etaxonomy.taxeditor.propertytests.navigatorPropertyTester"
833
            namespace="eu.etaxonomy.taxeditor.propertytests"
842
             class="eu.etaxonomy.taxeditor.navigation.navigator.TaxonNodePropertyTester"
843
            id="eu.etaxonomy.taxeditor.navigation.navigator.navigatorPropertyTester"
844
            namespace="eu.etaxonomy.taxeditor.navigation.navigator.navigatorPropertyTester"
834 845
            properties="hasTaxa"
835
            type="eu.etaxonomy.cdm.model.taxon.Classification">
846
            type="eu.etaxonomy.cdm.model.taxon.TaxonNode">
836 847
      </propertyTester>
837 848
   <propertyTester
838 849
         class="eu.etaxonomy.taxeditor.preference.PreferencePropertyTester"
......
875 886
            </iterate>
876 887
         </with>
877 888
      </definition>
878
      <definition
879
            id="isClassification">
880
         <with
881
               variable="selection">
882
            <iterate
883
                  ifEmpty="false">
884
               <instanceof
885
                     value="eu.etaxonomy.cdm.model.taxon.Classification">
886
               </instanceof>
887
            </iterate>
888
         </with>
889
      </definition>
889
     
890 890
      <definition
891 891
            id="isChecklistEditorEnabled">
892 892
         <with
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TaxonNodePropertyTester.java
7 7
 */
8 8
package eu.etaxonomy.taxeditor.navigation.navigator;
9 9

  
10
import java.util.ArrayList;
11
import java.util.Collection;
12

  
10 13
import org.eclipse.core.expressions.PropertyTester;
11 14

  
12 15
import eu.etaxonomy.cdm.model.taxon.Classification;
......
16 19
	
17 20
	private static final Object HAS_SYNONYMS = "hasSynonyms"; //$NON-NLS-1$
18 21
	private static final Object HAS_TAXA = "hasTaxa"; //$NON-NLS-1$
22
	private static final Object IS_CLASSIFICATION = "isClassification"; //$NON-NLS-1$
19 23
	
20 24
	/** {@inheritDoc} */
21 25
	public boolean test(Object receiver, String property, Object[] args,
22 26
			Object expectedValue) {
27
		if (receiver instanceof Collection){
28
			if (((Collection)receiver).iterator().hasNext()){
29
				receiver = ((Collection)receiver).iterator().next();
30
			}
31
		}
23 32
		if (receiver instanceof TaxonNode && HAS_SYNONYMS.equals(property)) {
24 33
			Taxon taxon = ((TaxonNode) receiver).getTaxon();
25 34
			if(taxon != null){
......
27 36
			}
28 37
		}
29 38

  
30
		if (receiver instanceof Classification && HAS_TAXA.equals(property)) {
31
			Classification taxononomicTree = (Classification) receiver;
32
			return taxononomicTree.getChildNodes().size() > 0;
39
		if (receiver instanceof TaxonNode && HAS_TAXA.equals(property)) {
40
			TaxonNode node = (TaxonNode) receiver;
41
			if (!node.hasTaxon()){
42
				return node.getChildNodes().size() > 0;
43
			}else{
44
				return false;
45
			}
46
		}
47
		if (receiver instanceof TaxonNode && IS_CLASSIFICATION.equals(property)) {
48
			TaxonNode node = (TaxonNode) receiver;
49
			return !node.hasTaxon();
33 50
		}
34 51
		
35 52
		return false;
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/CloneClassificationHandler.java
12 12

  
13 13
import eu.etaxonomy.cdm.model.reference.Reference;
14 14
import eu.etaxonomy.cdm.model.taxon.Classification;
15
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
15 16
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
16 17
import eu.etaxonomy.taxeditor.model.AbstractUtility;
17 18
import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
......
31 32
        ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
32 33
        if (currentSelection instanceof IStructuredSelection) {
33 34
            Object selectedElement = ((IStructuredSelection) currentSelection).getFirstElement();
34
            if (selectedElement instanceof Classification) {
35
                Classification classification = (Classification) selectedElement;
35
            if (selectedElement instanceof TaxonNode && !((TaxonNode)selectedElement).hasTaxon()) {
36
                Classification classification = ((TaxonNode)selectedElement).getClassification();
36 37
                TaxonNavigator taxonNavigator = (TaxonNavigator)AbstractUtility.showView(TaxonNavigator.ID);
37 38
                CloneClassificationWizard wizard = new CloneClassificationWizard(classification);
38 39
                WizardDialog dialog = new WizardDialog(Display.getCurrent().getActiveShell(), wizard);

Also available in: Unified diff