Commit 29fca608 authored by claes's avatar claes

Table object implemented

parent b75b2a03
......@@ -28,6 +28,7 @@ public class GeDyn {
public static final int mDynType_FillLevel = 1 << 21;
public static final int mDynType_FastCurve = 1 << 22;
public static final int mDynType_AnalogText = 1 << 23;
public static final int mDynType_Table = 1 << 24;
public static final int mActionType_No = 0;
public static final int mActionType_Inherit = 1 << 0;
......
package jpwr.jop;
import jpwr.rt.*;
import java.awt.*;
import java.awt.event.*;
public class GeDynTable extends GeDynElem {
public String[] attribute;
public String[] selAttribute;
int rows;
int columns;
public GeCFormat[] cFormat;
public boolean[] attrFound;
public boolean[] selAttrFound;
PwrtRefId[] subid;
int[] p;
public int[] typeId;
public boolean[][] oldValueB;
public float[][] oldValueF;
public int[][] oldValueI;
public String[][] oldValueS;
boolean firstScan = true;
StringBuffer sb = new StringBuffer();
public GeDynTable( GeDyn dyn, String[] attribute, String[] format, String[] selAttribute,
int rows, int columns) {
super( dyn, GeDyn.mDynType_Table, GeDyn.mActionType_No);
this.rows = rows;
this.columns = columns;
this.attribute = attribute;
this.selAttribute = selAttribute;
cFormat = new GeCFormat[columns];
for ( int i = 0; i < columns; i++)
cFormat[i] = new GeCFormat( format[i]);
p = new int[columns];
subid = new PwrtRefId[columns];
typeId = new int[columns];
attrFound = new boolean[columns];
selAttrFound = new boolean[columns];
oldValueB = new boolean[columns][];
oldValueF = new float[columns][];
oldValueI = new int[columns][];
oldValueS = new String[columns][];
}
public void connect() {
for ( int i = 0; i < columns; i++) {
String attrName = dyn.getAttrName( attribute[i]);
if ( attrName.compareTo("") != 0) {
GdhrRefObjectInfo ret = dyn.en.gdh.refObjectInfo( attrName);
if ( ret.evenSts()) {
System.out.println( "Table: " + attrName);
attrFound[i] = false;
}
else {
attrFound[i] = true;
p[i] = ret.id;
subid[i] = ret.refid;
typeId[i] = ret.typeId;
if ( typeId[i] == Pwr.eType_Float32) {
oldValueF[i] = new float[rows];
}
else if ( typeId[i] == Pwr.eType_Boolean) {
oldValueB[i] = new boolean[rows];
}
else if ( typeId[i] == Pwr.eType_Int32 ||
typeId[i] == Pwr.eType_UInt32 ||
typeId[i] == Pwr.eType_Int16 ||
typeId[i] == Pwr.eType_UInt16 ||
typeId[i] == Pwr.eType_Int8 ||
typeId[i] == Pwr.eType_UInt8) {
oldValueI[i] = new int[rows];
}
else if ( typeId[i] == Pwr.eType_String ||
typeId[i] == Pwr.eType_Objid) {
oldValueS[i] = new String[rows];
}
}
}
}
}
public void disconnect() {
for ( int i = 0; i < columns; i++) {
if ( attrFound[i])
dyn.en.gdh.unrefObjectInfo( subid[i]);
}
}
public void scan() {
for ( int i = 0; i < columns; i++) {
if ( !attrFound[i])
continue;
if ( typeId[i] == Pwr.eType_Float32) {
float value0 = dyn.en.gdh.getObjectRefInfoFloat( p[i]);
for ( int j = 0; j < 1; j++) { // Just the first row...
if ( value0 != oldValueF[i][j] || firstScan) {
sb = cFormat[i].format( value0, sb);
((GeTable)dyn.comp).setValueAt(new String(sb), j, i);
// dyn.repaintNow = true;
oldValueF[i][j] = value0;
}
}
}
else if ( typeId[i] == Pwr.eType_Boolean) {
boolean value0 = dyn.en.gdh.getObjectRefInfoBoolean( p[i]);
for ( int j = 0; j < 1; j++) { // Just the first row...
if ( value0 != oldValueB[i][j] || firstScan) {
if ( value0)
((GeTable)dyn.comp).setValueAt("1", j, i);
else
((GeTable)dyn.comp).setValueAt("0", j, i);
// dyn.repaintNow = true;
oldValueB[i][j] = value0;
}
}
}
else if ( typeId[i] == Pwr.eType_Int32 ||
typeId[i] == Pwr.eType_UInt32 ||
typeId[i] == Pwr.eType_Int16 ||
typeId[i] == Pwr.eType_UInt16 ||
typeId[i] == Pwr.eType_Int8 ||
typeId[i] == Pwr.eType_UInt8) {
int value0 = dyn.en.gdh.getObjectRefInfoInt( p[i]);
for ( int j = 0; j < 1; j++) { // Just the first row...
if ( value0 != oldValueI[i][j] || firstScan) {
sb = cFormat[i].format( value0, sb);
((GeTable)dyn.comp).setValueAt(new String(sb), j, i);
// dyn.repaintNow = true;
oldValueI[i][j] = value0;
}
}
}
else if ( typeId[i] == Pwr.eType_String ||
typeId[i] == Pwr.eType_Objid) {
String value0 = dyn.en.gdh.getObjectRefInfoString( p[i], typeId[i]);
for ( int j = 0; j < 1; j++) { // Just the first row...
if ( firstScan || value0.compareTo( oldValueS[i][j]) != 0) {
sb = cFormat[i].format( value0, sb);
((GeTable)dyn.comp).setValueAt(new String(sb), j, i);
// dyn.repaintNow = true;
oldValueS[i][j] = value0;
}
}
}
if ( firstScan)
firstScan = false;
}
}
public void action( int eventType, MouseEvent e) {
int row;
int column;
switch ( eventType) {
case GeDyn.eEvent_MB1Click:
column = ((GeTable)dyn.comp).getSelectedColumn();
row = ((GeTable)dyn.comp).getSelectedRow();
System.out.println( "MB1Click " + row + " " + column);
break;
case GeDyn.eEvent_MB3Press:
System.out.println("mb3 press");
// Get the selected object
column = ((GeTable)dyn.comp).getSelectedColumn();
row = ((GeTable)dyn.comp).getSelectedRow();
System.out.println("Row " + row + " Column " + column);
if ( row == -1 || column == -1)
break;
if ( typeId[column] == Pwr.eType_Objid) {
// Name of an attribute that contains the objid of the reference object
String name = dyn.getAttrNameNoSuffix( attribute[column]);
name = name + "[" + row + "]";
CdhrObjid reto = dyn.en.gdh.getObjectInfoObjid( name);
if ( reto.oddSts() && !reto.objid.isNull()) {
CdhrString rets = dyn.en.gdh.objidToName( reto.objid, Cdh.mName_volumeStrict);
System.out.println( "str: " + rets.str + " " + rets.getSts());
if ( rets.oddSts() && ! rets.str.equals(""))
new JopMethodsMenu( dyn.session, rets.str, JopUtility.GRAPH,
(Component)dyn.comp, e.getX(), e.getY());
}
}
break;
}
}
}
This diff is collapsed.
......@@ -28,6 +28,7 @@ public class GeDyn {
public static final int mDynType_FillLevel = 1 << 21;
public static final int mDynType_FastCurve = 1 << 22;
public static final int mDynType_AnalogText = 1 << 23;
public static final int mDynType_Table = 1 << 24;
public static final int mActionType_No = 0;
public static final int mActionType_Inherit = 1 << 0;
......
package jpwr.jop;
import jpwr.rt.*;
import java.awt.*;
import java.awt.event.*;
public class GeDynTable extends GeDynElem {
public String[] attribute;
public String[] selAttribute;
int rows;
int columns;
public GeCFormat[] cFormat;
public boolean[] attrFound;
public boolean[] selAttrFound;
PwrtRefId[] subid;
int[] p;
public int[] typeId;
public boolean[][] oldValueB;
public float[][] oldValueF;
public int[][] oldValueI;
public String[][] oldValueS;
boolean firstScan = true;
StringBuffer sb = new StringBuffer();
public GeDynTable( GeDyn dyn, String[] attribute, String[] format, String[] selAttribute,
int rows, int columns) {
super( dyn, GeDyn.mDynType_Table, GeDyn.mActionType_No);
this.rows = rows;
this.columns = columns;
this.attribute = attribute;
this.selAttribute = selAttribute;
cFormat = new GeCFormat[columns];
for ( int i = 0; i < columns; i++)
cFormat[i] = new GeCFormat( format[i]);
p = new int[columns];
subid = new PwrtRefId[columns];
typeId = new int[columns];
attrFound = new boolean[columns];
selAttrFound = new boolean[columns];
oldValueB = new boolean[columns][];
oldValueF = new float[columns][];
oldValueI = new int[columns][];
oldValueS = new String[columns][];
}
public void connect() {
for ( int i = 0; i < columns; i++) {
String attrName = dyn.getAttrName( attribute[i]);
if ( attrName.compareTo("") != 0) {
GdhrRefObjectInfo ret = dyn.en.gdh.refObjectInfo( attrName);
if ( ret.evenSts()) {
System.out.println( "Table: " + attrName);
attrFound[i] = false;
}
else {
attrFound[i] = true;
p[i] = ret.id;
subid[i] = ret.refid;
typeId[i] = ret.typeId;
if ( typeId[i] == Pwr.eType_Float32) {
oldValueF[i] = new float[rows];
}
else if ( typeId[i] == Pwr.eType_Boolean) {
oldValueB[i] = new boolean[rows];
}
else if ( typeId[i] == Pwr.eType_Int32 ||
typeId[i] == Pwr.eType_UInt32 ||
typeId[i] == Pwr.eType_Int16 ||
typeId[i] == Pwr.eType_UInt16 ||
typeId[i] == Pwr.eType_Int8 ||
typeId[i] == Pwr.eType_UInt8) {
oldValueI[i] = new int[rows];
}
else if ( typeId[i] == Pwr.eType_String ||
typeId[i] == Pwr.eType_Objid) {
oldValueS[i] = new String[rows];
}
}
}
}
}
public void disconnect() {
for ( int i = 0; i < columns; i++) {
if ( attrFound[i])
dyn.en.gdh.unrefObjectInfo( subid[i]);
}
}
public void scan() {
for ( int i = 0; i < columns; i++) {
if ( !attrFound[i])
continue;
if ( typeId[i] == Pwr.eType_Float32) {
float value0 = dyn.en.gdh.getObjectRefInfoFloat( p[i]);
for ( int j = 0; j < 1; j++) { // Just the first row...
if ( value0 != oldValueF[i][j] || firstScan) {
sb = cFormat[i].format( value0, sb);
((GeTable)dyn.comp).setValueAt(new String(sb), j, i);
// dyn.repaintNow = true;
oldValueF[i][j] = value0;
}
}
}
else if ( typeId[i] == Pwr.eType_Boolean) {
boolean value0 = dyn.en.gdh.getObjectRefInfoBoolean( p[i]);
for ( int j = 0; j < 1; j++) { // Just the first row...
if ( value0 != oldValueB[i][j] || firstScan) {
if ( value0)
((GeTable)dyn.comp).setValueAt("1", j, i);
else
((GeTable)dyn.comp).setValueAt("0", j, i);
// dyn.repaintNow = true;
oldValueB[i][j] = value0;
}
}
}
else if ( typeId[i] == Pwr.eType_Int32 ||
typeId[i] == Pwr.eType_UInt32 ||
typeId[i] == Pwr.eType_Int16 ||
typeId[i] == Pwr.eType_UInt16 ||
typeId[i] == Pwr.eType_Int8 ||
typeId[i] == Pwr.eType_UInt8) {
int value0 = dyn.en.gdh.getObjectRefInfoInt( p[i]);
for ( int j = 0; j < 1; j++) { // Just the first row...
if ( value0 != oldValueI[i][j] || firstScan) {
sb = cFormat[i].format( value0, sb);
((GeTable)dyn.comp).setValueAt(new String(sb), j, i);
// dyn.repaintNow = true;
oldValueI[i][j] = value0;
}
}
}
else if ( typeId[i] == Pwr.eType_String ||
typeId[i] == Pwr.eType_Objid) {
String value0 = dyn.en.gdh.getObjectRefInfoString( p[i], typeId[i]);
for ( int j = 0; j < 1; j++) { // Just the first row...
if ( firstScan || value0.compareTo( oldValueS[i][j]) != 0) {
sb = cFormat[i].format( value0, sb);
((GeTable)dyn.comp).setValueAt(new String(sb), j, i);
// dyn.repaintNow = true;
oldValueS[i][j] = value0;
}
}
}
if ( firstScan)
firstScan = false;
}
}
public void action( int eventType, MouseEvent e) {
int row;
int column;
switch ( eventType) {
case GeDyn.eEvent_MB1Click:
column = ((GeTable)dyn.comp).getSelectedColumn();
row = ((GeTable)dyn.comp).getSelectedRow();
System.out.println( "MB1Click " + row + " " + column);
break;
case GeDyn.eEvent_MB3Press:
System.out.println("mb3 press");
// Get the selected object
column = ((GeTable)dyn.comp).getSelectedColumn();
row = ((GeTable)dyn.comp).getSelectedRow();
System.out.println("Row " + row + " Column " + column);
if ( row == -1 || column == -1)
break;
if ( typeId[column] == Pwr.eType_Objid) {
// Name of an attribute that contains the objid of the reference object
String name = dyn.getAttrNameNoSuffix( attribute[column]);
name = name + "[" + row + "]";
CdhrObjid reto = dyn.en.gdh.getObjectInfoObjid( name);
if ( reto.oddSts() && !reto.objid.isNull()) {
CdhrString rets = dyn.en.gdh.objidToName( reto.objid, Cdh.mName_volumeStrict);
System.out.println( "str: " + rets.str + " " + rets.getSts());
if ( rets.oddSts() && ! rets.str.equals(""))
new JopMethodsMenu( dyn.session, rets.str, JopUtility.GRAPH,
(Component)dyn.comp, e.getX(), e.getY());
}
}
break;
}
}
}
This diff is collapsed.
......@@ -27,6 +27,7 @@ local_java_sources := \
JopBar.java \
JopTrend.java \
JopAxis.java \
GeTable.java \
GeDynElem.java \
GeDynDigLowColor.java \
GeDynDigColor.java \
......@@ -60,6 +61,7 @@ local_java_sources := \
GeDynPulldownMenu.java \
GeDynOptionMenu.java \
GeDynAnalogText.java \
GeDynTable.java \
JopSpiderFrame.java \
JopLoginFrame.java \
JopLoginApplet.java \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment