Skip to content

Commit

Permalink
Allow Result to be proxied
Browse files Browse the repository at this point in the history
  • Loading branch information
lincolnthree committed Jan 26, 2013
1 parent 4f0d8f8 commit 65299ce
Show file tree
Hide file tree
Showing 14 changed files with 110 additions and 86 deletions.
4 changes: 2 additions & 2 deletions aesh/src/main/java/org/jboss/forge/aesh/ShellCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
*/
package org.jboss.forge.aesh;

import java.util.List;

import org.jboss.aesh.cl.CommandLine;
import org.jboss.aesh.cl.CommandLineParser;
import org.jboss.aesh.cl.internal.ParameterInt;
Expand All @@ -17,8 +19,6 @@
import org.jboss.forge.ui.Result;
import org.jboss.forge.ui.UICommand;

import java.util.List;

/**
* @author <a href="mailto:stale.pedersen@jboss.org">Ståle W. Pedersen</a>
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import org.jboss.aesh.console.Console;
import org.jboss.forge.ui.Result;
import org.jboss.forge.ui.Results;
import org.jboss.forge.ui.UICommand;
import org.jboss.forge.ui.UICommandID;
import org.jboss.forge.ui.UIContext;
Expand Down Expand Up @@ -56,7 +57,7 @@ public void validate(UIValidationContext context)
public Result execute(UIContext context) throws Exception
{
console.clear();
return Result.success("");
return Results.success("");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.jboss.aesh.console.Console;
import org.jboss.forge.aesh.ShellContext;
import org.jboss.forge.ui.Result;
import org.jboss.forge.ui.Results;
import org.jboss.forge.ui.UICommand;
import org.jboss.forge.ui.UICommandID;
import org.jboss.forge.ui.UIContext;
Expand Down Expand Up @@ -69,7 +70,7 @@ public void validate(UIValidationContext context)
public Result execute(UIContext context) throws Exception
{
console.stop();
return Result.success("");
return Results.success("");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.jboss.forge.container.Addon;
import org.jboss.forge.container.AddonRegistry;
import org.jboss.forge.ui.Result;
import org.jboss.forge.ui.Results;
import org.jboss.forge.ui.UICommand;
import org.jboss.forge.ui.UICommandID;
import org.jboss.forge.ui.UIContext;
Expand Down Expand Up @@ -57,7 +58,7 @@ public void validate(UIValidationContext context)
@Override
public Result execute(UIContext context) throws Exception
{
return Result.success(listServices());
return Results.success(listServices());
}

private String listServices() throws IOException
Expand Down
3 changes: 2 additions & 1 deletion aesh/src/test/java/org/jboss/forge/aesh/FooCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import org.jboss.forge.container.services.Exported;
import org.jboss.forge.ui.Result;
import org.jboss.forge.ui.Results;
import org.jboss.forge.ui.UICommand;
import org.jboss.forge.ui.UICommandID;
import org.jboss.forge.ui.UIContext;
Expand Down Expand Up @@ -52,6 +53,6 @@ public void validate(UIValidationContext context)
@Override
public Result execute(UIContext context) throws Exception
{
return Result.success("boo");
return Results.success("boo");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
package org.jboss.forge.aesh.util;

import junit.framework.TestCase;

import org.jboss.aesh.cl.CommandLine;
import org.jboss.aesh.cl.CommandLineParser;
import org.jboss.aesh.cl.OptionBuilder;
import org.jboss.aesh.cl.ParsedOption;
import org.jboss.aesh.cl.internal.OptionInt;
import org.jboss.aesh.cl.internal.ParameterInt;
import org.jboss.forge.aesh.ShellContext;
import org.jboss.forge.ui.Result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.jboss.forge.resource.FileResource;
import org.jboss.forge.resource.ResourceFactory;
import org.jboss.forge.ui.Result;
import org.jboss.forge.ui.Results;
import org.jboss.forge.ui.UICommand;
import org.jboss.forge.ui.UICommandID;
import org.jboss.forge.ui.UIContext;
Expand Down Expand Up @@ -101,7 +102,7 @@ public Result execute(UIContext context) throws Exception
directory.getChildDirectory("src/test/java").mkdirs();
directory.getChildDirectory("src/test/resources").mkdirs();

return Result.success();
return Results.success();
}

/*
Expand Down
74 changes: 5 additions & 69 deletions ui/api/src/main/java/org/jboss/forge/ui/Result.java
Original file line number Diff line number Diff line change
@@ -1,81 +1,17 @@
/*
* Copyright 2012 Red Hat, Inc. and/or its affiliates.
* Copyright 2013 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Eclipse Public License version 1.0, available at
* http://www.eclipse.org/legal/epl-v10.html
*/

package org.jboss.forge.ui;

/**
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
*/
public abstract class Result
public interface Result
{
public String getMessage();

private final Class<? extends UICommand> command;
private final String message;

public static final Result success()
{
return new ResultSuccess((String) null);
}

public static final Result success(String message)
{
return new ResultSuccess(message);
}

public static final Result success(Class<? extends UICommand> command)
{
return new ResultSuccess(command);
}

public static final Result success(Class<? extends UICommand> next, String message)
{
return new ResultSuccess(message);
}

public static final Result fail(String message)
{
return new ResultFail(message);
}

public static final Result fail(Class<? extends UICommand> command)
{
return new ResultFail(command);
}

public static final Result fail(Class<? extends UICommand> next, String message)
{
return new ResultFail(message);
}

Result(String message)
{
this.message = message;
this.command = null;
}

Result(Class<? extends UICommand> command)
{
this.message = null;
this.command = command;
}

Result(Class<? extends UICommand> command, String message)
{
this.command = command;
this.message = message;
}

public String getMessage()
{
return this.message;
}

public Class<? extends UICommand> getCommand()
{
return this.command;
}
}
public Class<? extends UICommand> getCommand();
}
2 changes: 1 addition & 1 deletion ui/api/src/main/java/org/jboss/forge/ui/ResultFail.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/**
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
*/
public final class ResultFail extends Result
public class ResultFail extends Results
{
ResultFail(String message)
{
Expand Down
2 changes: 1 addition & 1 deletion ui/api/src/main/java/org/jboss/forge/ui/ResultSuccess.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/**
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
*/
public final class ResultSuccess extends Result
public class ResultSuccess extends Results
{
ResultSuccess(String message)
{
Expand Down
82 changes: 82 additions & 0 deletions ui/api/src/main/java/org/jboss/forge/ui/Results.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* Copyright 2012 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Eclipse Public License version 1.0, available at
* http://www.eclipse.org/legal/epl-v10.html
*/

package org.jboss.forge.ui;

/**
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
*/
public abstract class Results implements Result
{
private final Class<? extends UICommand> command;
private final String message;

public static final Results success()
{
return new ResultSuccess((String) null);
}

public static final Results success(String message)
{
return new ResultSuccess(message);
}

public static final Results success(Class<? extends UICommand> command)
{
return new ResultSuccess(command);
}

public static final Results success(Class<? extends UICommand> next, String message)
{
return new ResultSuccess(message);
}

public static final Results fail(String message)
{
return new ResultFail(message);
}

public static final Results fail(Class<? extends UICommand> command)
{
return new ResultFail(command);
}

public static final Results fail(Class<? extends UICommand> next, String message)
{
return new ResultFail(message);
}

Results(String message)
{
this.message = message;
this.command = null;
}

Results(Class<? extends UICommand> command)
{
this.message = null;
this.command = command;
}

Results(Class<? extends UICommand> command, String message)
{
this.command = command;
this.message = message;
}

@Override
public String getMessage()
{
return this.message;
}

@Override
public Class<? extends UICommand> getCommand()
{
return this.command;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import org.jboss.forge.container.services.Exported;
import org.jboss.forge.ui.Result;
import org.jboss.forge.ui.Results;
import org.jboss.forge.ui.UICommand;
import org.jboss.forge.ui.UICommandID;
import org.jboss.forge.ui.UIContext;
Expand Down Expand Up @@ -46,7 +47,7 @@ public void validate(UIValidationContext context)
@Override
public Result execute(UIContext context) throws Exception
{
return Result.success();
return Results.success();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void validate(UIValidationContext context)
@Override
public Result execute(UIContext context) throws Exception
{
return Result.success();
return Results.success();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import org.jboss.forge.container.services.Exported;
import org.jboss.forge.ui.Result;
import org.jboss.forge.ui.Results;
import org.jboss.forge.ui.UICommand;
import org.jboss.forge.ui.UIContext;
import org.jboss.forge.ui.UIInput;
Expand Down Expand Up @@ -78,10 +79,10 @@ public Result next(UIWizardContext context) throws Exception
{
if (useFramework.getValue())
{
return Result.success(MockChooseFrameworkStep.class);
return Results.success(MockChooseFrameworkStep.class);
}

return Result.success();
return Results.success();
}

/*
Expand All @@ -94,10 +95,10 @@ public Result execute(UIContext context) throws Exception
{
if (projectDir.getValue().mkdirs())
{
return Result.success("Success");
return Results.success("Success");
}

return Result.fail("Reason");
return Results.fail("Reason");

}

Expand Down

0 comments on commit 65299ce

Please sign in to comment.