(no commit message)
[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.jface.viewers.IStructuredSelection;
16 import org.eclipse.ui.IEditorInput;
17
18 import eu.etaxonomy.cdm.model.common.Group;
19 import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
20 import eu.etaxonomy.taxeditor.bulkeditor.BulkEditor;
21 import eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput;
22 import eu.etaxonomy.taxeditor.bulkeditor.input.GroupEditorInput;
23 import eu.etaxonomy.taxeditor.bulkeditor.input.OccurrenceEditorInput;
24 import eu.etaxonomy.taxeditor.ui.section.description.DerivedUnitElement;
25
26 /**
27 * <p>BulkEditorPropertyTester class.</p>
28 *
29 * @author p.ciardelli
30 * @created 21.09.2009
31 * @version 1.0
32 */
33 public class BulkEditorPropertyTester extends PropertyTester {
34 private static final Logger logger = Logger
35 .getLogger(BulkEditorPropertyTester.class);
36
37 private static final String GROUP = "isGroup";
38 private static final String DERIVEDUNIT = "isDerivedUnit";
39 /* (non-Javadoc)
40 * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
41 */
42 /** {@inheritDoc} */
43 public boolean test(Object receiver, String property, Object[] args,
44 Object expectedValue) {
45 BulkEditor bulkEditor = (BulkEditor) receiver;
46
47 if ("isMergingEnabled".equals(property)) {
48 IEditorInput input = bulkEditor.getEditorInput();
49 if (input instanceof AbstractBulkEditorInput) {
50 return ((AbstractBulkEditorInput) input).isMergingEnabled();
51 }
52 }
53 if(GROUP.equals(property)){
54 return isGroup(bulkEditor);
55 }
56
57 if (DERIVEDUNIT.equals(property)){
58
59 return isDerivedUnit(bulkEditor);
60 }
61 // if (("isPublishFlagEditingEnabled").equals(property)) {
62 // IEditorInput input = bulkEditor.getEditorInput();
63 // if (input instanceof NameEditorInput) {
64 // return ((NameEditorInput) input).isPublishFlagEnabled();
65 // }
66 // }
67 return false;
68 }
69
70 private boolean isDerivedUnit(BulkEditor bulkEditor) {
71 IEditorInput input = bulkEditor.getEditorInput();
72 return (input instanceof OccurrenceEditorInput) ? true : false;
73 }
74
75 private boolean isGroup(BulkEditor bulkEditor) {
76 IEditorInput input = bulkEditor.getEditorInput();
77 return (input instanceof GroupEditorInput) ? true : false;
78 }
79 }