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.border;
020:
021: import javax.swing.BorderFactory;
022: import javax.swing.border.EtchedBorder;
023:
024: import com.jeta.forms.store.properties.BorderProperty;
025: import com.jeta.forms.store.properties.ColorProperty;
026: import com.jeta.forms.store.properties.EtchedBorderProperty;
027:
028: /**
029: * View that is used to create and edit bevel borders
030: *
031: * @author Jeff Tassin
032: */
033: public class EtchedBorderView extends AbstractBorderView {
034:
035: /**
036: * ctor
037: */
038: public EtchedBorderView() {
039: this (null);
040: }
041:
042: /**
043: * ctor
044: */
045: public EtchedBorderView(EtchedBorderProperty bp) {
046: super ("com/jeta/swingbuilder/gui/border/etchedBorder.frm");
047: if (bp == null) {
048: setBorderProperty(new EtchedBorderProperty());
049: } else {
050: setBorderProperty(bp);
051: }
052: setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
053:
054: addCustomColor(EtchedBorderNames.ID_HIGHLIGHT_COLOR_SELECTOR,
055: ColorProperty.DEFAULT_COLOR);
056: addCustomColor(EtchedBorderNames.ID_SHADOW_COLOR_SELECTOR,
057: ColorProperty.DEFAULT_COLOR);
058: }
059:
060: /**
061: * Creates a border property based on the view inputs
062: */
063: public BorderProperty createBorderProperty() {
064: EtchedBorderProperty bp = new EtchedBorderProperty(getType());
065: bp
066: .setHighlightColorProperty(getColorProperty(EtchedBorderNames.ID_HIGHLIGHT_COLOR_SELECTOR));
067: bp
068: .setShadowColorProperty(getColorProperty(EtchedBorderNames.ID_SHADOW_COLOR_SELECTOR));
069: setTitle(bp);
070: return bp;
071: }
072:
073: /**
074: * @return a description for this view. Typically used for a title in a
075: * dialog
076: */
077: public String getDescription() {
078: return "Etched Border";
079: }
080:
081: /**
082: * @return the type of border (RAISED or LOWERED)
083: */
084: public int getType() {
085: if (getView().getBoolean(
086: EtchedBorderNames.ID_ETCHED_RAISED_RADIO)) {
087: return EtchedBorder.RAISED;
088: } else {
089: return EtchedBorder.LOWERED;
090: }
091: }
092:
093: /**
094: * Updates this view based on the given border settings
095: */
096: public void setBorderProperty(BorderProperty border) {
097: super .setBorderProperty(border);
098: if (border instanceof EtchedBorderProperty) {
099: EtchedBorderProperty bb = (EtchedBorderProperty) border;
100: if (bb.getEtchType() == EtchedBorder.RAISED) {
101: getView().getRadioButton(
102: EtchedBorderNames.ID_ETCHED_RAISED_RADIO)
103: .setSelected(true);
104: } else {
105: getView().getRadioButton(
106: EtchedBorderNames.ID_ETCHED_LOWERED_RADIO)
107: .setSelected(true);
108: }
109:
110: setColorProperty(
111: EtchedBorderNames.ID_HIGHLIGHT_COLOR_SELECTOR, bb
112: .getHighlightColorProperty());
113: setColorProperty(
114: EtchedBorderNames.ID_SHADOW_COLOR_SELECTOR, bb
115: .getShadowColorProperty());
116: } else {
117: assert (false);
118: }
119: }
120:
121: }
|