01: /*
02: * Copyright (C) 2005 Jeff Tassin
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2.1 of the License, or (at your option) any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: */
18:
19: package com.jeta.swingbuilder.gui.properties.editors;
20:
21: import java.awt.Component;
22: import java.awt.Graphics;
23: import java.awt.Rectangle;
24:
25: import com.jeta.forms.store.properties.CompoundLineProperty;
26: import com.jeta.open.gui.framework.JETADialog;
27: import com.jeta.open.gui.utils.JETAToolbox;
28: import com.jeta.open.i18n.I18N;
29: import com.jeta.swingbuilder.gui.components.line.CompoundLineValidator;
30: import com.jeta.swingbuilder.gui.components.line.CompoundLineView;
31: import com.jeta.swingbuilder.gui.properties.JETAPropertyEditor;
32: import com.jeta.swingbuilder.gui.utils.FormDesignerUtils;
33:
34: public class LineEditor extends JETAPropertyEditor {
35: /**
36: * Used to render the value of our border
37: */
38: private ValuePainter m_value_painter;
39:
40: /**
41: * ctor
42: */
43: public LineEditor() {
44: m_value_painter = new ValuePainter(I18N
45: .getLocalizedMessage("line definition"));
46: m_value_painter
47: .setPreImages((javax.swing.ImageIcon) FormDesignerUtils
48: .loadImage("forms/line_property.gif"));
49: }
50:
51: /**
52: * Invokes a dialog used to update the property
53: */
54: public void invokePropertyDialog(Component comp) {
55: CompoundLineView view = new CompoundLineView(
56: (CompoundLineProperty) getValue());
57: JETADialog dlg = (JETADialog) JETAToolbox.createDialog(
58: JETADialog.class, comp, true);
59: dlg.addValidator(view, new CompoundLineValidator());
60: dlg.setPrimaryPanel(view);
61: dlg.setSize(dlg.getPreferredSize());
62: dlg.setTitle(I18N.getLocalizedMessage("Edit Line"));
63: dlg.showCenter();
64: if (dlg.isOk()) {
65: setValue(view.createLineProperty());
66: }
67: }
68:
69: /**
70: * Determines whether this class renders itself using the
71: * paintValue(Graphics g, Rectangle rect) method. Generally, editors that
72: * are not JComponents are paintable.
73: */
74: public boolean isPaintable() {
75: return true;
76: }
77:
78: /**
79: * Method that renders the text on the given graphics context
80: */
81: public void paintValue(Graphics g, Rectangle rect) {
82: // forward the call to the value painter
83: m_value_painter.paintValue(g, rect);
84: }
85:
86: /**
87: * Sets the value for this editor
88: */
89: public void setValue(Object value) {
90: super .setValue(value);
91: }
92:
93: /**
94: * @return true since we have a custom editor dialog for this type
95: */
96: public boolean supportsCustomEditor() {
97: return true;
98: }
99: }
|