Skip to content

Commit

Permalink
#4 class GenericDataModel extends AbstractTableModel, soll aber
Browse files Browse the repository at this point in the history
von DefaultTableModel abgeleitet werden
  • Loading branch information
homebeaver committed Nov 16, 2019
1 parent 37d5196 commit 3e57cf6
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 56 deletions.
7 changes: 3 additions & 4 deletions client/src/main/java/com/klst/gossip/GenericDataModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
100 changes: 48 additions & 52 deletions client/src/main/java/com/klst/gossip/GridFields.java
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -15,38 +13,34 @@

// 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<TableColumn> initialColumns : all columns, in the order in which were added to the model.
// - List<TableColumn> currentColumns : all columns, in the order they would appear if all were visible.

public class GridFields extends DefaultTableColumnModelExt // extends DefaultTableColumnModel
implements TableColumnModelExt {

private static final long serialVersionUID = 5218395949102734661L;

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<TableColumn> initialColumns = new ArrayList<TableColumn>();
// 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)
Expand Down Expand Up @@ -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<TableColumn> 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<TableColumn> 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
Expand Down Expand Up @@ -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
//
Expand Down

0 comments on commit 3e57cf6

Please sign in to comment.