use of org.eclipse.swt.browser.Browser in project cubrid-manager by CUBRID.
the class CubridNoticeInfoEditorPart method createPartControl.
/**
* Create the editor content
*
* @param parent the parent composite
*/
public void createPartControl(Composite parent) {
Composite composite = new Composite(parent, SWT.None);
GridLayout layout = new GridLayout();
composite.setLayout(layout);
try {
Button ignoreButton = new Button(composite, SWT.CHECK);
ignoreButton.setText(Messages.cubridNoticeIgnoreButtonLbl);
ignoreButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
String ignore = PersistUtils.getPreferenceValue(CommonUIPlugin.PLUGIN_ID, CubridNoticeUtil.IGNORE_NOTICE);
if (StringUtil.isEmpty(ignore)) {
ignore = index;
} else {
ignore = ignore + "," + index;
}
PersistUtils.setPreferenceValue(CommonUIPlugin.PLUGIN_ID, CubridNoticeUtil.IGNORE_NOTICE, ignore);
getSite().getWorkbenchWindow().getActivePage().closeEditor(editor, false);
}
});
Browser browser = new Browser(composite, SWT.NONE);
browser.setUrl(noticeURL);
browser.setLayoutData(new GridData(GridData.FILL_BOTH));
} catch (Exception e) {
Label label = new Label(parent, SWT.NONE);
IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport();
try {
IWebBrowser browser = support.getExternalBrowser();
browser.openURL(new URL(CommonUITool.urlEncodeForSpaces(noticeURL.toCharArray())));
} catch (Exception browserEx) {
LOGGER.error(browserEx.getMessage(), browserEx);
label.setText(Messages.errCannotOpenExternalBrowser);
return;
}
label.setText(Messages.errCannotOpenInternalBrowser);
}
}
use of org.eclipse.swt.browser.Browser in project bndtools by bndtools.
the class JPMBrowserView method createPartControl.
@Override
public void createPartControl(Composite parent) {
StackLayout stack = new StackLayout();
parent.setLayout(stack);
JpmPreferences prefs = new JpmPreferences();
if (prefs.getBrowserSelection() == JpmPreferences.PREF_BROWSER_EXTERNAL) {
external = true;
Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new GridLayout(2, false));
new Label(composite, SWT.NONE).setText("JPM is configured to open in an external browser.");
Hyperlink linkToPrefs = new Hyperlink(composite, SWT.NONE);
linkToPrefs.setText("Open Preference Page");
linkToPrefs.setUnderlined(true);
linkToPrefs.addHyperlinkListener(new HyperlinkAdapter() {
@Override
public void linkActivated(HyperlinkEvent e) {
PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(getViewSite().getShell(), "bndtools.prefPages.jpm", new String[] { "bndtools.prefPages.jpm" }, null);
dialog.open();
}
});
// linkToPrefs.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, true, false));
stack.topControl = composite;
} else {
if (prefs.getBrowserSelection() == JpmPreferences.PREF_BROWSER_PLATFORM_DEFAULT) {
browser = new Browser(parent, SWT.NONE);
stack.topControl = browser;
} else if (prefs.getBrowserSelection() == JpmPreferences.PREF_BROWSER_WEBKIT) {
browser = new Browser(parent, SWT.WEBKIT);
stack.topControl = browser;
} else if (prefs.getBrowserSelection() == JpmPreferences.PREF_BROWSER_MOZILLA) {
browser = new Browser(parent, SWT.MOZILLA);
stack.topControl = browser;
}
createActions();
// Prevent navigation away from JPM4J.org, and redirect from HTTP back to HTTPS
browser.addLocationListener(new LocationAdapter() {
@Override
public void changing(LocationEvent event) {
setContentDescription(event.location);
/*
*
if (event.location.startsWith(HTTPS_URL))
return;
if (event.location.startsWith(HTTP_URL))
event.location = event.location.replaceFirst(HTTP_URL, HTTP_URL);
else
event.doit = false;
*/
}
});
}
selectionService = getViewSite().getWorkbenchWindow().getSelectionService();
selectionService.addSelectionListener(this);
handleWorkbenchSelection(selectionService.getSelection());
}
use of org.eclipse.swt.browser.Browser in project translationstudio8 by heartsome.
the class HtmlBrowserEditor method createPartControl.
@Override
public void createPartControl(Composite parent) {
GridLayoutFactory.fillDefaults().numColumns(1).applyTo(parent);
parent.setLayoutData(new GridData(GridData.FILL_BOTH));
cmp = new Composite(parent, SWT.BORDER);
GridLayoutFactory.fillDefaults().numColumns(1).applyTo(cmp);
GridDataFactory.fillDefaults().grab(true, true).applyTo(cmp);
browser = new Browser(cmp, SWT.NONE);
browser.setLayoutData(new GridData(GridData.FILL_BOTH));
browser.setUrl(htmlUrl);
browser.addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(MouseEvent e) {
getSite().getPart().setFocus();
super.mouseDown(e);
}
});
}
use of org.eclipse.swt.browser.Browser in project cubrid-manager by CUBRID.
the class NoticeDialog method createDialogArea.
protected Control createDialogArea(Composite parent) {
Composite parentComp = (Composite) super.createDialogArea(parent);
{
GridLayout tLayout = new GridLayout();
tLayout.marginHeight = 0;
tLayout.marginWidth = 0;
tLayout.verticalSpacing = 0;
tLayout.horizontalSpacing = 0;
parentComp.setLayout(tLayout);
parentComp.setLayoutData(new GridData(GridData.FILL_BOTH));
}
try {
Browser browser = new Browser(parentComp, SWT.NONE);
browser.setSize(500, 400);
{
GridLayout tLayout = new GridLayout();
tLayout.marginHeight = 0;
tLayout.marginWidth = 0;
tLayout.verticalSpacing = 0;
tLayout.horizontalSpacing = 0;
browser.setLayout(tLayout);
browser.setLayoutData(new GridData(GridData.FILL_BOTH));
}
browser.setUrl(url);
} catch (Exception e) {
}
return parent;
}
use of org.eclipse.swt.browser.Browser in project cubrid-manager by CUBRID.
the class CubridNewInfoEditorPart method createPartControl.
/**
* Create the editor content
*
* @param parent the parent composite
*/
public void createPartControl(Composite parent) {
String url = Platform.getNL().equals("ko_KR") ? CHECK_NEW_INFO_URL_KO : CHECK_NEW_INFO_URL_EN;
try {
Browser browser = new Browser(parent, SWT.NONE);
browser.setUrl(url);
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
Label label = new Label(parent, SWT.NONE);
IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport();
try {
IWebBrowser browser = support.getExternalBrowser();
browser.openURL(new URL(CommonUITool.urlEncodeForSpaces(url.toCharArray())));
} catch (Exception browserEx) {
LOGGER.warn(browserEx.getMessage(), browserEx);
label.setText(Messages.errCannotOpenExternalBrowser);
return;
}
label.setText(Messages.errCannotOpenInternalBrowser);
}
}
Aggregations