1 14 package org.wings; 15 16 import org.apache.commons.logging.Log; 17 import org.apache.commons.logging.LogFactory; 18 19 20 36 public abstract class SRootContainer extends SContainer { 37 private final static transient Log log = LogFactory.getLog(SRootContainer.class); 38 39 42 protected final SContainer contentPane; 43 44 48 public SRootContainer() { 49 contentPane = new SPanel(); 50 super.setLayout(new SRootLayout()); 51 super.addComponent(getContentPane(), null, getComponentCount()); 52 } 53 54 60 public void pushDialog(SDialog dialog) { 61 log.debug("push dialog = " + dialog.getName()); 62 super.addComponent(dialog, null, getComponentCount()); 63 dialog.setFrame(this); 64 reload(); 65 } 66 67 72 public SDialog popDialog() { 73 int count = getComponentCount(); 74 if (count <= 1) 75 throw new IllegalStateException ("there's no dialog left!"); 76 77 SDialog dialog = (SDialog) getComponent(count - 1); 78 super.remove(dialog); 79 dialog.setFrame(null); 80 81 reload(); 82 log.debug("pop dialog = " + dialog.getName()); 83 return dialog; 84 } 85 86 public void removeDialog(SDialog dialog) { 87 super.remove(dialog); 88 dialog.setFrame((SFrame) null); 89 reload(); 90 } 91 92 95 public int getDialogCount() { 96 return getComponentCount() - 1; 97 } 98 99 102 public SContainer getContentPane() { 103 return contentPane; 104 } 105 106 109 public SComponent addComponent(SComponent c, Object constraint, int index) { 110 throw new IllegalArgumentException ("use getContentPane().addComponent()"); 111 } 112 113 116 public void remove(SComponent c) { 117 throw new IllegalArgumentException ("use getContentPane().removeComponent()"); 118 } 119 } 120 | Popular Tags |