4 package eu
.etaxonomy
.taxeditor
.ui
.element
;
8 import org
.eclipse
.swt
.SWT
;
9 import org
.eclipse
.swt
.browser
.Browser
;
10 import org
.eclipse
.swt
.events
.ControlEvent
;
11 import org
.eclipse
.swt
.events
.ControlListener
;
12 import org
.eclipse
.swt
.graphics
.Rectangle
;
13 import org
.eclipse
.ui
.forms
.widgets
.TableWrapData
;
18 * <p>BrowserElement class.</p>
22 public class BrowserElement
extends AbstractCdmFormElement
implements ControlListener
{
24 private Browser browser
;
26 private String imageUriString
;
29 * <p>Constructor for BrowserElement.</p>
32 * @param formFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
33 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object.
34 * @param imageUri a {@link java.net.URI} object.
36 protected BrowserElement(CdmFormFactory formFactory
, ICdmFormElement parentElement
, URI imageUri
, int style
) {
37 super(formFactory
, parentElement
);
38 formFactory
.createLabel(getLayoutComposite(), "");
40 browser
= new Browser(getLayoutComposite(), SWT
.NONE
);
43 getLayoutComposite().setLayoutData(LayoutConstants
.FILL());
49 browser
.addControlListener(this);
51 this.setImageUri(imageUri
);
54 private void layoutBrowser() {
55 TableWrapData layoutData
= LayoutConstants
.FILL();
56 layoutData
.heightHint
= 1000;
58 browser
.setLayoutData(layoutData
);
61 private void showBrowser() {
64 html
= "<HTML><HEAD><TITLE></TITLE></HEAD><BODY marginwidth=0 marginheight=0 leftmargin=0 topmargin=0>";
65 html
+= "<img width=\"" + calculateWidth() + "\" src=\"" + getImageUriString() + "\" />";
66 html
+= "</BODY></HTML>";
68 browser
.setText(html
);
72 * <p>calculateWidth</p>
76 public int calculateWidth() {
77 Rectangle boundaries
= browser
.getBounds();
78 return boundaries
.width
;
82 public void controlMoved(ControlEvent e
) {
87 public void controlResized(ControlEvent e
) {
94 * @param imageUri the imageUri to set
96 public void setImageUri(URI imageUri
) {
97 setImageUriString(imageUri
!= null ? imageUri
.toString() : "");
101 * <p>Setter for the field <code>imageUriString</code>.</p>
103 * @param imageUriString a {@link java.lang.String} object.
105 public void setImageUriString(String imageUriString
){
106 this.imageUriString
= imageUriString
;
111 * <p>Getter for the field <code>imageUriString</code>.</p>
113 * @return the imageUri
115 public String
getImageUriString() {
116 return imageUriString
;