[Review request] Adding pre-built cells and cell factories to JavaFX
Daniel Fuchs
daniel.fuchs at oracle.com
Thu May 10 01:44:09 PDT 2012
On 5/9/12 2:11 AM, openjfx-dev-request at openjdk.java.net wrote:
>> From: Richard Bair<richard.bair at oracle.com>
> Subject: Re: [Review request] Adding pre-built cells and cell
> factories to JavaFX
> To: jonathan.giles at oracle.com
> Cc: "openjfx-dev at openjdk.java.net"<openjfx-dev at openjdk.java.net>
> Message-ID:<EFDE319D-8C84-4E38-92CC-939A180CBA7D at oracle.com>
> Content-Type: text/plain; charset=iso-8859-1
>
> Jonathan, I was just thinking (I know we talked about this before some time back but I don't remember the reasoning), why do we have the ***Factory classes? Why not just move those factory methods onto the appropriate Cells? So it would be:
>
> listView.setCellFactory(TextFieldCell.cellFactory(...));
>
> Just thinking four fewer classes, and associating the factory methods with the class itself. What do you think?
>
> Richard
Hi Richard,
Sorry for jumping in this late - I've been away for a few days.
If you hide the ***Factory classes - then it means that you won't
be able to set cellFactory implementations from within
FXML - doesn't it?
You won't be able to write things like:
<TableColumn>
<cellFactory>
<CheckBoxTableCellFactory .../>
</cellFactory>
</TableColumn>
This may be OK - because I see that the
CheckBoxTableCell.forTableColumn(...) method requires a Callback and
an ObservableProperty as parameter - which you would have trouble to
serialize as FXML beans anyway...
Which in turn implies that configuring these factories is a thing
you would more easily do from within the controller's code...
So this seems like something that would not impact FXML or tools
like SceneBuilder, unless I missed something?
On the other hand - you could still be able to configure factories from
within FXML if there was static noop method that could return a factory.
Then you would be able to write:
<TableColumn>
<cellFactory>
<CheckBoxTableCell fx:factory="forTableColumn" .../>
</cellFactory>
</TableColumn>
but this requires the forTableColumn method to take no arguments.
The question is whether the properties required to configure the
factory instance can all be expressed in FXML as, it does not bring
you much to be able to set a factory from within FXML if you
still need to configure its properties from the controller's code.
Cheers,
-- daniel
>
> On May 8, 2012, at 3:29 PM, Richard Bair wrote:
>
>> I've been over this a few times with Jonathan and I think the API is really quite nice. I would especially like to hear any feedback from folks using FXML, from SceneBuilder, and from anybody who gives it a try. The API is essentially what Jonathan had done in DataFX and has had a significant amount of usage already so we're pretty confident that it is friendly to use :-).
>>
>> Thanks
>> Richard
>>
>> On May 8, 2012, at 3:14 PM, Jonathan Giles wrote:
>>
>>> Hi all,
>>>
>>> http://javafx-jira.kenai.com/browse/RT-19452
>>>
>>> This jira feature request asks for JavaFX to include a number of pre-built cell factories for use in ListView, TreeView and TableView. This was always intended functionality, it just took some time to get around to adding it. These cell factories are intended to support functionality such as editing by TextField, ChoiceBox, ComboBox, and CheckBox, easily converting objects into strings, and values into progress bars.
>>>
>>> I intend to move com.sun.javafx.scene.control.CheckBoxTreeItem into javafx.scene.control.
>>>
>>> The classes below I intend to move to javafx.scene.control.cell:
>>> com.sun.javafx.scene.control.cell.CheckBoxCellFactory
>>> com.sun.javafx.scene.control.cell.CheckBoxListCell
>>> com.sun.javafx.scene.control.cell.CheckBoxTableCell
>>> com.sun.javafx.scene.control.cell.CheckBoxTreeCell
>>> com.sun.javafx.scene.control.cell.ChoiceBoxCellFactory
>>> com.sun.javafx.scene.control.cell.ChoiceBoxListCell
>>> com.sun.javafx.scene.control.cell.ChoiceBoxTableCell
>>> com.sun.javafx.scene.control.cell.ChoiceBoxTreeCell
>>> com.sun.javafx.scene.control.cell.ComboBoxCellFactory
>>> com.sun.javafx.scene.control.cell.ComboBoxListCell
>>> com.sun.javafx.scene.control.cell.ComboBoxTableCell
>>> com.sun.javafx.scene.control.cell.ComboBoxTreeCell
>>> com.sun.javafx.scene.control.cell.ProgressBarCellFactory
>>> com.sun.javafx.scene.control.cell.ProgressBarTableCell
>>> com.sun.javafx.scene.control.cell.TextFieldCellFactory
>>> com.sun.javafx.scene.control.cell.TextFieldListCell
>>> com.sun.javafx.scene.control.cell.TextFieldTableCell
>>> com.sun.javafx.scene.control.cell.TextFieldTreeCell
>>>
>>> In addition to these classes, I am also introducing other, related classes, including:
>>> javafx.util.converter.FormatStringConverter
>>> com.sun.javafx.scene.control.cell.MapValueFactory (which will move to javafx.scene.control.cell to work alongside the PropertyValueFactory)
>>>
>>> To support the CheckBox inside a TreeView case, I'm including the CheckBoxTreeItem class that can ensure that parent and children tree items are updated when a tree item is selected or deselected.
>>>
>>> I have included considerable javadoc documentation already, but I intend to add more soon to include a number of worked examples on how to use this new API.
>>>
>>> I look forward to your feedback.
>>>
>>> -- Jonathan
More information about the openjfx-dev
mailing list