import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.tizen.common.ui.Activator;
+import org.tizen.common.util.BrowserWrapper;
import org.tizen.common.util.PluginUtil;
import org.tizen.common.util.SWTUtil;
root.setLayout(new GridLayout( 1, false ));
root.setLayoutData(new GridData(380, 250));
- final Browser browser = createBrowser(root);
- browser.setLayoutData(new GridData(GridData.FILL_BOTH));
+ BrowserWrapper browserWrapper = new BrowserWrapper(createBrowser(root));
+ browserWrapper.getBrowser().setLayoutData(new GridData(GridData.FILL_BOTH));
String color = SWTUtil.convertRGBToHexadecimal(getRGB());
String url = getColorPickerURL() + "?color=" + color;
- browser.setUrl(url);
- browser.refresh();
+ browserWrapper.setUrl(url);
- new SetColorFunction(browser, GET_COLOR_FUNCTION);
+ new SetColorFunction(browserWrapper.getBrowser(), GET_COLOR_FUNCTION);
applyDialogFont(root);
initializeDialogUnits(root);
import org.tizen.common.ui.Activator;
import org.tizen.common.ui.preferences.AppearancePreferencePage;
import org.tizen.common.util.ArrayUtil;
+import org.tizen.common.util.BrowserWrapper;
import org.tizen.common.util.StringUtil;
/**
*/
@Override
protected void fillTipArea() {
- this.tipArea.setUrl( getTips().get(getIndex()) );
+ BrowserWrapper browserWrapper = new BrowserWrapper(this.tipArea);
+ browserWrapper.setUrl(getTips().get(getIndex()));
setBrowserFunction();
}
\r
package org.tizen.common.ui.wizards;\r
\r
-import java.io.File;\r
-import java.net.MalformedURLException;\r
-\r
import org.eclipse.jface.resource.ImageDescriptor;\r
import org.eclipse.jface.viewers.*;\r
import org.eclipse.swt.SWT;\r
import org.slf4j.LoggerFactory;\r
import org.tizen.common.ui.Activator;\r
import org.tizen.common.ui.preferences.AppearancePreferencePage;\r
+import org.tizen.common.util.BrowserWrapper;\r
import org.tizen.common.util.HelpBrowser;\r
import org.tizen.common.util.ImageUtil;\r
import org.tizen.common.util.SWTUtil;\r
\r
private TreeViewer fTreeViewer;\r
private TableViewer fTableViewer;\r
- private Browser fBrowser;\r
+ private BrowserWrapper browserWrapper;\r
\r
protected boolean fGradient;\r
private Color topColor = new Color(Display.getDefault(), 115, 208, 255);\r
GridData gridData = new GridData(GridData.FILL_BOTH);\r
gridData.minimumWidth = BROWSER_WIDTH;\r
try {\r
- fBrowser = new Browser(parent, SWT.NONE);\r
- initializeBrowser(SWTUtil.getDisplay(), fBrowser);\r
- fBrowser.setLayoutData(gridData);\r
+ browserWrapper = new BrowserWrapper(parent, SWT.NONE, gridData);\r
+ initializeBrowser(SWTUtil.getDisplay(), browserWrapper.getBrowser());\r
} catch (SWTError e) {\r
// Exception skip: Ubuntu 12.04 browser compatibility problem\r
logger.error("Failed to create a browser", e);\r
- \r
Composite temporaryControl = new Composite(parent, SWT.NONE);\r
temporaryControl.setLayoutData(gridData);\r
}\r
}\r
\r
protected void setUrl(String url) {\r
- if (fBrowser != null && url != null) {\r
- try {\r
- File urlFile = new File( url );\r
- fBrowser.setUrl( urlFile.toURI().toURL().toString() );\r
- } catch (MalformedURLException e) {\r
- logger.error( e.getMessage(), e );\r
- }\r
+ if (browserWrapper != null && url != null) {\r
+ browserWrapper.setUrl( url );\r
}\r
}\r
\r
import java.io.File;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.SWTException;
import org.eclipse.swt.browser.Browser;
+import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
/**
- * @author Adam Kotwasinski, Samsung Electronics, Inc.
+ * BrowserWrapper.
+ *
+ * @author Changhyun Lee {@literal <changhyun1.lee@samsung.com>} (S-Core)
*/
public class BrowserWrapper {
+
private Browser browser;
-
+
+ public BrowserWrapper(Browser browser) {
+ this.browser = browser;
+ }
+
public BrowserWrapper(Composite composite) {
browser = new Browser(composite, SWT.NONE);
}
-
- public BrowserWrapper(Composite composite, GridData data) {
- this(composite, data, SWT.NONE);
+
+ public BrowserWrapper(Composite composite, int style) {
+ browser = new Browser(composite, style);
}
- public BrowserWrapper(Composite composite, GridData data, int style) {
+ public BrowserWrapper(Composite composite, int style, GridData data) {
browser = new Browser(composite, style);
browser.setLayoutData(data);
}
- public void setInput(final File f) {
+ public Browser getBrowser() {
+ return browser;
+ }
+
+ public void setUrl(final String url) {
asyncExec(new Runnable() {
public void run() {
if (!browser.isDisposed()) {
- browser.setUrl(f.getAbsolutePath());
+ browser.setUrl(url);
}
}
- } );
+ });
+ }
+
+ public void setUrl(final File url) {
+ setUrl(url.getAbsolutePath());
}
public void setText(String html) {
browser.setText(html);
}
+ public void refresh() {
+ browser.refresh();
+ }
+
public void setFocus() {
browser.setFocus();
}
- public Browser getBrowser() {
- return browser;
+ public Object evaluate (String script) throws SWTException {
+ return browser.evaluate(script);
+ }
+
+ public void setRedraw (boolean redraw) {
+ browser.setRedraw(redraw);
}
+
+ public void setBackground (Color color) {
+ browser.setBackground(color);
+ }
+
+ public void dispose() {
+ browser.dispose();
+ }
+
}