Skip to content

Commit

Permalink
Fixed default spec versions to Java EE6
Browse files Browse the repository at this point in the history
  • Loading branch information
gastaldi committed Jan 29, 2014
1 parent 06c074f commit df0b9e0
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.jboss.forge.addon.facets.FacetFactory;
import org.jboss.forge.addon.facets.constraints.FacetConstraint;
import org.jboss.forge.addon.javaee.cdi.CDIFacet;
import org.jboss.forge.addon.javaee.cdi.CDIFacet_1_0;
import org.jboss.forge.addon.javaee.ui.AbstractJavaEECommand;
import org.jboss.forge.addon.projects.facets.DependencyFacet;
import org.jboss.forge.addon.projects.facets.ResourcesFacet;
Expand Down Expand Up @@ -48,6 +49,9 @@ public Metadata getMetadata(UIContext context)
@WithAttributes(required = true, label = "CDI Version")
private UISelectOne<CDIFacet<?>> cdiVersion;

@Inject
private CDIFacet_1_0 cdiFacet_1_0;

@Override
public void initializeUI(UIBuilder builder) throws Exception
{
Expand All @@ -60,14 +64,7 @@ public String convert(CDIFacet<?> source)
}
});

for (CDIFacet<?> cdi : cdiVersion.getValueChoices())
{
if (cdiVersion.getValue() == null
|| cdi.getSpecVersion().compareTo(cdiVersion.getValue().getSpecVersion()) >= 1)
{
cdiVersion.setDefaultValue(cdi);
}
}
cdiVersion.setDefaultValue(cdiFacet_1_0);

builder.add(cdiVersion);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.jboss.forge.addon.facets.FacetFactory;
import org.jboss.forge.addon.facets.constraints.FacetConstraint;
import org.jboss.forge.addon.javaee.ejb.EJBFacet;
import org.jboss.forge.addon.javaee.ejb.EJBFacet_3_1;
import org.jboss.forge.addon.javaee.ui.AbstractJavaEECommand;
import org.jboss.forge.addon.projects.Project;
import org.jboss.forge.addon.projects.facets.DependencyFacet;
Expand Down Expand Up @@ -51,6 +52,9 @@ public Metadata getMetadata(UIContext context)
@WithAttributes(required = true, label = "EJB Version")
private UISelectOne<EJBFacet> ejbVersion;

@Inject
private EJBFacet_3_1 ejbFacet_3_1;

@Override
public void initializeUI(UIBuilder builder) throws Exception
{
Expand All @@ -63,14 +67,7 @@ public String convert(EJBFacet source)
}
});

for (EJBFacet choice : ejbVersion.getValueChoices())
{
if (ejbVersion.getValue() == null || choice.getSpecVersion().compareTo(ejbVersion.getValue().getSpecVersion()) >= 1)
{
ejbVersion.setDefaultValue(choice);
}
}

ejbVersion.setDefaultValue(ejbFacet_3_1);
builder.add(ejbVersion);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.jboss.forge.addon.facets.FacetFactory;
import org.jboss.forge.addon.facets.constraints.FacetConstraint;
import org.jboss.forge.addon.javaee.faces.FacesFacet;
import org.jboss.forge.addon.javaee.faces.FacesFacet_2_0;
import org.jboss.forge.addon.javaee.ui.AbstractJavaEECommand;
import org.jboss.forge.addon.projects.Project;
import org.jboss.forge.addon.projects.facets.DependencyFacet;
Expand Down Expand Up @@ -52,6 +53,9 @@ public Metadata getMetadata(UIContext context)
@WithAttributes(required = true, label = "JavaServer Faces Version")
private UISelectOne<FacesFacet> facesVersion;

@Inject
private FacesFacet_2_0 facesFacet_2_0;

@Override
public void initializeUI(UIBuilder builder) throws Exception
{
Expand All @@ -63,15 +67,7 @@ public String convert(FacesFacet source)
return source.getSpecVersion().toString();
}
});

for (FacesFacet choice : facesVersion.getValueChoices())
{
if (facesVersion.getValue() == null || choice.getSpecVersion().compareTo(facesVersion.getValue().getSpecVersion()) >= 1)
{
facesVersion.setDefaultValue(choice);
}
}

facesVersion.setDefaultValue(facesFacet_2_0);
builder.add(facesVersion);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.jboss.forge.addon.convert.Converter;
import org.jboss.forge.addon.facets.FacetFactory;
import org.jboss.forge.addon.javaee.jpa.JPAFacet;
import org.jboss.forge.addon.javaee.jpa.JPAFacet_2_0;
import org.jboss.forge.addon.javaee.jpa.PersistenceContainer;
import org.jboss.forge.addon.javaee.jpa.PersistenceMetaModelFacet;
import org.jboss.forge.addon.javaee.jpa.PersistenceProvider;
Expand Down Expand Up @@ -62,6 +63,9 @@ public class JPASetupWizard extends AbstractJavaEECommand implements UIWizard
@Inject
private JavaEEDefaultProvider defaultProvider;

@Inject
private JPAFacet_2_0 jpaFacet_2_0;

@Inject
private Imported<PersistenceMetaModelFacet> metaModelFacets;

Expand Down Expand Up @@ -105,16 +109,7 @@ public String convert(JPAFacet<?> source)
return source == null ? null : source.getSpecVersion().toString();
}
});

for (JPAFacet<?> choice : jpaVersion.getValueChoices())
{
if (jpaVersion.getValue() == null
|| choice.getSpecVersion().compareTo(jpaVersion.getValue().getSpecVersion()) >= 1)
{
jpaVersion.setDefaultValue(choice);
}
}

jpaVersion.setDefaultValue(jpaFacet_2_0);
}

private void initContainers(UIContext context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.jboss.forge.addon.facets.FacetFactory;
import org.jboss.forge.addon.facets.constraints.FacetConstraint;
import org.jboss.forge.addon.javaee.servlet.ServletFacet;
import org.jboss.forge.addon.javaee.servlet.ServletFacet_3_0;
import org.jboss.forge.addon.javaee.ui.AbstractJavaEECommand;
import org.jboss.forge.addon.projects.Project;
import org.jboss.forge.addon.projects.facets.DependencyFacet;
Expand Down Expand Up @@ -50,6 +51,9 @@ public Metadata getMetadata(UIContext context)
@Inject
@WithAttributes(required = true, label = "Servlet Version")
private UISelectOne<ServletFacet<?>> servletVersion;

@Inject
private ServletFacet_3_0 servletFacet_3_0;

@Override
public void initializeUI(UIBuilder builder) throws Exception
Expand All @@ -63,13 +67,7 @@ public String convert(ServletFacet<?> source)
}
});

for (ServletFacet<?> choice : servletVersion.getValueChoices())
{
if (servletVersion.getValue() == null || choice.getSpecVersion().compareTo(servletVersion.getValue().getSpecVersion()) >= 1)
{
servletVersion.setDefaultValue(choice);
}
}
servletVersion.setDefaultValue(servletFacet_3_0);

builder.add(servletVersion);
}
Expand Down

0 comments on commit df0b9e0

Please sign in to comment.