swingx
  1. swingx
  2. SWINGX-1379

JXTreeTable.TreeTableModelAdapter: support access to underlying TreeTableModel

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.6.2
    • Fix Version/s: 1.6.3
    • Component/s: TreeTable
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      1,379

      Description

      There is no way to get the original model put on a JXTreeTable without using
      reflection. To have a method to get it from the TreeTableCellRenderer would be
      useful when you don't have it (in the ColumnFactory for exemple). The only way I
      achieve it, was by doing this:
      @Override
      public void configureTableColumn(TableModel model, TableColumnExt columnExt) {
      super.configureTableColumn(model, columnExt);
      if
      (model.getClass().getName().startsWith("org.jdesktop.swingx.JXTreeTable$TreeTableModelAdapter"))
      {
      try

      { Field f = model.getClass().getDeclaredField("tree"); f.setAccessible(true); JTree tree = (JTree) f.get(model); TreeModel tm = tree.getModel(); //do something with the model on the column }

      catch (SecurityException e) {
      } catch (IllegalArgumentException e) {
      } catch (NoSuchFieldException e) {
      } catch (IllegalAccessException e) {
      }
      }
      }

        Activity

        Hide
        kleopatra added a comment -

        just fixing the subject (JXTreeTable had such a method, it's the adapter which doesn't
        and adding a link to a recent discussion with the same request:

        http://www.java.net/forum/topic/javadesktop/java-desktop-technologies/swinglabs/jxtreetable-and-columnfactory-0

        Show
        kleopatra added a comment - just fixing the subject (JXTreeTable had such a method, it's the adapter which doesn't and adding a link to a recent discussion with the same request: http://www.java.net/forum/topic/javadesktop/java-desktop-technologies/swinglabs/jxtreetable-and-columnfactory-0
        Hide
        kleopatra added a comment -

        As an intermediate - the future model most probably will be both a TableModel and a TreeModel,
        see the XOutline experiments in the incubator (kleopatra/foreign/netbeans/xoutline) -
        added a TreeTableModelProvider interface and made the adapter implement it.

        fixed as of revision 3914

        • added TreeTableModelProvider which guarantees to return a not-null TreeTableModel
        • changed TreeTableModelAdapter to implement
        • added unit tests
        • added example of custom columnFactory to JXTreeTableVisualCheck
        Show
        kleopatra added a comment - As an intermediate - the future model most probably will be both a TableModel and a TreeModel, see the XOutline experiments in the incubator (kleopatra/foreign/netbeans/xoutline) - added a TreeTableModelProvider interface and made the adapter implement it. fixed as of revision 3914 added TreeTableModelProvider which guarantees to return a not-null TreeTableModel changed TreeTableModelAdapter to implement added unit tests added example of custom columnFactory to JXTreeTableVisualCheck

          People

          • Assignee:
            kleopatra
            Reporter:
            klbsjpolp
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: