Revision d45bc597
Added by Patrick Plitzner almost 8 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/datasource/handler/DataSourceMenuPropertyTester.java | ||
---|---|---|
1 | 1 |
// $Id$ |
2 | 2 |
/** |
3 | 3 |
* Copyright (C) 2007 EDIT |
4 |
* European Distributed Institute of Taxonomy
|
|
4 |
* European Distributed Institute of Taxonomy |
|
5 | 5 |
* http://www.e-taxonomy.eu |
6 |
*
|
|
6 |
* |
|
7 | 7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
8 | 8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
9 | 9 |
*/ |
... | ... | |
13 | 13 |
import org.eclipse.core.expressions.PropertyTester; |
14 | 14 |
import org.eclipse.jface.viewers.IStructuredSelection; |
15 | 15 |
|
16 |
import eu.etaxonomy.cdm.model.metadata.CdmMetaData.MetaDataPropertyName; |
|
16 | 17 |
import eu.etaxonomy.taxeditor.view.datasource.CdmMetaDataAwareDataSourceContainer; |
17 | 18 |
|
18 | 19 |
/** |
19 |
* <p>DataSourceMenuPropertyTester class.</p> |
|
20 |
* |
|
21 | 20 |
* @author n.hoffmann |
22 | 21 |
* @created Sep 23, 2010 |
23 | 22 |
* @version 1.0 |
... | ... | |
26 | 25 |
|
27 | 26 |
private static final String COMPATIBLE = "isCompatible"; |
28 | 27 |
private static final String TEST = "test"; |
28 |
private static final String HAS_DATA_MODEL = "hasDataModel"; |
|
29 | 29 |
|
30 |
/* |
|
31 |
* (non-Javadoc) |
|
32 |
* |
|
33 |
* @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, |
|
34 |
* java.lang.String, java.lang.Object[], java.lang.Object) |
|
35 |
*/ |
|
36 | 30 |
/** {@inheritDoc} */ |
37 | 31 |
@Override |
38 | 32 |
public boolean test(Object receiver, String property, Object[] args, |
39 | 33 |
Object expectedValue) { |
40 | 34 |
|
41 | 35 |
Object[] selectedElements = ((IStructuredSelection) receiver).toArray(); |
42 |
|
|
43 | 36 |
if (selectedElements.length == 0 && property.equals(TEST)) { |
44 | 37 |
// nothing selected so all tests should fail |
45 | 38 |
return true; |
... | ... | |
52 | 45 |
if (COMPATIBLE.equals(property)) { |
53 | 46 |
return isCompatible(selectedElements); |
54 | 47 |
} |
55 |
|
|
56 |
|
|
57 |
|
|
58 |
|
|
48 |
if (HAS_DATA_MODEL.equals(property)) { |
|
49 |
return hasDataModel(selectedElements); |
|
50 |
} |
|
59 | 51 |
return false; |
60 | 52 |
} |
61 | 53 |
|
54 |
private boolean hasDataModel(Object[] selectedElements) { |
|
55 |
|
|
56 |
if (selectedElements.length == 0 ) { |
|
57 |
// nothing selected so all tests should fail |
|
58 |
return false; |
|
59 |
} |
|
60 |
for (Object object : selectedElements) { |
|
61 |
|
|
62 |
if (object instanceof CdmMetaDataAwareDataSourceContainer) { |
|
63 |
CdmMetaDataAwareDataSourceContainer container = (CdmMetaDataAwareDataSourceContainer) object; |
|
64 |
String schemaVersion = container.getMetaData(MetaDataPropertyName.DB_SCHEMA_VERSION); |
|
65 |
return !schemaVersion.equals(CdmMetaDataAwareDataSourceContainer.DEFAULT_ENTRY); |
|
66 |
} |
|
67 |
} |
|
68 |
return false; |
|
69 |
|
|
70 |
} |
|
62 | 71 |
|
63 | 72 |
|
64 |
/** |
|
65 |
* @param selectedElements |
|
66 |
* @return |
|
67 |
*/ |
|
68 | 73 |
private boolean isCompatible(Object[] selectedElements) { |
69 |
|
|
74 |
|
|
70 | 75 |
if (selectedElements.length == 0 ) { |
71 | 76 |
// nothing selected so all tests should fail |
72 | 77 |
return false; |
... | ... | |
79 | 84 |
} |
80 | 85 |
} |
81 | 86 |
return false; |
82 |
|
|
87 |
|
|
83 | 88 |
} |
84 | 89 |
} |
Also available in: Unified diff
Remove "Close Connection" and changed "Connect" to "Create Data Model"
#5758