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
;
19 * <p>DataSourceMenuPropertyTester class.</p>
22 * @created Sep 23, 2010
25 public class DataSourceMenuPropertyTester
extends PropertyTester
{
27 private static final String COMPATIBLE
= "isCompatible";
32 * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object,
33 * java.lang.String, java.lang.Object[], java.lang.Object)
37 public boolean test(Object receiver
, String property
, Object
[] args
,
38 Object expectedValue
) {
40 Object
[] selectedElements
= ((IStructuredSelection
) receiver
).toArray();
42 if (selectedElements
.length
== 0) {
43 // nothing selected so all tests should fail
47 if (COMPATIBLE
.equals(property
)) {
48 return isCompatible(selectedElements
);
55 * @param selectedElements
58 private boolean isCompatible(Object
[] selectedElements
) {
59 for (Object object
: selectedElements
) {
61 if (object
instanceof CdmMetaDataAwareDataSourceContainer
) {
62 CdmMetaDataAwareDataSourceContainer container
= (CdmMetaDataAwareDataSourceContainer
) object
;
63 return container
.isDataSourceCompatible();