Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refinements in the eventhings port. Created some more bridge classes.
- Loading branch information
Showing
67 changed files
with
3,717 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import sbt._ | ||
|
||
class LiftProject(info: ProjectInfo) extends DefaultWebProject(info) { | ||
val liftVersion = "2.3-SNAPSHOT" | ||
|
||
// uncomment the following if you want to use the snapshot repo | ||
val scalatoolsSnapshot = ScalaToolsSnapshots | ||
|
||
// val localMaven = "local maven" at "file:///home/dpp/.m2/repository" | ||
|
||
// If you're using JRebel for Lift development, uncomment | ||
// this line | ||
// override def scanDirectories = Nil | ||
|
||
override def libraryDependencies = Set( | ||
"net.liftweb" %% "lift-webkit" % liftVersion % "compile->default", | ||
"net.liftweb" %% "lift-wizard" % liftVersion % "compile->default", | ||
"org.mortbay.jetty" % "jetty" % "6.1.22" % "test->default", | ||
"junit" % "junit" % "4.5" % "test->default", | ||
"ch.qos.logback" % "logback-classic" % "0.9.26", | ||
"org.scala-tools.testing" %% "specs" % "1.6.6" % "test->default", | ||
"com.h2database" % "h2" % "1.2.138" | ||
) ++ super.libraryDependencies | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,20 @@ | ||
package net.liftweb.seventhings.lib; | ||
|
||
import scala.collection.Seq; | ||
import scala.collection.mutable.ListBuffer; | ||
|
||
public class ListJ { | ||
|
||
public static Seq Nil() { | ||
return scala.collection.immutable.Nil$.MODULE$; | ||
} | ||
|
||
public static Seq toSeq(Object... obj) { | ||
ListBuffer buf = new ListBuffer(); | ||
for (Object o : obj) { | ||
buf.$plus$eq(o); | ||
} | ||
return buf.toSeq(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package net.liftweb.seventhings.lib; | ||
|
||
import scala.PartialFunction; | ||
|
||
import java.util.List; | ||
import java.util.Collections; | ||
import java.util.Arrays; | ||
|
||
interface MatchClause<T> { | ||
public boolean test (T subject); | ||
public Object apply(T subject); | ||
} | ||
|
||
interface F0V { //extends PartialFunction<Void, Object> { | ||
public Object apply(); | ||
} | ||
|
||
|
||
class Matcher<T> { | ||
|
||
private final List<MatchClause<T>> matchers; | ||
|
||
public static <T> Matcher<T> matcher(MatchClause<T>... matchers) { | ||
return new Matcher<T>(matchers); | ||
} | ||
|
||
public Matcher(MatchClause<T>... matchers) { | ||
this.matchers = Collections.unmodifiableList(Arrays.asList(matchers)); | ||
} | ||
|
||
public F0V match(final T subject) { | ||
return new F0V() { | ||
public Object apply() { | ||
for(MatchClause<T> matcher: matchers) { | ||
if(matcher.test(subject)) { | ||
return matcher.apply(subject); | ||
} | ||
} | ||
return null; // TODO should return Empty | ||
} | ||
}; | ||
} | ||
|
||
} | ||
|
||
/* | ||
class liftjmatch { | ||
public static void main(String[] args) { | ||
final MatchClause<Object> mString = new MatchClause<Object>() { | ||
public boolean test(Object x) { return x instanceof String; } | ||
public void apply(Object x) { System.out.println("String: " + x); } | ||
}; | ||
final MatchClause<Object> mInteger = new MatchClause<Object>() { | ||
public boolean test(Object x) { return x instanceof Integer; } | ||
public void apply(Object x) { System.out.println("Integer: " + x); } | ||
}; | ||
final MatchClause<Object> mOther = new MatchClause<Object>() { | ||
public boolean test(Object x) { return true; } | ||
public void apply(Object x) { System.out.println("Other: " + x); } | ||
}; | ||
Matcher<Object> m = Matcher.matcher( | ||
mString, | ||
mInteger, | ||
mOther | ||
); | ||
m.match("Hello World").apply(); | ||
m.match(1).apply(); | ||
} | ||
} | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
src/main/java/net/liftweb/seventhings/snippet/MyWizard.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package net.liftweb.seventhings.snippet; | ||
|
||
import net.liftweb.http.AbstractScreen; | ||
import net.liftweb.http.SJ; | ||
import net.liftweb.http.js.JsCmd; | ||
import net.liftweb.http.js.jquery.JqJsCmds; | ||
import net.liftweb.seventhings.lib.JqJsCmdsJ; | ||
import net.liftweb.seventhings.lib.ListJ; | ||
import net.liftweb.seventhings.lib.WizardJ; | ||
import net.liftweb.util.Func; | ||
import net.liftweb.util.Func0; | ||
import net.liftweb.wizard.Wizard; | ||
|
||
/** | ||
* An example of a wizard in Lift | ||
*/ | ||
public class MyWizard extends WizardJ { | ||
|
||
private MyWizardScala wizardScala = new MyWizardScala(); | ||
|
||
private final MyWizardScala.ParentNameScreen parentName; | ||
private final MyWizardScala.FavoritePetScreen favoritePet; | ||
private final MyWizardScala.NameAndAgeScreen nameAndAge; | ||
|
||
public MyWizard() { | ||
parentName = wizardScala.getParentName(); | ||
favoritePet = wizardScala.getFavoritePet(); | ||
nameAndAge = wizardScala.getNameAndAge(); | ||
} | ||
|
||
public JsCmd calcAjaxOnDone() { | ||
return JqJsCmdsJ.j().unblock(); | ||
} | ||
|
||
// define the first screen | ||
|
||
// We ask the parent's name if the person is under 18 | ||
// private WizardJ.ScreenJ parentNameObj = new WizardJ.ScreenJ() { | ||
// String parentName = fieldj(SJ.j().$qmark("Mom or Dad's name"), ListJ.toSeq( | ||
// valMinLen(Func.lift(new Func0<Integer>() { | ||
// public Integer apply() { | ||
// return 2; | ||
// } | ||
// }), Func.lift(new Func0<String>() { | ||
// public String apply() { | ||
// return SJ.j().$qmark("Name Too Short"); | ||
// } | ||
// })), | ||
// valMaxLen(Func.lift(new Func0<Integer>() { | ||
// public Integer apply() { | ||
// return 40; | ||
// } | ||
// }), Func.lift(new Func0<String>() { | ||
// public String apply() { | ||
// return SJ.j().$qmark("Name Too Long"); | ||
// } | ||
// })))); | ||
// }; | ||
|
||
|
||
// we ask for the favorite pet | ||
// private WizardJ.Screen favoritePet = new WizardJ.Screen() { | ||
// String petName = AbstractScreen.field(SJ.j().$qmark("Pet's name", "", | ||
// AbstractScreen.valMinLen(2, SJ.j().$qmark("Name Too Short")), | ||
// AbstractScreen.valMaxLen(40, SJ.j().$qmark("Name Too Long")))); | ||
// }; | ||
|
||
|
||
|
||
|
||
// // what to do on completion of the wizard | ||
// public void finish() { | ||
// SJ.j().notice("Thank you for registering your pet: " + | ||
// favoritePet.petName() + | ||
// " your age * 3: " + nameAndAge.age() * 3); | ||
// } | ||
|
||
public void finish() { | ||
wizardScala.finish(); | ||
} | ||
|
||
} |
66 changes: 0 additions & 66 deletions
66
src/main/java/net/liftweb/seventhings/snippet/MyWizardJava.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.