if (!needsUpdate) { proto.markChecked ();
if (!needsUpdate)
    public void updatePrototype (String name) {        // System.err.println ("UPDATE PROTO: "+app.getName()+"/"+name);        Prototype proto = getPrototype (name);        if (proto == null)            return;        if (System.currentTimeMillis() - proto.getLastCheck() < 1000)            return;        synchronized (proto) {        if (System.currentTimeMillis() - proto.getLastCheck() < 1000)            return;        File dir = new File (appDir, name);        boolean needsUpdate = false;        HashSet updatables = null;        // our plan is to do as little as possible, so first check if anything has changed at all...        for (Iterator i = proto.updatables.values().iterator(); i.hasNext(); ) {            Updatable upd = (Updatable) i.next();            if (upd.needsUpdate ()) {                if (updatables == null)                    updatables = new HashSet ();                needsUpdate = true;                updatables.add (upd);            }        }        // check if file have been created since last update        if (proto.lastUpdate < dir.lastModified ()) {            String[] list = dir.list();            for (int i=0; i<list.length; i++) {                String fn = list[i];                if (!proto.updatables.containsKey (fn)) {                    if (fn.endsWith (app.templateExtension) || fn.endsWith (app.scriptExtension) ||	    	fn.endsWith (app.actionExtension) || fn.endsWith (app.skinExtension) ||	    	"type.properties".equalsIgnoreCase (fn)) {                        needsUpdate = true;                        // updatables.add ("[new:"+proto.getName()+"/"+fn+"]");                    }                }            }        }        if (!needsUpdate) {            proto.markChecked ();            return;        }        // let the thread know we had to do something.        idleSeconds = 0;        // app.logEvent ("TypeManager: Updating prototypes for "+app.getName()+": "+updatables);        // first go through new files and create new items        String[] list = dir.list ();        for (int i=0; i<list.length; i++) {            String fn = list[i];            int dot = fn.indexOf (".");            if (dot < 0)                continue;            if (proto.updatables.containsKey (fn) || !(fn.endsWith (app.templateExtension) || fn.endsWith (app.scriptExtension) ||            fn.endsWith (app.actionExtension) || fn.endsWith (app.skinExtension) || "type.properties".equalsIgnoreCase (fn))) {                continue;            }            String tmpname = list[i].substring(0, dot);            File tmpfile = new File (dir, list[i]);            if (list[i].endsWith (app.templateExtension)) {                try {                    Template t = new Template (tmpfile, tmpname, proto);                    proto.updatables.put (list[i], t);                    proto.templates.put (tmpname, t);                } catch (Throwable x) {                    app.logEvent ("Error updating prototype: "+x);                }            } else if (list[i].endsWith (app.scriptExtension)) {                try {                    FunctionFile ff = new FunctionFile (tmpfile, tmpname, proto);                    proto.updatables.put (list[i], ff);                    proto.functions.put (tmpname, ff);                } catch (Throwable x) {                    app.logEvent ("Error updating prototype: "+x);                }            }  else if (list[i].endsWith (app.actionExtension)) {                try {                    ActionFile af = new ActionFile (tmpfile, tmpname, proto);                    proto.updatables.put (list[i], af);                    proto.actions.put (tmpname, af);                } catch (Throwable x) {                    app.logEvent ("Error updating prototype: "+x);                }            }  else if (list[i].endsWith (app.skinExtension)) {                SkinFile sf = new SkinFile (tmpfile, tmpname, proto);                proto.updatables.put (list[i], sf);                proto.skins.put (tmpname, sf);            }        }        // next go through existing updatables        if (updatables != null) {            for (Iterator i = updatables.iterator(); i.hasNext(); ) {                Updatable upd = (Updatable) i.next();                if (upd.needsUpdate ()) {                    if (upd instanceof DbMapping)                        rewire = true;                    try {                        upd.update ();                    } catch (Exception x) {                         if (upd instanceof DbMapping)                            app.logEvent ("Error updating db mapping for type "+name+": "+x);                         else                            app.logEvent ("Error updating "+upd+" of prototye type "+name+": "+x);                    }                }            }        }        proto.markUpdated();        } // end of synchronized (proto)        // app.scriptingEngine.updatePrototype (proto);    }