Skip to content

Commit

Permalink
#6 vorerst nur Info Window Produkt / quick & dirty
Browse files Browse the repository at this point in the history
  • Loading branch information
homebeaver committed Feb 1, 2020
1 parent 2aeef17 commit 96224e7
Show file tree
Hide file tree
Showing 6 changed files with 563 additions and 53 deletions.
45 changes: 41 additions & 4 deletions client/src/main/java/com/klst/gossip/GenericDataModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import org.compiere.model.GridFieldVO;
import org.compiere.model.GridTab;
import org.compiere.util.DisplayType;
import org.compiere.util.Env;
import org.compiere.util.Msg;

// TableModel bedeutet Java Swing Table, nicht DB Table!
public class GenericDataModel extends DefaultTableModel { // extends AbstractTableModel implements Serializable
Expand All @@ -24,7 +26,8 @@ public class GenericDataModel extends DefaultTableModel { // extends AbstractTab

private int windowNo;
private GridTab gridTab; // Tab Model - a combination of AD_Tab (the display attributes) and AD_Table information.

private String name, tableName;

//private GridFieldBridge[] fields = null; // oder noch besser:
private GridFields fields;
private int rowsToLoad = -1; // der Loader liefert es
Expand All @@ -34,9 +37,41 @@ public class GenericDataModel extends DefaultTableModel { // extends AbstractTab
public GenericDataModel(GridTab gridTab, int windowNo) {
this.windowNo = windowNo;
this.gridTab = gridTab;
this.fields = new GridFields(this.gridTab.getFields());
if(this.gridTab==null) {
this.fields = new GridFields();
} else {
this.fields = new GridFields(this.gridTab.getFields());
this.name = gridTab.getName();
this.tableName = gridTab.get_TableName();
LOG.warning("gridTab.Name="+name + " gridTab.TableName="+tableName);
}
}

public GenericDataModel(String string, int infoWindowId) {
this((GridTab)null, infoWindowId);
this.name = string;
if("Product".equals(string)) {
this.tableName = "M_PRODUCT_STOCK_V"; // aus InfoProduct : String s_sqlFrom = " M_PRODUCT_STOCK_V ";
/* aus InfoProduct
new ColumnInfo(" ", "M_Warehouse_ID", IDColumn.class),
new ColumnInfo(Msg.translate(Env.getCtx(), "WarehouseName"), "WarehouseName", String.class),
new ColumnInfo(Msg.translate(Env.getCtx(), "QtyAvailable"), "sum(QtyAvailable)", Double.class, true, true, null),
new ColumnInfo(Msg.translate(Env.getCtx(), "QtyOnHand"), "sum(QtyOnHand)", Double.class),
new ColumnInfo(Msg.translate(Env.getCtx(), "QtyReserved"), "sum(QtyReserved)", Double.class),
new ColumnInfo(Msg.translate(Env.getCtx(), "QtyOrdered"), "sum(QtyOrdered)", Double.class)};
*/
// fields.addColumn(new GridFieldBridge("M_Warehouse_ID", Msg.translate(Env.getCtx(), "M_Warehouse_ID"), IDColumn.class));
fields.addColumn(new GridFieldBridge("M_Warehouse_ID", Msg.translate(Env.getCtx(), "Warehouse"), Integer.class, DisplayType.ID));
fields.addColumn(new GridFieldBridge("WarehouseName", Msg.translate(Env.getCtx(), "WarehouseName"), String.class, DisplayType.String));
fields.addColumn(new GridFieldBridge("QtyAvailable", Msg.translate(Env.getCtx(), "QtyAvailable"), Double.class, DisplayType.Number));
fields.addColumn(new GridFieldBridge("QtyOnHand", Msg.translate(Env.getCtx(), "QtyOnHand"), Double.class, DisplayType.Number));
fields.addColumn(new GridFieldBridge("QtyReserved", Msg.translate(Env.getCtx(), "QtyReserved"), Double.class, DisplayType.Number));
fields.addColumn(new GridFieldBridge("QtyOrdered", Msg.translate(Env.getCtx(), "QtyOrdered"), Double.class, DisplayType.Number));
// ...
} else {
LOG.warning("TODO nicht implementiert für "+string); // TODO
}
}
public String toString() {
return getClass().getName() +" windowNo="+windowNo + " gridTab:["+gridTab+"]" + " #fields="+fields.getColumnCount();
}
Expand Down Expand Up @@ -173,11 +208,13 @@ public void add(Object[] row) {
}

public String getName() {
return this.gridTab.getName();
return this.name;
// return this.gridTab.getName();
}

public String getTableName() {
return this.gridTab.get_TableName();
return this.tableName;
// return this.gridTab.get_TableName();
}

public int getWindowNo() {
Expand Down
48 changes: 42 additions & 6 deletions client/src/main/java/com/klst/gossip/GridFieldBridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public class GridFieldBridge extends TableColumnExt { // TableColumnExt extends
private static final Logger LOG = Logger.getLogger(GridFieldBridge.class.getName());

private GridField field = null;
private Class<?> colClass = null;
private int displayType = 0; //-1;

// TableColumn ctors:
//public TableColumn()
Expand All @@ -39,6 +41,19 @@ public GridFieldBridge(GridField field) {
setHeaderValue(this.field.getHeader());
// setEditable(this.field.isEditable(true)); // always checkContext
}
public GridFieldBridge(String columnName, String header, Class<?> colClass, int displayType) {
super();
this.field = null;
this.colClass = colClass;
this.displayType = displayType;

setIdentifier(columnName);
setHeaderValue(header);
}

public Class<?> getColClass() {
return this.colClass;
}

public int getAD_Column_ID() {
return field.getAD_Column_ID();
Expand All @@ -53,6 +68,7 @@ public int getAD_Tab_ID() {
}

public int getAD_Field_ID() {
if(field==null) return -1;
return field.getAD_Field_ID();
}

Expand Down Expand Up @@ -89,6 +105,7 @@ public int getAD_Reference_Value_ID(){
}

public String getColumnName() {
if(field==null) return (String)getIdentifier();
return field.getColumnName(); // oder (String)this.getIdentifier();
}

Expand All @@ -101,18 +118,23 @@ public String getHeader() {
}

public String getColumnSQL() {
// LOG.config(""+field);
if(field==null) return (String)getIdentifier();
return field.getColumnSQL(true); // ColumnName or Virtual Column // boolean withAS
}

public boolean isEditable(boolean checkContext) { // in super TableColumnExt gibt es isEditable() ohne para !
if(field==null) return false;
return field.isEditable(true); // always checkContext
}

public boolean isMandatory(boolean checkContext) {
if(field==null) return false;
return field.isMandatory(true); // checkContext
}

public boolean isDisplayed() {
if(field==null) return true;
return field.isDisplayed();
}

Expand All @@ -125,22 +147,27 @@ public boolean isFieldOnly() {
}

public boolean isHeading() {
if(field==null) return false;
return field.isHeading();
}

public boolean isReadOnly() {
if(field==null) return true;
return field.isReadOnly();
}

public boolean isUpdateable() {
if(field==null) return false;
return field.isUpdateable();
}

public boolean isEncryptedColumn() {
if(field==null) return false;
return field.isEncryptedColumn();
}

public boolean isSameLine() {
if(field==null) return false;
return field.isSameLine();
}

Expand All @@ -161,15 +188,18 @@ public int getSeqNoGrid() { // ist immer 0!
}

public int getDisplayType() {
if(field==null) return this.displayType;
return field.getDisplayType();
}

public int getWindowNo() {
if(field==null) return -1; // TODO interim
return field.getWindowNo();
}

public int getIncluded_Tab_ID() {
return field.getIncluded_Tab_ID();
if(field==null) return -1; // TODO interim
return field.getIncluded_Tab_ID();
}

public String getValueMax() {
Expand Down Expand Up @@ -207,11 +237,17 @@ public MImage getImage() {
public String toString() {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("GridFieldBridge[");
stringBuilder.append("Field_IDe=").append(getAD_Field_ID());
stringBuilder.append(", isDisplayed=").append(isDisplayed());
stringBuilder.append(", isDisplayedGrid=").append(isDisplayedGrid());
stringBuilder.append("] ");
stringBuilder.append(this.field.toStringX());
if(field==null) {
stringBuilder.append("ColumnName=").append(getColumnName());
stringBuilder.append(", DisplayType=").append(getDisplayType());
stringBuilder.append("] ");
} else {
stringBuilder.append("Field_IDe=").append(getAD_Field_ID());
stringBuilder.append(", isDisplayed=").append(isDisplayed());
stringBuilder.append(", isDisplayedGrid=").append(isDisplayedGrid());
stringBuilder.append("] ");
stringBuilder.append(this.field.toStringX());
}
return stringBuilder.toString();
}

Expand Down
4 changes: 4 additions & 0 deletions client/src/main/java/com/klst/gossip/GridFields.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ public class GridFields extends DefaultTableColumnModelExt // extends DefaultTab

private static final Logger LOG = Logger.getLogger(GridFields.class.getName());

public GridFields() {
super();
LOG.warning("empty - use addColumn");
}
public GridFields(GridField[] gfields) {
super();
LOG.config("GridField[].length="+gfields.length); // Land:33
Expand Down
Loading

0 comments on commit 96224e7

Please sign in to comment.