2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.taxeditor
.propertysheet
.reference
;
12 import org
.apache
.log4j
.Logger
;
13 import org
.eclipse
.jface
.viewers
.ILabelProvider
;
14 import org
.eclipse
.swt
.graphics
.Color
;
15 import org
.eclipse
.ui
.views
.properties
.PropertyDescriptor
;
17 import eu
.etaxonomy
.cdm
.model
.reference
.Book
;
18 import eu
.etaxonomy
.cdm
.model
.reference
.Journal
;
19 import eu
.etaxonomy
.cdm
.model
.reference
.ReferenceBase
;
20 import eu
.etaxonomy
.taxeditor
.ITaxEditorConstants
;
21 import eu
.etaxonomy
.taxeditor
.TaxEditorPlugin
;
22 import eu
.etaxonomy
.taxeditor
.controller
.GlobalController
;
25 * This subclass is for cases where only one subclass of <code>ReferenceBase</code>
26 * can be edited in the property source.
28 * For instance, if the user is editing an
29 * <code>Article</code>, one of its fields would be a
30 * <code>SingleRefTypePropertySource</code> restricted to a <code>Journal</code>,
31 * and the reference type drop-down would be replaced by the non-editable
38 public class SingleRefTypePropertySource
extends ReferencePropertySource
{
39 private static final Logger logger
= Logger
40 .getLogger(SingleRefTypePropertySource
.class);
42 public static final String BOOK
= "Book";
43 public static final String JOURNAL
= "Journal";
45 private String referenceType
;
47 public SingleRefTypePropertySource(ReferenceBase reference
, String referenceType
) {
50 this.referenceType
= referenceType
;
53 protected PropertyDescriptor
createReferenceTypeDescriptor() {
54 return new PropertyDescriptor(P_ID_REFERENCETYPE
, P_REFERENCETYPE
) {
55 public ILabelProvider
getLabelProvider() {
56 return super.getLabelProvider();
61 public Object
getPropertyValue(Object id
) {
63 // Reference Type: show non-editable reference type in property value
64 if (id
.equals(P_ID_REFERENCETYPE
)) {
68 return super.getPropertyValue(id
);