if (dragComponents.contains(dropComp)) {   } else { device.print("ADD_DHTML('");
if (dropComp.isVisible()) { if (dragComponents.contains(dropComp)) {   } else { device.print("ADD_DHTML('"); device.print(dropComp.getName()); device.print("'+NO_DRAG);\n"); } device.print("dd.elements['");
    public void write(final Device device, final SComponent _c)            throws IOException {        if (!_c.isVisible()) return;        _c.fireRenderEvent(SComponent.START_RENDERING);        final SFrame component = (SFrame) _c;        Browser browser = SessionManager.getSession().getUserAgent();        SFrame frame = (SFrame) component;        String language = SessionManager.getSession().getLocale().getLanguage();        String title = frame.getTitle();        List headers = frame.headers();        String encoding = SessionManager.getSession().getCharacterEncoding();        /**         *  We need to put IE6 into quirks mode         *  for box model compatibility. (border-box).         *  For that we make use of a comment in the first line.         *  This is a known bug in IE6         */        if (BrowserType.IE.equals(browser.getBrowserType())) {            if (browser.getMajorVersion() == 6) {                device.print("<!-- IE6 quirks mode switch -->\n");            }        }        if (renderXmlDeclaration == null || renderXmlDeclaration.booleanValue()) {            device.print("<?xml version=\"1.0\" encoding=\"");            Utils.write(device, encoding);            device.print("\"?>\n");        }        Utils.writeRaw(device, documentType);        device.print("\n");        device.print("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"");        Utils.write(device, language);        device.print("\" lang=\"");        Utils.write(device, language);        device.print("\">\n");        /* Insert version and compile time.         * Since the Version Class is generated on compile time, build errors         * in SDK's are quite normal. Just run the Version.java ant task.         */        device.print("<!-- This is wingS (http://www.j-wings.org) version ");        device.print(Version.getVersion());        device.print(" (Build date: ");        device.print(Version.getCompileTime());        device.print(") -->\n");                device.print("<head>");        if (title != null) {            device.print("<title>");            Utils.write(device, title);            device.print("</title>\n");        }        device.print("<meta http-equiv=\"Content-type\" content=\"text/html; charset=");        Utils.write(device, encoding);        device.print("\"/>\n");        Collection callableNames = CallableManager.getInstance().callableNames();        Collection allHeaders = new ArrayList(headers.size() + callableNames.size());        allHeaders.addAll(headers);        for (Iterator iterator = callableNames.iterator(); iterator.hasNext();) {            String name = (String) iterator.next();            Script header = new Script("text/javascript", new DefaultURLResource("../dwr/interface/" + name + ".js"));            allHeaders.add(header);        }        for (Iterator iterator = allHeaders.iterator(); iterator.hasNext();) {            Object next = iterator.next();            if (next instanceof Renderable) {                ((Renderable) next).write(device);            } else {                Utils.write(device, next.toString());            }            device.print("\n");        }        SComponent focus = frame.getFocus();        Object lastFocus = frame.getClientProperty("focus");        if (focus != lastFocus) {            if (lastFocus != null) {                ScriptListener[] scriptListeners = frame.getScriptListeners();                for (int i = 0; i < scriptListeners.length; i++) {                    ScriptListener scriptListener = scriptListeners[i];                    if (scriptListener instanceof FocusScriptListener)                        component.removeScriptListener(scriptListener);                }            }            if (focus != null) {                FocusScriptListener listener = new FocusScriptListener("onload", "requestFocus('" + focus.getName() + "')");                frame.addScriptListener(listener);            }            frame.putClientProperty("focus", focus);        }        // let ie understand hover css styles on elements other than anchors        if (BrowserType.IE.equals(browser.getBrowserType())) {            // externalize hover behavior            final String classPath = (String)SessionManager.getSession().getCGManager().getObject("Behaviors.ieHover", String.class);            ClasspathResource res = new ClasspathResource(classPath, "text/x-component");            String behaviorUrl = SessionManager.getSession().getExternalizeManager().externalize(res, ExternalizeManager.GLOBAL);            device.print("<style type=\"text/css\" media=\"screen\">\n");            device.print("body{behavior:url(");            device.print(behaviorUrl);            device.print(");}\n");            device.print("</style>\n");        }                // TODO: move this to a dynamic script resource        SToolTipManager toolTipManager = component.getSession().getToolTipManager();        device                .print("<script type=\"text/javascript\">\n")                .print("domTT_addPredefined('default', 'caption', false");        if (toolTipManager.isFollowMouse())            device.print(", 'trail', true");        device.print(", 'delay', ").print(toolTipManager.getInitialDelay());        device.print(", 'lifetime', ").print(toolTipManager.getDismissDelay());        device                .print(");\n")                .print("</script>\n");                device.print("</head>\n");        device.print("<body");        Utils.optAttribute(device, "id", frame.getName());        Utils.optAttribute(device, "class", frame.getStyle());        Utils.writeEvents(device, frame);        device.print(">\n");        if (frame.isVisible()) {            // now add JS for DnD if neccessary.            DragAndDropManager dndManager = frame.getSession().getDragAndDropManager();            List dragComponents = dndManager.getDragSources();            List dropComponents = dndManager.getDropTargets();            Iterator dragIter = dragComponents.iterator();            Iterator dropIter = dropComponents.iterator();            if (dragIter.hasNext()) {                // this needs to be added to the body, so use device.print()                // TODO: is caching by the VM enough or make this only initialize once?                ClasspathResource res = new ClasspathResource(WZ_DND_JS, "text/javascript");                String jScriptUrl = frame.getSession().getExternalizeManager().externalize(res, ExternalizeManager.GLOBAL);                device.print("<script type=\"text/javascript\" src=\"");                device.print(jScriptUrl);                device.print("\"></script>\n");             }                        frame.getLayout().write(device);            device.print("\n");            // now add all menus            Iterator iter = frame.getMenus().iterator();            while (iter.hasNext()) {                SComponent menu = (SComponent)iter.next();                menu.write(device);            }            // now add final JS for DnD if neccessary.            if (dragIter.hasNext()) {                device.print("<script type=\"text/javascript\">\n<!--\n");                device.print("SET_DHTML();\n");                while (dragIter.hasNext()) {                    SComponent dragComp = (SComponent)dragIter.next();                    device.print("ADD_DHTML('");                    device.print(dragComp.getName());                    device.print("'+CLONE+TRANSPARENT);\n");                    device.print("dd.elements['");                    device.print(dragComp.getName());                    device.print("'].dragsource=1;\n");                }                while (dropIter.hasNext()) {                    SComponent dropComp = (SComponent)dropIter.next();                    if (dragComponents.contains(dropComp)) {                        // This is a draggable and a dropTarget, it's already                        // added.                    } else {                        device.print("ADD_DHTML('");                        device.print(dropComp.getName());                        device.print("'+NO_DRAG);\n");                    }                    device.print("dd.elements['");                    device.print(dropComp.getName());                    device.print("'].droptarget=1;\n");                }                device.print("var wdnd_managerId = '");                device.print(dndManager.getEncodedLowLevelEventId());                device.print("';\n");                device.print("//-->\n</script>");                // TODO: is caching by the VM enough or make this only initialize once?                ClasspathResource res = new ClasspathResource(DND_JS, "text/javascript");                String jScriptUrl = SessionManager.getSession().getExternalizeManager().externalize(res, ExternalizeManager.GLOBAL);                device.print("<script type=\"text/javascript\" src=\"");                device.print(jScriptUrl);                device.print("\"></script>\n");             }        }        device.print("\n</body></html>\n");        _c.fireRenderEvent(SComponent.DONE_RENDERING);    }