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.ItsNatLabelEditor;
025: import org.itsnat.comp.html.ItsNatHTMLComponentManager;
026: import org.itsnat.comp.html.ItsNatHTMLInputCheckBox;
027: import org.itsnat.comp.html.ItsNatHTMLInputText;
028: import org.itsnat.comp.html.ItsNatHTMLInputTextFormatted;
029: import org.itsnat.comp.html.ItsNatHTMLLabel;
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 LabelTreeNode extends FeatureTreeNode implements
038: EventListener, PropertyChangeListener {
039: protected ItsNatHTMLLabel comp1;
040: protected ItsNatHTMLLabel comp2;
041: protected ItsNatHTMLLabel comp3;
042: protected ItsNatHTMLLabel comp4;
043: protected ItsNatHTMLLabel comp5;
044:
045: public LabelTreeNode() {
046: }
047:
048: public void startExamplePanel() {
049: try {
050: ItsNatHTMLDocument itsNatDoc = (ItsNatHTMLDocument) getItsNatDocument();
051: ItsNatHTMLComponentManager componentMgr = itsNatDoc
052: .getItsNatHTMLComponentManager();
053:
054: this .comp1 = (ItsNatHTMLLabel) componentMgr
055: .createItsNatComponentById("labelId1");
056: comp1.setValue("Any Text");
057: ItsNatHTMLInputText textInput = componentMgr
058: .createItsNatHTMLInputText(null, null);
059: shared(comp1, textInput);
060:
061: this .comp2 = (ItsNatHTMLLabel) componentMgr
062: .createItsNatComponentById("labelId2");
063: comp2.setValue(Boolean.TRUE);
064: ItsNatHTMLInputCheckBox checkBox = componentMgr
065: .createItsNatHTMLInputCheckBox(null, null);
066: shared(comp2, checkBox);
067:
068: this .comp3 = (ItsNatHTMLLabel) componentMgr
069: .createItsNatComponentById("labelId3");
070: comp3.setValue(new Integer(3));
071: ItsNatHTMLSelectComboBox comboBox = componentMgr
072: .createItsNatHTMLSelectComboBox(null, null);
073: DefaultComboBoxModel model = (DefaultComboBoxModel) comboBox
074: .getComboBoxModel();
075: for (int i = 0; i < 5; i++)
076: model.addElement(new Integer(i));
077: shared(comp3, comboBox);
078:
079: this .comp4 = (ItsNatHTMLLabel) componentMgr
080: .createItsNatComponentById("labelId4");
081: comp4.setValue(new Date());
082: ItsNatHTMLInputTextFormatted textInputFormatted = componentMgr
083: .createItsNatHTMLInputTextFormatted(null, null);
084: shared(comp4, textInputFormatted);
085:
086: this .comp5 = (ItsNatHTMLLabel) componentMgr
087: .createItsNatComponentById("labelId5");
088: comp5.setValue("Any \n Text");
089: ItsNatHTMLTextArea textArea = componentMgr
090: .createItsNatHTMLTextArea(null, null);
091: shared(comp5, textArea);
092:
093: } catch (PropertyVetoException ex) {
094: throw new RuntimeException(ex);
095: }
096: }
097:
098: public void endExamplePanel() {
099: this .comp1.dispose();
100: this .comp1 = null;
101:
102: this .comp2.dispose();
103: this .comp2 = null;
104:
105: this .comp3.dispose();
106: this .comp3 = null;
107:
108: this .comp4.dispose();
109: this .comp4 = null;
110:
111: this .comp5.dispose();
112: this .comp5 = null;
113: }
114:
115: public void shared(ItsNatHTMLLabel comp, ItsNatComponent editorComp) {
116: ItsNatHTMLDocument itsNatDoc = (ItsNatHTMLDocument) getItsNatDocument();
117: ItsNatHTMLComponentManager componentMgr = itsNatDoc
118: .getItsNatHTMLComponentManager();
119: ItsNatLabelEditor editor = componentMgr
120: .createDefaultItsNatLabelEditor(editorComp);
121: comp.setItsNatLabelEditor(editor);
122: comp.addEventListener("dblclick", this );
123: comp.addPropertyChangeListener("value", this );
124: }
125:
126: public void handleEvent(Event evt) {
127: log(evt.getCurrentTarget() + " " + evt.getType());
128: }
129:
130: public void propertyChange(PropertyChangeEvent evt) {
131: log(evt.getClass() + ", old: " + evt.getOldValue() + ", new: "
132: + evt.getNewValue());
133: }
134: }
|