use of org.pentaho.ui.xul.swt.tags.SwtButton in project pentaho-kettle by pentaho.
the class XulDatabaseExplorerController method init.
public void init() {
SwtButton theAcceptButton = (SwtButton) this.document.getElementById("databaseExplorerDialog_accept");
SwtButton theCancelButton = (SwtButton) this.document.getElementById("databaseExplorerDialog_cancel");
if (this.isJustLook) {
theAcceptButton.setVisible(false);
theCancelButton.setLabel(BaseMessages.getString(getClass(), "DatabaseExplorer.Button.Ok"));
theAcceptButton.setDisabled(false);
} else {
theAcceptButton.setLabel(BaseMessages.getString(getClass(), "DatabaseExplorer.Button.Ok"));
theCancelButton.setLabel(BaseMessages.getString(getClass(), "DatabaseExplorer.Button.Cancel"));
theAcceptButton.setDisabled(true);
}
this.dbExplorerDialog = (SwtDialog) this.document.getElementById("databaseExplorerDialog");
createDatabaseNodes();
if (this.status != UiPostActionStatus.OK) {
// something goes dramatically wrong!
return;
}
this.bf.setDocument(super.document);
this.bf.setBindingType(Type.ONE_WAY);
this.expandCollapseButton = (XulButton) document.getElementById("expandCollapseButton");
this.databaseTree = (XulTree) document.getElementById("databaseTree");
this.databaseTreeBinding = bf.createBinding(this.model, "database", this.databaseTree, "elements");
bf.createBinding(model, "selectedNode", theAcceptButton, "disabled", new BindingConvertor<DatabaseExplorerNode, Boolean>() {
@Override
public Boolean sourceToTarget(DatabaseExplorerNode arg0) {
return (!isJustLook && (arg0 == null || !arg0.isTable()));
}
@Override
public DatabaseExplorerNode targetToSource(Boolean arg0) {
// TODO Auto-generated method stub
return null;
}
});
bf.setBindingType(Binding.Type.BI_DIRECTIONAL);
this.bf.createBinding(this.databaseTree, "selectedItems", this.model, "selectedNode", new BindingConvertor<List<DatabaseExplorerNode>, DatabaseExplorerNode>() {
@Override
public DatabaseExplorerNode sourceToTarget(List<DatabaseExplorerNode> arg0) {
if (arg0 == null || arg0.size() == 0) {
return null;
}
return arg0.get(0);
}
@Override
public List<DatabaseExplorerNode> targetToSource(DatabaseExplorerNode arg0) {
return Collections.singletonList(arg0);
}
});
BindingConvertor<DatabaseExplorerNode, Boolean> isDisabledConvertor = new BindingConvertor<DatabaseExplorerNode, Boolean>() {
public Boolean sourceToTarget(DatabaseExplorerNode value) {
return !(value != null && value.isTable());
}
public DatabaseExplorerNode targetToSource(Boolean value) {
return null;
}
};
bf.setBindingType(Binding.Type.ONE_WAY);
this.bf.createBinding(this.databaseTree, "selectedItem", "buttonMenuPopUp", "disabled", isDisabledConvertor);
this.bf.createBinding(this.databaseTree, "selectedItem", "buttonMenuPopUpImg", "disabled", isDisabledConvertor);
this.bf.createBinding(this.databaseTree, "selectedItem", "action_popup", "disabled", isDisabledConvertor);
fireBindings();
}
Aggregations