KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > wings > plaf > css > msie > TabbedPaneCG


1 /*
2  * $Id: TabbedPaneCG.java,v 1.3 2005/06/07 12:55:59 neurolabs Exp $
3  * Copyright 2000,2005 wingS development team.
4  *
5  * This file is part of wingS (http://www.j-wings.org).
6  *
7  * wingS is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU Lesser General Public License
9  * as published by the Free Software Foundation; either version 2.1
10  * of the License, or (at your option) any later version.
11  *
12  * Please see COPYING for the complete licence.
13  */

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 JavaDoc;
31 import java.util.HashMap JavaDoc;
32 import java.util.Map JavaDoc;
33
34 /**
35  * @author ole
36  *
37  */

38 public class TabbedPaneCG extends org.wings.plaf.css.TabbedPaneCG implements SParentFrameListener {
39     private static final String JavaDoc FORMS_JS = (String JavaDoc) SessionManager
40     .getSession().getCGManager().getObject("JScripts.form",
41             String JavaDoc.class);
42
43
44     /* (non-Javadoc)
45      * @see org.wings.plaf.css.TabbedPaneCG#writeButtonStart(org.wings.io.Device, org.wings.STabbedPane, java.lang.String)
46      */

47     protected void writeButtonStart(Device device, STabbedPane tabbedPane, String JavaDoc value) throws IOException JavaDoc {
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 JavaDoc 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     /* (non-Javadoc)
75      * @see org.wings.plaf.css.TabbedPaneCG#writeButtonEnd(org.wings.io.Device)
76      */

77     protected void writeButtonEnd(Device device) throws IOException JavaDoc {
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 JavaDoc msieMappings = new HashMap JavaDoc();
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