Project

General

Profile

Download (2.77 KB) Statistics
| Branch: | Tag: | Revision:
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
import org.eclipse.ui.IEditorInput;
16

    
17
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditor;
18
import eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput;
19
import eu.etaxonomy.taxeditor.bulkeditor.input.GroupEditorInput;
20
import eu.etaxonomy.taxeditor.bulkeditor.input.MediaEditorInput;
21
import eu.etaxonomy.taxeditor.bulkeditor.input.OccurrenceEditorInput;
22
import eu.etaxonomy.taxeditor.bulkeditor.input.TaxonEditorInput;
23

    
24
/**
25
 * @author p.ciardelli
26
 * @created 21.09.2009
27
 * @version 1.0
28
 */
29
public class BulkEditorPropertyTester extends PropertyTester {
30

    
31
    @SuppressWarnings("unused")
32
    private static final Logger logger = Logger
33
			.getLogger(BulkEditorPropertyTester.class);
34

    
35
	private static final String IS_MERGING_ENABLED = "isMergingEnabled";
36

    
37
	public static final String IS_GROUP_EDITOR = "isGroupEditor";
38
    public static final String IS_DERIVED_UNIT_EDITOR = "isDerivedUnitEditor";
39
    public static final String IS_TAXON_EDITOR = "isTaxonEditor";
40
    public static final String IS_CONVERT_ENABLED = "isConvertingEnabled";
41
    public static final String IS_PERSON = "isPerson";
42
    public static final String IS_TEAM = "isTeam";
43
    public static final String IS_MEDIA_EDITOR = "isMediaEditor";
44

    
45
    /** {@inheritDoc} */
46
	@Override
47
    public boolean test(Object receiver, String property, Object[] args,
48
			Object expectedValue) {
49
		BulkEditor bulkEditor = null;
50

    
51
		bulkEditor = (BulkEditor) receiver;
52
		if (IS_MERGING_ENABLED.equals(property)) {
53
			IEditorInput input = bulkEditor.getEditorInput();
54
			if (input instanceof AbstractBulkEditorInput) {
55
				return ((AbstractBulkEditorInput<?>) input).isMergingEnabled();
56
			}
57
		}
58
		if (IS_CONVERT_ENABLED.equals(property)) {
59
			IEditorInput input = bulkEditor.getEditorInput();
60
			if (input instanceof AbstractBulkEditorInput) {
61
				return ((AbstractBulkEditorInput<?>) input).isConvertingEnabled();
62
			}
63
		}
64
		else if(IS_GROUP_EDITOR.equals(property)){
65
			return bulkEditor.getEditorInput() instanceof GroupEditorInput;
66
		}
67
		else if (IS_DERIVED_UNIT_EDITOR.equals(property)){
68
            return bulkEditor.getEditorInput() instanceof OccurrenceEditorInput;
69
		}
70
        else if(IS_TAXON_EDITOR.equals(property)){
71
            return bulkEditor.getEditorInput() instanceof TaxonEditorInput;
72
        }
73
        else if(IS_MEDIA_EDITOR.equals(property)){
74
            return bulkEditor.getEditorInput() instanceof MediaEditorInput;
75
        }
76
		return false;
77
	}
78
}
(2-2/6)