# HG changeset patch # User Jaroslav Tulach # Date 1365048756 -7200 # Node ID b486f65ac4f53325563f3562af43a3a9e6db4a7a # Parent a85e27899a809bb72dbe03a632bb634a3bd0e66a Allow models to be (static) inner classes diff -r a85e27899a80 -r b486f65ac4f5 javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/PageProcessor.java --- a/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/PageProcessor.java Wed Apr 03 18:23:49 2013 +0200 +++ b/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/PageProcessor.java Thu Apr 04 06:12:36 2013 +0200 @@ -138,7 +138,7 @@ w.append(" private boolean locked;\n"); w.append(" private org.apidesign.bck2brwsr.htmlpage.Knockout ko;\n"); w.append(body.toString()); - w.append(" private static Class<" + e.getSimpleName() + "> modelFor() { return null; }\n"); + w.append(" private static Class<" + inPckName(e) + "> modelFor() { return null; }\n"); w.append(" public ").append(className).append("() {\n"); w.append(" ko = org.apidesign.bck2brwsr.htmlpage.Knockout.applyBindings(this, "); writeStringArray(propsGetSet, w); @@ -785,4 +785,18 @@ w.write(" return sb.toString();\n"); w.write(" }\n"); } + + private String inPckName(Element e) { + StringBuilder sb = new StringBuilder(); + while (e.getKind() != ElementKind.PACKAGE) { + if (sb.length() == 0) { + sb.append(e.getSimpleName()); + } else { + sb.insert(0, '.'); + sb.insert(0, e.getSimpleName()); + } + e = e.getEnclosingElement(); + } + return sb.toString(); + } } diff -r a85e27899a80 -r b486f65ac4f5 javaquery/api/src/test/java/org/apidesign/bck2brwsr/htmlpage/PeopleImpl.java --- a/javaquery/api/src/test/java/org/apidesign/bck2brwsr/htmlpage/PeopleImpl.java Wed Apr 03 18:23:49 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,34 +0,0 @@ -/** - * Back 2 Browser Bytecode Translator - * Copyright (C) 2012 Jaroslav Tulach - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. Look for COPYING file in the top folder. - * If not, see http://opensource.org/licenses/GPL-2.0. - */ -package org.apidesign.bck2brwsr.htmlpage; - -import org.apidesign.bck2brwsr.htmlpage.api.Model; -import org.apidesign.bck2brwsr.htmlpage.api.Property; - -/** - * - * @author Jaroslav Tulach - */ -@Model(className = "People", properties = { - @Property(array = true, name = "info", type = PersonImpl.class), - @Property(array = true, name = "nicknames", type = String.class), - @Property(array = true, name = "age", type = int.class), -}) -public class PeopleImpl { - -} diff -r a85e27899a80 -r b486f65ac4f5 javaquery/api/src/test/java/org/apidesign/bck2brwsr/htmlpage/PersonImpl.java --- a/javaquery/api/src/test/java/org/apidesign/bck2brwsr/htmlpage/PersonImpl.java Wed Apr 03 18:23:49 2013 +0200 +++ b/javaquery/api/src/test/java/org/apidesign/bck2brwsr/htmlpage/PersonImpl.java Thu Apr 04 06:12:36 2013 +0200 @@ -50,4 +50,11 @@ p.setSex(Sex.MALE); } } + + @Model(className = "People", properties = { + @Property(array = true, name = "info", type = PersonImpl.class), + @Property(array = true, name = "nicknames", type = String.class), + @Property(array = true, name = "age", type = int.class),}) + public class PeopleImpl { + } }