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.ListSelectionModel;
026:
027: import de.finix.contelligent.client.event.ContelligentEvent;
028: import de.finix.contelligent.client.gui.AbstractComponentEditor;
029:
030: public class ColumnEditor extends AbstractComponentEditor {
031:
032: private static Logger logger = Logger.getLogger(ColumnEditor.class
033: .getName());
034:
035: private ComponentTableModel componentTableModel;
036:
037: private ComponentTable componentTable;
038:
039: public void init() {
040:
041: update();
042:
043: componentTable.getSelectionModel().setSelectionMode(
044: ListSelectionModel.SINGLE_SELECTION);
045: componentTable.setBorder(null);
046: componentTable.setShowHorizontalLines(false);
047:
048: add(componentTable, BorderLayout.CENTER);
049:
050: componentTable.addFocusListener(new FocusAdapter() {
051: public void focusGained(FocusEvent e) {
052: getView().setActions(ColumnEditor.this .getActions());
053: }
054: });
055: }
056:
057: public void update() {
058: if (componentTableModel == null) {
059: componentTableModel = new ComponentTableModel(
060: getComponent(), getView(), ComponentTableModel.COLS);
061: componentTableModel.setEditable(isEditable());
062: componentTable = new ComponentTable(componentTableModel,
063: getView());
064: } else {
065: componentTableModel.updateModel();
066: componentTable.calculateColumnWidths();
067: }
068: }
069:
070: public void setEditable(boolean editable) {
071: super .setEditable(editable);
072: if (componentTableModel != null) {
073: componentTableModel.setEditable(isEditable());
074: }
075: }
076:
077: public void rollback() {
078: componentTableModel.rollback();
079: }
080:
081: public void commit() {
082: componentTableModel.commit();
083: setEditable(false);
084: }
085:
086: protected void updateComponent() {
087: }
088:
089: protected void componentChanged(ContelligentEvent event) {
090: update();
091: }
092:
093: protected void childComponentAdded(ContelligentEvent event) {
094: }
095:
096: protected void childComponentRemoved(ContelligentEvent event) {
097: }
098:
099: protected void childComponentChanged(ContelligentEvent event) {
100: }
101:
102: protected void descendentComponentChanged(ContelligentEvent event) {
103: }
104: }
|