001: /*
002: * Copyright Javelin Software, All rights reserved.
003: */
004:
005: package com.javelin.swinglets.table;
006:
007: import java.awt.*;
008: import java.util.*;
009: import java.io.*;
010:
011: import javax.swing.table.*;
012: import com.javelin.swinglets.*;
013: import com.javelin.swinglets.table.*;
014: import com.javelin.swinglets.plaf.*;
015:
016: /**
017: * STableFooter defines a table footer.
018: *
019: * @author Robin Sharp
020: */
021:
022: public class STableFooter extends SComponent {
023: /**
024: * Constant for the column index.
025: */
026: public final static String COMMAND = "_COMMAND";
027:
028: /**
029: * Creates a STableFooter.
030: * This defaults to invisible.
031: */
032: public STableFooter(STable table) {
033: this .table = table;
034: }
035:
036: public int getLabelCount() {
037: return 0;
038: }
039:
040: public String getLabel(int x) {
041: return null;
042: }
043:
044: public String getCommand(int x) {
045: return null;
046: }
047:
048: /**
049: * Returns the name of the class for L&F of this component.
050: */
051: public Class getUIClass() {
052: return STableFooter.class;
053: }
054:
055: /**
056: * Get the table for this STableHeader.
057: */
058: public STable getTable() {
059: return table;
060: }
061:
062: /**
063: * Get the table for this STableHeader.
064: */
065: public STableFooter setTable(STable table) {
066: if (getTable() == table)
067: return this ;
068:
069: if (table != null) {
070: table.setTableFooter(this );
071: }
072:
073: this .table = table;
074:
075: return this ;
076: }
077:
078: /**
079: * Set Table header renderer for each look and feel.
080: */
081: public STableFooter setTableFooterRenderer(String lookAndFeel,
082: STableCellRenderer tableFooterRenderer) {
083: tableFooterRenderers.put(lookAndFeel, tableFooterRenderer);
084:
085: return this ;
086: }
087:
088: /**
089: * Get Table header renderer, for the current look and feel.
090: */
091: public STableCellRenderer getTableFooterRenderer() {
092: return getTableFooterRenderer(getLookAndFeel().getClass()
093: .getName());
094: }
095:
096: /**
097: * Get Table footer renderer, or null.
098: * <P>
099: * If a renderer has not been installed for the look and feel, it is.
100: * picked up from the LookAndFeel as SLookAndFeel.TABLE_DEFAULT_FOOTER_RENDERER.
101: */
102: public STableCellRenderer getTableFooterRenderer(String lookAndFeel) {
103: STableCellRenderer renderer = (STableCellRenderer) tableFooterRenderers
104: .get(lookAndFeel);
105:
106: if (renderer == null) {
107: Class clazz = getLookAndFeel().getUIDefaults()
108: .getTableCellRenderer(
109: SLookAndFeel.TABLE_DEFAULT_FOOTER_RENDERER);
110:
111: //System.out.println( lookAndFeel + " " + clazz.getName() );
112:
113: if (clazz != null) {
114: try {
115: renderer = (STableCellRenderer) clazz.newInstance();
116: } catch (Exception e) {
117: throw new IllegalArgumentException(
118: "Cannot load footer renderer for class "
119: + clazz.getName());
120: }
121: }
122:
123: if (renderer != null) {
124: tableFooterRenderers.put(lookAndFeel, renderer);
125: }
126: }
127:
128: return renderer;
129: }
130:
131: // PRIVATE //////////////////////////////////////////////////////////////
132:
133: protected STable table;
134:
135: protected Hashtable tableFooterRenderers = new Hashtable();
136:
137: }
|