1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2007 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
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.
|
9
|
*/
|
10
|
|
11
|
package eu.etaxonomy.taxeditor.bulkeditor.command;
|
12
|
|
13
|
import org.apache.log4j.Logger;
|
14
|
import org.eclipse.core.expressions.PropertyTester;
|
15
|
|
16
|
import org.eclipse.ui.IEditorInput;
|
17
|
|
18
|
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditor;
|
19
|
import eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput;
|
20
|
import eu.etaxonomy.taxeditor.bulkeditor.input.GroupEditorInput;
|
21
|
import eu.etaxonomy.taxeditor.bulkeditor.input.OccurrenceEditorInput;
|
22
|
import eu.etaxonomy.taxeditor.bulkeditor.input.TaxonEditorInput;
|
23
|
|
24
|
/**
|
25
|
* <p>BulkEditorPropertyTester class.</p>
|
26
|
*
|
27
|
* @author p.ciardelli
|
28
|
* @created 21.09.2009
|
29
|
* @version 1.0
|
30
|
*/
|
31
|
public class BulkEditorPropertyTester extends PropertyTester {
|
32
|
|
33
|
@SuppressWarnings("unused")
|
34
|
private static final Logger logger = Logger
|
35
|
.getLogger(BulkEditorPropertyTester.class);
|
36
|
|
37
|
private static final String IS_MERGING_ENABLED = "isMergingEnabled";
|
38
|
|
39
|
private static final String IS_GROUP_EDITOR = "isGroupEditor";
|
40
|
public static final String IS_DERIVED_UNIT_EDITOR = "isDerivedUnitEditor";
|
41
|
public static final String IS_TAXON_EDITOR = "isTaxonEditor";
|
42
|
public static final String IS_CONVERT_ENABLED = "isConvertingEnabled";
|
43
|
public static final String IS_PERSON = "isPerson";
|
44
|
public static final String IS_TEAM = "isTeam";
|
45
|
/* (non-Javadoc)
|
46
|
* @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
|
47
|
*/
|
48
|
/** {@inheritDoc} */
|
49
|
@Override
|
50
|
public boolean test(Object receiver, String property, Object[] args,
|
51
|
Object expectedValue) {
|
52
|
BulkEditor bulkEditor = null;
|
53
|
|
54
|
|
55
|
bulkEditor = (BulkEditor) receiver;
|
56
|
if (IS_MERGING_ENABLED.equals(property)) {
|
57
|
IEditorInput input = bulkEditor.getEditorInput();
|
58
|
if (input instanceof AbstractBulkEditorInput) {
|
59
|
return ((AbstractBulkEditorInput<?>) input).isMergingEnabled();
|
60
|
}
|
61
|
}
|
62
|
if (IS_CONVERT_ENABLED.equals(property)) {
|
63
|
IEditorInput input = bulkEditor.getEditorInput();
|
64
|
if (input instanceof AbstractBulkEditorInput) {
|
65
|
return ((AbstractBulkEditorInput<?>) input).isConvertingEnabled();
|
66
|
}
|
67
|
}
|
68
|
else if(IS_GROUP_EDITOR.equals(property)){
|
69
|
return bulkEditor.getEditorInput() instanceof GroupEditorInput;
|
70
|
}
|
71
|
else if (IS_DERIVED_UNIT_EDITOR.equals(property)){
|
72
|
return bulkEditor.getEditorInput() instanceof OccurrenceEditorInput;
|
73
|
}
|
74
|
else if(IS_TAXON_EDITOR.equals(property)){
|
75
|
return bulkEditor.getEditorInput() instanceof TaxonEditorInput;
|
76
|
}
|
77
|
|
78
|
// if (("isPublishFlagEditingEnabled").equals(property)) {
|
79
|
// IEditorInput input = bulkEditor.getEditorInput();
|
80
|
// if (input instanceof NameEditorInput) {
|
81
|
// return ((NameEditorInput) input).isPublishFlagEnabled();
|
82
|
// }
|
83
|
// }
|
84
|
return false;
|
85
|
}
|
86
|
}
|