Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
aslakknutsen committed May 21, 2014
1 parent 908ce66 commit 8e3dfd1
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import org.jboss.forge.arquillian.container.model.Dependency;
import org.jboss.forge.arquillian.util.DependencyUtil;

public class AddContainerDependencyCommand extends AbstractProjectCommand implements UIWizardStep {
public class AddContainerDependencyStep extends AbstractProjectCommand implements UIWizardStep {

@Inject
private InputComponentFactory inputFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import org.jboss.forge.arquillian.container.model.ContainerType;
import org.jboss.forge.arquillian.util.DependencyUtil;

public class AddContainerCommand extends AbstractProjectCommand implements UIWizardStep {
public class AddContainerStep extends AbstractProjectCommand implements UIWizardStep {

@Inject
private ProjectFactory projectFactory;
Expand All @@ -55,7 +55,7 @@ public class AddContainerCommand extends AbstractProjectCommand implements UIWiz
private UISelectOne<ContainerType> containerAdapterType;

@Inject
@WithAttributes(shortName = 'c', label = "Container Adapter", type = InputType.DROPDOWN, required = true)
@WithAttributes(shortName = 'c', label = "Container Adapter", type = InputType.DROPDOWN, required = false)
private UISelectOne<Container> containerAdapter;

@Inject
Expand All @@ -72,7 +72,7 @@ public UICommandMetadata getMetadata(final UIContext context) {

@Override
public void initializeUI(final UIBuilder builder) throws Exception {
builder.add(containerAdapterType)
builder//.add(containerAdapterType)
.add(containerAdapter)
.add(containerAdapterVersion);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ public Iterable<Profile> call() throws Exception {
return profileManager.getArquillianProfiles(getSelectedProject(builder.getUIContext()));
}
});
container.setDefaultValue(new Callable<Profile>() {
@Override
public Profile call() throws Exception {
Iterable<Profile> profiles = container.getValueChoices();
if(profiles != null && profiles.iterator().hasNext()) {
return profiles.iterator().next();
}
return null;
}
});
container.setItemLabelConverter(new Converter<Profile, String>() {
@Override
public String convert(Profile source) {
Expand Down Expand Up @@ -103,7 +113,6 @@ public Iterable<Configuration> call() throws Exception {
return Collections.emptyList();
}
});

containerValue.setEnabled(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ public Result execute(UIExecutionContext context) throws Exception {
@Override
@SuppressWarnings("unchecked")
public NavigationResult next(UINavigationContext context) throws Exception {
return Results.navigateTo(AddContainerCommand.class,
AddContainerDependencyCommand.class);
return Results.navigateTo(
AddContainerStep.class,
AddContainerDependencyStep.class);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.io.FileNotFoundException;
import java.io.StringWriter;
import java.util.Properties;
import java.util.concurrent.Callable;

import javax.inject.Inject;

Expand Down Expand Up @@ -62,9 +63,20 @@ public UICommandMetadata getMetadata(UIContext context) {
}

@Override
public void initializeUI(UIBuilder builder) throws Exception {
public void initializeUI(final UIBuilder builder) throws Exception {
builder.add(value)
.add(enableJPA);

value.setDefaultValue(new Callable<JavaResource>() {
@Override
public JavaResource call() throws Exception {
Object selected = builder.getUIContext().getInitialSelection().get();
if(selected != null && selected instanceof JavaResource) {
return (JavaResource)selected;
}
return null;
}
});
}

@Override
Expand Down

0 comments on commit 8e3dfd1

Please sign in to comment.