Revision 8481f952
Added by Andreas Müller almost 4 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/BrowserElement.java | ||
---|---|---|
1 | 1 |
/** |
2 |
*
|
|
2 |
* |
|
3 | 3 |
*/ |
4 | 4 |
package eu.etaxonomy.taxeditor.ui.element; |
5 | 5 |
|
... | ... | |
18 | 18 |
* <p>BrowserElement class.</p> |
19 | 19 |
* |
20 | 20 |
* @author n.hoffmann |
21 |
* @version $Id: $ |
|
22 | 21 |
*/ |
23 | 22 |
public class BrowserElement extends AbstractCdmFormElement implements ControlListener{ |
24 | 23 |
|
25 | 24 |
private Browser browser; |
26 |
|
|
25 |
|
|
27 | 26 |
private String imageUriString; |
28 |
|
|
27 |
|
|
29 | 28 |
/** |
30 | 29 |
* <p>Constructor for BrowserElement.</p> |
31 | 30 |
* |
... | ... | |
37 | 36 |
protected BrowserElement(CdmFormFactory formFactory, ICdmFormElement parentElement, URI imageUri, int style) { |
38 | 37 |
super(formFactory, parentElement); |
39 | 38 |
formFactory.createLabel(getLayoutComposite(), ""); |
40 |
|
|
39 |
|
|
41 | 40 |
browser = new Browser(getLayoutComposite(), SWT.NONE); |
42 | 41 |
addControl(browser); |
43 |
|
|
42 |
|
|
44 | 43 |
getLayoutComposite().setLayoutData(LayoutConstants.FILL()); |
45 |
|
|
44 |
|
|
46 | 45 |
|
47 | 46 |
layoutBrowser(); |
48 |
|
|
47 |
|
|
49 | 48 |
showBrowser(); |
50 | 49 |
browser.addControlListener(this); |
51 |
|
|
50 |
|
|
52 | 51 |
this.setImageUri(imageUri); |
53 | 52 |
} |
54 | 53 |
|
55 |
/** |
|
56 |
* |
|
57 |
*/ |
|
58 | 54 |
private void layoutBrowser() { |
59 | 55 |
TableWrapData layoutData = LayoutConstants.FILL(); |
60 | 56 |
layoutData.heightHint = 1000; |
61 |
|
|
57 |
|
|
62 | 58 |
browser.setLayoutData(layoutData); |
63 | 59 |
} |
64 | 60 |
|
65 |
/** |
|
66 |
* |
|
67 |
*/ |
|
68 | 61 |
private void showBrowser() { |
69 |
|
|
62 |
|
|
70 | 63 |
String html = ""; |
71 | 64 |
html = "<HTML><HEAD><TITLE></TITLE></HEAD><BODY marginwidth=0 marginheight=0 leftmargin=0 topmargin=0>"; |
72 | 65 |
html += "<img width=\"" + calculateWidth() + "\" src=\"" + getImageUriString() + "\" />"; |
73 | 66 |
html += "</BODY></HTML>"; |
74 |
|
|
67 |
|
|
75 | 68 |
browser.setText(html); |
76 | 69 |
} |
77 |
|
|
70 |
|
|
78 | 71 |
/** |
79 | 72 |
* <p>calculateWidth</p> |
80 | 73 |
* |
81 | 74 |
* @return a int. |
82 | 75 |
*/ |
83 |
public int calculateWidth() {
|
|
76 |
public int calculateWidth() { |
|
84 | 77 |
Rectangle boundaries = browser.getBounds(); |
85 | 78 |
return boundaries.width; |
86 | 79 |
} |
87 |
|
|
88 |
/* (non-Javadoc) |
|
89 |
* @see org.eclipse.swt.events.ControlListener#controlMoved(org.eclipse.swt.events.ControlEvent) |
|
90 |
*/ |
|
91 |
/** {@inheritDoc} */ |
|
92 |
public void controlMoved(ControlEvent e) { |
|
80 |
|
|
81 |
@Override |
|
82 |
public void controlMoved(ControlEvent e) { |
|
93 | 83 |
showBrowser(); |
94 | 84 |
} |
95 | 85 |
|
96 |
/* (non-Javadoc) |
|
97 |
* @see org.eclipse.swt.events.ControlListener#controlResized(org.eclipse.swt.events.ControlEvent) |
|
98 |
*/ |
|
99 |
/** {@inheritDoc} */ |
|
100 |
public void controlResized(ControlEvent e) { |
|
86 |
@Override |
|
87 |
public void controlResized(ControlEvent e) { |
|
101 | 88 |
showBrowser(); |
102 | 89 |
} |
103 | 90 |
|
... | ... | |
109 | 96 |
public void setImageUri(URI imageUri) { |
110 | 97 |
setImageUriString(imageUri != null ? imageUri.toString() : ""); |
111 | 98 |
} |
112 |
|
|
99 |
|
|
113 | 100 |
/** |
114 | 101 |
* <p>Setter for the field <code>imageUriString</code>.</p> |
115 | 102 |
* |
... | ... | |
128 | 115 |
public String getImageUriString() { |
129 | 116 |
return imageUriString; |
130 | 117 |
} |
131 |
|
|
132 | 118 |
} |
Also available in: Unified diff
cleanup