Browse Data

From: Mike Kienenberger (mkienen..laska.net)
Date: Wed Oct 20 2004 - 14:44:40 EDT

  • Next message: jir..bjectstyle.org: "[OS-JIRA] Created: (CAY-217) Browse Data Tool for Modeler"

    Earlier this morning, I finished the basic "Browse Data" functionality for
    both DbEntities and ObjEntities. I then spent the rest of the day trying to
    figure out how to make a JTable display it. :)

    The TableBindingBuilder thing is awesome. The JGoodies stuff is also very
    nice once I figured out how to use it.

    JTable sucked in JDK 1.1.8, and I'm sorry to say that I don't see any
    improvements in using it since I last used it in 1999. :) It still seems a
    nightmare to properly size a JTable, and then getting the viewport the right
    size is equally difficult.

    I've tried looking at rebuildTable() in DbEntityAttributeTab and
    ObjEntityAttributeTab, but I must be missing whatever trick it takes.

    I've tried calling something like this:

        public void resetDataTableWidths() {
            int columnCount = data.getColumnModel().getColumnCount();
            int totalColumnWidth = 0;
            for (int col = 0; col < columnCount; ++col)
            {
                int columnWidth = 100;
                data.getColumnModel().getColumn(col).setMinWidth(columnWidth);
                totalColumnWidth += columnWidth;
            }
            
            Dimension dimension = data.getPreferredScrollableViewportSize();
            dimension.width = totalColumnWidth;
            dimension.height = data.getRowHeight() * data.getRowCount();
            data.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
            data.setPreferredSize(dimension);
            data.setPreferredScrollableViewportSize(dimension);
        }

    right after

                this.tableBinding2 =
    dataBuilder.bindToTable(view.getDataJTable(), "data");
                tableBinding2.updateView();
                view.resetDataTableWidths();

    and it kinda works, except that it doesn't if you rebuild the table or if
    you scroll below the "white" area in the ScrollView.

    Hopefully, I'm missing something trivial :)

    -Mike



    This archive was generated by hypermail 2.0.0 : Wed Oct 20 2004 - 14:43:15 EDT