use of org.pentaho.ui.xul.util.AbstractModelList in project data-access by pentaho.
the class MultitableGuiModel method populateJoinGuiModel.
public void populateJoinGuiModel(Domain domain, MultiTableDatasourceDTO dto, List tables) {
this.selectedTables.clear();
// Populate "selectedTables" from availableTables using logicalRelationships.
AbstractModelList<JoinTableModel> selectedTablesList = new AbstractModelList<JoinTableModel>();
if (dto != null) {
for (String selectedTable : dto.getSelectedTables()) {
this.selectTable(selectedTable, selectedTablesList, tables);
}
this.selectedTables.addAll(selectedTablesList);
// Populates joins.
this.computeJoins(dto);
// Populate fact table.
if (dto.isDoOlap()) {
for (JoinTableModel table : this.selectedTables) {
if (tablesAreEqual(table.getName(), dto.getSchemaModel().getFactTable().getName())) {
this.setFactTable(table);
break;
}
}
}
}
// Populate available tables discarding selected tables.
this.processAvailableTables(tables);
if (domain != null) {
// Existing joinTableModels will not have fields. We can add these from the domain.
this.addFieldsToTables(domain, this.availableTables);
}
}
use of org.pentaho.ui.xul.util.AbstractModelList in project data-access by pentaho.
the class TablesSelectionStep method setBindings.
public void setBindings() {
BindingFactory bf = new GwtBindingFactory(document);
bf.createBinding(this.joinGuiModel.getAvailableTables(), "children", this.availableTables, "elements");
bf.createBinding(this.joinGuiModel.getSelectedTables(), "children", this.selectedTables, "elements");
bf.createBinding(this.joinGuiModel.getSelectedTables(), "children", this.factTables, "elements", new BindingConvertor<AbstractModelList<JoinTableModel>, Collection<JoinTableModel>>() {
@Override
public Collection<JoinTableModel> sourceToTarget(AbstractModelList<JoinTableModel> list) {
List<JoinTableModel> tables = new ArrayList<JoinTableModel>();
tables.addAll(list.asList());
JoinTableModel emptyOption = new JoinTableModel();
emptyOption.setName(MessageHandler.getString("multitable.SELECT_TABLE"));
// Empty option must be always 0.
tables.add(0, emptyOption);
return tables;
}
@Override
public AbstractModelList<JoinTableModel> targetToSource(final Collection<JoinTableModel> list) {
return null;
}
});
bf.createBinding(this.joinGuiModel, "schemas", this.schemas, "elements", new BindingConvertor<List<String>, Collection<String>>() {
@Override
public Collection<String> sourceToTarget(List<String> list) {
List<String> tables = new ArrayList<String>();
tables.addAll(list);
return tables;
}
@Override
public List<String> targetToSource(final Collection<String> list) {
return null;
}
});
bf.createBinding(this.factTables, "selectedIndex", this.joinGuiModel, "factTable", new BindingConvertor<Integer, JoinTableModel>() {
@Override
public JoinTableModel sourceToTarget(final Integer index) {
if (index == -1) {
return null;
}
// Index 0 represents [select table] option.
// To be valid index must not be 0.
checkValidState();
int i = (int) index;
i--;
return i < 0 ? null : joinGuiModel.getSelectedTables().get(i);
}
@Override
public Integer targetToSource(final JoinTableModel value) {
return joinGuiModel.getSelectedTables().indexOf(value);
}
});
// use a binding to handle the visibility state of the schema type radio group
try {
bf.createBinding(joinGuiModel, "doOlap", "factTableVbox", "visible").fireSourceChanged();
} catch (Exception e) {
e.printStackTrace();
mtdatasource.displayErrors(new JoinError(e.getMessage(), e.getMessage()));
}
}
Aggregations