child tables go away when MultilineTableCellRenderer used

This is the forum for JIDE Common Layer which is open sourced at https://github.com/jidesoft/jide-oss. Please note, JIDE technical support doesn't monitor this forum as often as other forums. Please consider subscribe for technical support for JIDE Common Layer so that you can use customer only forum to get a timely response.

Moderator: JIDE Support

Forum rules
Community driven forum for open source JIDE Common Layer. JIDE technical support doesn't monitor this forum as often as other forums. If you only use JIDE Common Layer, please consider subscribing for technical support for JIDE Common Layer so that you can use customer only forum to get a timely response.

child tables go away when MultilineTableCellRenderer used

Postby ack1035 » Tue Jun 10, 2008 10:10 am

Hello,
When I override getCellRenderer() on my hierarchical table class, and have it return a MultilineTableCellRenderer, the rows no longer expand to show the child tables. In fact the hasChild() method on my TableModel isn’t even called.

Is it possible to have rows that both expand into child tables and use a MultilineTableCellRenderer?

Thanks,
Alex
ack1035
 
Posts: 11
Joined: Tue Jun 10, 2008 10:02 am

Postby JIDE Support » Tue Jun 10, 2008 10:13 am

If possible, can you try to modify HierarchicalTableDemo to reproduce the issue and email or post here the changed code?

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Postby ack1035 » Tue Jun 10, 2008 12:05 pm

I emailed the modified code, which reproduced the following results:

-word wrap is now enabled, but
-items in the subtables that formerly had children no longer do ("ComboBox" and "CellEditors")

Here's an excerpt to show how I did this (around line 139):

TableModel model = ((TableModel) value);
if (model instanceof HierarchicalTableModel) {
HierarchicalTable childTable = new HierarchicalTable(model) {
@Override
public void scrollRectToVisible(Rectangle aRect) {
HierarchicalTableDemo.scrollRectToVisible(this, aRect);
}
TableCellRenderer cellRenderer =
new MultilineTableCellRenderer();

@Override
public TableCellRenderer getCellRenderer(int row, int column) {
return cellRenderer;
}
};
childTable.setRowAutoResizes(true);

...

The behavior I'd like is to have both the word wrap and not to lose subtables.

Thanks,
Alex
ack1035
 
Posts: 11
Joined: Tue Jun 10, 2008 10:02 am

Postby JIDE Support » Tue Jun 10, 2008 12:43 pm

I see. Of course you won't see the +/- icon as you override our cell renderer that paints the +/- icon. The correct way is to use our CellRenderer/EditorManager way. Just get rid of your code of getCellRenderer and use the code below for the model.

Code: Select all
    static class GridsProductTableModel extends DefaultContextSensitiveTableModel implements HierarchicalTableModel {
        public GridsProductTableModel() {
            super(JIDE_GRIDS, DETAIL_COLUMNS);
        }

        @Override
        public Class<?> getCellClassAt(int row, int column) {
            return String.class;
        }

        @Override
        public EditorContext getEditorContextAt(int row, int column) {
            return MultilineTableCellRenderer.CONTEXT;
        }
       
        @Override
        public boolean isCellEditable(int row, int column) {
            return false;
        }

        public boolean hasChild(int row) {
            Object name = getValueAt(row, 0);
            if ("CellEditors".equals(name) || "ComboBox".equals(name)) {
                return true;
            }
            else {
                return false;
            }
        }

        public boolean isHierarchical(int row) {
            return true;
        }

        public boolean isExpandable(int row) {
            return true;
        }

        public Object getChildValueAt(int row) {
            TableModel model = null;
            Object name = getValueAt(row, 0);
            if ("ComboBox".equals(name)) {
                model = new DefaultTableModel(JIDE_COMBOBOXES, DETAIL_COLUMNS) {
                    @Override
                    public boolean isCellEditable(int row, int column) {
                        return false;
                    }
                };
            }
            else if ("CellEditors".equals(name)) {
                model = new DefaultTableModel(JIDE_CELLEDITORS, DETAIL_COLUMNS) {
                    @Override
                    public boolean isCellEditable(int row, int column) {
                        return false;
                    }
                };
            }
            return model;
        }
    }
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am


Return to JIDE Common Layer Open Source Project Discussion (Community Driven)

Who is online

Users browsing this forum: No registered users and 63 guests