3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
11 package eu
.etaxonomy
.taxeditor
.datasource
.handler
;
13 import org
.eclipse
.core
.expressions
.PropertyTester
;
14 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
16 import eu
.etaxonomy
.taxeditor
.datasource
.view
.CdmMetaDataAwareDataSourceContainer
;
17 import eu
.etaxonomy
.taxeditor
.preference
.IPreferenceKeys
;
18 import eu
.etaxonomy
.taxeditor
.preference
.PreferencesUtil
;
21 * <p>DataSourceMenuPropertyTester class.</p>
24 * @created Sep 23, 2010
27 public class DataSourceMenuPropertyTester
extends PropertyTester
{
29 private static final String COMPATIBLE
= "isCompatible";
34 * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object,
35 * java.lang.String, java.lang.Object[], java.lang.Object)
39 public boolean test(Object receiver
, String property
, Object
[] args
,
40 Object expectedValue
) {
42 Object
[] selectedElements
= ((IStructuredSelection
) receiver
).toArray();
44 if (selectedElements
.length
== 0) {
45 // nothing selected so all tests should fail
49 if (COMPATIBLE
.equals(property
)) {
50 return isCompatible(selectedElements
);
60 * @param selectedElements
63 private boolean isCompatible(Object
[] selectedElements
) {
64 for (Object object
: selectedElements
) {
66 if (object
instanceof CdmMetaDataAwareDataSourceContainer
) {
67 CdmMetaDataAwareDataSourceContainer container
= (CdmMetaDataAwareDataSourceContainer
) object
;
68 return container
.isDataSourceCompatible();