001: /*
002: * Copyright 2001-2006 C:1 Financial Services GmbH
003: *
004: * This software is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Lesser General Public
006: * License Version 2.1, as published by the Free Software Foundation.
007: *
008: * This software is distributed in the hope that it will be useful,
009: * but WITHOUT ANY WARRANTY; without even the implied warranty of
010: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
011: * Lesser General Public License for more details.
012: *
013: * You should have received a copy of the GNU Lesser General Public
014: * License along with this library; if not, write to the Free Software
015: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
016: */
017:
018: package de.finix.contelligent.client.gui.composed;
019:
020: import java.awt.BorderLayout;
021: import java.awt.event.FocusAdapter;
022: import java.awt.event.FocusEvent;
023: import java.util.logging.Logger;
024:
025: import javax.swing.JScrollPane;
026: import javax.swing.ListSelectionModel;
027:
028: import de.finix.contelligent.client.event.ContelligentEvent;
029: import de.finix.contelligent.client.gui.AbstractComponentEditor;
030:
031: public class RowEditor extends AbstractComponentEditor {
032:
033: private static Logger logger = Logger.getLogger(RowEditor.class
034: .getName());
035:
036: private ComponentTableModel componentTableModel;
037:
038: private ComponentTable componentTable;
039:
040: public void init() {
041: update();
042:
043: componentTable.getSelectionModel().setSelectionMode(
044: ListSelectionModel.SINGLE_SELECTION);
045: componentTable.setBorder(null);
046: componentTable.setShowHorizontalLines(true);
047:
048: JScrollPane scrollPane = new JScrollPane(componentTable);
049: add(scrollPane, BorderLayout.CENTER);
050:
051: componentTable.addFocusListener(new FocusAdapter() {
052: public void focusGained(FocusEvent e) {
053: getView().setActions(getActions());
054: }
055: });
056: }
057:
058: public void update() {
059: if (componentTableModel == null) {
060: componentTableModel = new ComponentTableModel(
061: getComponent(), getView(), ComponentTableModel.ROWS);
062: componentTableModel.setEditable(isEditable());
063: componentTable = new ComponentTable(componentTableModel,
064: getView());
065: } else {
066: componentTableModel.updateModel();
067: componentTable.calculateColumnWidths();
068: }
069: }
070:
071: public void setEditable(boolean editable) {
072: super .setEditable(editable);
073: if (componentTableModel != null) {
074: componentTableModel.setEditable(isEditable());
075: }
076: }
077:
078: public void rollback() {
079: componentTableModel.rollback();
080: }
081:
082: public void commit() {
083: componentTableModel.commit();
084: setEditable(false);
085: }
086:
087: protected void updateComponent() {
088: }
089:
090: protected void componentChanged(ContelligentEvent event) {
091: update();
092: }
093:
094: protected void childComponentAdded(ContelligentEvent event) {
095: }
096:
097: protected void childComponentRemoved(ContelligentEvent event) {
098: }
099:
100: protected void childComponentChanged(ContelligentEvent event) {
101: }
102:
103: protected void descendentComponentChanged(ContelligentEvent event) {
104: }
105: }
|