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.tabpane;
020:
021: import java.awt.BorderLayout;
022: import java.awt.Dimension;
023:
024: import javax.swing.JTable;
025: import javax.swing.table.TableColumnModel;
026:
027: import com.jeta.forms.components.panel.FormPanel;
028: import com.jeta.forms.store.properties.TabProperty;
029: import com.jeta.forms.store.properties.TabbedPaneProperties;
030: import com.jeta.open.gui.framework.JETAPanel;
031: import com.jeta.swingbuilder.gui.utils.FormDesignerUtils;
032:
033: /**
034: * View for editing tab properties.
035: *
036: * @author Jeff Tassin
037: */
038: public class TabDesignerView extends JETAPanel {
039: private FormPanel m_view;
040:
041: private TabsModel m_tabs_model;
042:
043: public TabDesignerView(TabbedPaneProperties props) {
044: m_view = new FormPanel(
045: "com/jeta/swingbuilder/gui/components/tabpane/tabDesigner.jfrm");
046: setLayout(new BorderLayout());
047: add(m_view, BorderLayout.CENTER);
048: setController(new TabDesignerController(this ));
049:
050: m_tabs_model = new TabsModel(props);
051: JTable table = m_view.getTable(TabDesignerNames.ID_TABS_TABLE);
052: table.setModel(m_tabs_model);
053:
054: int col_width = 60;
055: TableColumnModel cmodel = table.getColumnModel();
056: cmodel.getColumn(TabsModel.ICON_COLUMN).setPreferredWidth(
057: col_width);
058: cmodel.getColumn(TabsModel.TITLE_COLUMN).setPreferredWidth(
059: col_width * 5);
060: }
061:
062: /**
063: * Adds a tab to the model.
064: */
065: public void addTabProperty(TabProperty tp) {
066: m_tabs_model.addRow(tp);
067: }
068:
069: public Dimension getPreferredSize() {
070: return FormDesignerUtils.getWindowDimension(this , 250, 150);
071: }
072:
073: /**
074: * @return the currently selected tab property. Null is returned if no item
075: * is selected.
076: */
077: public TabProperty getSelectedTabProperty() {
078: int row = m_view.getTable(TabDesignerNames.ID_TABS_TABLE)
079: .getSelectedRow();
080: if (row >= 0) {
081: return (TabProperty) m_tabs_model.getRow(row);
082: } else {
083: return null;
084: }
085: }
086:
087: public TabbedPaneProperties getTabbedPaneProperties() {
088: TabbedPaneProperties tprop = new TabbedPaneProperties();
089: for (int row = 0; row < m_tabs_model.getRowCount(); row++) {
090: tprop.addTab((TabProperty) m_tabs_model.getRow(row));
091: }
092: return tprop;
093: }
094:
095: /**
096: * Modifies an existing tab property with a new property
097: */
098: public void setTabProperty(TabProperty newProp, TabProperty oldProp) {
099: m_tabs_model.setTabProperty(newProp, oldProp);
100: }
101:
102: }
|