View Javadoc
1   package org.argeo.cms.ui.internal;
2   
3   import javax.jcr.RepositoryException;
4   
5   import org.argeo.cms.ui.util.CmsUiUtils;
6   import org.argeo.cms.ui.widgets.EditableImage;
7   import org.eclipse.swt.graphics.Point;
8   import org.eclipse.swt.widgets.Composite;
9   import org.eclipse.swt.widgets.Control;
10  import org.eclipse.swt.widgets.Text;
11  
12  /** NOT working yet. */
13  public class SimpleEditableImage extends EditableImage {
14  	private static final long serialVersionUID = -5689145523114022890L;
15  
16  	private String src;
17  	private Point imageSize;
18  
19  	public SimpleEditableImage(Composite parent, int swtStyle) {
20  		super(parent, swtStyle);
21  		// load(getControl());
22  		getParent().layout();
23  	}
24  
25  	public SimpleEditableImage(Composite parent, int swtStyle, String src,
26  			Point imageSize) {
27  		super(parent, swtStyle);
28  		this.src = src;
29  		this.imageSize = imageSize;
30  	}
31  
32  	@Override
33  	protected Control createControl(Composite box, String style) {
34  		if (isEditing()) {
35  			return createText(box, style);
36  		} else {
37  			return createLabel(box, style);
38  		}
39  	}
40  
41  	protected String createImgTag() throws RepositoryException {
42  		String imgTag;
43  		if (src != null)
44  			imgTag = CmsUiUtils.img(src, imageSize);
45  		else
46  			imgTag = CmsUiUtils.noImg(imageSize != null ? imageSize
47  					: NO_IMAGE_SIZE);
48  		return imgTag;
49  	}
50  
51  	protected Text createText(Composite box, String style) {
52  		Text text = new Text(box, getStyle());
53  		CmsUiUtils.style(text, style);
54  		return text;
55  	}
56  
57  	public String getSrc() {
58  		return src;
59  	}
60  
61  	public void setSrc(String src) {
62  		this.src = src;
63  	}
64  
65  	public Point getImageSize() {
66  		return imageSize;
67  	}
68  
69  	public void setImageSize(Point imageSize) {
70  		this.imageSize = imageSize;
71  	}
72  
73  }