public void run(IAction action) {
String selection = findSelectedText();
- if (selection != null && selection.trim().length() > 0) {
- URL url;
- IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if (window != null) {
- IWorkbenchPage page = window.getActivePage();
- try {
- IViewPart part = page.findView(BrowserView.ID_BROWSER);
- if (part == null) {
- part = page.showView(BrowserView.ID_BROWSER);
- } else {
- page.bringToTop(part);
- }
- String urlStr = getUrl(selection);
- if (urlStr != null && !urlStr.equals("")) {
- ((BrowserView) part).setUrl(urlStr);
- }
- } catch (Exception e) {
+ if (selection == null || selection.trim().length() == 0) {
+ selection = "";
+ }
+ URL url;
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ if (window != null) {
+ IWorkbenchPage page = window.getActivePage();
+ try {
+ IViewPart part = page.findView(BrowserView.ID_BROWSER);
+ if (part == null) {
+ part = page.showView(BrowserView.ID_BROWSER);
+ } else {
+ page.bringToTop(part);
+ }
+ String urlStr = getUrl(selection);
+ if (urlStr != null && !urlStr.equals("")) {
+ ((BrowserView) part).setUrl(urlStr);
}
+ } catch (Exception e) {
}
}
}