support for JSR 295

This forum is used by users to request and discuss new product features. Please do not use this forum for technical support including bug reports.

Moderator: JIDE Support

Forum rules
Product suggestions only. Please do not use this forum for technical support including bug reports.

support for JSR 295

Postby Harald.Fischer » Tue Apr 19, 2011 10:29 am

Hi,

does anybody know of JIDE planning to adopt JSR 295 (beans binding) for their various tables - assuming they don't support it yet (and hence this assumption led me to _this_ board)?

Or do they support this JSR yet and we guys did something wrong? (We're using NetBeans 6.9.1 and did not succeed in binding SortableTable or even JideTable in NetBean's GUI Builder. When we populated the bound model, nothing showed up in the tables :(. Whereas a normal JTable is doing just fine.)

Thanks for ANY statement or hint which resource or document would be worth to check.
Harald
Harald.Fischer
 
Posts: 6
Joined: Thu Aug 11, 2005 12:38 am

Re: support for JSR 295

Postby JIDE Support » Tue Apr 19, 2011 11:31 am

Just tested in Netbeans 6.8 and could not observe any issue. May I ask which JIDE release you are using?

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

Re: support for JSR 295

Postby Harald.Fischer » Wed Apr 20, 2011 12:44 am

Sorry, should have stated this in my first post: We're using release 2.10.2.

Thanks
Harald
Harald Fischer-Hohlweck
mailto:Harald.Fischer-Hohlweck@ibix.de
IBIX Informationssysteme GmbH
Vor dem Lauch 19
D-70599 Stuttgart
Germany
Harald.Fischer
 
Posts: 6
Joined: Thu Aug 11, 2005 12:38 am

Re: support for JSR 295

Postby JIDE Support » Wed Apr 20, 2011 2:26 pm

Can you please elaborate a little bit about the issues you observed regarding JideTable? A screencast if possible would be highly appreciated.

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

Re: support for JSR 295

Postby Harald.Fischer » Thu Apr 28, 2011 4:55 am

Hi,

back again - sorry for the delay! And - sorry again - I have to avow that I was inaccurate in stating JideTable does not bind properly. Actually it does! As you (JIDE people) supposed: Only SortableTable is affected by this issue.

Now that we've examined all this more carefully, things turned out to be as follows:
- Both JideTable and SortableTable bind properly to our model;
- JideTable binds properly to selectedItem, but SortableTable throws a ClassCastException when bound to selectedItem and a table cell is selected (by mouse click, e.g.);
- nothing changes with JIDE release 3.0.2 and / or "BetterBeansBinding" 1.3.0.

Is there any chance to get this fixed in near future??

:oops: Although I'm feeling more and more uncomfortable that I have chosen this forum (but don't know how to switch to another …), for the sake of completeness let me append the CCE:

Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException
at java.lang.Class.cast(Class.java:2990)
at org.jdesktop.beansbinding.Binding.convertReverse(Binding.java:1321)
at org.jdesktop.beansbinding.Binding.getTargetValueForSource(Binding.java:909)
at org.jdesktop.beansbinding.Binding.saveUnmanaged(Binding.java:1268)
at org.jdesktop.beansbinding.Binding.save(Binding.java:1254)
at org.jdesktop.beansbinding.AutoBinding.trySaveThenRefresh(AutoBinding.java:176)
at org.jdesktop.beansbinding.AutoBinding.targetChangedImpl(AutoBinding.java:249)
at org.jdesktop.beansbinding.Binding.targetChanged(Binding.java:1433)
at org.jdesktop.beansbinding.Binding.access$1300(Binding.java:38)
at org.jdesktop.beansbinding.Binding$PSL.propertyStateChanged(Binding.java:1620)
at org.jdesktop.beansbinding.PropertyHelper.firePropertyStateChange(PropertyHelper.java:212)
at org.jdesktop.beansbinding.BeanProperty.notifyListeners(BeanProperty.java:712)
at org.jdesktop.beansbinding.BeanProperty.access$1000(BeanProperty.java:143)
at org.jdesktop.beansbinding.BeanProperty$SourceEntry.cachedValueChanged(BeanProperty.java:369)
at org.jdesktop.beansbinding.BeanProperty$SourceEntry.propertyValueChanged(BeanProperty.java:409)
at org.jdesktop.beansbinding.BeanProperty$SourceEntry.propertyChange(BeanProperty.java:414)
at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:339)
at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:276)
at org.jdesktop.swingbinding.adapters.BeanAdapterBase.firePropertyChange(BeanAdapterBase.java:112)
at org.jdesktop.swingbinding.adapters.JTableAdapterProvider$Adapter$Handler.tableSelectionChanged(JTableAdapterProvider.java:81)
at org.jdesktop.swingbinding.adapters.JTableAdapterProvider$Adapter$Handler.valueChanged(JTableAdapterProvider.java:91)
at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:167)
at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:147)
at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:194)
at javax.swing.DefaultListSelectionModel.changeSelection(DefaultListSelectionModel.java:388)
at javax.swing.DefaultListSelectionModel.changeSelection(DefaultListSelectionModel.java:398)
at javax.swing.DefaultListSelectionModel.setSelectionInterval(DefaultListSelectionModel.java:442)
at javax.swing.JTable.changeSelectionModel(JTable.java:2352)
at javax.swing.JTable.changeSelection(JTable.java:2421)
at com.jidesoft.grid.JideTable.changeSelection(Unknown Source)
at com.jidesoft.grid.NavigableTable.changeSelection(Unknown Source)
at javax.swing.plaf.basic.BasicTableUI$Handler.adjustSelection(BasicTableUI.java:1085)
at javax.swing.plaf.basic.BasicTableUI$Handler.mousePressed(BasicTableUI.java:1008)
at com.jidesoft.swing.DelegateMouseInputListener.mousePressed(Unknown Source)
at java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:263)
at java.awt.Component.processMouseEvent(Component.java:6286)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
at java.awt.Component.processEvent(Component.java:6054)
at java.awt.Container.processEvent(Container.java:2041)
at java.awt.Component.dispatchEventImpl(Component.java:4652)
at java.awt.Container.dispatchEventImpl(Container.java:2099)
at java.awt.Component.dispatchEvent(Component.java:4482)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4577)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4235)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
at java.awt.Container.dispatchEventImpl(Container.java:2085)
at java.awt.Window.dispatchEventImpl(Window.java:2478)
at java.awt.Component.dispatchEvent(Component.java:4482)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:644)
at java.awt.EventQueue.access$000(EventQueue.java:85)
at java.awt.EventQueue$1.run(EventQueue.java:603)
at java.awt.EventQueue$1.run(EventQueue.java:601)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:98)
at java.awt.EventQueue$2.run(EventQueue.java:617)
at java.awt.EventQueue$2.run(EventQueue.java:615)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:614)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

Let me know, if example code, screenshots, screencasts, ??? would be helpful.

Thanks,
Harald
Harald.Fischer
 
Posts: 6
Joined: Thu Aug 11, 2005 12:38 am

Re: support for JSR 295

Postby JIDE Support » Thu Apr 28, 2011 9:53 am

Thanks for your update. No worry about the forum.

Can you please share with us the sample code regarding how you bind the selected item with SortableTable? Since getCellClassAt() returns different class type for different columns, just wonder if there is a possibility of mis-binding.

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

Re: support for JSR 295

Postby Harald.Fischer » Fri Apr 29, 2011 9:18 am

Hi,

I tried to extract the lines of code I suggest as essential. Please keep in mind, that this is generated completely by NetBeans (except for contraction of object allocations with declarations, line feeds, and indentation I applied for readability).

Code: Select all
  private org.jdesktop.beansbinding.BindingGroup bindingGroup = new org.jdesktop.beansbinding.BindingGroup();
  private de.ibix.NewModel newClass1 = new de.ibix.NewModel();
  private com.jidesoft.grid.SortableTable jideTable1 = new com.jidesoft.grid.SortableTable();
  // !!!!!!!!!
  // please notice that exactly the same code works fine with:
//private com.jidesoft.grid.JideTable jideTable1 = new com.jidesoft.grid.JideTable();
  // !!!!!!!!!

  org.jdesktop.beansbinding.ELProperty eLProperty = org.jdesktop.beansbinding.ELProperty.create("${observableList}");

  org.jdesktop.swingbinding.JTableBinding jTableBinding =
    org.jdesktop.swingbinding.SwingBindings.createJTableBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE,
                                                                newClass1,
                                                                eLProperty,
                                                                jideTable1);

  org.jdesktop.swingbinding.JTableBinding.ColumnBinding columnBinding =
    jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${id}"));
  columnBinding.setColumnName("ID");
  columnBinding.setColumnClass(String.class);
  columnBinding.setEditable(false);

  columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${text}"));
  // ...
  // some more columns, one of them having type org.joda.time.DateTime
  // ...

  bindingGroup.addBinding(jTableBinding);
  jTableBinding.bind();
  org.jdesktop.beansbinding.Binding binding =
    org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE,
                                                         newClass1,
                                                         org.jdesktop.beansbinding.ELProperty.create("${selectedNewPoJo}"),
                                                         jideTable1,
                                                         org.jdesktop.beansbinding.BeanProperty.create("selectedElement"));
  bindingGroup.addBinding(binding);

  // ...
  // layout stuff here
  // ...

  bindingGroup.bind();


Since these pretty code windows compact this stuff to a few screen lines :), here's the whole source file (actually three source files: NetBeans generated NewJFrame, our model class NewModel and our class NewPoJo of model elements):

Code: Select all
// =======
// File de.ibix.NewJFrame.java
// =======

/*
 * Copyright (c) IBIX Informationssysteme GmbH, 2011
 *
 * Created on 27.04.2011
 */

/*
 * NewJFrame.java
 *
 * Created on 27.04.2011, 08:10:21
 */
package de.ibix;

/**
 *
 * @author fo
 */
public class NewJFrame extends javax.swing.JFrame
{
  /** Creates new form NewJFrame */
  public NewJFrame()
  {
    initComponents();
   
    this.newClass1.populate();
  }


  /** This method is called from within the constructor to
   * initialize the form.
   * WARNING: Do NOT modify this code. The content of this method is
   * always regenerated by the Form Editor.
   */
  @SuppressWarnings( "unchecked" )
  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  private void initComponents() {
    bindingGroup = new org.jdesktop.beansbinding.BindingGroup();

    newClass1 = new de.ibix.NewModel();
    jScrollPane1 = new javax.swing.JScrollPane();
    jideTable1 = new com.jidesoft.grid.JideTable();

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

    jideTable1.setColumnSelectionAllowed(true);

    org.jdesktop.beansbinding.ELProperty eLProperty = org.jdesktop.beansbinding.ELProperty.create("${observableList}");
    org.jdesktop.swingbinding.JTableBinding jTableBinding = org.jdesktop.swingbinding.SwingBindings.createJTableBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, newClass1, eLProperty, jideTable1);
    org.jdesktop.swingbinding.JTableBinding.ColumnBinding columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${id}"));
    columnBinding.setColumnName("ID");
    columnBinding.setColumnClass(String.class);
    columnBinding.setEditable(false);
    columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${text}"));
    columnBinding.setColumnName("Text");
    columnBinding.setColumnClass(String.class);
    columnBinding.setEditable(false);
    columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${date}"));
    columnBinding.setColumnName("Date");
    columnBinding.setColumnClass(org.joda.time.DateTime.class);
    columnBinding.setEditable(false);
    bindingGroup.addBinding(jTableBinding);
    jTableBinding.bind();org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, newClass1, org.jdesktop.beansbinding.ELProperty.create("${selectedNewPoJo}"), jideTable1, org.jdesktop.beansbinding.BeanProperty.create("selectedElement"));
    bindingGroup.addBinding(binding);

    jScrollPane1.setViewportView(jideTable1);
    jideTable1.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
        .addContainerGap(13, Short.MAX_VALUE)
        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 375, javax.swing.GroupLayout.PREFERRED_SIZE)
        .addContainerGap())
    );
    layout.setVerticalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(layout.createSequentialGroup()
        .addContainerGap()
        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 275, javax.swing.GroupLayout.PREFERRED_SIZE)
        .addContainerGap(13, Short.MAX_VALUE))
    );

    bindingGroup.bind();

    pack();
  }// </editor-fold>//GEN-END:initComponents


  /**
   * @param args the command line arguments
   */
  public static void main( String args[] )
  {
    java.awt.EventQueue.invokeLater( new Runnable()
    {

      public void run()
      {
        new NewJFrame().setVisible( true );
      }
    } );
  }
  // Variables declaration - do not modify//GEN-BEGIN:variables
  private javax.swing.JScrollPane jScrollPane1;
  private com.jidesoft.grid.JideTable jideTable1;
  private de.ibix.NewModel newClass1;
  private org.jdesktop.beansbinding.BindingGroup bindingGroup;
  // End of variables declaration//GEN-END:variables
}

// =======
// File de.ibix.NewModel.java
// =======
/*
 * Copyright (c) IBIX Informationssysteme GmbH, 2011
 *
 * Created on 27.04.2011
 */

package de.ibix;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.util.ArrayList;

import org.jdesktop.observablecollections.ObservableCollections;
import org.jdesktop.observablecollections.ObservableList;

/**
 * A model class.
 *
 * @author fo
 */
public class NewModel
{
  public static final String              PROP_SELECTEDNEWPOJO  = "selectedNewPoJo";
  final private ObservableList< NewPoJo > observableList        = ObservableCollections.observableList( new ArrayList< NewPoJo >() );
  final private PropertyChangeSupport     propertyChangeSupport = new PropertyChangeSupport( this );
  private NewPoJo                         selectedNewPoJo       = null;

  /**
   * Populates this model with dummies.
   */
  public void populate()
  {
    System.err.println( "populating model" );

    this.observableList.addAll( NewPoJo.createDummies() );
  }

  /**
   * Get the value of selectedNewPoJo
   *
   * @return the value of selectedNewPoJo
   */
  public NewPoJo getSelectedNewPoJo()
  {
    System.err.println( "get selectedNewPoJo <" + selectedNewPoJo + ">" );

    return selectedNewPoJo;
  }

  /**
   * Set the value of selectedNewPoJo
   *
   * @param newSelectedNewPoJo new value of selectedNewPoJo
   */
  public void setSelectedNewPoJo( NewPoJo newSelectedNewPoJo )
  {
    System.err.println( "set selectedNewPoJo to <" + newSelectedNewPoJo + ">" );

    NewPoJo oldSelectedNewPoJo = this.selectedNewPoJo;
    this.selectedNewPoJo = newSelectedNewPoJo;
    propertyChangeSupport.firePropertyChange( PROP_SELECTEDNEWPOJO, oldSelectedNewPoJo, newSelectedNewPoJo );
  }

  /**
   * Get the value of observableList
   *
   * @return the value of observableList
   */
  public ObservableList< NewPoJo > getObservableList()
  {
    return observableList;
  }

  /**
   * Add PropertyChangeListener.
   *
   * @param listener to add
   */
  public void addPropertyChangeListener( PropertyChangeListener listener )
  {
    propertyChangeSupport.addPropertyChangeListener( listener );
  }

  /**
   * Remove PropertyChangeListener.
   *
   * @param listener to remove
   */
  public void removePropertyChangeListener( PropertyChangeListener listener )
  {
    propertyChangeSupport.removePropertyChangeListener( listener );
  }
}

// =======
// File de.ibix.NewPoJo.java
// =======
/*
 * Copyright (c) IBIX Informationssysteme GmbH, 2011
 *
 * Created on 27.04.2011
 */

package de.ibix;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.text.DecimalFormat;
import java.text.Format;
import java.util.ArrayList;
import java.util.List;
import javax.swing.text.NumberFormatter;

import org.joda.time.DateTime;

/**
 * A PoJo class of model elements.
 *
 * @author fo
 */
public class NewPoJo
{
  public static final String          PROP_ID               = "id";
  public static final String          PROP_TEXT             = "text";
  public static final String          PROP_DATE             = "date";
  final private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport( this );
  private String                      id                    = null;
  private String                      text                  = null;
  private DateTime                    date                  = null;

  /**
   * Constructs a <code>NewPoJo</code>.
   *
   * @param id_A ID of new <code>NewPoJo</code>
   * @param text_A TEXT of new <code>NewPoJo</code>
   * @param date_A DATE of new <code>NewPoJo</code>
   */
  public NewPoJo( String id_A, String text_A, DateTime date_A )
  {
    this.setId( id_A );
    this.setText( text_A );
    this.setDate( date_A );
  }

  /**
   * Creates and returns a {@link List} of <code>NewPoJo</code> dummies.
   *
   * @return some <code>NewPoJo</code> dummies
   */
  public static List< NewPoJo > createDummies()
  {
    final List< NewPoJo > aList = new ArrayList< NewPoJo >( 10 );
    final Format aIDFormat = new NumberFormatter( new DecimalFormat( "ID-00000" ) ).getFormat();
    final Format aTextFormat = new NumberFormatter( new DecimalFormat( "Text 00000" ) ).getFormat();

    for ( int i = 0; i < 10; i++ )
    {
      System.err.println( "creating dummy " + i );

      final NewPoJo aNewPoJo = new NewPoJo( aIDFormat.format( i ),
                                            aTextFormat.format( i ),
                                            new DateTime().minusDays( i ) );
      aList.add( aNewPoJo );
    }

    return aList;
  }

  /**
   * Get the value of id
   *
   * @return the value of id
   */
  public String getId()
  {
    return id;
  }

  /**
   * Set the value of id
   *
   * @param newId new value of id
   */
  public void setId( String newId )
  {
    String oldId = this.id;
    this.id = newId;
    propertyChangeSupport.firePropertyChange( PROP_ID, oldId, newId );
  }

  /**
   * Get the value of text
   *
   * @return the value of text
   */
  public String getText()
  {
    return text;
  }

  /**
   * Set the value of text
   *
   * @param newText new value of text
   */
  public void setText( String newText )
  {
    String oldText = this.text;
    this.text = newText;
    propertyChangeSupport.firePropertyChange( PROP_TEXT, oldText, newText );
  }

  /**
   * Get the value of date
   *
   * @return the value of date
   */
  public DateTime getDate()
  {
    return date;
  }

  /**
   * Set the value of date
   *
   * @param newDate new value of date
   */
  public void setDate( DateTime newDate )
  {
    DateTime oldDate = this.date;
    this.date = newDate;
    propertyChangeSupport.firePropertyChange( PROP_DATE, oldDate, newDate );
  }

  @Override
  public String toString()
  {
    return "NewPoJo{" + "id=" + id + ", text=" + text + ", date=" + date + '}';
  }

  /**
   * Add PropertyChangeListener.
   *
   * @param listener to add
   */
  public void addPropertyChangeListener( PropertyChangeListener listener )
  {
    propertyChangeSupport.addPropertyChangeListener( listener );
  }

  /**
   * Remove PropertyChangeListener.
   *
   * @param listener to remove
   */
  public void removePropertyChangeListener( PropertyChangeListener listener )
  {
    propertyChangeSupport.removePropertyChangeListener( listener );
  }
}


Please let me know, if this is not what you expected us to fill in here. I would have attached source files, if it were possible. Should I hand'em over to you by mail??

Thanks
Harald
Harald.Fischer
 
Posts: 6
Joined: Thu Aug 11, 2005 12:38 am

Re: support for JSR 295

Postby JIDE Support » Mon May 02, 2011 1:02 pm

Sorry for the late response. Embarrassingly, although I could get your source code run, I cannot see any visible row even if I change the table to JTable, which blocks me to next step for selected item. Not sure what I did wrong. Attached is the modified test case FYI. Tried to run it in both Netbeans and IntelliJ and got the same empty frame.
Code: Select all
// =======
// File de.ibix.NewJFrame.java
// =======

/*
* Copyright (c) IBIX Informationssysteme GmbH, 2011
*
* Created on 27.04.2011
*/

/*
* NewJFrame.java
*
* Created on 27.04.2011, 08:10:21
*/

import org.jdesktop.observablecollections.ObservableCollections;
import org.jdesktop.observablecollections.ObservableList;

import javax.swing.*;
import javax.swing.text.NumberFormatter;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.text.DecimalFormat;
import java.text.Format;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
*
* @author fo
*/
public class NewJFrame extends javax.swing.JFrame
{
  /** Creates new form NewJFrame */
  public NewJFrame()
  {
    initComponents();

    this.newClass1.populate();
  }


  /** This method is called from within the constructor to
   * initialize the form.
   * WARNING: Do NOT modify this code. The content of this method is
   * always regenerated by the Form Editor.
   */
  @SuppressWarnings( "unchecked" )
  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  private void initComponents() {
    bindingGroup = new org.jdesktop.beansbinding.BindingGroup();

    newClass1 = new NewModel();
    jScrollPane1 = new javax.swing.JScrollPane();
    jideTable1 = new JTable();

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

    jideTable1.setColumnSelectionAllowed(true);

    org.jdesktop.beansbinding.ELProperty eLProperty = org.jdesktop.beansbinding.ELProperty.create("${observableList}");
    org.jdesktop.swingbinding.JTableBinding jTableBinding = org.jdesktop.swingbinding.SwingBindings.createJTableBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, newClass1, eLProperty, jideTable1);
    org.jdesktop.swingbinding.JTableBinding.ColumnBinding columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${id}"));
    columnBinding.setColumnName("ID");
    columnBinding.setColumnClass(String.class);
    columnBinding.setEditable(false);
    columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${text}"));
    columnBinding.setColumnName("Text");
    columnBinding.setColumnClass(String.class);
    columnBinding.setEditable(false);
//    columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${date}"));
//    columnBinding.setColumnName("Date");
//    columnBinding.setColumnClass(Date.class);
//    columnBinding.setEditable(false);
    bindingGroup.addBinding(jTableBinding);
    jTableBinding.bind();
//      org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, newClass1, org.jdesktop.beansbinding.ELProperty.create("${selectedNewPoJo}"), jideTable1, org.jdesktop.beansbinding.BeanProperty.create("selectedElement"));
//    bindingGroup.addBinding(binding);
//      binding.bind();

    jScrollPane1.setViewportView(jideTable1);
    jideTable1.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
        .addContainerGap(13, Short.MAX_VALUE)
        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 375, javax.swing.GroupLayout.PREFERRED_SIZE)
        .addContainerGap())
    );
    layout.setVerticalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(layout.createSequentialGroup()
        .addContainerGap()
        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 275, javax.swing.GroupLayout.PREFERRED_SIZE)
        .addContainerGap(13, Short.MAX_VALUE))
    );

    bindingGroup.bind();

    pack();
  }// </editor-fold>//GEN-END:initComponents


  /**
   * @param args the command line arguments
   */
  public static void main( String args[] )
  {
    java.awt.EventQueue.invokeLater( new Runnable()
    {

      public void run()
      {
        new NewJFrame().setVisible( true );
      }
    } );
  }
  // Variables declaration - do not modify//GEN-BEGIN:variables
  private javax.swing.JScrollPane jScrollPane1;
  private JTable jideTable1;
  private NewModel newClass1;
  private org.jdesktop.beansbinding.BindingGroup bindingGroup;
  // End of variables declaration//GEN-END:variables
}

class NewModel
{
  public static final String              PROP_SELECTEDNEWPOJO  = "selectedNewPoJo";
  final private ObservableList< NewPoJo > observableList        = ObservableCollections.observableList(new ArrayList<NewPoJo>());
  final private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport( this );
  private NewPoJo                         selectedNewPoJo       = null;

  /**
   * Populates this model with dummies.
   */
  public void populate()
  {
    System.err.println( "populating model" );

    this.observableList.addAll( NewPoJo.createDummies() );
  }

  /**
   * Get the value of selectedNewPoJo
   *
   * @return the value of selectedNewPoJo
   */
  public NewPoJo getSelectedNewPoJo()
  {
    System.err.println( "get selectedNewPoJo <" + selectedNewPoJo + ">" );

    return selectedNewPoJo;
  }

  /**
   * Set the value of selectedNewPoJo
   *
   * @param newSelectedNewPoJo new value of selectedNewPoJo
   */
  public void setSelectedNewPoJo( NewPoJo newSelectedNewPoJo )
  {
    System.err.println( "set selectedNewPoJo to <" + newSelectedNewPoJo + ">" );

    NewPoJo oldSelectedNewPoJo = this.selectedNewPoJo;
    this.selectedNewPoJo = newSelectedNewPoJo;
    propertyChangeSupport.firePropertyChange( PROP_SELECTEDNEWPOJO, oldSelectedNewPoJo, newSelectedNewPoJo );
  }

  /**
   * Get the value of observableList
   *
   * @return the value of observableList
   */
  public ObservableList< NewPoJo > getObservableList()
  {
    return observableList;
  }

  /**
   * Add PropertyChangeListener.
   *
   * @param listener to add
   */
  public void addPropertyChangeListener( PropertyChangeListener listener )
  {
    propertyChangeSupport.addPropertyChangeListener( listener );
  }

  /**
   * Remove PropertyChangeListener.
   *
   * @param listener to remove
   */
  public void removePropertyChangeListener( PropertyChangeListener listener )
  {
    propertyChangeSupport.removePropertyChangeListener( listener );
  }
}

class NewPoJo
{
  public static final String          PROP_ID               = "id";
  public static final String          PROP_TEXT             = "text";
//  public static final String          PROP_DATE             = "date";
  final private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport( this );
  private String                      id                    = null;
  private String                      text                  = null;
//  private Date date                  = null;

  /**
   * Constructs a <code>NewPoJo</code>.
   *
   * @param id_A ID of new <code>NewPoJo</code>
   * @param text_A TEXT of new <code>NewPoJo</code>
   */
  public NewPoJo( String id_A, String text_A )
  {
    this.setId( id_A );
    this.setText( text_A );
//    this.setDate( date_A );
  }

  /**
   * Creates and returns a {@link List} of <code>NewPoJo</code> dummies.
   *
   * @return some <code>NewPoJo</code> dummies
   */
  public static List< NewPoJo > createDummies()
  {
    final List< NewPoJo > aList = new ArrayList< NewPoJo >( 10 );
    final Format aIDFormat = new NumberFormatter( new DecimalFormat( "ID-00000" ) ).getFormat();
    final Format aTextFormat = new NumberFormatter( new DecimalFormat( "Text 00000" ) ).getFormat();

    for ( int i = 0; i < 10; i++ )
    {
      System.err.println( "creating dummy " + i );

      final NewPoJo aNewPoJo = new NewPoJo( aIDFormat.format( i ),
                                            aTextFormat.format( i ) );
      aList.add( aNewPoJo );
    }

    return aList;
  }

  /**
   * Get the value of id
   *
   * @return the value of id
   */
  public String getId()
  {
    return id;
  }

  /**
   * Set the value of id
   *
   * @param newId new value of id
   */
  public void setId( String newId )
  {
    String oldId = this.id;
    this.id = newId;
    propertyChangeSupport.firePropertyChange( PROP_ID, oldId, newId );
  }

  /**
   * Get the value of text
   *
   * @return the value of text
   */
  public String getText()
  {
    return text;
  }

  /**
   * Set the value of text
   *
   * @param newText new value of text
   */
  public void setText( String newText )
  {
    String oldText = this.text;
    this.text = newText;
    propertyChangeSupport.firePropertyChange( PROP_TEXT, oldText, newText );
  }

  /*
   * Get the value of date
   *
   * @return the value of date
   */
/*
  public Date getDate()
  {
    return date;
  }
*/

  /*
   * Set the value of date
   *
   * @param newDate new value of date
   */
/*
  public void setDate( Date newDate )
  {
    Date oldDate = this.date;
    this.date = newDate;
    propertyChangeSupport.firePropertyChange( PROP_DATE, oldDate, newDate );
  }
*/

  @Override
  public String toString()
  {
    return "NewPoJo{" + "id=" + id + ", text=" + text + '}';
  }

  /**
   * Add PropertyChangeListener.
   *
   * @param listener to add
   */
  public void addPropertyChangeListener( PropertyChangeListener listener )
  {
    propertyChangeSupport.addPropertyChangeListener( listener );
  }

  /**
   * Remove PropertyChangeListener.
   *
   * @param listener to remove
   */
  public void removePropertyChangeListener( PropertyChangeListener listener )
  {
    propertyChangeSupport.removePropertyChangeListener( listener );
  }
}

Thanks,
EmptyFrame.png
EmptyFrame.png (23.51 KiB) Viewed 3531 times
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 33834
Joined: Sun Sep 14, 2003 10:49 am

Re: support for JSR 295

Postby Harald.Fischer » Tue May 03, 2011 6:45 am

Hi,

after a lot of trial and error we finally came to the conclusion, that one has to separate the code into three different class files - the GUI class (NewJFrame in our original cast), the model class (NewModel) and the model element class (NewPoJo). Don't know where this comes from - maybe some reflection caveats??

I reckon literally using following three java files in default package (plus one NetBeans form file added for convenience) should work (i.e. the panel should present a table with three columns, and selecting rows should trigger the model to print out some debug messages). Replacing JideTable in NewJFrame by SortableTable should evoke a ClassCastException when selecting rows.

NewJFrame.java (generated code):
Code: Select all
/*
 * Copyright (c) IBIX Informationssysteme GmbH, 2011
 *
 * Created on 27.04.2011
 */

/*
 * NewJFrame.java
 *
 * Created on 27.04.2011, 08:10:21
 */

/**
 *
 * @author fo
 */
public class NewJFrame extends javax.swing.JFrame
{
  /** Creates new form NewJFrame */
  public NewJFrame()
  {
    initComponents();
   
    this.newClass1.populate();
  }


  /** This method is called from within the constructor to
   * initialize the form.
   * WARNING: Do NOT modify this code. The content of this method is
   * always regenerated by the Form Editor.
   */
  @SuppressWarnings( "unchecked" )
  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  private void initComponents() {
    bindingGroup = new org.jdesktop.beansbinding.BindingGroup();

    newClass1 = new NewModel();
    jScrollPane1 = new javax.swing.JScrollPane();
    jideTable1 = new com.jidesoft.grid.JideTable();

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

    jideTable1.setColumnSelectionAllowed(true);

    org.jdesktop.beansbinding.ELProperty eLProperty = org.jdesktop.beansbinding.ELProperty.create("${observableList}");
    org.jdesktop.swingbinding.JTableBinding jTableBinding = org.jdesktop.swingbinding.SwingBindings.createJTableBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, newClass1, eLProperty, jideTable1);
    org.jdesktop.swingbinding.JTableBinding.ColumnBinding columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${id}"));
    columnBinding.setColumnName("ID");
    columnBinding.setColumnClass(String.class);
    columnBinding.setEditable(false);
    columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${text}"));
    columnBinding.setColumnName("Text");
    columnBinding.setColumnClass(String.class);
    columnBinding.setEditable(false);
    columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${date}"));
    columnBinding.setColumnName("Date");
    columnBinding.setColumnClass(java.util.Date.class);
    columnBinding.setEditable(false);
    bindingGroup.addBinding(jTableBinding);
    jTableBinding.bind();org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, newClass1, org.jdesktop.beansbinding.ELProperty.create("${selectedNewPoJo}"), jideTable1, org.jdesktop.beansbinding.BeanProperty.create("selectedElement"));
    bindingGroup.addBinding(binding);

    jScrollPane1.setViewportView(jideTable1);
    jideTable1.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
        .addContainerGap(13, Short.MAX_VALUE)
        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 375, javax.swing.GroupLayout.PREFERRED_SIZE)
        .addContainerGap())
    );
    layout.setVerticalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(layout.createSequentialGroup()
        .addContainerGap()
        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 275, javax.swing.GroupLayout.PREFERRED_SIZE)
        .addContainerGap(13, Short.MAX_VALUE))
    );

    bindingGroup.bind();

    pack();
  }// </editor-fold>//GEN-END:initComponents


  /**
   * @param args the command line arguments
   */
  public static void main( String args[] )
  {
    java.awt.EventQueue.invokeLater( new Runnable()
    {

      public void run()
      {
        new NewJFrame().setVisible( true );
      }
    } );
  }
  // Variables declaration - do not modify//GEN-BEGIN:variables
  private javax.swing.JScrollPane jScrollPane1;
  private com.jidesoft.grid.JideTable jideTable1;
  private NewModel newClass1;
  private org.jdesktop.beansbinding.BindingGroup bindingGroup;
  // End of variables declaration//GEN-END:variables
}


NewModel.java:
Code: Select all
/*
 * Copyright (c) IBIX Informationssysteme GmbH, 2011
 *
 * Created on 27.04.2011
 */

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.util.ArrayList;

import org.jdesktop.observablecollections.ObservableCollections;
import org.jdesktop.observablecollections.ObservableList;

/**
 * A model class.
 *
 * @author fo
 */
public class NewModel
{
  public static final String              PROP_SELECTEDNEWPOJO  = "selectedNewPoJo";

  final private ObservableList< NewPoJo > observableList        = ObservableCollections.observableList( new ArrayList< NewPoJo >() );

  final private PropertyChangeSupport     propertyChangeSupport = new PropertyChangeSupport( this );

  private NewPoJo                         selectedNewPoJo       = null;

  /**
   * Populates this model with dummies.
   */
  public void populate()
  {
    System.err.println( "populating model" );

    this.observableList.addAll( NewPoJo.createDummies() );
  }

  /**
   * Get the value of selectedNewPoJo
   *
   * @return the value of selectedNewPoJo
   */
  public NewPoJo getSelectedNewPoJo()
  {
    System.err.println( "get selectedNewPoJo <" + selectedNewPoJo + ">" );

    return selectedNewPoJo;
  }

  /**
   * Set the value of selectedNewPoJo
   *
   * @param newSelectedNewPoJo new value of selectedNewPoJo
   */
  public void setSelectedNewPoJo( NewPoJo newSelectedNewPoJo )
  {
    System.err.println( "set selectedNewPoJo to <" + newSelectedNewPoJo + ">" );

    NewPoJo oldSelectedNewPoJo = this.selectedNewPoJo;
    this.selectedNewPoJo       = newSelectedNewPoJo;
    propertyChangeSupport.firePropertyChange( PROP_SELECTEDNEWPOJO, oldSelectedNewPoJo, newSelectedNewPoJo );
  }

  /**
   * Get the value of observableList
   *
   * @return the value of observableList
   */
  public ObservableList< NewPoJo > getObservableList()
  {
    return observableList;
  }

  /**
   * Add PropertyChangeListener.
   *
   * @param listener to add
   */
  public void addPropertyChangeListener( PropertyChangeListener listener )
  {
    propertyChangeSupport.addPropertyChangeListener( listener );
  }

  /**
   * Remove PropertyChangeListener.
   *
   * @param listener to remove
   */
  public void removePropertyChangeListener( PropertyChangeListener listener )
  {
    propertyChangeSupport.removePropertyChangeListener( listener );
  }
}


NewPoJo.java:
Code: Select all
/*
 * Copyright (c) IBIX Informationssysteme GmbH, 2011
 *
 * Created on 27.04.2011
 */

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.text.DecimalFormat;
import java.text.Format;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.swing.text.NumberFormatter;


/**
 * A PoJo class of model elements.
 *
 * @author fo
 */
public class NewPoJo
{
  public static final String          PROP_ID               = "id";

  public static final String          PROP_TEXT             = "text";

  public static final String          PROP_DATE             = "date";

  final private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport( this );

  private String                      id                    = null;

  private String                      text                  = null;

  private Date                        date                  = null;

  /**
   * Constructs a <code>NewPoJo</code>.
   *
   * @param id_A ID of new <code>NewPoJo</code>
   * @param text_A TEXT of new <code>NewPoJo</code>
   * @param date_A DATE of new <code>NewPoJo</code>
   */
  public NewPoJo( String id_A, String text_A, Date date_A )
  {
    this.setId( id_A );
    this.setText( text_A );
    this.setDate( date_A );
  }

  /**
   * Creates and returns a {@link List} of <code>NewPoJo</code> dummies.
   *
   * @return some <code>NewPoJo</code> dummies
   */
  public static List< NewPoJo > createDummies()
  {
    final List< NewPoJo > aList       = new ArrayList< NewPoJo >( 10 );
    final Format          aIDFormat   = new NumberFormatter( new DecimalFormat( "ID-00000" ) ).getFormat();
    final Format          aTextFormat = new NumberFormatter( new DecimalFormat( "Text 00000" ) ).getFormat();

    for ( int i = 0; i < 10; i++ )
    {
      System.err.println( "creating dummy " + i );

      final NewPoJo aNewPoJo = new NewPoJo( aIDFormat.format( i ),
                                            aTextFormat.format( i ),
                                            new Date() );
      aList.add( aNewPoJo );
    }

    return aList;
  }

  /**
   * Get the value of id
   *
   * @return the value of id
   */
  public String getId()
  {
    return id;
  }

  /**
   * Set the value of id
   *
   * @param newId new value of id
   */
  public void setId( String newId )
  {
    String oldId = this.id;
    this.id      = newId;
    propertyChangeSupport.firePropertyChange( PROP_ID, oldId, newId );
  }

  /**
   * Get the value of text
   *
   * @return the value of text
   */
  public String getText()
  {
    return text;
  }

  /**
   * Set the value of text
   *
   * @param newText new value of text
   */
  public void setText( String newText )
  {
    String oldText = this.text;
    this.text      = newText;
    propertyChangeSupport.firePropertyChange( PROP_TEXT, oldText, newText );
  }

  /**
   * Get the value of date
   *
   * @return the value of date
   */
  public Date getDate()
  {
    return date;
  }

  /**
   * Set the value of date
   *
   * @param newDate new value of date
   */
  public void setDate( Date newDate )
  {
    Date oldDate = this.date;
    this.date    = newDate;
    propertyChangeSupport.firePropertyChange( PROP_DATE, oldDate, newDate );
  }

  @Override
  public String toString()
  {
    return "NewPoJo{" + "id=" + id + ", text=" + text + ", date=" + date + '}';
  }

  /**
   * Add PropertyChangeListener.
   *
   * @param listener to add
   */
  public void addPropertyChangeListener( PropertyChangeListener listener )
  {
    propertyChangeSupport.addPropertyChangeListener( listener );
  }

  /**
   * Remove PropertyChangeListener.
   *
   * @param listener to remove
   */
  public void removePropertyChangeListener( PropertyChangeListener listener )
  {
    propertyChangeSupport.removePropertyChangeListener( listener );
  }
}


NewJFrame.form:
Code: Select all
<?xml version="1.1" encoding="UTF-8" ?>

<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
  <NonVisualComponents>
    <Component class="NewModel" name="newClass1">
    </Component>
  </NonVisualComponents>
  <Properties>
    <Property name="defaultCloseOperation" type="int" value="3"/>
  </Properties>
  <SyntheticProperties>
    <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
  </SyntheticProperties>
  <AuxValues>
    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
  </AuxValues>

  <Layout>
    <DimensionLayout dim="0">
      <Group type="103" groupAlignment="0" attributes="0">
          <Group type="102" alignment="1" attributes="0">
              <EmptySpace pref="13" max="32767" attributes="0"/>
              <Component id="jScrollPane1" min="-2" pref="375" max="-2" attributes="0"/>
              <EmptySpace max="-2" attributes="0"/>
          </Group>
      </Group>
    </DimensionLayout>
    <DimensionLayout dim="1">
      <Group type="103" groupAlignment="0" attributes="0">
          <Group type="102" alignment="0" attributes="0">
              <EmptySpace max="-2" attributes="0"/>
              <Component id="jScrollPane1" min="-2" pref="275" max="-2" attributes="0"/>
              <EmptySpace pref="13" max="32767" attributes="0"/>
          </Group>
      </Group>
    </DimensionLayout>
  </Layout>
  <SubComponents>
    <Container class="javax.swing.JScrollPane" name="jScrollPane1">
      <AuxValues>
        <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
      </AuxValues>

      <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
      <SubComponents>
        <Component class="com.jidesoft.grid.JideTable" name="jideTable1">
          <Properties>
            <Property name="columnModel" type="javax.swing.table.TableColumnModel" editor="org.netbeans.modules.form.editors2.TableColumnModelEditor">
              <TableColumnModel selectionModel="1">
                <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true">
                  <Title/>
                  <Editor/>
                  <Renderer/>
                </Column>
                <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true">
                  <Title/>
                  <Editor/>
                  <Renderer/>
                </Column>
                <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true">
                  <Title/>
                  <Editor/>
                  <Renderer/>
                </Column>
              </TableColumnModel>
            </Property>
            <Property name="columnSelectionAllowed" type="boolean" value="true"/>
            <Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.editors2.JTableHeaderEditor">
              <TableHeader reorderingAllowed="true" resizingAllowed="true"/>
            </Property>
          </Properties>
          <BindingProperties>
            <BindingProperty name="elements" source="newClass1" sourcePath="${observableList}" target="jideTable1" targetPath="elements" updateStrategy="0" immediately="true">
              <Subbinding sourcePath="${id}">
                <BindingParameter name="NAME" value="ID"/>
                <BindingParameter name="javax.swing.binding.ParameterKeys.COLUMN_CLASS" value="String.class"/>
                <BindingParameter name="javax.swing.binding.ParameterKeys.EDITABLE" value="false"/>
              </Subbinding>
              <Subbinding sourcePath="${text}">
                <BindingParameter name="NAME" value="Text"/>
                <BindingParameter name="javax.swing.binding.ParameterKeys.COLUMN_CLASS" value="String.class"/>
                <BindingParameter name="javax.swing.binding.ParameterKeys.EDITABLE" value="false"/>
              </Subbinding>
              <Subbinding sourcePath="${date}">
                <BindingParameter name="NAME" value="Date"/>
                <BindingParameter name="javax.swing.binding.ParameterKeys.COLUMN_CLASS" value="java.util.Date.class"/>
                <BindingParameter name="javax.swing.binding.ParameterKeys.EDITABLE" value="false"/>
              </Subbinding>
            </BindingProperty>
            <BindingProperty name="selectedElement" source="newClass1" sourcePath="${selectedNewPoJo}" target="jideTable1" targetPath="selectedElement" updateStrategy="0" immediately="false">
              <BindingParameter name="IGNORE_ADJUSTING" value="N"/>
            </BindingProperty>
          </BindingProperties>
        </Component>
      </SubComponents>
    </Container>
  </SubComponents>
</Form>


Hope this helps!
Harald
Harald.Fischer
 
Posts: 6
Joined: Thu Aug 11, 2005 12:38 am

Re: support for JSR 295

Postby JIDE Support » Tue May 03, 2011 10:11 am

Thanks. It is where the issue is. However, I'm so sorry to say that SortableTable might not be able to work with the binding if Netbeans doesn't change their package a little bit.

Sortable has to install a SortableTableModel over the original table model to realize sorting function. However, this action will break JTableAdapterProvider#getElement(JTable, int) because table.getModel() is no longer an instance of NewPoJo. It then returns a hashmap which later throws ClassCastException. I tried to figure out a work around for you however failed. The JTableBinding class is final and its constructor is protected which makes me not possible to create a instance by ourselves to change some logic further.

I also tried to create a pure new ISortableTableModel and let it extending ListBindingManager. This approach also failed because the method ListBindingManager#getElement(int) is again final and the elements field is private. That fact blocks my way to delegate my new created ListBindingManager to their existing BindingTableModel.

You may have to submit the bug report to Netbeans as well to see how they can loose their package a little bit. I guess the easiest solution for them is to introduce an interface like BindingWrapper, which takes "ObjectgetElement(int)" as its method. In this way, we are able to let JIDE SortableTableModel implements that interface and delegate the invocation to the underlying BindingTableModel.

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

Re: support for JSR 295

Postby Harald.Fischer » Wed May 04, 2011 12:18 am

Hi,

thank you for this detailled analysis! And yes, we will forward this to the beansbinding (or actually: BetterBeansBinding) project group. Maybe they will do a little bit refinement in the sense you proposed.

Thank you again for your time and effort!
Harald
Harald.Fischer
 
Posts: 6
Joined: Thu Aug 11, 2005 12:38 am


Return to Product Suggestions

Who is online

Users browsing this forum: No registered users and 1 guest