use of org.pentaho.ui.xul.util.DialogController.DialogListener in project data-access by pentaho.
the class GwtDatasourceEditorEntryPoint method showEditAnalysisDialog.
public void showEditAnalysisDialog(final DialogListener listener, final IDatasourceInfo datasourceInfo) {
final DialogListener<AnalysisImportDialogModel> importDialoglistener = new DialogListener<AnalysisImportDialogModel>() {
public void onDialogCancel() {
final AnalysisImportDialogController controller = importDialog.getAnalysisImportDialogController();
final FormPanel analysisDataFormPanel = controller.getFormPanel();
controller.removeHiddenPanels();
controller.buildAndSetParameters();
analysisDataFormPanel.removeFromParent();
RootPanel.get().add(analysisDataFormPanel);
}
public void onDialogAccept(final AnalysisImportDialogModel importDialogModel) {
final AnalysisImportDialogController controller = importDialog.getAnalysisImportDialogController();
final FormPanel analysisDataFormPanel = controller.getFormPanel();
controller.removeHiddenPanels();
controller.buildAndSetParameters(true);
analysisDataFormPanel.removeFromParent();
RootPanel.get().add(analysisDataFormPanel);
analysisDataFormPanel.addSubmitCompleteHandler(new SubmitCompleteHandler() {
@Override
public void onSubmitComplete(SubmitCompleteEvent event) {
String results = event.getResults();
String message = controller.convertToNLSMessage(results, controller.getFileName());
if (!SUCCESS_3.equals(results)) {
if (OVERWRITE_8.equals(results) || OVERWRITE__CATALOG_7.equals(results)) {
overwriteFileDialog(analysisDataFormPanel, message, controller);
} else {
listener.onDialogError(message);
}
} else {
analysisDataFormPanel.removeFromParent();
listener.onDialogAccept(null);
}
}
});
analysisDataFormPanel.submit();
}
public void onDialogReady() {
}
public void onDialogError(String errorMessage) {
listener.onDialogError(errorMessage);
}
};
final AsyncConstructorListener<GwtImportDialog> constructorListener = new AsyncConstructorListener<GwtImportDialog>() {
public void asyncConstructorDone(GwtImportDialog dialog) {
dialog.showAnalysisImportDialog(importDialoglistener, datasourceInfo);
}
};
if (importDialog == null) {
importDialog = new GwtImportDialog(constructorListener);
} else {
importDialog.showAnalysisImportDialog(importDialoglistener, datasourceInfo);
}
}
use of org.pentaho.ui.xul.util.DialogController.DialogListener in project data-access by pentaho.
the class GwtDatasourceEditorEntryPoint method showMetadataImportDialog.
public void showMetadataImportDialog(final DialogListener listener) {
final DialogListener<MetadataImportDialogModel> importDialoglistener = new DialogListener<MetadataImportDialogModel>() {
public void onDialogCancel() {
final MetadataImportDialogController controller = importDialog.getMetadataImportDialogController();
final FormPanel analysisDataFormPanel = controller.getFormPanel();
controller.removeHiddenPanels();
controller.buildAndSetParameters();
analysisDataFormPanel.removeFromParent();
RootPanel.get().add(analysisDataFormPanel);
}
public void onDialogAccept(final MetadataImportDialogModel importDialogModel) {
final MetadataImportDialogController controller = importDialog.getMetadataImportDialogController();
final FormPanel metaDataFormPanel = controller.getFormPanel();
controller.removeHiddenPanels();
controller.buildAndSetParameters();
metaDataFormPanel.removeFromParent();
RootPanel.get().add(metaDataFormPanel);
controller.setImportCompleteCallback(new MetadataImportDialogController.ImportCompleteCallback() {
@Override
public void onImportSuccess() {
listener.onDialogAccept(null);
}
@Override
public void onImportCancel() {
listener.onDialogCancel();
}
});
metaDataFormPanel.submit();
}
public void onDialogReady() {
}
@Override
public void onDialogError(String errorMessage) {
listener.onDialogError(errorMessage);
}
};
final AsyncConstructorListener<GwtImportDialog> constructorListener = new AsyncConstructorListener<GwtImportDialog>() {
public void asyncConstructorDone(GwtImportDialog dialog) {
dialog.showMetadataImportDialog(importDialoglistener);
}
};
if (importDialog == null) {
importDialog = new GwtImportDialog(constructorListener);
} else {
importDialog.showMetadataImportDialog(importDialoglistener);
}
}
use of org.pentaho.ui.xul.util.DialogController.DialogListener in project data-access by pentaho.
the class GwtDatasourceEditorEntryPoint method showWizard.
/**
* Entry-point from Javascript, responds to provided callback with the following:
* <p>
* onOk(String JSON, String mqlString);
* onCancel();
* onError(String errorMessage);
*
* @param callback
*/
private void showWizard(final boolean reportingOnlyValid, final JavaScriptObject callback) {
final DialogListener<Domain> listener = new DialogListener<Domain>() {
public void onDialogCancel() {
wizard.removeDialogListener(this);
if (callback != null) {
notifyCallbackCancel(callback);
}
}
public void onDialogAccept(final Domain domain) {
MessageHandler.getInstance().closeWaitingDialog();
wizard.removeDialogListener(this);
WAQRTransport transport = WAQRTransport.createFromMetadata(domain);
notifyCallbackSuccess(callback, true, transport);
notifyDialogCallbackSuccess(callback, domain.getId());
}
public void onDialogReady() {
if (callback != null) {
notifyCallbackReady(callback);
}
}
@Override
public void onDialogError(String errorMessage) {
notifyCallbackError(callback, errorMessage);
}
};
showWizard(reportingOnlyValid, listener);
}
use of org.pentaho.ui.xul.util.DialogController.DialogListener in project data-access by pentaho.
the class ConnectionController method updateConnection.
@Bindable
public void updateConnection() {
RequestBuilder updateConnectionBuilder = new RequestBuilder(RequestBuilder.POST, ConnectionController.getServiceURL("update"));
updateConnectionBuilder.setHeader("Content-Type", "application/json");
try {
AutoBean<IDatabaseConnection> bean = createIDatabaseConnectionBean(currentConnection);
updateConnectionBuilder.sendRequest(AutoBeanCodex.encode(bean).getPayload(), new RequestCallback() {
@Override
public void onError(Request request, Throwable exception) {
displayErrorMessage(exception);
}
@Override
public void onResponseReceived(Request request, Response response) {
try {
if (response.getStatusCode() == Response.SC_OK) {
datasourceModel.getGuiStateModel().updateConnection(existingConnectionName, currentConnection);
datasourceModel.setSelectedRelationalConnection(currentConnection);
DialogListener dialogListener = connectionSetter.getOuterListener();
if (dialogListener != null) {
dialogListener.onDialogAccept(currentConnection);
}
} else {
openErrorDialog(MessageHandler.getString("ERROR"), // $NON-NLS-1$
MessageHandler.getString(// $NON-NLS-1$
"ConnectionController.ERROR_0004_UNABLE_TO_UPDATE_CONNECTION"));
}
} catch (Exception e) {
displayErrorMessage(e);
}
}
});
} catch (RequestException e) {
displayErrorMessage(e);
}
}
Aggregations