001: /*
002: * This file is not part of the ItsNat framework.
003: *
004: * Original source code use and closed source derivatives are authorized
005: * to third parties with no restriction or fee.
006: * The original source code is owned by the author.
007: *
008: * This program is distributed AS IS in the hope that it will be useful,
009: * but WITHOUT ANY WARRANTY; without even the implied warranty of
010: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
011: *
012: * Author: Jose Maria Arranz Santamaria
013: * (C) Innowhere Software Services S.L., Spanish company, year 2007
014: */
015:
016: package org.itsnat.feashow.features.components.labels;
017:
018: import java.beans.PropertyChangeEvent;
019: import java.beans.PropertyChangeListener;
020: import java.beans.PropertyVetoException;
021: import java.util.Date;
022: import javax.swing.DefaultComboBoxModel;
023: import org.itsnat.comp.ItsNatComponent;
024: import org.itsnat.comp.free.ItsNatFreeLabel;
025: import org.itsnat.comp.ItsNatLabelEditor;
026: import org.itsnat.comp.html.ItsNatHTMLComponentManager;
027: import org.itsnat.comp.html.ItsNatHTMLInputCheckBox;
028: import org.itsnat.comp.html.ItsNatHTMLInputText;
029: import org.itsnat.comp.html.ItsNatHTMLInputTextFormatted;
030: import org.itsnat.comp.html.ItsNatHTMLSelectComboBox;
031: import org.itsnat.comp.html.ItsNatHTMLTextArea;
032: import org.itsnat.core.html.ItsNatHTMLDocument;
033: import org.itsnat.feashow.FeatureTreeNode;
034: import org.w3c.dom.events.Event;
035: import org.w3c.dom.events.EventListener;
036:
037: public class FreeLabelTreeNode extends FeatureTreeNode implements
038: EventListener, PropertyChangeListener {
039: protected ItsNatFreeLabel comp1;
040: protected ItsNatFreeLabel comp2;
041: protected ItsNatFreeLabel comp3;
042: protected ItsNatFreeLabel comp4;
043: protected ItsNatFreeLabel comp5;
044:
045: public FreeLabelTreeNode() {
046: }
047:
048: public void startExamplePanel() {
049: try {
050: ItsNatHTMLDocument itsNatDoc = (ItsNatHTMLDocument) getItsNatDocument();
051: ItsNatHTMLComponentManager componentMgr = itsNatDoc
052: .getItsNatHTMLComponentManager();
053:
054: this .comp1 = (ItsNatFreeLabel) componentMgr
055: .createItsNatComponentById("labelId1", "freeLabel",
056: null);
057: comp1.setValue("Any Text");
058: ItsNatHTMLInputText textInput = componentMgr
059: .createItsNatHTMLInputText(null, null);
060: shared(comp1, textInput);
061:
062: this .comp2 = (ItsNatFreeLabel) componentMgr
063: .createItsNatComponentById("labelId2", "freeLabel",
064: null);
065: comp2.setValue(Boolean.TRUE);
066: ItsNatHTMLInputCheckBox checkBox = componentMgr
067: .createItsNatHTMLInputCheckBox(null, null);
068: shared(comp2, checkBox);
069:
070: this .comp3 = (ItsNatFreeLabel) componentMgr
071: .createItsNatComponentById("labelId3", "freeLabel",
072: null);
073: comp3.setValue(new Integer(3));
074: ItsNatHTMLSelectComboBox comboBox = componentMgr
075: .createItsNatHTMLSelectComboBox(null, null);
076: DefaultComboBoxModel model = (DefaultComboBoxModel) comboBox
077: .getComboBoxModel();
078: for (int i = 0; i < 5; i++)
079: model.addElement(new Integer(i));
080: shared(comp3, comboBox);
081:
082: this .comp4 = (ItsNatFreeLabel) componentMgr
083: .createItsNatComponentById("labelId4", "freeLabel",
084: null);
085: comp4.setValue(new Date());
086: ItsNatHTMLInputTextFormatted textInputFormatted = componentMgr
087: .createItsNatHTMLInputTextFormatted(null, null);
088: shared(comp4, textInputFormatted);
089:
090: this .comp5 = (ItsNatFreeLabel) componentMgr
091: .createItsNatComponentById("labelId5", "freeLabel",
092: null);
093: comp5.setValue("Any \n Text");
094: ItsNatHTMLTextArea textArea = componentMgr
095: .createItsNatHTMLTextArea(null, null);
096: shared(comp5, textArea);
097: } catch (PropertyVetoException ex) {
098: throw new RuntimeException(ex);
099: }
100: }
101:
102: public void endExamplePanel() {
103: this .comp1.dispose();
104: this .comp1 = null;
105:
106: this .comp2.dispose();
107: this .comp2 = null;
108:
109: this .comp3.dispose();
110: this .comp3 = null;
111:
112: this .comp4.dispose();
113: this .comp4 = null;
114:
115: this .comp5.dispose();
116: this .comp5 = null;
117: }
118:
119: public void shared(ItsNatFreeLabel comp, ItsNatComponent editorComp) {
120: ItsNatHTMLDocument itsNatDoc = (ItsNatHTMLDocument) getItsNatDocument();
121: ItsNatHTMLComponentManager componentMgr = itsNatDoc
122: .getItsNatHTMLComponentManager();
123: ItsNatLabelEditor editor = componentMgr
124: .createDefaultItsNatLabelEditor(editorComp);
125: comp.setItsNatLabelEditor(editor);
126: comp.addEventListener("click", this );
127: comp.addPropertyChangeListener("value", this );
128: comp.setEditorActivatorEvent("click");
129: }
130:
131: public void handleEvent(Event evt) {
132: log(evt.getCurrentTarget() + " " + evt.getType());
133: }
134:
135: public void propertyChange(PropertyChangeEvent evt) {
136: log(evt.getClass() + ", old: " + evt.getOldValue() + ", new: "
137: + evt.getNewValue());
138: }
139: }
|