01: /*
02: * This file is not part of the ItsNat framework.
03: *
04: * Original source code use and closed source derivatives are authorized
05: * to third parties with no restriction or fee.
06: * The original source code is owned by the author.
07: *
08: * This program is distributed AS IS in the hope that it will be useful,
09: * but WITHOUT ANY WARRANTY; without even the implied warranty of
10: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11: *
12: * Author: Jose Maria Arranz Santamaria
13: * (C) Innowhere Software Services S.L., Spanish company, year 2007
14: */
15:
16: package org.itsnat.feashow.features.components.labels;
17:
18: import java.beans.PropertyChangeEvent;
19: import java.beans.PropertyChangeListener;
20: import java.beans.PropertyVetoException;
21: import org.itsnat.comp.free.ItsNatFreeLabel;
22: import org.itsnat.comp.ItsNatLabelEditor;
23: import org.itsnat.comp.html.ItsNatHTMLComponentManager;
24: import org.itsnat.comp.html.ItsNatHTMLInputText;
25: import org.itsnat.core.html.ItsNatHTMLDocument;
26: import org.itsnat.feashow.FeatureTreeNode;
27: import org.itsnat.feashow.features.components.shared.Person;
28: import org.w3c.dom.events.Event;
29: import org.w3c.dom.events.EventListener;
30:
31: public class FreeLabelCustomEditorTreeNode extends FeatureTreeNode
32: implements EventListener, PropertyChangeListener {
33: protected ItsNatFreeLabel comp;
34:
35: public FreeLabelCustomEditorTreeNode() {
36: }
37:
38: public void startExamplePanel() {
39: ItsNatHTMLDocument itsNatDoc = (ItsNatHTMLDocument) getItsNatDocument();
40: ItsNatHTMLComponentManager componentMgr = itsNatDoc
41: .getItsNatHTMLComponentManager();
42:
43: this .comp = (ItsNatFreeLabel) componentMgr
44: .createItsNatComponentById("labelId", "freeLabel", null);
45: try {
46: comp.setValue(new Person("Jose M.", "Arranz"));
47: } catch (PropertyVetoException ex) {
48: throw new RuntimeException(ex);
49: }
50:
51: ItsNatLabelEditor editor = new PersonCustomLabelEditor();
52: comp.setItsNatLabelEditor(editor);
53:
54: comp.addEventListener("dblclick", this );
55: comp.addPropertyChangeListener("value", this );
56: }
57:
58: public void endExamplePanel() {
59: this .comp.dispose();
60: this .comp = null;
61: }
62:
63: public void handleEvent(Event evt) {
64: log(evt.getCurrentTarget() + " " + evt.getType());
65: }
66:
67: public void propertyChange(PropertyChangeEvent evt) {
68: log(evt.getClass() + ", old: " + evt.getOldValue() + ", new: "
69: + evt.getNewValue());
70: }
71: }
|