Search in sources :

Example 1 with OpenShiftCoreException

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);
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) CoreException(org.eclipse.core.runtime.CoreException) OpenShiftCoreException(org.jboss.tools.openshift.common.core.OpenShiftCoreException) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) OpenShiftCoreException(org.jboss.tools.openshift.common.core.OpenShiftCoreException)

Example 2 with OpenShiftCoreException

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()));
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) OpenShiftCoreException(org.jboss.tools.openshift.common.core.OpenShiftCoreException)

Example 3 with OpenShiftCoreException

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);
}
Also used : Binding(org.eclipse.core.databinding.Binding) RequiredControlDecorationUpdater(org.jboss.tools.openshift.internal.common.ui.databinding.RequiredControlDecorationUpdater) IStatus(org.eclipse.core.runtime.IStatus) IValidator(org.eclipse.core.databinding.validation.IValidator) Button(org.eclipse.swt.widgets.Button) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) OpenShiftCoreException(org.jboss.tools.openshift.common.core.OpenShiftCoreException) File(java.io.File)

Example 4 with OpenShiftCoreException

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));
}
Also used : OpenShiftCoreException(org.jboss.tools.openshift.common.core.OpenShiftCoreException) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Aggregations

OpenShiftCoreException (org.jboss.tools.openshift.common.core.OpenShiftCoreException)4 IStatus (org.eclipse.core.runtime.IStatus)2 File (java.io.File)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 MalformedURLException (java.net.MalformedURLException)1 Binding (org.eclipse.core.databinding.Binding)1 IValidator (org.eclipse.core.databinding.validation.IValidator)1 IProject (org.eclipse.core.resources.IProject)1 CoreException (org.eclipse.core.runtime.CoreException)1 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)1 Button (org.eclipse.swt.widgets.Button)1 Label (org.eclipse.swt.widgets.Label)1 Text (org.eclipse.swt.widgets.Text)1 RequiredControlDecorationUpdater (org.jboss.tools.openshift.internal.common.ui.databinding.RequiredControlDecorationUpdater)1 Test (org.junit.Test)1