use of org.pentaho.ui.xul.XulException in project pdi-dataservice-server-plugin by pentaho.
the class DataServiceRemapStepChooserDialogTest method testOpen.
@Test
public void testOpen() throws XulException, KettleException {
Shell shell = mock(Shell.class);
final Document document = mock(Document.class);
SwtDialog swtDialog = mock(SwtDialog.class);
when(document.getElementById(DataServiceRemapStepChooserDialog.XUL_DIALOG_ID)).thenReturn(swtDialog);
DataServiceRemapStepChooserDialogController controller = mock(DataServiceRemapStepChooserDialogController.class);
DataServiceRemapStepChooserDialog dialog = spy(new DataServiceRemapStepChooserDialog(shell, controller));
doAnswer(new Answer() {
private int invocations = 0;
@Override
public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
if (invocations == 0) {
invocations++;
return document;
} else {
throw new XulException("");
}
}
}).when(dialog).initXul(same(shell), any(XulLoader.class), any(XulRunner.class));
dialog.open();
verify(dialog).initXul(same(shell), any(XulLoader.class), any(XulRunner.class));
verify(swtDialog).show();
try {
dialog.open();
} catch (Exception e) {
Assert.assertTrue(e instanceof KettleException);
}
}
use of org.pentaho.ui.xul.XulException in project data-access by pentaho.
the class GwtDatasourceEditorEntryPoint method overwriteFileDialog.
/**
* used to handle the overwrite in repository message
*
* @param parentFormPanel
* @param message
* @param controller
*/
public void overwriteFileDialog(final FormPanel parentFormPanel, String message, final IOverwritableController controller) {
// Experiment
XulConfirmBox confirm = null;
try {
confirm = (XulConfirmBox) wizard.getMainWizardContainer().getDocumentRoot().createElement("confirmbox");
} catch (XulException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
confirm.setTitle("Confirmation");
confirm.setMessage(message);
confirm.setAcceptLabel("Ok");
confirm.setCancelLabel("Cancel");
confirm.addDialogCallback(new XulDialogCallback<String>() {
public void onClose(XulComponent component, Status status, String value) {
if (status == XulDialogCallback.Status.ACCEPT) {
controller.setOverwrite(true);
controller.removeHiddenPanels();
controller.buildAndSetParameters();
parentFormPanel.submit();
}
}
public void onError(XulComponent component, Throwable err) {
return;
}
});
confirm.open();
}
use of org.pentaho.ui.xul.XulException in project data-access by pentaho.
the class AnalysisImportDialogController method overwriteFileDialog.
@Bindable
public void overwriteFileDialog(int code) {
if (code != PUBLISH_SCHEMA_CATALOG_EXISTS_ERROR && code != PUBLISH_SCHEMA_EXISTS_ERROR) {
return;
}
String msg = messages.getString("Mondrian.OVERWRITE_EXISTING_SCHEMA");
if (PUBLISH_SCHEMA_CATALOG_EXISTS_ERROR == code) {
msg = messages.getString("Mondrian.OVERWRITE_EXISTING_CATALOG");
}
XulConfirmBox confirm = null;
try {
confirm = (XulConfirmBox) document.createElement("confirmbox");
} catch (XulException e) {
Window.alert(e.getMessage());
}
confirm.setTitle("Confirmation");
confirm.setMessage(msg);
confirm.setAcceptLabel("Ok");
confirm.setCancelLabel("Cancel");
confirm.addDialogCallback(new XulDialogCallback<String>() {
public void onClose(XulComponent component, Status status, String value) {
if (status == XulDialogCallback.Status.ACCEPT) {
overwrite = true;
removeHiddenPanels();
buildAndSetParameters();
formPanel.submit();
}
}
public void onError(XulComponent component, Throwable err) {
return;
}
});
confirm.open();
}
use of org.pentaho.ui.xul.XulException in project data-access by pentaho.
the class DatasourceAdminDialogController method getDatasourceTypes.
private void getDatasourceTypes() {
List<String> datasourceTypes = manager.getTypes();
// Clear out the current component list
List<XulComponent> components = datasourceTypeMenuPopup.getChildNodes();
// remove exist import and plugins
for (int i = 0; i < components.size(); i++) {
XulComponent component = components.get(i);
if (component.getId() == null) {
continue;
}
if (component.getId().startsWith("import") || component.getId().startsWith("plugin")) {
// remove import and plugins items
datasourceTypeMenuPopup.removeComponent(component);
}
}
// find separator
components = datasourceTypeMenuPopup.getChildNodes();
int beforePlugins = 0;
XulComponent beforePluginsMenuItem = null;
for (int i = 0; i < components.size(); i++) {
XulComponent component = components.get(i);
if ("beforePlugins".equals(component.getId())) {
beforePlugins = i;
beforePluginsMenuItem = component;
}
}
List<IDatasourceInfo> datasourceInfoList = datasourceAdminDialogModel.getDatasourcesList();
// Add "Import..." items first
for (String datasourceType : datasourceTypes) {
IUIDatasourceAdminService datasourceAdminService = manager.getService(datasourceType);
if (datasourceAdminService instanceof DSWUIDatasourceService) {
// Data Source Wizard
continue;
}
if (datasourceAdminService instanceof JdbcDatasourceService) {
// JDBC
continue;
}
if (// Analysis - import
!(datasourceAdminService instanceof MondrianUIDatasourceService) && !(datasourceAdminService instanceof MetadataUIDatasourceService)) {
// Metadata - import
continue;
}
if (!datasourceAdminService.isCreatable()) {
continue;
}
XulMenuitem menuItem;
try {
String displayName = DatasourceInfo.getDisplayType(datasourceType, messageBundle);
String label = messageBundle.getString(IMPORT_MSG_ID, displayName);
menuItem = (XulMenuitem) document.createElement("menuitem");
menuItem.setLabel(label);
menuItem.setCommand(getName() + ".launchNewUI(\"" + datasourceType + "\")");
menuItem.setId("import" + datasourceType);
datasourceTypeMenuPopup.addChildAt(menuItem, beforePlugins++);
} catch (XulException e) {
throw new RuntimeException(e);
}
}
// Add plugin items
boolean hasPlugins = false;
beforePlugins++;
for (String datasourceType : datasourceTypes) {
IUIDatasourceAdminService datasourceAdminService = manager.getService(datasourceType);
if (datasourceAdminService instanceof DSWUIDatasourceService) {
// Data Source Wizard
continue;
}
if (datasourceAdminService instanceof JdbcDatasourceService) {
// JDBC
continue;
}
if (datasourceAdminService instanceof MondrianUIDatasourceService) {
// Analysis - import
continue;
} else if (datasourceAdminService instanceof MetadataUIDatasourceService) {
// Metadata - import
continue;
}
if (!datasourceAdminService.isCreatable()) {
continue;
}
hasPlugins = true;
XulMenuitem menuItem;
try {
String displayName = DatasourceInfo.getDisplayType(datasourceType, messageBundle);
String label = messageBundle.getString(PLUGIN_MSG_ID, displayName);
menuItem = (XulMenuitem) document.createElement("menuitem");
menuItem.setLabel(label);
menuItem.setCommand(getName() + ".launchNewUI(\"" + datasourceType + "\")");
menuItem.setId("plugin" + datasourceType);
datasourceTypeMenuPopup.addChildAt(menuItem, beforePlugins++);
} catch (XulException e) {
throw new RuntimeException(e);
}
}
beforePluginsMenuItem.setVisible(hasPlugins);
datasourceAdminDialogModel.setDatasourceTypeList(datasourceTypes);
}
use of org.pentaho.ui.xul.XulException in project data-access by pentaho.
the class MainWizardController method init.
public void init() {
// We need the SelectDatasourceStep at all times, add it now
wizardDialog = (XulDialog) document.getElementById("main_wizard_window");
summaryDialog = (XulDialog) document.getElementById("summaryDialog");
finishButton = (XulButton) document.getElementById(FINISH_BTN_ELEMENT_ID);
// $NON-NLS-1$
datasourceName = (XulTextbox) document.getElementById("datasourceName");
bf.createBinding(datasourceName, "value", wizardModel, "datasourceName");
wizardModel.addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent propertyChangeEvent) {
if (propertyChangeEvent.getPropertyName().equals("datasourceName")) {
steps.get(activeStep).setValid(steps.get(activeStep).isValid());
}
}
});
bf.setBindingType(Binding.Type.ONE_WAY);
datatypeMenuList = (XulMenuList) document.getElementById("datatypeMenuList");
Binding datasourceBinding = bf.createBinding(wizardModel, "datasources", datatypeMenuList, "elements");
bf.setBindingType(Binding.Type.ONE_WAY);
bf.createBinding(datatypeMenuList, "selectedItem", wizardModel, "selectedDatasource");
bf.setBindingType(Binding.Type.ONE_WAY);
bf.createBinding(wizardModel, "selectedDatasource", this, "selectedDatasource");
bf.createBinding(this, ACTIVE_STEP_PROPERTY_NAME, BACK_BTN_ELEMENT_ID, DISABLED_PROPERTY_NAME, new BackButtonBindingConverter());
dummyDatasource = ((DummyDatasource) wizardModel.getDatasources().iterator().next());
activeDatasource = dummyDatasource;
selectDatasourceStep = dummyDatasource.getSelectDatasourceStep();
try {
for (IWizardDatasource datasource : wizardModel.getDatasources()) {
datasource.init(getXulDomContainer(), wizardModel);
}
steps.add(selectDatasourceStep);
selectDatasourceStep.activating();
setActiveStep(0);
datasourceBinding.fireSourceChanged();
setSelectedDatasource(dummyDatasource);
datasourceService.getDatasourceIllegalCharacters(new XulServiceCallback<String>() {
@Override
public void success(String retVal) {
}
@Override
public void error(String message, Throwable error) {
}
});
} catch (XulException e) {
MessageHandler.getInstance().showErrorDialog("Error", e.getMessage());
e.printStackTrace();
} catch (InvocationTargetException e) {
MessageHandler.getInstance().showErrorDialog("Error", e.getMessage());
e.printStackTrace();
}
}
Aggregations