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
.eclipse
.jface
.viewers
.ILabelProvider
;
13 import org
.eclipse
.ui
.views
.properties
.PropertyDescriptor
;
15 import eu
.etaxonomy
.cdm
.model
.reference
.ReferenceBase
;
18 * This subclass is for cases where only one subclass of <code>ReferenceBase</code>
19 * can be edited in the property source.
21 * For instance, if the user is editing an
22 * <code>Article</code>, one of its fields would be a
23 * <code>SingleRefTypePropertySource</code> restricted to a <code>Journal</code>,
24 * and the reference type drop-down would be replaced by the non-editable
31 public class SingleRefTypePropertySource
extends ReferencePropertySource
{
33 public static final String BOOK
= "Book";
34 public static final String JOURNAL
= "Journal";
36 private String referenceType
;
38 public SingleRefTypePropertySource(ReferenceBase
<?
> reference
, String referenceType
) {
41 this.referenceType
= referenceType
;
44 protected PropertyDescriptor
createReferenceTypeDescriptor() {
45 return new PropertyDescriptor(P_ID_REFERENCETYPE
, P_REFERENCETYPE
) {
46 public ILabelProvider
getLabelProvider() {
47 return super.getLabelProvider();
52 public Object
getPropertyValue(Object id
) {
54 // Reference Type: show non-editable reference type in property value
55 if (id
.equals(P_ID_REFERENCETYPE
)) {
59 return super.getPropertyValue(id
);