4 package eu
.etaxonomy
.taxeditor
.ui
.forms
;
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
;
16 * <p>BrowserElement class.</p>
21 public class BrowserElement
extends AbstractCdmFormElement
implements ControlListener
{
23 private Browser browser
;
25 private String imageUriString
;
28 * <p>Constructor for BrowserElement.</p>
31 * @param formFactory a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory} object.
32 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
33 * @param imageUri a {@link java.net.URI} object.
35 protected BrowserElement(CdmFormFactory formFactory
, ICdmFormElement parentElement
, URI imageUri
, int style
) {
36 super(formFactory
, parentElement
);
37 formFactory
.createLabel(getLayoutComposite(), "");
39 browser
= new Browser(getLayoutComposite(), SWT
.NONE
);
42 getLayoutComposite().setLayoutData(CdmFormFactory
.FILL());
48 browser
.addControlListener(this);
50 this.setImageUri(imageUri
);
56 private void layoutBrowser() {
57 TableWrapData layoutData
= CdmFormFactory
.FILL();
58 layoutData
.heightHint
= 1000;
60 browser
.setLayoutData(layoutData
);
66 private void showBrowser() {
69 html
= "<HTML><HEAD><TITLE></TITLE></HEAD><BODY marginwidth=0 marginheight=0 leftmargin=0 topmargin=0>";
70 html
+= "<img width=\"" + calculateWidth() + "\" src=\"" + getImageUriString() + "\" />";
71 html
+= "</BODY></HTML>";
73 browser
.setText(html
);
77 * <p>calculateWidth</p>
81 public int calculateWidth() {
82 Rectangle boundaries
= browser
.getBounds();
83 return boundaries
.width
;
87 * @see org.eclipse.swt.events.ControlListener#controlMoved(org.eclipse.swt.events.ControlEvent)
90 public void controlMoved(ControlEvent e
) {
95 * @see org.eclipse.swt.events.ControlListener#controlResized(org.eclipse.swt.events.ControlEvent)
98 public void controlResized(ControlEvent e
) {
105 * @param imageUri the imageUri to set
107 public void setImageUri(URI imageUri
) {
108 setImageUriString(imageUri
!= null ? imageUri
.toString() : "");
112 * <p>Setter for the field <code>imageUriString</code>.</p>
114 * @param imageUriString a {@link java.lang.String} object.
116 public void setImageUriString(String imageUriString
){
117 this.imageUriString
= imageUriString
;
122 * <p>Getter for the field <code>imageUriString</code>.</p>
124 * @return the imageUri
126 public String
getImageUriString() {
127 return imageUriString
;
131 public void setSelected(boolean selected
) {