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 cubrid-manager by CUBRID.
the class JdbcOptionComposite method createButtonComp.
/**
*
* Create button composite
*
* @param composite the composite
*/
private void createButtonComp(Composite composite) {
Composite buttonComposite = new Composite(composite, SWT.NONE);
{
GridLayout layout = new GridLayout();
layout.numColumns = 3;
buttonComposite.setLayout(layout);
buttonComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
}
Hyperlink link = new Hyperlink(buttonComposite, SWT.None);
link.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
link.setText(Messages.titleJdbcAdvancedOptionView);
link.addMouseListener(new MouseListener() {
public void mouseUp(MouseEvent e) {
IWorkbenchBrowserSupport browserSupport = PlatformUI.getWorkbench().getBrowserSupport();
try {
IWebBrowser br = browserSupport.createBrowser(null);
br.openURL(new URL(Messages.msgCubridJdbcInfoUrl));
} catch (Exception ignored) {
}
}
public void mouseDown(MouseEvent e) {
}
public void mouseDoubleClick(MouseEvent e) {
}
});
addButton = new Button(buttonComposite, SWT.PUSH);
addButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
addButton.setText(Messages.btnAdd);
addButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
TableItem itemNew = new TableItem(jdbcInfoTv.getTable(), SWT.SINGLE);
int newIndex = jdbcInfoTv.getTable().getItemCount() - 1;
focusCell(itemNew, newIndex, 0);
}
});
Button delButton = new Button(buttonComposite, SWT.PUSH);
delButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
delButton.setText(Messages.btnDelete);
delButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
TableItem[] selection = jdbcInfoTv.getTable().getSelection();
if (selection == null || selection.length == 0) {
return;
}
jdbcInfoTv.getTable().setSelection(-1);
for (TableItem item : selection) {
item.dispose();
}
}
});
}
use of org.eclipse.ui.browser.IWorkbenchBrowserSupport in project cubrid-manager by CUBRID.
the class NoticeDashboardPage method createFormText.
private FormText createFormText(Composite composite) {
FormText text = toolkit.createFormText(composite, true);
text.addHyperlinkListener(new IHyperlinkListener() {
public void linkExited(HyperlinkEvent e) {
}
public void linkEntered(HyperlinkEvent e) {
}
public void linkActivated(HyperlinkEvent e) {
String href = (String) e.getHref();
String url = CommonUITool.urlEncodeForSpaces(href);
try {
IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport();
IWebBrowser browser = support.getExternalBrowser();
browser.openURL(new URL(url));
} catch (PartInitException e1) {
LOGGER.error("Can not initialize web browser on the application.", e1);
} catch (MalformedURLException e2) {
LOGGER.error("The url {} is invalid.", url, e2);
}
}
});
return text;
}
use of org.eclipse.ui.browser.IWorkbenchBrowserSupport in project cubrid-manager by CUBRID.
the class GeneralInfoPage method createChartsetGroup.
/**
* Create chartset information group
*
* @param parent the parent composite
*/
private void createChartsetGroup(Composite parent) {
Group charsetGroup = new Group(parent, SWT.NONE);
charsetGroup.setText(Messages.grpCharsetInfo);
GridData gdCharsetGroup = new GridData(GridData.FILL_HORIZONTAL);
charsetGroup.setLayoutData(gdCharsetGroup);
GridLayout layoutCharsetGroup = new GridLayout();
layoutCharsetGroup.numColumns = 3;
charsetGroup.setLayout(layoutCharsetGroup);
enIsoRadio = new Button(charsetGroup, SWT.RADIO);
final GridData gdEnIsoRadio = new GridData(SWT.FILL, SWT.CENTER, true, false);
enIsoRadio.setLayoutData(gdEnIsoRadio);
enIsoRadio.setText(CHARSET_EN_US_ISO88591);
enIsoRadio.setSelection(true);
enUtfRadio = new Button(charsetGroup, SWT.RADIO);
final GridData gdEnUtfRadio = new GridData(SWT.FILL, SWT.CENTER, true, false);
enUtfRadio.setLayoutData(gdEnUtfRadio);
enUtfRadio.setText(CHARSET_EN_US_UTF8);
koEuckrRadio = new Button(charsetGroup, SWT.RADIO);
final GridData gdKoEuckrRadio = new GridData(SWT.FILL, SWT.CENTER, true, false);
koEuckrRadio.setLayoutData(gdKoEuckrRadio);
koEuckrRadio.setText(CHARSET_KO_KR_EUCKR);
koUtfRadio = new Button(charsetGroup, SWT.RADIO);
final GridData gdKoUtfRadio = new GridData(SWT.FILL, SWT.CENTER, true, false);
koUtfRadio.setLayoutData(gdKoUtfRadio);
koUtfRadio.setText(CHARSET_KO_KR_UTF8);
userDefinedRadio = new Button(charsetGroup, SWT.RADIO);
final GridData gdUserDefinedRadio = new GridData(SWT.FILL, SWT.CENTER, true, false);
koUtfRadio.setLayoutData(gdUserDefinedRadio);
userDefinedRadio.setText(Messages.lblUserDefinedCharset);
userDefinedRadio.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
Button btn = (Button) e.widget;
userDefinedCharsetText.setEnabled(btn.getSelection());
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
userDefinedCharsetText = new Text(charsetGroup, SWT.BORDER);
final GridData gdDetailCombo = new GridData(SWT.FILL, SWT.CENTER, true, false);
userDefinedCharsetText.setLayoutData(gdDetailCombo);
userDefinedCharsetText.setEnabled(false);
userDefinedCharsetText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
//TODO whether need check the input style?
valid();
}
});
Hyperlink link = new Hyperlink(charsetGroup, SWT.None);
GridData gdLink = new GridData(SWT.FILL, SWT.CENTER, true, false);
gdLink.horizontalSpan = 3;
link.setLayoutData(gdLink);
link.setText(Messages.msgLocaleManual);
link.addMouseListener(new MouseAdapter() {
public void mouseUp(MouseEvent e) {
IWorkbenchBrowserSupport browserSupport = PlatformUI.getWorkbench().getBrowserSupport();
try {
IWebBrowser br = browserSupport.createBrowser(null);
String url = Messages.msgLocaleManualUrl91;
if (CompatibleUtil.isAfter930(server.getServerInfo())) {
url = Messages.msgLocaleManualUrl93;
} else if (CompatibleUtil.isAfter920(server.getServerInfo())) {
url = Messages.msgLocaleManualUrl92;
}
br.openURL(new URL(url));
} catch (Exception ignored) {
}
}
});
}
use of org.eclipse.ui.browser.IWorkbenchBrowserSupport in project sling by apache.
the class AbstractOpenInBrowserHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection sel = HandlerUtil.getCurrentSelection(event);
JcrNode node = SelectionUtils.getFirst(sel, JcrNode.class);
if (node == null) {
return null;
}
Shell shell = HandlerUtil.getActiveShell(event);
IModule module = ServerUtil.getModule(node.getProject());
if (module == null) {
MessageDialog.openWarning(shell, "Cannot open browser", "Not configured for any server");
return null;
}
IServer[] servers = ServerUtil.getServersByModule(module, new NullProgressMonitor());
if (servers == null || servers.length == 0) {
MessageDialog.openWarning(shell, "Cannot open browser", "Not configured for any server");
return null;
}
IServer server = servers[0];
URL url;
try {
url = getUrlToOpen(node, server);
} catch (MalformedURLException e) {
StatusManager.getManager().handle(new Status(Status.WARNING, Activator.PLUGIN_ID, "Url is invalid", e), StatusManager.SHOW);
return null;
}
try {
IWorkbenchBrowserSupport browserSupport = HandlerUtil.getActiveWorkbenchWindow(event).getWorkbench().getBrowserSupport();
browserSupport.createBrowser("org.apache.sling.ide.openOnServer").openURL(url);
} catch (PartInitException e) {
StatusManager.getManager().handle(new Status(Status.WARNING, Activator.PLUGIN_ID, "Failed creating browser instance", e), StatusManager.SHOW | StatusManager.LOG);
}
return null;
}
Aggregations