001: /*
002: * Copyright (C) 2005 Jeff Tassin
003: *
004: * This library is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Lesser General Public
006: * License as published by the Free Software Foundation; either
007: * version 2.1 of the License, or (at your option) any later version.
008: *
009: * This library is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: * Lesser General Public License for more details.
013: *
014: * You should have received a copy of the GNU Lesser General Public
015: * License along with this library; if not, write to the Free Software
016: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
017: */
018:
019: package com.jeta.swingbuilder.gui.properties.editors;
020:
021: import java.awt.Component;
022: import java.awt.Graphics;
023: import java.awt.Rectangle;
024:
025: import javax.swing.ImageIcon;
026:
027: import com.jeta.forms.store.properties.effects.PaintProperty;
028: import com.jeta.open.gui.framework.JETADialog;
029: import com.jeta.open.gui.utils.JETAToolbox;
030: import com.jeta.open.i18n.I18N;
031: import com.jeta.swingbuilder.gui.effects.PaintAssignmentView;
032: import com.jeta.swingbuilder.gui.properties.JETAPropertyEditor;
033: import com.jeta.swingbuilder.gui.utils.FormDesignerUtils;
034: import com.jeta.swingbuilder.resources.Icons;
035:
036: public class FillEditor extends JETAPropertyEditor {
037: /**
038: * Used to render the value of our border
039: */
040: private ValuePainter m_value_painter;
041:
042: private static ImageIcon[] m_icon = { (ImageIcon) FormDesignerUtils
043: .loadImage(Icons.PAINT_BRUSH_16) };
044:
045: /**
046: * ctor
047: */
048: public FillEditor() {
049: m_value_painter = new ValuePainter(I18N
050: .getLocalizedMessage("Solid"));
051: m_value_painter.setPreImages(m_icon);
052: }
053:
054: /**
055: * Invokes a dialog used to update the property
056: */
057: public void invokePropertyDialog(Component comp) {
058: PaintAssignmentView view = new PaintAssignmentView(
059: (PaintProperty) getValue());
060: JETADialog dlg = (JETADialog) JETAToolbox.createDialog(
061: JETADialog.class, (java.awt.Component) comp, true);
062: dlg.setPrimaryPanel(view);
063: dlg.setSize(dlg.getPreferredSize());
064: dlg.setTitle(I18N.getLocalizedMessage("Edit Fill"));
065: dlg.showCenter();
066: if (dlg.isOk()) {
067: setValue(view.getPaintProperty());
068: }
069: }
070:
071: /**
072: * Determines whether this class renders itself using the
073: * paintValue(Graphics g, Rectangle rect) method. Generally, editors that
074: * are not JComponents are paintable.
075: */
076: public boolean isPaintable() {
077: return true;
078: }
079:
080: /**
081: * Method that renders the text on the given graphics context
082: */
083: public void paintValue(Graphics g, Rectangle rect) {
084: // forward the call to the value painter
085: m_value_painter.paintValue(g, rect);
086: }
087:
088: /**
089: *
090: */
091: public void setValue(Object value) {
092: super .setValue(value);
093: if (value instanceof PaintProperty) {
094: m_value_painter
095: .setValue(((PaintProperty) value).toString());
096: } else {
097: assert (false);
098: }
099: }
100:
101: /**
102: * @return true since we have a custom editor dialog for this type
103: */
104: public boolean supportsCustomEditor() {
105: return true;
106: }
107: }
|