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 javax.swing.ImageIcon;
26:
27: import com.jeta.forms.store.properties.ScrollBarsProperty;
28: import com.jeta.open.gui.framework.JETADialog;
29: import com.jeta.open.gui.utils.JETAToolbox;
30: import com.jeta.open.i18n.I18N;
31: import com.jeta.swingbuilder.gui.components.scrollbars.ScrollPolicyView;
32: import com.jeta.swingbuilder.gui.properties.JETAPropertyEditor;
33: import com.jeta.swingbuilder.gui.utils.FormDesignerUtils;
34: import com.jeta.swingbuilder.resources.Icons;
35:
36: /**
37: * Property editor for scrollbars. A scroll property is a custom JETAProperty
38: * for scrollable components such as JTextArea, JList, JTable, etc. We currently
39: * don't support directly editing JScrollPanes in the builder so we have this
40: * 'psuedo' property instead that is attached to scrollable components.
41: *
42: * @author Jeff Tassin
43: */
44: public class ScrollBarsEditor extends JETAPropertyEditor {
45: /**
46: * Used to render the value of our border
47: */
48: private ValuePainter m_value_painter;
49:
50: private static ImageIcon[] m_icon = { (ImageIcon) FormDesignerUtils
51: .loadImage(Icons.SCROLL_BARS_16) };
52:
53: /**
54: * ctor
55: */
56: public ScrollBarsEditor() {
57: m_value_painter = new ValuePainter(I18N
58: .getLocalizedMessage("Scroll Property"));
59: m_value_painter.setPreImages(m_icon);
60: }
61:
62: /**
63: * Invokes a dialog used to update the property
64: */
65: public void invokePropertyDialog(Component comp) {
66: ScrollPolicyView view = new ScrollPolicyView(
67: (ScrollBarsProperty) getValue());
68: JETADialog dlg = JETAToolbox.invokeDialog(view, comp, I18N
69: .getLocalizedMessage("Scroll Preferences"));
70: if (dlg.isOk()) {
71: setValue(view.getScrollBarsProperty());
72: }
73: }
74:
75: /**
76: * Determines whether this class renders itself using the
77: * paintValue(Graphics g, Rectangle rect) method. Generally, editors that
78: * are not JComponents are paintable.
79: */
80: public boolean isPaintable() {
81: return true;
82: }
83:
84: /**
85: * Method that renders the text on the given graphics context
86: */
87: public void paintValue(Graphics g, Rectangle rect) {
88: // forward the call to the value painter
89: m_value_painter.paintValue(g, rect);
90: }
91:
92: /**
93: * @return true since we have a custom editor dialog for this type
94: */
95: public boolean supportsCustomEditor() {
96: return true;
97: }
98: }
|