01: /*
02: ItsNat Java Web Application Framework
03: Copyright (C) 2007 Innowhere Software Services S.L., Spanish Company
04: Author: Jose Maria Arranz Santamaria
05:
06: This program is free software: you can redistribute it and/or modify
07: it under the terms of the GNU Affero General Public License as published by
08: the Free Software Foundation, either version 3 of the License, or
09: (at your option) any later version. See the GNU Affero General Public
10: License for more details. See the copy of the GNU Affero General Public License
11: included in this program. If not, see <http://www.gnu.org/licenses/>.
12: */
13: package org.itsnat.impl.comp;
14:
15: import java.beans.PropertyVetoException;
16: import javax.swing.event.CellEditorListener;
17: import org.itsnat.comp.ItsNatComponent;
18: import org.itsnat.comp.ItsNatLabelEditor;
19: import org.itsnat.core.ItsNatException;
20: import org.w3c.dom.Element;
21: import org.w3c.dom.events.Event;
22:
23: /**
24: *
25: * @author jmarranz
26: */
27: public class LabelEditorProcessor extends EditorProcessorBase implements
28: CellEditorListener {
29: public LabelEditorProcessor(ItsNatLabelImpl compParent) {
30: super (compParent);
31: }
32:
33: public ItsNatLabelImpl getItsNatLabel() {
34: return (ItsNatLabelImpl) compParent;
35: }
36:
37: public ItsNatLabelEditor getItsNatLabelEditor() {
38: return (ItsNatLabelEditor) cellEditor;
39: }
40:
41: public void setItsNatLabelEditor(ItsNatLabelEditor cellEditor) {
42: setCellEditor(cellEditor);
43: }
44:
45: public void startEdition() {
46: if (prepareEdition()) {
47: openEditor();
48: }
49: }
50:
51: private void openEditor() {
52: // setCurrentContext(cellInfo,path);
53:
54: ItsNatLabelImpl label = getItsNatLabel();
55: Object value = label.getValue();
56: Element contentElem = label.getElement();
57: beforeShow(contentElem);
58: ItsNatLabelEditor cellEditor = getItsNatLabelEditor();
59: ItsNatComponent compEditor = cellEditor
60: .getLabelEditorComponent(label, value, contentElem);
61: afterShow(compEditor);
62: }
63:
64: protected void openEditor(Event evt) {
65: openEditor();
66: }
67:
68: public void acceptNewValue(Object value) {
69: try {
70: getItsNatLabel().setValue(value);
71: } catch (PropertyVetoException ex) {
72: throw new ItsNatException(ex);
73: }
74: }
75:
76: public void clearCurrentContext() {
77: // setCurrentContext(null,null);
78: }
79: }
|