use of org.pentaho.ui.xul.containers.XulTree in project data-access by pentaho.
the class StageDataStep method generateDataTypeDisplay_horizontal.
private void generateDataTypeDisplay_horizontal() {
// $NON-NLS-1$
XulTree tree = (XulTree) document.getElementById("csvModelDataTable");
tree.setRows(datasourceModel.getModelInfo().getColumns().length);
bf.setBindingType(Binding.Type.ONE_WAY);
tree.setBindingProvider(new FactoryBasedBindingProvider(bf) {
@Override
public BindingConvertor getConvertor(XulEventSource source, String prop1, XulEventSource target, String prop2) {
if (source instanceof ColumnInfo) {
if (prop1.equals("length") || prop1.equals("precision")) {
// $NON-NLS-1$ //$NON-NLS-2$
return BindingConvertor.integer2String();
} else if (prop1.equals("include") && prop2.equals("value")) {
// this is the binding from the cell to the value of the checkbox
return null;
} else if (prop1.equals("include")) {
// this binding is from the model to the checkbox
return BindingConvertor.boolean2String();
} else if (prop1.equals("availableDataTypes")) {
// $NON-NLS-1$
return new BindingConvertor<List, Vector>() {
@SuppressWarnings("unchecked")
public Vector sourceToTarget(List value) {
return new Vector(value);
}
@SuppressWarnings("unchecked")
public List targetToSource(Vector value) {
return new ArrayList(value);
}
};
} else if (prop1.equals("formatStrings")) {
// $NON-NLS-1$
return new BindingConvertor<List, Vector>() {
@SuppressWarnings("unchecked")
public Vector sourceToTarget(List value) {
return new Vector(value);
}
@SuppressWarnings("unchecked")
public List targetToSource(Vector value) {
return new ArrayList(value);
}
};
} else if (prop1.equals("dataType") && prop2.equals("selectedIndex")) {
// $NON-NLS-1$ //$NON-NLS-2$
return new BindingConvertor<DataType, Integer>() {
@Override
public Integer sourceToTarget(DataType value) {
List<DataType> types = ColumnInfo.getAvailableDataTypes();
for (int i = 0; i < types.size(); i++) {
if (types.get(i).equals(value)) {
return i;
}
}
return 0;
}
@Override
public DataType targetToSource(Integer value) {
return ColumnInfo.getAvailableDataTypes().get(value);
}
};
} else if (prop1.equals("formatStringsDisabled")) {
return null;
} else {
return BindingConvertor.string2String();
}
} else {
return null;
}
}
});
tree.setElements(Arrays.asList(datasourceModel.getModelInfo().getColumns()));
if (datasourceModel.getModelInfo().getColumns().length > 0) {
tree.setSelectedRows(new int[] { 0 });
}
tree.update();
}
Aggregations