use of org.jboss.tools.openshift.common.core.OpenShiftCoreException in project jbosstools-openshift by jbosstools.
the class OpenShiftDebugMode method waitFor.
protected IPod waitFor(NewPodDetectorJob podDetector, IProgressMonitor monitor) throws CoreException {
try {
podDetector.join(NewPodDetectorJob.TIMEOUT, monitor);
IStatus result = podDetector.getResult();
if (result == null) {
// timed out!
throw new CoreException(podDetector.getTimeOutStatus());
} else if (!result.isOK()) {
throw new CoreException(result);
}
return podDetector.getPod();
} catch (OperationCanceledException | InterruptedException e) {
throw new OpenShiftCoreException(e);
}
}
use of org.jboss.tools.openshift.common.core.OpenShiftCoreException in project jbosstools-openshift by jbosstools.
the class ConnectionsRegistry method remove.
public boolean remove(IConnection connection) {
try {
ConnectionURL connectionUrl = ConnectionURL.forConnection(connection);
if (!connectionsByUrl.containsKey(connectionUrl)) {
return false;
}
connectionsByUrl.remove(connectionUrl);
removePropertyChangeListener(connection);
if (this.recentConnection == connection) {
this.recentConnection = null;
}
fireChange(connection, EventType.REMOVED);
return true;
} catch (UnsupportedEncodingException e) {
throw new OpenShiftCoreException(e, NLS.bind("Could not remove connection {0}", connection.getHost()));
} catch (MalformedURLException e) {
throw new OpenShiftCoreException(e, NLS.bind("Could not remove connection {0}", connection.getHost()));
}
}
use of org.jboss.tools.openshift.common.core.OpenShiftCoreException in project jbosstools-openshift by jbosstools.
the class ServerSettingsWizardPage method createSourcePathControls.
@SuppressWarnings("unchecked")
private void createSourcePathControls(Composite parent, ServerSettingsWizardPageModel model, DataBindingContext dbc) {
Label sourcePathLabel = new Label(parent, SWT.NONE);
sourcePathLabel.setText("Source Path: ");
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(sourcePathLabel);
Text sourcePathText = new Text(parent, SWT.BORDER);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(sourcePathText);
Binding sourcePathBinding = ValueBindingBuilder.bind(WidgetProperties.text(SWT.Modify).observe(sourcePathText)).validatingAfterConvert(new IValidator() {
@Override
public IStatus validate(Object value) {
String path = (String) value;
if (StringUtils.isEmpty(path)) {
return ValidationStatus.cancel("Please provide a local path to deploy from.");
}
String provideValidPathMessage = "Please provide a valid local path to deploy from.";
try {
path = VariablesHelper.replaceVariables(path);
} catch (OpenShiftCoreException e) {
String message = org.apache.commons.lang.StringUtils.substringAfter(e.getMessage(), "Exception:");
return ValidationStatus.error(provideValidPathMessage + "\nError: " + message);
}
if (!isReadableFile(path)) {
return ValidationStatus.error(provideValidPathMessage);
}
return ValidationStatus.ok();
}
private boolean isReadableFile(String path) {
return new File(path).canRead();
}
}).to(BeanProperties.value(ServerSettingsWizardPageModel.PROPERTY_SOURCE_PATH).observe(model)).in(dbc);
ControlDecorationSupport.create(sourcePathBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater(true));
Button browseSourceButton = new Button(parent, SWT.PUSH);
browseSourceButton.setText("Browse...");
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).indent(10, SWT.DEFAULT).applyTo(browseSourceButton);
browseSourceButton.addSelectionListener(onBrowseSource(browseSourceButton.getShell()));
Button browseWorkspaceSourceButton = new Button(parent, SWT.PUSH | SWT.READ_ONLY);
browseWorkspaceSourceButton.setText("Workspace...");
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(browseWorkspaceSourceButton);
browseWorkspaceSourceButton.addSelectionListener(onBrowseWorkspace(browseWorkspaceSourceButton.getShell()));
UIUtils.setEqualButtonWidth(browseSourceButton, browseWorkspaceSourceButton);
}
use of org.jboss.tools.openshift.common.core.OpenShiftCoreException in project jbosstools-openshift by jbosstools.
the class VariablesHelperTest method testReplaceVariables.
@Test
public void testReplaceVariables() throws Exception {
String name = "foo";
String value = VariablesHelper.addWorkspacePrefix(name);
try {
VariablesHelper.replaceVariables(value);
fail("missing resource should fail to resolve");
} catch (OpenShiftCoreException e) {
}
assertEquals(value, VariablesHelper.replaceVariables(value, true));
IProject bar = getOrcreateProject(name);
assertEquals(bar.getLocation().toOSString(), VariablesHelper.replaceVariables(value));
}
Aggregations