Track property selection in property sheet

View: New views
4 Messages — Rating Filter:   Alert me  

Track property selection in property sheet

by Vadeg :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Greetings!



How can I track selection changes in the PropertySheetView? It seems, that table has a package scope.





Re: Track property selection in property sheet

by Tim Boudreau :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Vadeg wrote:
Greetings!
How can I track selection changes in the PropertySheetView? It seems, that table has a package scope.
There is no API for this.  You'd have to fish around in the component hierarchy, find the JTable and listen to its SelectionModel.

Feel free to file an enhancement request w/ your use case if you think this would be a useful enhancement.

-Tim

Track property selection in property sheet

by Vadeg :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Tim Boudreau wrote:
> Vadeg wrote:

>
> >

> > Greetings!

> > How can I track selection changes in the PropertySheetView? It seems, that

> > table has a package scope.

> >

> >
>

> There is no API for this.  You'd have to fish around in the component

> hierarchy, find the JTable and listen to its SelectionModel.

>

> Feel free to file an enhancement request w/ your use case if you think this

> would be a useful enhancement.

>

> -Tim

>

> --

> View this message in context: http://www.nabble.com/Track-property-selection-in-property-sheet-tp24287991p24340135.html

> Sent from the Netbeans RCP/Platform Users (Open API) mailing list archive at Nabble.com.




I've found only ths:

class org.openide.explorer.propertysheet.PropertySheet




Code:
    //Package private for unit tests

    SheetTable table = new SheetTable();

    PSheet psheet = new PSheet();







I've tracked all events from these objects and none of them fires "to the world" that selection was made,





Re: Track property selection in property sheet

by Tim Boudreau :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Vadeg wrote:
Code:
    //Package private for unit tests

    SheetTable table = new SheetTable();

    PSheet psheet = new PSheet();
You would need to do somthing like

JTable findTable (Container startingContainer) {
   if (startingContainer instanceof JTable) {
       return (JTable) startingContainer;
   }
   for (Component c : startingContainer.getChildren() {
         if (c instanceof Container) {
             JTable result = findTable ((Container)c));
             if (result != null) return result;
          }  
   }
}

then listen on the selection model returned by the JTable's getSelectionModel() method.

Bear in mind, this approach is not highly recommended, since there is no official API for tracking selection in the property sheet.  It would be better to have a supported API for it.  At the same time, this should work for the forseeable future.

-Tim