Module: spiralcraft-core
Provides a Command pattern that exposes arbitrary functions on application components to user interface or other controllers designed to trigger application functions generically.
package myPackage;
import spiralcraft.command.Command;
import spiralcraft.command.CommandAdapter;
public class MyWidget
{
public String doWork(String x,int y)
{
}
public Command<MyWidget,String> doWorkCommand(final String x,final int y)
{
return new CommandAdapter<MyClass,Void>()
{
setTarget(MyWidget.this);
@Override
protected void run()
{
try
{ setResult(doWork(x,y));
}
catch (Exception ex)
{ setException(ex);
}
}
};
}
}