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.components.scrollbars;
020:
021: import java.awt.BorderLayout;
022:
023: import javax.swing.JScrollPane;
024:
025: import com.jeta.forms.components.panel.FormPanel;
026: import com.jeta.forms.store.properties.CompoundBorderProperty;
027: import com.jeta.forms.store.properties.ScrollBarsProperty;
028: import com.jeta.open.gui.framework.JETAPanel;
029: import com.jeta.swingbuilder.gui.utils.IntegerComboMap;
030:
031: /**
032: * Displays the scroll policy for a given component.
033: *
034: * @author Jeff Tassin
035: */
036: public class ScrollPolicyView extends JETAPanel {
037: /**
038: * The projectSettings.jfrm form
039: */
040: private FormPanel m_view;
041:
042: private ScrollBarsProperty m_prop = new ScrollBarsProperty();
043:
044: private static IntegerComboMap m_vmap = new IntegerComboMap();
045: private static IntegerComboMap m_hmap = new IntegerComboMap();
046:
047: static {
048: m_vmap.map(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
049: "AS_NEEDED");
050: m_vmap.map(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, "ALWAYS");
051: m_vmap.map(JScrollPane.VERTICAL_SCROLLBAR_NEVER, "NEVER");
052:
053: m_hmap.map(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED,
054: "AS_NEEDED");
055: m_hmap.map(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS, "ALWAYS");
056: m_hmap.map(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER, "NEVER");
057: }
058:
059: /**
060: * ctor
061: */
062: public ScrollPolicyView(ScrollBarsProperty prop) {
063: m_prop.setValue(prop);
064: initialize(prop);
065: setController(new ScrollPolicyController(this ));
066: }
067:
068: /**
069: * @return the scroll property defined by the current view
070: */
071: public ScrollBarsProperty getScrollBarsProperty() {
072: m_prop
073: .setHorizontalScrollBarPolicy(m_hmap
074: .getSelectedValue(getComboBox(ScrollPolicyNames.ID_HORIZONTAL_POLICY)));
075: m_prop
076: .setVerticalScrollBarPolicy(m_vmap
077: .getSelectedValue(getComboBox(ScrollPolicyNames.ID_VERTICAL_POLICY)));
078: m_prop.setScrollName(m_view
079: .getText(ScrollPolicyNames.ID_NAME_FIELD));
080: return m_prop;
081: }
082:
083: /**
084: * Initializes the view
085: */
086: public void initialize(ScrollBarsProperty prop) {
087: setLayout(new BorderLayout());
088: m_view = new FormPanel(
089: "com/jeta/swingbuilder/gui/components/scrollbars/scrollBars.jfrm");
090: add(m_view, BorderLayout.CENTER);
091:
092: m_view.setText(ScrollPolicyNames.ID_NAME_FIELD, prop
093: .getScrollName());
094: m_hmap.setSelectedItem(
095: getComboBox(ScrollPolicyNames.ID_HORIZONTAL_POLICY),
096: prop.getHorizontalScrollBarPolicy());
097: m_vmap.setSelectedItem(
098: getComboBox(ScrollPolicyNames.ID_VERTICAL_POLICY), prop
099: .getVerticalScrollBarPolicy());
100:
101: String border_txt = "DEFAULT";
102:
103: CompoundBorderProperty border = prop.getBorderProperty();
104: if (border != null)
105: border_txt = border.toString();
106: m_view.setText(ScrollPolicyNames.ID_BORDER_LABEL, border_txt);
107: }
108: }
|