use of org.jboss.tools.foundation.ui.util.BrowserUtility in project jbosstools-openshift by jbosstools.
the class OpenInWebConsoleHandler method execute.
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
ISelection currentSelection = UIUtils.getCurrentSelection(event);
IResource resource = UIUtils.getFirstElement(currentSelection, IResource.class);
Connection connection = null;
if (resource == null) {
connection = UIUtils.getFirstElement(currentSelection, Connection.class);
} else {
connection = ConnectionsRegistryUtil.safeGetConnectionFor(resource);
}
String msg;
if (connection == null) {
msg = "Could not find an OpenShift connection to open a console for";
} else {
String url = getWebConsoleUrl(connection, resource);
if (!StringUtils.isEmpty(url)) {
new BrowserUtility().checkedCreateExternalBrowser(url, OpenShiftUIActivator.PLUGIN_ID, OpenShiftUIActivator.getDefault().getLog());
return Status.OK_STATUS;
}
msg = NLS.bind("Could not determine the url for the web console on {0}", connection.getHost());
}
MessageDialog.openWarning(HandlerUtil.getActiveShell(event), "No Web Console Url", msg);
return new Status(IStatus.WARNING, OpenShiftUIActivator.PLUGIN_ID, msg);
}
use of org.jboss.tools.foundation.ui.util.BrowserUtility in project jbosstools-openshift by jbosstools.
the class ConnectionWizardPage method onUserdocLinkClicked.
protected void onUserdocLinkClicked(final IObservableValue<String> userdocUrlObservable) {
String userdocUrl = (String) userdocUrlObservable.getValue();
if (StringUtils.isEmpty(userdocUrl)) {
return;
}
new BrowserUtility().checkedCreateExternalBrowser(userdocUrl, OpenShiftCommonUIActivator.PLUGIN_ID, OpenShiftCommonUIActivator.getDefault().getLog());
}
use of org.jboss.tools.foundation.ui.util.BrowserUtility in project jbosstools-openshift by jbosstools.
the class WebHooksComponent method onClickWebhook.
private SelectionAdapter onClickWebhook(final IBuildConfig buildConfig) {
return new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
String url = buildConfig.getBuildSource().getURI();
url = StringUtils.removeEnd(url, ".git");
if (isGitHub(url)) {
// open https://github.com/<user>/<repo>/settings/hooks
if (!url.endsWith("/")) {
url = url + "/";
}
url += "settings/hooks";
}
new BrowserUtility().checkedCreateExternalBrowser(url, OpenShiftUIActivator.PLUGIN_ID, OpenShiftUIActivator.getDefault().getLog());
}
};
}
use of org.jboss.tools.foundation.ui.util.BrowserUtility in project jbosstools-openshift by jbosstools.
the class OpenShiftPreferencePage method createFieldEditors.
@Override
public void createFieldEditors() {
Link link = new Link(getFieldEditorParent(), SWT.WRAP);
link.setText("The OpenShift client binary (oc) is required for features such as Port Forwarding or Log Streaming. " + "You can find more information about how to install it from <a>here</a>.");
GridDataFactory.fillDefaults().span(3, 1).hint(1, 60).grab(true, false).applyTo(link);
link.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
new BrowserUtility().checkedCreateExternalBrowser(DOWNLOAD_INSTRUCTIONS_URL, OpenShiftUIActivator.PLUGIN_ID, OpenShiftUIActivator.getDefault().getLog());
}
});
this.cliLocationEditor = new CliFileEditor();
cliLocationEditor.setFilterPath(SystemUtils.getUserHome());
String[] suffixes = ocBinary.getExtensions();
String[] filters = new String[suffixes.length];
for (int i = 0; i < filters.length; i++) {
filters[i] = "*" + suffixes[i];
}
cliLocationEditor.setFileExtensions(filters);
cliLocationEditor.setValidateStrategy(FileFieldEditor.VALIDATE_ON_KEY_STROKE);
addField(cliLocationEditor);
ocVersionLabel = new Label(getFieldEditorParent(), SWT.WRAP);
ocVersionLabel.setFont(JFaceResources.getFontRegistry().getItalic(JFaceResources.DEFAULT_FONT));
GridDataFactory.fillDefaults().span(3, 1).applyTo(ocVersionLabel);
ocMessageComposite = new Composite(getFieldEditorParent(), SWT.NONE);
GridDataFactory.fillDefaults().span(3, 1).applyTo(ocMessageComposite);
GridLayoutFactory.fillDefaults().numColumns(2).applyTo(ocMessageComposite);
Label label = new Label(ocMessageComposite, SWT.NONE);
label.setImage(JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING));
GridDataFactory.fillDefaults().align(SWT.BEGINNING, SWT.TOP).applyTo(label);
ocMessageLabel = new Label(ocMessageComposite, SWT.NONE);
GridDataFactory.fillDefaults().grab(true, false).applyTo(ocMessageLabel);
ocMessageComposite.setVisible(false);
}
use of org.jboss.tools.foundation.ui.util.BrowserUtility in project jbosstools-openshift by jbosstools.
the class ServerSettingsWizardPage method createOCWarningControls.
@SuppressWarnings("unchecked")
private void createOCWarningControls(Composite container, ServerSettingsWizardPageModel model, DataBindingContext dbc) {
Composite composite = new Composite(container, SWT.NONE);
GridDataFactory.fillDefaults().applyTo(composite);
GridLayoutFactory.fillDefaults().numColumns(2).applyTo(composite);
ValueBindingBuilder.bind(WidgetProperties.visible().observe(composite)).to(BeanProperties.value(ServerSettingsWizardPageModel.PROPERTY_OC_BINARY_STATUS).observe(model)).converting(new Converter(IStatus.class, Boolean.class) {
@Override
public Object convert(Object fromObject) {
return !((IStatus) fromObject).isOK();
}
}).in(dbc);
Label label = new Label(composite, SWT.NONE);
ValueBindingBuilder.bind(WidgetProperties.image().observe(label)).to(BeanProperties.value(ServerSettingsWizardPageModel.PROPERTY_OC_BINARY_STATUS).observe(model)).converting(new Converter(IStatus.class, Image.class) {
@Override
public Object convert(Object fromObject) {
switch(((IStatus) fromObject).getSeverity()) {
case IStatus.WARNING:
return JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING);
case IStatus.ERROR:
return JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR);
default:
return null;
}
}
}).in(dbc);
Link link = new Link(composite, SWT.WRAP);
ValueBindingBuilder.bind(WidgetProperties.text().observe(link)).to(BeanProperties.value(ServerSettingsWizardPageModel.PROPERTY_OC_BINARY_STATUS).observe(model)).converting(new Converter(IStatus.class, String.class) {
@Override
public Object convert(Object fromObject) {
return ((IStatus) fromObject).getMessage();
}
}).in(dbc);
link.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (DOWNLOAD_LINK_TEXT.equals(e.text)) {
new BrowserUtility().checkedCreateExternalBrowser(DOWNLOAD_INSTRUCTIONS_URL, OpenShiftUIActivator.PLUGIN_ID, OpenShiftUIActivator.getDefault().getLog());
} else {
int rc = PreferencesUtil.createPreferenceDialogOn(getShell(), OPEN_SHIFT_PREFERENCE_PAGE_ID, new String[] { OPEN_SHIFT_PREFERENCE_PAGE_ID }, null).open();
if (rc == Dialog.OK) {
new Job("Checking oc binary") {
@Override
protected IStatus run(IProgressMonitor monitor) {
IStatus stat = OCBinary.getInstance().getStatus(model.getConnection(), monitor);
model.setOCBinaryStatus(stat);
return stat;
}
}.schedule();
}
}
}
});
GridDataFactory.fillDefaults().hint(LINK_DEFAULT_WIDTH, SWT.DEFAULT).applyTo(link);
MultiValidator validator = new MultiValidator() {
@Override
protected IStatus validate() {
IObservableValue<IStatus> observable = BeanProperties.value(ServerSettingsWizardPageModel.PROPERTY_OC_BINARY_STATUS).observe(model);
Status status = (Status) observable.getValue();
switch(status.getSeverity()) {
case IStatus.ERROR:
return OpenShiftUIActivator.statusFactory().errorStatus(OpenShiftUIMessages.OCBinaryErrorMessage);
case IStatus.WARNING:
return OpenShiftUIActivator.statusFactory().warningStatus(OpenShiftUIMessages.OCBinaryWarningMessage);
}
return status;
}
};
dbc.addValidationStatusProvider(validator);
BeanProperties.value(ServerSettingsWizardPageModel.PROPERTY_OC_BINARY_STATUS).observe(model).addValueChangeListener(event -> getShell().pack());
}
Aggregations