This is great. I just submitted a minor change to the variable names and Javadoc, but otherwise I love this. Combined with the annotation change proposed here:
http://java.dzone.com/news/building-simple-rss-client it will be much easier to write and launch apps in Pivot 1.2. Thanks! On Friday, May 01, 2009, at 10:01AM, "Noel Grandin" <[email protected]> wrote: >Hi > >I've been using the following patch to DeskopApplicationContext for my >code quite a bit. > >It makes it easier to make my pivot code runnable from inside an IDE - >now I can just point Eclipse to one of my classes and got "Run As Java >Application" > >Regards, Noel. > >Index: wtk/src/pivot/wtk/DesktopApplicationContext.java >=================================================================== >--- wtk/src/pivot/wtk/DesktopApplicationContext.java (revision 770656) >+++ wtk/src/pivot/wtk/DesktopApplicationContext.java (working copy) >@@ -26,6 +26,7 @@ > > import pivot.collections.HashMap; > import pivot.collections.immutable.ImmutableMap; >+import pivot.tutorials.layout.Forms; > import pivot.wtk.media.Image; > import pivot.wtk.media.Picture; > >@@ -172,6 +173,25 @@ > System.exit(0); > } > >+ /** >+ * Utility method to make it easier to define main() entry-points in >applications. >+ * >+ * Then your main class looks like: >+ * <code> >+ * public class MyApp implements Application { >+ * public static void main(String[] args) throws Exception { >+ * DesktopApplicationContext.main(MyApp.class, args); >+ * } >+ * } >+ * </code> >+ */ >+ public static void main(Class<? extends Application> clazz, String[] >args) { >+ String [] newArgs = new String[args.length+1]; >+ System.arraycopy(args, 0, newArgs, 1, args.length); >+ newArgs[0] = clazz.getName(); >+ main(newArgs); >+ } >+ > public static void main(String[] args) { > if (application != null) { > throw new IllegalStateException(); > >
