Access to ListView Cells

Will Hoover java.whoover at gmail.com
Fri Aug 31 06:22:38 PDT 2012


Maybe I wasn't clear enough in my description, but I'm not looking to
manipulate any business data, but rather just the visual indicator. I'm also
not looking to perform any actions based upon a selection. I just need to
status indicator to show a visual aide to the user when say another
connected user makes a change. Think of a chat application where you have a
roster of users. As each user in the roster comes online a green indicator
is displayed for them.

 

From: centarforumi at gmail.com [mailto:centarforumi at gmail.com] On Behalf Of
Slavko Scekic
Sent: Friday, August 31, 2012 8:24 AM
To: Will Hoover
Cc: jonathan.giles at oracle.com; openjfx-dev at openjdk.java.net
Subject: Re: Access to ListView Cells

 

Well, I think that ListView's selectionModel property is what you need, if
you want to change the process' state from within the GUI list (i.e. user
selects a row and issues a command). If you want to update process' state
programmatically, you can use ListView's getItems() method.

To my understanding, ListCell is intended only to display, not manipulate
data in this sense. So, if you have more than one possible state (i.e. node
to display), you'd change your StatusIndicator to look something like this:

StatusIndicator extends Parent {
        ...
        public Status getStatus() {
                return status;
        }
        public void setStatus(Status status) {
                if(status.equals(oneOption))
                {
                    this.graphic= oneOptionGraphic;
                }
                else
                {
                   this.praphic= anotherOptionGraphic;
                }
        }
        ...
}
Or something similar, this is just a guess based on your code.

On Fri, Aug 31, 2012 at 1:39 PM, Will Hoover <java.whoover at gmail.com> wrote:

Hi Jonathan,

I have a ListView that contains custom ListCells which have a node that
visually indicates a status of a business process and a label for the
process name. I would like to be able to allow the user to set the status of
an item at any given time. How would I do so without accessing the cell from
myListView?

myListView.setCellFactory(new Callback<ListView<String>, ListCell<String>>()
{
        public ListCell<String> call(ListView<String> list) {
                return new NodeStatusView();
        }
});

NodeStatusView extends ListCell<String> {
        ...
        StatusIndicator statusIndicator;
        ...
        public void updateItem(String item, boolean empty) {
                super.updateItem(item, empty);
                if (!empty && item != null) {
                        setText(item);
                        myStatusNode = new StatusIndicator();
                        setGraphic(this.myStatusNode);
                }
        }
        ...
        public StatusIndicator getStatusIndicator() {
                return statusIndicator;
        }
        ...
}

StatusIndicator extends Parent {
        ...
        public Status getStatus() {
                return status;
        }
        public void setStatus(Status status) {
                this.status = status;
        }
        ...

}

-----Original Message-----
From: Jonathan Giles [mailto:jonathan.giles at oracle.com]
Sent: Thursday, August 30, 2012 4:57 PM
To: Will Hoover
Cc: openjfx-dev at openjdk.java.net
Subject: Re: Access to ListView Cells

There isn't any API to access the cells within a ListView, unless you
provide the cell factory yourself. It would be useful to understand your use
case for wanting to access the cells outside of a cell factory.

-- Jonathan

On 31/08/2012 4:28 a.m., Will Hoover wrote:
> I may be missing something, but there doesn't seem to be a way to
> access cells generated from a ListView?
>
>
>

 



More information about the openjfx-dev mailing list