2
Fork 0

[svn r297] some hack work to enable some features and removed all compiler warnings

This commit is contained in:
willemc 2007-11-26 00:01:25 +01:00
parent 1e74f3c039
commit 6a2813f43d
20 changed files with 829 additions and 57 deletions

View file

@ -35,6 +35,8 @@ import java.awt.Image;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.util.ArrayList;
@ -73,6 +75,7 @@ import com.idcanet.vasc.core.VascViewRenderer;
import com.idcanet.vasc.core.actions.GlobalVascAction;
import com.idcanet.vasc.core.actions.RowVascAction;
import com.idcanet.vasc.core.column.VascTableColumn;
import com.idcanet.vasc.core.ui.VascColorChooser;
import com.idcanet.vasc.core.ui.VascColumnValueModelListener;
import com.idcanet.vasc.core.ui.VascDate;
import com.idcanet.vasc.core.ui.VascList;
@ -80,6 +83,7 @@ import com.idcanet.vasc.core.ui.VascTextField;
import com.idcanet.vasc.core.ui.VascToggle;
import com.idcanet.vasc.core.ui.VascUIComponent;
import com.idcanet.vasc.core.ui.VascValueModel;
import com.idcanet.vasc.impl.swing.ui.SwingColorChooser;
import com.idcanet.vasc.impl.swing.ui.SwingDate;
import com.idcanet.vasc.impl.swing.ui.SwingList;
import com.idcanet.vasc.impl.swing.ui.SwingTextField;
@ -117,6 +121,7 @@ public class SwingVascViewRenderer implements VascViewRenderer {
table.putUIComponent(VascList.class, SwingList.class);
table.putUIComponent(VascToggle.class, SwingToggle.class);
table.putUIComponent(VascDate.class, SwingDate.class);
table.putUIComponent(VascColorChooser.class, SwingColorChooser.class);
this.table=table;
}
@ -141,7 +146,7 @@ public class SwingVascViewRenderer implements VascViewRenderer {
*/
public void renderEdit(Object rowBean) throws Exception {
logger.fine("Rending Edit View");
table.getVascTableController().initEditObject(table, rowBean);
rowBean = table.getVascTableController().initEditObject(table, rowBean);
String beanValue = rowBean.toString();
if (table.getUIIdentifierVascTableColomn()!=null) {
Object vv = table.getUIIdentifierVascTableColomn().getVascColumnValue().getValue(table.getUIIdentifierVascTableColomn(), rowBean);
@ -160,16 +165,7 @@ public class SwingVascViewRenderer implements VascViewRenderer {
if(result==null) {
return;
}
try {
result = table.getVascDataSource().merge(rowBean);
} finally {
// todo: make faster
// add to table at position old old object
// then remove old object
// send refresh
table.getVascTableController().refreshData(table);
}
table.getVascTableController().mergeObject(table, result);
}
public void renderDelete(Object rowBean) throws Exception {
@ -455,8 +451,17 @@ public class SwingVascViewRenderer implements VascViewRenderer {
VascColumnModel model = new VascColumnModel();
table.getVascTableController().addEventListener(model);
JTable jTable = new JTable(model);
JTable jTable = new JTable();
//TODO: remove this extra model for sorting, AND fixup a real sorting stuff
TableSorter tableSorter = new TableSorter();
// this regs the listeners for the sorting
tableSorter.setTableHeader(jTable.getTableHeader());
tableSorter.setTableModel(model);
jTable.setModel(tableSorter);
jTable.getTableHeader().setReorderingAllowed(false);
// remove auto columns :(
int cols = jTable.getColumnModel().getColumnCount();
for (int i=0;i<cols;i++) {
@ -479,15 +484,32 @@ public class SwingVascViewRenderer implements VascViewRenderer {
jTable.addColumn(t);
counter++;
}
jTable.getSelectionModel().addListSelectionListener(new TableSectionListener(jTable));
jTable.getSelectionModel().addListSelectionListener(new TableSectionListener(jTable,tableSorter));
jTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
jTable.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
if (e.getClickCount() == 2) {
Object o = table.getSelectedObject();
if (o==null) {
return;
}
try {
table.getVascViewRenderer().renderEdit(o);
} catch (Exception ee) {
table.getVascTableController().handleException(ee, table);
}
}
}
});
JScrollPane scrollPane = new JScrollPane(jTable);
parent2.add(scrollPane);
}
class TableSectionListener implements ListSelectionListener {
JTable jTable;
TableSectionListener(JTable table) {
TableSorter tableSorter;
TableSectionListener(JTable table,TableSorter tableSorter) {
this.jTable = table;
this.tableSorter=tableSorter;
}
public void valueChanged(ListSelectionEvent e) {
if (e.getValueIsAdjusting()) {
@ -495,6 +517,8 @@ public class SwingVascViewRenderer implements VascViewRenderer {
}
int rowIndex = jTable.getSelectedRow();
if (rowIndex!=-1) {
// temp; gets index by sorter
rowIndex = tableSorter.modelIndex(rowIndex);
Object data = table.getTableData().get(rowIndex);
table.setSelectedObject(data);
} else {
@ -621,6 +645,7 @@ public class SwingVascViewRenderer implements VascViewRenderer {
Object bean = table.getTableData().get(rowIndex);
logger.finer("Rending column; "+columnIndex+" bean: "+bean);
// TODO: this is slowing....
List<VascTableColumn> list = new ArrayList<VascTableColumn>();
for(VascTableColumn c:table.getTableColumns()) {
if (c.isListDisplay()==false) {