9b79702d042f645758f13ac1c5b994279abb2431
3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
11 package eu
.etaxonomy
.taxeditor
.propertysheet
.images
;
13 import java
.util
.Vector
;
15 import org
.apache
.log4j
.Logger
;
16 import org
.eclipse
.ui
.views
.properties
.IPropertyDescriptor
;
17 import org
.eclipse
.ui
.views
.properties
.IPropertySource
;
18 import org
.eclipse
.ui
.views
.properties
.PropertyDescriptor
;
20 import eu
.etaxonomy
.cdm
.model
.media
.ImageFile
;
21 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
28 public class ImagePropertySource
implements IPropertySource
{
29 private static final Logger logger
= Logger
30 .getLogger(ImagePropertySource
.class);
32 private ImageFile imageFile
;
36 // Property unique keys
37 public static final String P_ID_IMAGE
= "image";
39 // Property display keys
40 public static final String P_IMAGE
= "Image URI";
45 public ImagePropertySource(Taxon taxon
, ImageFile imageFile
) {
47 this.imageFile
= imageFile
;
49 addDescriptor(P_ID_IMAGE
);
52 protected Vector
<PropertyDescriptor
> descriptors
= new Vector
<PropertyDescriptor
>();
54 protected void addDescriptor(String id
) {
55 if (id
.equals(P_ID_IMAGE
)) {
56 descriptors
.addElement(
57 new PropertyDescriptor(P_ID_IMAGE
, P_IMAGE
));
62 * @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue()
64 public Object
getEditableValue() {
69 * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors()
71 public IPropertyDescriptor
[] getPropertyDescriptors() {
72 return (IPropertyDescriptor
[]) descriptors
.toArray(
73 new IPropertyDescriptor
[descriptors
.size()]);
77 * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object)
79 public Object
getPropertyValue(Object id
) {
80 if (id
.equals(P_ID_IMAGE
)) {
81 return imageFile
.getUri();
87 * @see org.eclipse.ui.views.properties.IPropertySource#isPropertySet(java.lang.Object)
89 public boolean isPropertySet(Object id
) {
94 * @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object)
96 public void resetPropertyValue(Object id
) {}
99 * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)
101 public void setPropertyValue(Object id
, Object value
) {
103 logger
.error("Not yet implemented.");
105 // if (id.equals(P_ID_IMAGE)) {
107 // // TODO put this in an operation to allow undo
108 // ImageFile imageFile = ImageFile.NewInstance((String) value, null);
110 // ImagesUtil.removeTaxonImage(taxon, imageFile);
111 // ImagesUtil.addTaxonImage(taxon, imageFile);
113 // this.imageFile = imageFile;
118 public ImageFile
getImageFile(){
123 * @param taxon the taxon to set
125 public void setTaxon(Taxon taxon
) {
132 public Taxon
getTaxon() {