У меня есть данные XML для отображения в сетке дерева. Основываясь на примере кода и обучении, я разработал несколько классов и попытался отобразить их в Tree Grid, но на экране ничего не появляется.
Ниже приведен пример данных XML
<configadmin>
<service id="service1">
<property name="minutes" type="STRING" value="120"/>
<property name="seconds" type="STRING" value="60"/>
<property name="hours" type="STRING" value="1"/>
</service>
<service id="service2">
<property name="host" type="STRING" value="localhost"/>
<property name="port" type="STRING" value="8080"/>
</service>
</configadmin>
public class ConfigId {
private String id;
private List<ConfigProperty> configProperty = new ArrayList<>();
public ConfigId(String id) {
this.id = id;
}
/**
* @return the id
*/
public String getId() {
return id;
}
/**
* @param id the id to set
*/
public void setId(String id) {
this.id = id;
}
/**
* @return the configProperty
*/
public List<ConfigProperty> getConfigProperty() {
return configProperty;
}
/**
* @param configProperty the configProperty to set
*/
public void setConfigProperty(List<ConfigProperty> configProperty) {
this.configProperty = configProperty;
}
/**
* @param configProperty the configProperty to add
*/
public void addConfigProperty(ConfigProperty configProperty) {
this.configProperty.add(configProperty);
}
}
public class ConfigProperty{
private String name;
private String type;
private String value;
public ConfigProperty(String name, String type, String value) {
this.name = name;
this.type = type;
this.value = value;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the type
*/
public String getType() {
return type;
}
/**
* @param type the type to set
*/
public void setType(String type) {
this.type = type;
}
/**
* @return the value
*/
public String getValue() {
return value;
}
/**
* @param value the value to set
*/
public void setValue(String value) {
this.value = value;
}
}
UI Code
gridLayout.setSizeUndefined();
gridLayout.setSpacing(true);
Panel panel = new Panel("Configuration Settings");
panel.setWidth("130px");
TreeGrid serviceGrid = new TreeGrid();
List<ConfigId> serviceList = xmlConfigDomParser.getServicesList();
serviceGrid.setItems(serviceList);
gridLayout.addComponent(panel, 0, 0);
gridLayout.addComponent(button, 2, 0);
gridLayout.addComponent(serviceGrid, 0, 2);
Я пытаюсь решить следующий сценарий,
При щелчке идентификатора службы должны отображаться все свойства и редактироваться только значения.
Сначала я не могу отобразить данные в сетке дерева, пожалуйста, сообщите.
Service Id, Name, Type, Value
service1
minutes, STRING, 120
seconds, STRING, 60
hours, STRING, 1
service2
host, STRING, localhost
port, STRING, 8080