Search in sources :

Example 1 with UIUpdatingJob

use of org.jboss.tools.openshift.internal.common.ui.job.UIUpdatingJob in project jbosstools-openshift by jbosstools.

the class OpenShiftPreferencePage method validateLocation.

private boolean validateLocation(String location) {
    if (StringUtils.isBlank(location)) {
        return true;
    }
    File file = new File(location);
    // page.
    if (!file.exists()) {
        cliLocationEditor.setErrorMessage(NLS.bind("{0} was not found.", file));
        return false;
    }
    if (!file.canExecute()) {
        cliLocationEditor.setErrorMessage(NLS.bind("{0} does not have execute permissions.", file));
        return false;
    }
    setValid(false);
    ocVersionLabel.setText("Checking OpenShift client version...");
    this.versionVerificationJob = new UIUpdatingJob("Checking oc binary...") {

        private Version version;

        @Override
        protected IStatus run(IProgressMonitor monitor) {
            version = new OCBinaryVersionValidator(location).getVersion(monitor);
            if (monitor.isCanceled()) {
                return Status.CANCEL_STATUS;
            }
            return Status.OK_STATUS;
        }

        @Override
        protected IStatus updateUI(IProgressMonitor monitor) {
            if (!getResult().isOK()) {
                return getResult();
            }
            if (!ocMessageComposite.isDisposed() && !monitor.isCanceled()) {
                setValid(true);
                if (Version.emptyVersion.equals(version)) {
                    ocVersionLabel.setText("Could not determine your OpenShift client version");
                } else {
                    ocVersionLabel.setText(NLS.bind("Your OpenShift client version is {0}.{1}.{2}", new Object[] { version.getMajor(), version.getMinor(), version.getMicro() }));
                }
                ocMessageLabel.setText(NLS.bind("OpenShift client version 1.1.1 or higher is required to avoid rsync issues.", version));
                ocMessageComposite.setVisible(!OCBinaryVersionValidator.isCompatibleForPublishing(version));
            }
            return super.updateUI(monitor);
        }
    };
    versionVerificationJob.schedule();
    return true;
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IStatus(org.eclipse.core.runtime.IStatus) Version(org.osgi.framework.Version) UIUpdatingJob(org.jboss.tools.openshift.internal.common.ui.job.UIUpdatingJob) OCBinaryVersionValidator(org.jboss.tools.openshift.internal.core.preferences.OCBinaryVersionValidator) File(java.io.File)

Aggregations

File (java.io.File)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 IStatus (org.eclipse.core.runtime.IStatus)1 UIUpdatingJob (org.jboss.tools.openshift.internal.common.ui.job.UIUpdatingJob)1 OCBinaryVersionValidator (org.jboss.tools.openshift.internal.core.preferences.OCBinaryVersionValidator)1 Version (org.osgi.framework.Version)1