1 14 package org.wings.plaf.css.msie; 15 16 import org.wings.SComponent; 17 import org.wings.SConstants; 18 import org.wings.SFrame; 19 import org.wings.STabbedPane; 20 import org.wings.event.SParentFrameEvent; 21 import org.wings.event.SParentFrameListener; 22 import org.wings.externalizer.ExternalizeManager; 23 import org.wings.header.Script; 24 import org.wings.io.Device; 25 import org.wings.resource.ClasspathResource; 26 import org.wings.resource.DefaultURLResource; 27 import org.wings.session.SessionManager; 28 import org.wings.style.CSSSelector; 29 30 import java.io.IOException ; 31 import java.util.HashMap ; 32 import java.util.Map ; 33 34 38 public class TabbedPaneCG extends org.wings.plaf.css.TabbedPaneCG implements SParentFrameListener { 39 private static final String FORMS_JS = (String ) SessionManager 40 .getSession().getCGManager().getObject("JScripts.form", 41 String .class); 42 43 44 47 protected void writeButtonStart(Device device, STabbedPane tabbedPane, String value) throws IOException { 48 device.print("<button onclick=\"addHiddenField(this.form,'"); 49 device.print(tabbedPane.getParentFrame().getEventEpoch()); 50 device.print(SConstants.UID_DIVIDER); 51 device.print(SConstants.IEFIX_BUTTONACTION); 52 device.print("','"); 53 device.print(tabbedPane.getName()); 54 device.print(SConstants.UID_DIVIDER); 55 device.print(value); 56 device.print("')\""); 57 } 58 59 public void installCG(SComponent component) { 60 super.installCG(component); 61 component.addParentFrameListener(this); 62 } 63 64 public void parentFrameAdded(SParentFrameEvent e) { 65 SFrame parentFrame = e.getParentFrame(); 66 ClasspathResource res = new ClasspathResource(FORMS_JS, "text/javascript"); 67 String jScriptUrl = SessionManager.getSession().getExternalizeManager().externalize(res, ExternalizeManager.GLOBAL); 68 parentFrame.addHeader(new Script("text/javascript", new DefaultURLResource(jScriptUrl))); 69 } 70 71 public void parentFrameRemoved(SParentFrameEvent e) { 72 } 73 74 77 protected void writeButtonEnd(Device device) throws IOException { 78 super.writeButtonEnd(device); 79 device.print("<span> </span>"); 80 } 81 82 public CSSSelector mapSelector(SComponent addressedComponent, CSSSelector selector) { 83 CSSSelector mappedSelector = (CSSSelector) msieMappings.get(selector); 84 return mappedSelector != null ? mappedSelector : selector; 85 } 86 87 private static final Map msieMappings = new HashMap (); 88 static { 89 msieMappings.put(STabbedPane.SELECTOR_SELECTED_TAB, new CSSSelector (" *.STabbedPane_Tab_selected")); 90 msieMappings.put(STabbedPane.SELECTOR_UNSELECTED_TAB, new CSSSelector (" *.STabbedPane_Tab_unselected")); 91 msieMappings.put(STabbedPane.SELECTOR_CONTENT, new CSSSelector (" td.STabbedPane_pane")); 92 msieMappings.put(STabbedPane.SELECTOR_TAB_AREA, new CSSSelector (" table.STabbedPane th")); 93 } 94 95 96 } 97 | Popular Tags |