From 3e57cf6f55b40f5245c5074ea272de7814b754e2 Mon Sep 17 00:00:00 2001 From: homebeaver Date: Sat, 16 Nov 2019 19:10:22 +0100 Subject: [PATCH] #4 class GenericDataModel extends AbstractTableModel, soll aber von DefaultTableModel abgeleitet werden --- .../com/klst/gossip/GenericDataModel.java | 7 +- .../main/java/com/klst/gossip/GridFields.java | 100 +++++++++--------- 2 files changed, 51 insertions(+), 56 deletions(-) diff --git a/client/src/main/java/com/klst/gossip/GenericDataModel.java b/client/src/main/java/com/klst/gossip/GenericDataModel.java index fa613fe..981454d 100644 --- a/client/src/main/java/com/klst/gossip/GenericDataModel.java +++ b/client/src/main/java/com/klst/gossip/GenericDataModel.java @@ -119,17 +119,16 @@ Object[] getRow(int rowIndex) { @Override public Class getColumnClass(int columnIndex) { GridFieldBridge field = (GridFieldBridge)this.fields.getColumn(columnIndex); -// GridField field = this.fields[column]; int displayType = field.getDisplayType(); if(logDisplayType.containsKey(field)) { // schon geloggt } else { - LOG.config(field + " displayType:"+displayType); + LOG.config(field + " Storage Class:"+DisplayType.getClass(displayType, true)); logDisplayType.put(field, displayType); } - // Return Storage Class - ist aber nicht die DisplayClass + // Return Storage Class, (used for MiniTable) - ist aber nicht die DisplayClass // die ist nämlich VEditor oder so! - return DisplayType.getClass(displayType, true); // true == Boolean as CheckBox TODO, die anderen displayType + return DisplayType.getClass(displayType, true); // true == nur für Boolean as CheckBox // TODO } // wg. LOG diff --git a/client/src/main/java/com/klst/gossip/GridFields.java b/client/src/main/java/com/klst/gossip/GridFields.java index d8abed2..967e7a7 100644 --- a/client/src/main/java/com/klst/gossip/GridFields.java +++ b/client/src/main/java/com/klst/gossip/GridFields.java @@ -1,10 +1,8 @@ package com.klst.gossip; import java.util.ArrayList; -import java.util.Enumeration; import java.util.List; import java.util.logging.Logger; -import javax.swing.ListSelectionModel; import javax.swing.event.TableColumnModelListener; import javax.swing.table.TableColumn; @@ -15,9 +13,12 @@ // GridField aka TableColumn, vll von TableColumn ableiten // diese Klasse kapselt GridField[] fields -// und hat nur LOG-Funktionalität // durch das Ableiten von org.jdesktop.swingx.table.DefaultTableColumnModelExt sind alle notwendigen Methoden wg implements TableColumnModelExt vorimplementiert +// in super sind zwei Listen +// - List initialColumns : all columns, in the order in which were added to the model. +// - List currentColumns : all columns, in the order they would appear if all were visible. + public class GridFields extends DefaultTableColumnModelExt // extends DefaultTableColumnModel implements TableColumnModelExt { @@ -25,28 +26,21 @@ public class GridFields extends DefaultTableColumnModelExt // extends DefaultTab private static final Logger LOG = Logger.getLogger(GridFields.class.getName()); -// private GridFieldBridge[] fields = null; // gelöscht, denn die Felderliste gibt es schon in der Oberklasse - - // in DefaultTableColumnModelExt private List initialColumns = new ArrayList(); - // ctor - //public DefaultTableColumnModelExt() -// public GridFields(GridFieldBridge[] fields) { -// super(); -// this.fields = fields; -// } public GridFields(GridField[] gfields) { super(); LOG.config("GridField[].length="+gfields.length); // Land:33 -// this.fields = new GridFieldBridge[gfields.length]; // löschen for(int c = 0; c < gfields.length; c++) { GridField gfield = gfields[c]; - GridFieldBridge aColumn = new GridFieldBridge(gfield); -// this.addColumn(aColumn); // befüllt die Feldliste - if(aColumn.isDisplayed() && aColumn.isDisplayedGrid()) { + TableColumnExt aColumn = new GridFieldBridge(gfield); + GridFieldBridge gColumn = (GridFieldBridge)aColumn; + if(gColumn.isDisplayed() && gColumn.isDisplayedGrid()) { // display column + aColumn.setToolTipText(gColumn.getDescription()); // TODO funktioniert nicht +// aColumn.setCellRenderer(cellRenderer); this.addColumn(aColumn); + LOG.config(c+" add visible: "+aColumn + " Description:"+gColumn.getDescription()+ " CellRenderer=CellRenderer"+aColumn.getCellRenderer()); } else { - LOG.config("not visible: "+aColumn); + LOG.config(c+" not visible: "+aColumn); /* aColumn.setVisible(false); liefert Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 6 >= 6 at java.util.Vector.elementAt(Vector.java:477) @@ -96,43 +90,51 @@ public GridFields(GridField[] gfields) { } } // TODO: die Breite ist nicht angepasst! + } // wg. implements TableColumnModelExt -// -// @Override -// public int getColumnCount(boolean includeHidden) { -// LOG.config(""+super.getColumnCount(false)+"/"+super.getColumnCount(true)); -// return super.getColumnCount(includeHidden); -// } -// -// @Override -// public List getColumns(boolean includeHidden) { -// // TODO Auto-generated method stub -// return null; -// } -// -// @Override -// public TableColumnExt getColumnExt(Object identifier) { -// // TODO Auto-generated method stub -// return null; -// } -// -// @Override -// public TableColumnExt getColumnExt(int columnIndex) { -// // TODO Auto-generated method stub -// return null; -// } -// + + @Override + public int getColumnCount(boolean includeHidden) { + LOG.config("includeHidden="+includeHidden + " (false/true)="+super.getColumnCount(false)+"/"+super.getColumnCount(true)); + return super.getColumnCount(includeHidden); + } + + @Override + public List getColumns(boolean includeHidden) { + LOG.config("return super..."); + return super.getColumns(includeHidden); + } + + @Override + public TableColumnExt getColumnExt(Object identifier) { + LOG.config("return super..."); + return super.getColumnExt(identifier); + } + + @Override + public TableColumnExt getColumnExt(int columnIndex) { + LOG.config("return super..."); + return super.getColumnExt(columnIndex); + } + + @Override + public void addColumnModelListener(TableColumnModelListener x) { + LOG.config("TableColumnModelListener "+x); + super.addColumnModelListener(x); + } + + // wg. implements TableColumnModel -// + // @Override // public void addColumn(TableColumn aColumn) { -// // TODO Auto-generated method stub -// +// LOG.config("TableColumn "+aColumn); +// super.addColumn(aColumn); // } -// + // @Override // public void removeColumn(TableColumn column) { // // TODO Auto-generated method stub @@ -229,12 +231,6 @@ public GridFields(GridField[] gfields) { // } // // @Override -// public void addColumnModelListener(TableColumnModelListener x) { -// // TODO Auto-generated method stub -// -// } -// -// @Override // public void removeColumnModelListener(TableColumnModelListener x) { // // TODO Auto-generated method stub //