craftleft.gif (3002 bytes)QuickTable
Home | API | Tutorial | Download | Support | Contact topblack.gif (108 bytes)


QuickTable User Cp  |  Register  |  Members  |  Search  |  Help
    |- QuickTable Discussion Forums > UI , Look and Feel, Colors, Navigation, font, Locale Post New Topic   Post A Reply
Bypassing invisible and readonly columns with MyDBTableEvent... printer friendly version
next newest post | next oldest post
Author Messages
tilh
Private First Class

Gender: Male
Location: Singapore
Registered: Jul 2005
Status: Offline
Posts: 19

Click here to see the profile for tilh Send email to tilh Send private message to tilh Find more posts by tilh Edit or delete this message Reply w/Quote
Posted Tuesday, November 1, 2005 @ 23:29:41  

I'm trying to bypass invisible and readonly columns with the TAB key.
In using the MyDBTableEventListerner.afterColumnSelectionChange,
I try to figure out that if is not a "non-TABable" field, I move to the next.

The problem is when I try to change rows. It just would not work, it keeps returning to the old row.

The below is a progra you can try. Try to TAB through - it drives me nuts.
It seems quicktable is calling:

setValueAt() didn't update the data R1C1 at row=1 col=2 because new value same as old value

and resetting the selected row.

import java.awt.BorderLayout;
import java.io.*;
import java.util.Properties;
import javax.swing.JFrame;
import javax.swing.JTable;
import javax.swing.event.ChangeEvent;
import quick.dbtable.*;
/*
* dBTableTest.java
*
* Created on August 21, 2005, 3:43 AM
*/

public class dBTableTest1 extends JFrame {
DBTable dBTable1;
/** Creates a new instance of dBTableTest */
public dBTableTest1(PipedOutputStream pOut) {
Properties prop = new Properties();
prop.put("delimiter","\t");
prop.put("firstRowHasColumnNames","true");

setSize(500,200);
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
// InputStream in = new InputStream();
dBTable1 = new DBTable();

try {
PipedInputStream pIn = new PipedInputStream(pOut);

getContentPane().add(dBTable1, BorderLayout.CENTER);
dBTable1.refresh(pIn,prop);
dBTable1.addDBTableEventListener(new MyDBTableEventListerner());

Column col = dBTable1.getColumn(0);
col.setVisible(false);
col = dBTable1.getColumn(4);
col.setVisible(false);

col = dBTable1.getColumn(3);
// col.setReadOnly(true);

dBTable1.editCellAt(0,1);

} catch (Exception e) {
e.printStackTrace();
}
}

class MyDBTableEventListerner extends quick.dbtable.DBTableEventListener {
public void afterRowSelectionChange(int fromRow, int toRow) {
// this is done before ColumnChange
int col = dBTable1.getSelectedColumn();
System.out.println("After changing Row from " + fromRow + " to " + toRow + " col " + col);
}

public void afterColumnSelectionChange(int fromColumn, int toColumn) {
int nowRow = dBTable1.getSelectedRow();
if (toColumn == 0 && fromColumn == dBTable1.getColumnCount() -1) {
nowRow++;
}
System.out.println("After changing Col from " + fromColumn + " to " + toColumn + " row " + nowRow);
Column column = dBTable1.getColumn(toColumn);
int c = toColumn;
System.out.print("Moving from " + nowRow +"," + c);
while ((! column.isVisible() || column.getReadOnly() == true ) && c < dBTable1.getColumnCount() ) {
c++;
if (c == dBTable1.getColumnCount()) {
c = 0;
nowRow++;
if (nowRow == dBTable1.getRowCount()) {
// possibly insertRow
nowRow = 0;
}
}
System.out.print(">" + c);
column = dBTable1.getColumn(c);
}
System.out.println(" to " + nowRow + "," +c);
if (c != toColumn) {
dBTable1.debug = true;
dBTable1.selectCell(nowRow,c);
dBTable1.getTable().changeSelection(nowRow,c, false, false);
}
}

// not called !!!!!
public boolean beforeColumnSelectionChange(int fromColumn,
int toColumn,
int fromRow,
int toRow) {
System.out.println("Before changing from " + fromRow + "," + fromColumn + " to " + toRow + "," + toRow);
return true;
}
}

public static void writer(PipedOutputStream pOut) {
StringBuffer buf = new StringBuffer();
buf.append("Column0\tColumn 1\tColumn 2\tColumn 3\tColumn 4\n");
buf.append("R0C0\tR0C1\tR0C2\tROC3\tROC4\n");
buf.append("R1C0\tR1C1\tR1C2\tR1C3\tR1C4\n");
buf.append("R2C0\tR2C1\tR2C2\tR1C3\tR2C4\n");

String s = new String(buf);
byte[] byteArray = s.getBytes();
try {
pOut.write(byteArray);
pOut.flush();
pOut.close();
} catch (Exception e) {
e.printStackTrace();
}

}
public static void main(String args[]) {
final PipedOutputStream pOut = new PipedOutputStream();
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
dBTableTest1 comp = new dBTableTest1(pOut);
comp.setVisible(true);
comp.toFront();
}
});
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
writer(pOut);
}
});

}
}

Admin
Board Owner

Gender: Unspecified
Location:
Registered: Jul 2003
Status: Offline
Posts: 9

Click here to see the profile for Admin Send email to Admin Send private message to Admin Find more posts by Admin Edit or delete this message Reply w/Quote
Posted Thursday, November 3, 2005 @ 10:13:13  

Please download the latest version. It automatically handles the tab through invisible columns.
tilh
Private First Class

Gender: Male
Location: Singapore
Registered: Jul 2005
Status: Offline
Posts: 19

Click here to see the profile for tilh Send email to tilh Send private message to tilh Find more posts by tilh Edit or delete this message Reply w/Quote
Posted Thursday, November 3, 2005 @ 22:02:08  

I just download the new version.

and still tabs through invisible columns

Admin
Board Owner

Gender: Unspecified
Location:
Registered: Jul 2003
Status: Offline
Posts: 9

Click here to see the profile for Admin Send email to Admin Send private message to Admin Find more posts by Admin Edit or delete this message Reply w/Quote
Posted Sunday, November 6, 2005 @ 10:38:40  

Please download the latest 2.0.5.24 version and try.
tilh
Private First Class

Gender: Male
Location: Singapore
Registered: Jul 2005
Status: Offline
Posts: 19

Click here to see the profile for tilh Send email to tilh Send private message to tilh Find more posts by tilh Edit or delete this message Reply w/Quote
Posted Sunday, November 6, 2005 @ 22:07:18  

OK, looks good.

Unfortunately, it does not TAB back to (0,0) once it reaches the end ....

Admin
Board Owner

Gender: Unspecified
Location:
Registered: Jul 2003
Status: Offline
Posts: 9

Click here to see the profile for Admin Send email to Admin Send private message to Admin Find more posts by Admin Edit or delete this message Reply w/Quote
Posted Sunday, November 6, 2005 @ 23:53:55  

Fixed the tab back to 0,0 problem, please try the latest version again.
Post New Topic   Post A Reply Jump to:
Contact Us | QuickTable - A Java DBGrid | Privacy Policy All times are GMT -5 Hours.
Welcome to QuickTable Forums, Guest!  
Login
Username :
Password :
In order to fully utilize the abilities of this board, you are required to register as a member. Registration is free, and allows you to do lots of things including turning on or off certain features of this board. Register now!
Powered by CuteCast v2.0 BETA 2
Copyright © 2001-2003 ArtsCore Studios