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
.ui
.views
.properties
.PropertyDescriptor
;
16 import eu
.etaxonomy
.cdm
.model
.reference
.ReferenceBase
;
19 * This subclass is for cases where only one subclass of <code>ReferenceBase</code>
20 * can be edited in the property source.
22 * For instance, if the user is editing an
23 * <code>Article</code>, one of its fields would be a
24 * <code>SingleRefTypePropertySource</code> restricted to a <code>Journal</code>,
25 * and the reference type drop-down would be replaced by the non-editable
32 public class SingleRefTypePropertySource
extends ReferencePropertySource
{
33 private static final Logger logger
= Logger
34 .getLogger(SingleRefTypePropertySource
.class);
36 public static final String BOOK
= "Book";
37 public static final String JOURNAL
= "Journal";
39 private String referenceType
;
41 public SingleRefTypePropertySource(ReferenceBase reference
, String referenceType
) {
44 this.referenceType
= referenceType
;
47 protected PropertyDescriptor
createReferenceTypeDescriptor() {
48 return new PropertyDescriptor(P_ID_REFERENCETYPE
, P_REFERENCETYPE
) {
49 public ILabelProvider
getLabelProvider() {
50 return super.getLabelProvider();
55 public Object
getPropertyValue(Object id
) {
57 // Reference Type: show non-editable reference type in property value
58 if (id
.equals(P_ID_REFERENCETYPE
)) {
62 return super.getPropertyValue(id
);