Skip to content

Commit

Permalink
[JBIDE-21340] existing proj validation: removed dirty check & git rem…
Browse files Browse the repository at this point in the history
…ote HTTPS is now warning
  • Loading branch information
adietish authored and fbricon committed Jan 8, 2016
1 parent ed3fb22 commit 7dffff3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 25 deletions.
Expand Up @@ -1510,7 +1510,7 @@ public static List<String> getRemoteGitRepos(IProject project) throws CoreExcept
*/
public static String getDefaultRemoteRepo(org.eclipse.core.resources.IProject project) throws CoreException {
Stream<String> stream = getRemoteGitReposFilteredStream(project);
return stream == null ? null : stream.findFirst().get();
return stream == null ? null : stream.findFirst().orElse(null);
}

private static Stream<String> getRemoteGitReposFilteredStream(IProject project) throws CoreException {
Expand Down
Expand Up @@ -11,7 +11,6 @@
package org.jboss.tools.openshift.internal.ui.wizard.newapp;

import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.nio.file.Files;
import java.nio.file.Paths;
Expand Down Expand Up @@ -39,11 +38,9 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.variables.VariablesPlugin;
import org.eclipse.egit.core.internal.util.ProjectUtil;
import org.eclipse.jface.databinding.fieldassist.ControlDecorationSupport;
import org.eclipse.jface.databinding.swt.ISWTObservableValue;
import org.eclipse.jface.databinding.swt.WidgetProperties;
Expand All @@ -70,8 +67,6 @@
import org.eclipse.jface.viewers.ViewerComparator;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.errors.NoWorkTreeException;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyledText;
Expand All @@ -97,6 +92,7 @@
import org.eclipse.ui.model.WorkbenchLabelProvider;
import org.eclipse.ui.progress.UIJob;
import org.jboss.tools.common.ui.WizardUtils;
import org.jboss.tools.common.ui.databinding.ParametrizableWizardPageSupport;
import org.jboss.tools.common.ui.databinding.ValueBindingBuilder;
import org.jboss.tools.openshift.common.core.utils.ProjectUtils;
import org.jboss.tools.openshift.core.connection.Connection;
Expand Down Expand Up @@ -868,10 +864,8 @@ protected IStatus validate() {
try {
List<String> repos = EGitUtils.getRemoteGitRepos(project);
if (repos == null || repos.isEmpty()) {
status = ValidationStatus.error(
status = ValidationStatus.warning(
NLS.bind("A remote Git repository using the HTTP(S) protocol must be defined on project {0}", projectName));
} else {
status = getGitDirtyStatus(project);
}
} catch (CoreException e) {
status = ValidationStatus.error(
Expand Down Expand Up @@ -916,22 +910,6 @@ public IObservableList getTargets() {
}
}

private IStatus getGitDirtyStatus(org.eclipse.core.resources.IProject project) {
try {
if (EGitUtils.isDirty(project, false, new NullProgressMonitor())) {
return ValidationStatus.error(NLS.bind(
"The project {0} has uncommitted changes. Please commit those changes first.",
project.getName()));
} else {
return ValidationStatus.ok();
}
} catch (NoWorkTreeException | IOException | GitAPIException e) {
return ValidationStatus.error(NLS.bind(
"The git repository for project {0} looks corrupt. Please fix it before using it.",
project.getName()));
}
}

private void filterTemplates(Text text, org.eclipse.core.resources.IProject project) {
String tags = findMatchingTags(project);
if (tags != null && !text.isDisposed()) {
Expand All @@ -954,4 +932,12 @@ private String substituteVariables(String string) {
throw new RuntimeException(ex);
}
}

@Override
protected void setupWizardPageSupport(DataBindingContext dbc) {
ParametrizableWizardPageSupport.create(
IStatus.ERROR | IStatus.INFO | IStatus.CANCEL, this,
dbc);
}

}

0 comments on commit 7dffff3

Please sign in to comment.