Adjustments to recent changes in LibrAlign.
[taxeditor.git] / eu.etaxonomy.taxeditor.bulkeditor / src / main / java / eu / etaxonomy / taxeditor / bulkeditor / command / BulkEditorPropertyTester.java
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.OccurrenceEditorInput;
21 import eu.etaxonomy.taxeditor.bulkeditor.input.TaxonEditorInput;
22
23 /**
24 * <p>BulkEditorPropertyTester class.</p>
25 *
26 * @author p.ciardelli
27 * @created 21.09.2009
28 * @version 1.0
29 */
30 public class BulkEditorPropertyTester extends PropertyTester {
31
32 @SuppressWarnings("unused")
33 private static final Logger logger = Logger
34 .getLogger(BulkEditorPropertyTester.class);
35
36 private static final String IS_MERGING_ENABLED = "isMergingEnabled";
37
38 private static final String IS_GROUP_EDITOR = "isGroupEditor";
39 public static final String IS_DERIVED_UNIT_EDITOR = "isDerivedUnitEditor";
40 public static final String IS_TAXON_EDITOR = "isTaxonEditor";
41
42 /* (non-Javadoc)
43 * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
44 */
45 /** {@inheritDoc} */
46 @Override
47 public boolean test(Object receiver, String property, Object[] args,
48 Object expectedValue) {
49 BulkEditor bulkEditor = (BulkEditor) receiver;
50
51 if (IS_MERGING_ENABLED.equals(property)) {
52 IEditorInput input = bulkEditor.getEditorInput();
53 if (input instanceof AbstractBulkEditorInput) {
54 return ((AbstractBulkEditorInput<?>) input).isMergingEnabled();
55 }
56 }
57 else if(IS_GROUP_EDITOR.equals(property)){
58 return bulkEditor.getEditorInput() instanceof GroupEditorInput;
59 }
60 else if (IS_DERIVED_UNIT_EDITOR.equals(property)){
61 return bulkEditor.getEditorInput() instanceof OccurrenceEditorInput;
62 }
63 else if(IS_TAXON_EDITOR.equals(property)){
64 return bulkEditor.getEditorInput() instanceof TaxonEditorInput;
65 }
66 // if (("isPublishFlagEditingEnabled").equals(property)) {
67 // IEditorInput input = bulkEditor.getEditorInput();
68 // if (input instanceof NameEditorInput) {
69 // return ((NameEditorInput) input).isPublishFlagEnabled();
70 // }
71 // }
72 return false;
73 }
74 }