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.propertysheet.images;
|
12
|
|
13
|
import java.util.Vector;
|
14
|
|
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;
|
19
|
import org.eclipse.ui.views.properties.TextPropertyDescriptor;
|
20
|
|
21
|
import eu.etaxonomy.cdm.model.media.ImageFile;
|
22
|
import eu.etaxonomy.cdm.model.taxon.Taxon;
|
23
|
|
24
|
/**
|
25
|
* @author p.ciardelli
|
26
|
* @created 30.03.2009
|
27
|
* @version 1.0
|
28
|
*/
|
29
|
public class ImagePropertySource implements IPropertySource {
|
30
|
private static final Logger logger = Logger
|
31
|
.getLogger(ImagePropertySource.class);
|
32
|
|
33
|
private ImageFile imageFile;
|
34
|
|
35
|
private Taxon taxon;
|
36
|
|
37
|
// Property unique keys
|
38
|
public static final String P_ID_IMAGE = "image";
|
39
|
|
40
|
// Property display keys
|
41
|
public static final String P_IMAGE = "Image URI";
|
42
|
|
43
|
/**
|
44
|
* @param url
|
45
|
*/
|
46
|
public ImagePropertySource(Taxon taxon, ImageFile imageFile) {
|
47
|
this.taxon = taxon;
|
48
|
this.imageFile = imageFile;
|
49
|
|
50
|
addDescriptor(P_ID_IMAGE);
|
51
|
}
|
52
|
|
53
|
protected Vector<PropertyDescriptor> descriptors = new Vector<PropertyDescriptor>();
|
54
|
|
55
|
protected void addDescriptor(String id) {
|
56
|
if (id.equals(P_ID_IMAGE)) {
|
57
|
descriptors.addElement(
|
58
|
new PropertyDescriptor(P_ID_IMAGE, P_IMAGE));
|
59
|
}
|
60
|
}
|
61
|
|
62
|
/* (non-Javadoc)
|
63
|
* @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue()
|
64
|
*/
|
65
|
public Object getEditableValue() {
|
66
|
return this;
|
67
|
}
|
68
|
|
69
|
/* (non-Javadoc)
|
70
|
* @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors()
|
71
|
*/
|
72
|
public IPropertyDescriptor[] getPropertyDescriptors() {
|
73
|
return (IPropertyDescriptor[]) descriptors.toArray(
|
74
|
new IPropertyDescriptor[descriptors.size()]);
|
75
|
}
|
76
|
|
77
|
/* (non-Javadoc)
|
78
|
* @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object)
|
79
|
*/
|
80
|
public Object getPropertyValue(Object id) {
|
81
|
if (id.equals(P_ID_IMAGE)) {
|
82
|
return imageFile.getUri();
|
83
|
}
|
84
|
return null;
|
85
|
}
|
86
|
|
87
|
/* (non-Javadoc)
|
88
|
* @see org.eclipse.ui.views.properties.IPropertySource#isPropertySet(java.lang.Object)
|
89
|
*/
|
90
|
public boolean isPropertySet(Object id) {
|
91
|
return false;
|
92
|
}
|
93
|
|
94
|
/* (non-Javadoc)
|
95
|
* @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object)
|
96
|
*/
|
97
|
public void resetPropertyValue(Object id) {}
|
98
|
|
99
|
/* (non-Javadoc)
|
100
|
* @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)
|
101
|
*/
|
102
|
public void setPropertyValue(Object id, Object value) {
|
103
|
|
104
|
logger.error("Not yet implemented.");
|
105
|
|
106
|
// if (id.equals(P_ID_IMAGE)) {
|
107
|
//
|
108
|
// // TODO put this in an operation to allow undo
|
109
|
// ImageFile imageFile = ImageFile.NewInstance((String) value, null);
|
110
|
//
|
111
|
// ImagesUtil.removeTaxonImage(taxon, imageFile);
|
112
|
// ImagesUtil.addTaxonImage(taxon, imageFile);
|
113
|
//
|
114
|
// this.imageFile = imageFile;
|
115
|
//
|
116
|
// }
|
117
|
}
|
118
|
|
119
|
public ImageFile getImageFile(){
|
120
|
return imageFile;
|
121
|
}
|
122
|
}
|