1 14 package wingset; 15 16 17 import org.wings.*; 18 import org.wings.event.SComponentAdapter; 19 import org.wings.event.SComponentEvent; 20 import org.wings.session.SessionManager; 21 import org.apache.commons.logging.Log; 22 import org.apache.commons.logging.LogFactory; 23 24 30 abstract public class WingSetPane extends SPanel implements SConstants { 31 protected final static transient Log log = LogFactory.getLog(WingSetPane.class); 32 private static final SResourceIcon SOURCE_LABEL_ICON = new SResourceIcon("org/wings/icons/File.gif"); 33 private boolean initialized = false; 34 35 public WingSetPane() { 36 setLayout(createResourceTemplate("/templates/ContentLayout.thtml")); 37 38 SAnchor anchor = new SAnchor("../" + getClass().getName().substring(getClass().getName().indexOf('.') + 1) + ".java"); 39 anchor.setTarget("sourceWindow"); 40 anchor.add(new SLabel("view java source code", SOURCE_LABEL_ICON)); 41 add(anchor, "viewSource"); 42 43 addComponentListener(new SComponentAdapter() { 44 public void componentShown(SComponentEvent e) { 45 initializePanel(); 46 } 47 }); 48 } 49 50 protected void initializePanel() { 51 if (!initialized) { 52 SComponent exampleComponent = createExample(); 53 exampleComponent.setHorizontalAlignment(SConstants.CENTER); 54 add(exampleComponent, "content"); initialized = true; 56 } 57 } 58 59 62 protected abstract SComponent createExample(); 63 64 protected static SLayoutManager createResourceTemplate(String name) { 65 try { 66 return new STemplateLayout(SessionManager.getSession().getServletContext().getRealPath(name)); 67 } catch (Exception ex) { 68 log.error("Ex",ex); 69 } 70 return null; 71 } 72 } 73 | Popular Tags |