JavaFX Binding with WorkItem
I am working on a tool using the Integrity Java API. I am using JavaFX for the UI. I have a TableView and right now, to bind an ObservableList, I am converting a WorkItem to a different object type that I have cleverly named WorkItem2. What I am doing is in the below code snippet (the real class uses more fields). This allows me to use an ObservableList<WorkItem2> and then use normal data binding with JavaFX.
My question is, is there a way to do data binding with WorkItems directly? I would like to avoid having to create properties for every field if possible.
public class WorkItem2 {
private SimpleStringProperty id;
private SimpleStringProperty project;
private SimpleStringProperty summary;
public WorkItem2(WorkItem source) {
id = new SimpleStringProperty(source.getId());
Iterator fields = source.getFields();
while (fields.hasNext()) {
Field field = (Field) fields.next();
String name = field.getName();
switch (name) {
case "Project":
project = new SimpleStringProperty(field.getValueAsString());
break;
case "Summary":
summary = new SimpleStringProperty(field.getValueAsString());
break;
default:
break;
}
}
}
public String getID() {
return id.get();
}
public void setID(String s) {
id.set(s);
}
public String getProject() {
return project.get();
}
public void setProject(String s) {
project.set(s);
}
public String getSummary() {
return summary.get();
}
public void setSummary(String s) {
summary.set(s);
}
}

