use of org.pentaho.ui.xul.stereotype.Bindable in project data-access by pentaho.
the class WizardConnectionController method init.
@Bindable
public void init() {
XulServiceCallback<List<IDatabaseType>> callback = new XulServiceCallback<List<IDatabaseType>>() {
public void error(String message, Throwable error) {
error.printStackTrace();
}
public void success(List<IDatabaseType> retVal) {
databaseTypeHelper = new DatabaseTypeHelper(retVal);
}
};
dialectService.getDatabaseTypes(callback);
saveConnectionConfirmationDialog = // $NON-NLS-1$
(XulDialog) document.getElementById("saveConnectionConfirmationDialog");
overwriteConnectionConfirmationDialog = (XulDialog) document.getElementById("overwriteConnectionConfirmationDialog");
renameConnectionConfirmationDialog = (XulDialog) document.getElementById("renameConnectionConfirmationDialog");
// $NON-NLS-1$
errorDialog = (XulDialog) document.getElementById("errorDialog");
// $NON-NLS-1$
errorDetailsDialog = (XulDialog) document.getElementById("errorDetailsDialog");
// $NON-NLS-1$
errorLabel = (XulLabel) document.getElementById("errorLabel");
// $NON-NLS-1$
successDialog = (XulDialog) document.getElementById("successDialog");
// $NON-NLS-1$
successDetailsDialog = (XulDialog) document.getElementById("successDetailsDialog");
// $NON-NLS-1$
successLabel = (XulLabel) document.getElementById("successLabel");
// $NON-NLS-1$
removeConfirmationDialog = (XulDialog) document.getElementById("removeConfirmationDialog");
}
use of org.pentaho.ui.xul.stereotype.Bindable in project data-access by pentaho.
the class WizardConnectionController method overwriteCheck.
@Bindable
public void overwriteCheck() {
if (!saveConnectionConfirmationDialog.isHidden()) {
closeSaveConnectionConfirmationDialog();
}
if (!renameConnectionConfirmationDialog.isHidden()) {
closeRenameConnectionConfirmationDialog();
}
if (datasourceModel.isEditing() && previousConnectionName.equals(currentConnection.getName())) {
// if editing and no name change, proceed.
updateConnection();
} else {
String cacheBuster = String.valueOf(new java.util.Date().getTime());
// either new connection, or editing involved a name change.
RequestBuilder getConnectionBuilder = new RequestBuilder(RequestBuilder.GET, ConnectionController.getServiceURL("get", new String[][] { { "name", currentConnection.getName() }, { "ts", cacheBuster } }));
getConnectionBuilder.setHeader("Content-Type", "application/json");
try {
AutoBean<IDatabaseConnection> bean = createIDatabaseConnectionBean(currentConnection);
getConnectionBuilder.sendRequest(AutoBeanCodex.encode(bean).getPayload(), new RequestCallback() {
public void onResponseReceived(Request request, Response response) {
switch(response.getStatusCode()) {
case Response.SC_OK:
showOverwriteConnectionConfirmationDialog();
break;
case Response.SC_NOT_FOUND:
saveConnection();
break;
default:
// TODO: error message
saveConnection();
}
}
public void onError(Request request, Throwable exception) {
displayErrorMessage(exception);
}
});
} catch (Exception e) {
displayErrorMessage(e);
}
}
}
use of org.pentaho.ui.xul.stereotype.Bindable in project data-access by pentaho.
the class WizardDatasourceController method init.
@Bindable
public void init() {
// $NON-NLS-1$
clearModelWarningDialog = (XulDialog) document.getElementById("clearModelWarningDialog");
// $NON-NLS-1$
csvDataTable = (XulTree) document.getElementById("csvDataTable");
// $NON-NLS-1$
modelDataTable = (XulTree) document.getElementById("modelDataTable");
// $NON-NLS-1$
errorDialog = (XulDialog) document.getElementById("errorDialog");
// $NON-NLS-1$
errorLabel = (XulLabel) document.getElementById("errorLabel");
// $NON-NLS-1$
successDialog = (XulDialog) document.getElementById("successDialog");
// $NON-NLS-1$
successLabel = (XulLabel) document.getElementById("successLabel");
// $NON-NLS-1$
csvDatasourceName = (XulTextbox) document.getElementById("datasourceName");
// $NON-NLS-1$
datasourceDialog = (XulDialog) document.getElementById("datasourceDialog");
// $NON-NLS-1$
okButton = (XulButton) document.getElementById("datasourceDialog_accept");
// $NON-NLS-1$
cancelButton = (XulButton) document.getElementById("datasourceDialog_cancel");
// $NON-NLS-1$
datasourceTabbox = (XulTabbox) document.getElementById("datasourceDialogTabbox");
bf.setBindingType(Binding.Type.ONE_WAY);
// $NON-NLS-1$ //$NON-NLS-2$
bf.createBinding(datasourceModel, "validated", okButton, "!disabled");
bf.setBindingType(Binding.Type.BI_DIRECTIONAL);
final Binding domainBinding = bf.createBinding(datasourceModel.getGuiStateModel(), "datasourceName", csvDatasourceName, // $NON-NLS-1$ //$NON-NLS-2$
"value");
// $NON-NLS-1$ //$NON-NLS-2$
bf.createBinding(datasourceModel, "datasourceName", csvDatasourceName, "value");
BindingConvertor<DatasourceType, Integer> tabIndexConvertor = new BindingConvertor<DatasourceType, Integer>() {
@Override
public Integer sourceToTarget(DatasourceType value) {
Integer returnValue = null;
if (DatasourceType.SQL == value) {
returnValue = 0;
} else if (DatasourceType.CSV == value) {
returnValue = 1;
} else if (DatasourceType.OLAP == value) {
return 2;
} else if (DatasourceType.NONE == value) {
return 0;
}
return returnValue;
}
@Override
public DatasourceType targetToSource(Integer value) {
DatasourceType type = null;
if (value == 0) {
type = DatasourceType.SQL;
} else if (value == 1) {
type = DatasourceType.CSV;
} else if (value == 2) {
type = DatasourceType.OLAP;
}
return type;
}
};
bf.createBinding(datasourceModel, "datasourceType", datasourceTabbox, "selectedIndex", // $NON-NLS-1$ //$NON-NLS-2$
tabIndexConvertor);
okButton.setDisabled(true);
initialize();
try {
// Fires the population of the model listbox. This cascades down to the categories and columns. In essence, this
// call initializes the entire UI.
domainBinding.fireSourceChanged();
} catch (Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
}
use of org.pentaho.ui.xul.stereotype.Bindable in project data-access by pentaho.
the class WizardRelationalDatasourceController method setRelationalConnections.
@Bindable
public void setRelationalConnections(List<IDatabaseConnection> connections) {
List<String> names = new ArrayList<String>();
for (IDatabaseConnection conn : connections) {
names.add(conn.getName());
}
firePropertyChange(connectionNamesListProp, null, names);
}
use of org.pentaho.ui.xul.stereotype.Bindable in project data-access by pentaho.
the class WizardModel method setSelectedDatasource.
@Bindable
public void setSelectedDatasource(IWizardDatasource datasource) {
IWizardDatasource prevSelection = selectedDatasource;
selectedDatasource = datasource;
firePropertyChange("selectedDatasource", prevSelection, selectedDatasource);
}
Aggregations