001: /* *************************************************************************
002:
003: Millstone(TM)
004: Open Sourced User Interface Library for
005: Internet Development with Java
006:
007: Millstone is a registered trademark of IT Mill Ltd
008: Copyright (C) 2000-2005 IT Mill Ltd
009:
010: *************************************************************************
011:
012: This library is free software; you can redistribute it and/or
013: modify it under the terms of the GNU Lesser General Public
014: license version 2.1 as published by the Free Software Foundation.
015:
016: This library is distributed in the hope that it will be useful,
017: but WITHOUT ANY WARRANTY; without even the implied warranty of
018: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
019: Lesser General Public License for more details.
020:
021: You should have received a copy of the GNU Lesser General Public
022: License along with this library; if not, write to the Free Software
023: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
024:
025: *************************************************************************
026:
027: For more information, contact:
028:
029: IT Mill Ltd phone: +358 2 4802 7180
030: Ruukinkatu 2-4 fax: +358 2 4802 7181
031: 20540, Turku email: info@itmill.com
032: Finland company www: www.itmill.com
033:
034: Primary source for MillStone information and releases: www.millstone.org
035:
036: ********************************************************************** */
037:
038: package org.millstone.examples.features;
039:
040: import org.millstone.base.ui.*;
041:
042: public class FeatureWindow extends Feature {
043: Button addButton = new Button("Add to application", this , "addWin");
044: Button removeButton = new Button("Remove from application", this ,
045: "delWin");
046: Window demoWindow;
047: Form windowProperties;
048:
049: public FeatureWindow() {
050: super ();
051: }
052:
053: protected Component getDemoComponent() {
054:
055: OrderedLayout l = new OrderedLayout();
056: demoWindow = new Window("Feature Test Window");
057:
058: // Example panel
059: Panel show = new Panel("Test Window Control");
060: ((OrderedLayout) show.getLayout())
061: .setOrientation(OrderedLayout.ORIENTATION_HORIZONTAL);
062: show.addComponent(addButton);
063: show.addComponent(removeButton);
064: updateWinStatus();
065: l.addComponent(show);
066:
067: // Properties
068: PropertyPanel p = new PropertyPanel(demoWindow);
069: p.dependsOn(addButton);
070: p.dependsOn(removeButton);
071: windowProperties = p.createBeanPropertySet(new String[] {
072: "width", "height", "name", "border", "theme",
073: "scrollable", "scrollOffsetX", "scrollOffsetY" });
074: windowProperties.replaceWithSelect("border", new Object[] {
075: new Integer(Window.BORDER_DEFAULT),
076: new Integer(Window.BORDER_NONE),
077: new Integer(Window.BORDER_MINIMAL) }, new Object[] {
078: "Default", "None", "Minimal" });
079: p.addProperties("Window Properties", windowProperties);
080: l.addComponent(p);
081:
082: return l;
083: }
084:
085: protected String getExampleSrc() {
086: return "Window win = new Window();\n"
087: + "getApplication().addWindow(win);\n";
088:
089: }
090:
091: protected String getDescriptionXHTML() {
092: return "The window support of Millstone allows for opening and closing windows, "
093: + "refreshing one window from another (for asynchronous terminals), "
094: + "resizing windows and scrolling window content. "
095: + "There are also a number of preset window border styles defined by "
096: + "this feature.";
097: }
098:
099: protected String getImage() {
100: return "window.jpg";
101: }
102:
103: protected String getTitle() {
104: return "Window";
105: }
106:
107: public void addWin() {
108: getApplication().addWindow(demoWindow);
109: windowProperties.getField("name").setReadOnly(true);
110: updateWinStatus();
111: }
112:
113: public void delWin() {
114: getApplication().removeWindow(demoWindow);
115: windowProperties.getField("name").setReadOnly(false);
116: updateWinStatus();
117: }
118:
119: private void updateWinStatus() {
120: if (demoWindow.getApplication() == null) {
121: addButton.setEnabled(true);
122: removeButton.setEnabled(false);
123: } else {
124: addButton.setEnabled(false);
125: removeButton.setEnabled(true);
126: }
127: }
128: }
|