001: /*
002: * Copyright 2005 jWic Group (http://www.jwic.de)
003: * $Id: SubFrameControl.java,v 1.1 2006/01/16 08:31:12 lordsam Exp $
004: */
005: package de.jwic.controls;
006:
007: import de.jwic.base.ControlContainer;
008: import de.jwic.base.IControlContainer;
009: import de.jwic.base.IOuterLayout;
010:
011: /**
012: * Displays controls in a window style subframe.
013: * @author Florian Lippisch
014: */
015: public class SubFrameControl extends ControlContainer implements
016: IOuterLayout {
017:
018: private static final long serialVersionUID = 1L;
019:
020: private String width = "100%";
021: private int height = 0;
022: private String title = "";
023: private boolean borderLeft = false;
024: private boolean closeable = true;
025:
026: /**
027: * @param container
028: */
029: public SubFrameControl(IControlContainer container) {
030: super (container);
031: init();
032: }
033:
034: /**
035: * @param container
036: * @param name
037: */
038: public SubFrameControl(IControlContainer container, String name) {
039: super (container, name);
040: init();
041: }
042:
043: /**
044: * Initialize the control.
045: */
046: private void init() {
047: setRendererId(DEFAULT_OUTER_RENDERER);
048: }
049:
050: /**
051: * Returns the total height of the sub frame.
052: * @return int - height in pixel
053: */
054: public int getHeight() {
055: return height;
056: }
057:
058: /**
059: * Returns the title of the sub frame.
060: * @return
061: */
062: public String getTitle() {
063: return title;
064: }
065:
066: /**
067: * Returns the width of the sub frame.
068: * @return
069: */
070: public String getWidth() {
071: return width;
072: }
073:
074: /**
075: * Set the height of the frame. Set to 0 if the size should be dynamic.
076: * @param int - height in pixel
077: */
078: public void setHeight(int newHeight) {
079: height = newHeight;
080: }
081:
082: /**
083: * Set the title of the subframe.
084: * @param string
085: */
086: public void setTitle(String string) {
087: title = string;
088: }
089:
090: /**
091: * Set the width of the subframe.
092: * @param string
093: */
094: public void setWidth(String string) {
095: width = string;
096: }
097:
098: /**
099: * @param event
100: */
101: public void actionPerformed(String actionId, String param) {
102:
103: if (actionId.equals("closeframe")) {
104: closeFrame();
105: }
106: }
107:
108: /**
109: * Close/Hide the sub frame.
110: */
111: public void closeFrame() {
112: setVisible(false);
113: }
114:
115: /**
116: * @return
117: */
118: public boolean isBorderLeft() {
119: return borderLeft;
120: }
121:
122: /**
123: * @param b
124: */
125: public void setBorderLeft(boolean b) {
126: borderLeft = b;
127: }
128:
129: /**
130: * Returns <code>null</code> if the class has not been extended and
131: * no template name has been set.
132: * @see de.jwic.base.Control#getTemplateName()
133: */
134: public String getTemplateName() {
135: if (super .getTemplateName().equals(
136: SubFrameControl.class.getName())) {
137: return null;
138: }
139: return super .getTemplateName();
140: }
141:
142: /* (non-Javadoc)
143: * @see de.jwic.base.IOuterLayout#getOuterTemplateName()
144: */
145: public String getOuterTemplateName() {
146: return SubFrameControl.class.getName();
147: }
148:
149: /**
150: * @return Returns true if closeable.
151: */
152: public boolean isCloseable() {
153: return closeable;
154: }
155:
156: /**
157: * @param closeable Set to true if closeable.
158: */
159: public void setCloseable(boolean closeable) {
160: this.closeable = closeable;
161: }
162: }
|