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;
}
Aggregations