use of org.eclipse.ui.browser.IWorkbenchBrowserSupport in project cubrid-manager by CUBRID.
the class CubridOnlineForumAction method run.
public void run() {
String url = CommonUITool.urlEncodeForSpaces(Messages.msgCubridOnlineForumUrl);
try {
IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport();
IWebBrowser browser = support.getExternalBrowser();
browser.openURL(new URL(url));
} catch (PartInitException e) {
LOGGER.error("Can not initialize web browser on the application.", e);
} catch (MalformedURLException e) {
LOGGER.error("The url {} is invalid.", url, e);
}
}
use of org.eclipse.ui.browser.IWorkbenchBrowserSupport in project cubrid-manager by CUBRID.
the class HelpDocumentAction method run.
public void run() {
String url = CommonUITool.urlEncodeForSpaces(Messages.msgCubridHelpSiteUrl);
try {
IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport();
IWebBrowser browser = support.getExternalBrowser();
browser.openURL(new URL(url));
} catch (PartInitException e) {
LOGGER.error("Can not initialize web browser on the application.", e);
} catch (MalformedURLException e) {
LOGGER.error("The url {} is invalid.", url, e);
}
}
use of org.eclipse.ui.browser.IWorkbenchBrowserSupport 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);
}
}
use of org.eclipse.ui.browser.IWorkbenchBrowserSupport in project eclipse-integration-commons by spring-projects.
the class PluginManagerDialog method handleNavigation.
/**
* Handles navigation from a hyperlink in the description area.
*
* @param urlExpression
*/
protected void handleNavigation(String urlExpression) {
String errorMessage = null;
try {
URL url = new URL(urlExpression);
boolean launched = Program.launch(url.toString());
if (!launched) {
IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport();
try {
if (support != null) {
IWebBrowser browser = support.getExternalBrowser();
if (browser != null) {
browser.openURL(url);
return;
} else {
errorMessage = "Unable to find browser support to navigate to URL. Check default browser support in Eclipse or OS";
}
}
} catch (PartInitException e) {
errorMessage = "Unable to navigate to URL: " + e.getLocalizedMessage();
}
}
} catch (MalformedURLException e) {
errorMessage = "Unable to navigate to URL: " + e.getLocalizedMessage();
}
if (errorMessage != null) {
InternalMessageDialogue dialog = new InternalMessageDialogue("Problems navigating to URL", errorMessage + ": " + urlExpression, MessageDialog.ERROR, false);
dialog.open();
}
}
use of org.eclipse.ui.browser.IWorkbenchBrowserSupport in project eclipse-integration-commons by spring-projects.
the class UiUtil method uiThreadOpenUrl.
/**
* Don't call this method unless you are in the UI thread!
*/
private static void uiThreadOpenUrl(String location, int browserChoice) {
try {
URL url = null;
if (location != null) {
url = new URL(location);
}
if (browserChoice == WebBrowserPreference.EXTERNAL) {
try {
IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport();
support.getExternalBrowser().openURL(url);
} catch (Exception e) {
}
} else {
IWebBrowser browser;
int flags;
if (WorkbenchBrowserSupport.getInstance().isInternalWebBrowserAvailable()) {
flags = IWorkbenchBrowserSupport.AS_EDITOR | IWorkbenchBrowserSupport.LOCATION_BAR | IWorkbenchBrowserSupport.NAVIGATION_BAR;
} else {
flags = IWorkbenchBrowserSupport.AS_EXTERNAL | IWorkbenchBrowserSupport.LOCATION_BAR | IWorkbenchBrowserSupport.NAVIGATION_BAR;
}
String generatedId = "org.eclipse.mylyn.web.browser-" + Calendar.getInstance().getTimeInMillis();
browser = WorkbenchBrowserSupport.getInstance().createBrowser(flags, generatedId, null, null);
browser.openURL(url);
}
} catch (PartInitException e) {
MessageDialog.openError(Display.getDefault().getActiveShell(), "Failed to Open Browser", "Browser could not be initiated");
} catch (MalformedURLException e) {
if (location == null || location.trim().equals("")) {
MessageDialog.openInformation(Display.getDefault().getActiveShell(), "Failed to Open Browser", "No URL to open." + location);
} else {
MessageDialog.openInformation(Display.getDefault().getActiveShell(), "Failed to Open Browser", "Could not open URL: " + location);
}
}
}
Aggregations