facebook

JTable custom converter setup in properties window

  1. MyEclipse Archived
  2.  > 
  3. Matisse/Swing UI Development
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #287549 Reply

    Alastair
    Member

    I am currently evaluating MyEclipse from the perspective of using it for developing simple GUI components using the embedded Matisse designer, and have a particular question relating to data binding in tables.

    We will create a lot of components containing tables which will display information relating to a single type and so the creation and mapping of these tables needs to be as simple and quick as possible.

    To aid clarity, here are two sample classes along with a Converter implementation:

    public abstract class BaseDataObject
    {
        private final Map<String, Object> mapAttributeNamesToValues;
        
        public BaseDataObject()
        {
            //  This map is populated somewhere automatically
            this.mapAttributeNamesToValues = new HashMap<String, Object>();
        }
        
        public Set<String> getAttributeNames()
        {
            final Set<String> attributeNames = Collections.unmodifiableSet( this.mapAttributeNamesToValues.keySet() );
            return attributeNames;
        }
        
        public BaseDataObject getModel()
        {
            return this;
        }
    }
    
    public class SimpleDataObject extends BaseDataObject
    {
        public BaseDataObject()
        {
        }
    }
    
    public class BaseDataObjectToTableColumnModelConverter extends
            Converter<BaseDataObject, TableColumnModel>
    {
        BaseDataObjectToTableColumnModelConverter()
        {
        }
    
        @Override
        public TableColumnModel convertForward(
                BaseDataObject value )
        {
            final TableColumnModel model = new DefaultTableColumnModel();
            for ( final String nthAttribute : value.getAttributeNames() )
            {
                final TableColumn nthColumn = new TableColumn( 100 );
                nthColumn.setHeaderValue( nthAttribute );
                model.addColumn( nthColumn );
            }
            return model;
        }
    
        @Override
        public BaseDataObject convertReverse(
                TableColumnModel value )
        {
            return null;
        }
    }
    

    The plan is to have a converter which will be able to construct a TableColumnModel instance given a BaseDataObject instance and this is working ok, using the sample code shown below.

            org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings
                    .createAutoBinding(
                            org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_ONCE,
                            testDataObject, org.jdesktop.beansbinding.ELProperty
                                    .create("${model}"), jTable1,
                            org.jdesktop.beansbinding.BeanProperty
                                    .create("columnModel"));
            binding.setConverter( new BaseDataObjectToTableColumnModelConverter() );
    

    However, what I am unable to achieve is the setting up of the converter visually in the ‘Advanced’ tab of the properties editor as it always appears to be disabled. Can you tell me why that would be please?

    Also, is there a way of obviating the need for the BaseDataObject.getModel method so that the framework automatically passes the BaseDataObject to the converter?

    Any help would be much appreciated.

    Alastair.

    #287584 Reply

    Loyal Water
    Member

    Alastair,
    I have asked the dev team to look into this issue. I’ll get back to you with an update asap.

    #287744 Reply

    Alastair
    Member

    Hi Nipun,

    Is there any feedback on this yet?

    Thanks,

    Alastair.

    #287771 Reply

    Loyal Water
    Member

    Alastair,
    This seems like a bug that needs to be fixed. The 7.0 release M1 is being tested by the team at the moment so this can’t go in the 7.0 release. This would be addressed in the release after 7.0.

    #298585 Reply

    sijiafin
    Member

    You might also want to try this synchronization tool as an outside tool of reference.

Viewing 5 posts - 1 through 5 (of 5 total)
Reply To: JTable custom converter setup in properties window

You must be logged in to post in the forum log in