use of org.pentaho.ui.xul.XulException in project pentaho-kettle by pentaho.
the class DatabaseDialogHarness method showDialog.
private void showDialog() {
XulDomContainer container = null;
try {
DatabaseConnectionDialog dcDialog = new DatabaseConnectionDialog();
container = dcDialog.getSwtInstance(new Shell(SWT.NONE));
if (database != null) {
container.getEventHandler("dataHandler").setData(database);
}
} catch (XulException e) {
e.printStackTrace();
}
XulRoot root = (XulRoot) container.getDocumentRoot().getRootElement();
if (root instanceof XulDialog) {
((XulDialog) root).show();
}
if (root instanceof XulWindow) {
((XulWindow) root).open();
}
try {
database = (DatabaseMeta) container.getEventHandler("dataHandler").getData();
} catch (Exception e) {
e.printStackTrace();
}
String message = DatabaseDialogHarness.setMessage(database);
Shell shell = new Shell(SWT.DIALOG_TRIM);
shell.setLayout(new RowLayout());
Label label = new Label(shell, SWT.NONE);
label.setText(message);
Button button = new Button(shell, SWT.NONE);
button.setText("Edit Database ...");
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
try {
showDialog();
} catch (Exception e) {
e.printStackTrace();
}
}
});
shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!shell.getDisplay().readAndDispatch()) {
shell.getDisplay().sleep();
}
}
}
use of org.pentaho.ui.xul.XulException in project pentaho-kettle by pentaho.
the class SwingTest method showDialog.
private void showDialog(final Document doc) {
XulDomContainer container = null;
try {
container = new SwingXulLoader().loadXul(DatabaseConnectionDialog.DIALOG_DEFINITION_FILE, Messages.getBundle());
if (database != null) {
container.getEventHandler("dataHandler").setData(database);
}
} catch (Exception e) {
e.printStackTrace();
}
XulDialog dialog = (XulDialog) container.getDocumentRoot().getRootElement();
container.initialize();
dialog.show();
try {
@SuppressWarnings("unused") Object data = container.getEventHandler("dataHandler").getData();
} catch (XulException e) {
System.out.println("Error getting data");
}
}
use of org.pentaho.ui.xul.XulException in project pentaho-kettle by pentaho.
the class SpoonPerspectiveManager method activatePerspective.
/**
* Activates the given instance of the class literal passed in. Activating a perspective first deactivates the current
* perspective removing any overlays its applied to the UI. It then switches the main deck to display the perspective
* UI and applies the optional overlays to the main Spoon XUL container.
*
* @param clazz
* SpoonPerspective class literal
* @throws KettleException
* throws a KettleException if no perspective is found for the given parameter
*/
public void activatePerspective(Class<? extends SpoonPerspective> clazz) throws KettleException {
if (this.forcePerspective) {
// we are currently prevented from switching perspectives
return;
}
SpoonPerspective sp = perspectives.get(clazz);
if (sp == null) {
throw new KettleException("Could not locate perspective by class: " + clazz);
}
PerspectiveManager perspectiveManager = getPerspectiveManagerMap().get(sp);
if (perspectiveManager != null) {
perspectiveManager.initializeIfNeeded();
}
unloadPerspective(activePerspective);
activePerspective = sp;
List<XulOverlay> overlays = sp.getOverlays();
if (overlays != null) {
for (XulOverlay overlay : overlays) {
try {
ResourceBundle res = null;
if (overlay.getResourceBundleUri() != null) {
try {
res = ResourceBundle.getBundle(overlay.getResourceBundleUri());
} catch (MissingResourceException ignored) {
// Ignore errors
}
} else {
try {
res = ResourceBundle.getBundle(overlay.getOverlayUri().replace(".xul", ".properties"));
} catch (MissingResourceException ignored) {
// Ignore errors
}
}
if (res == null) {
res = new XulSpoonResourceBundle(sp.getClass());
}
domContainer.loadOverlay(overlay.getOverlayUri(), res);
} catch (XulException e) {
log.logError("Error activate perspective", e);
}
}
}
List<XulEventHandler> theXulEventHandlers = sp.getEventHandlers();
if (theXulEventHandlers != null) {
for (XulEventHandler handler : theXulEventHandlers) {
domContainer.addEventHandler(handler);
}
}
sp.setActive(true);
if (sp.equals(activePerspective)) {
deck.setSelectedIndex(deck.getChildNodes().indexOf(deck.getElementById("perspective-" + sp.getId())));
getSpoon().enableMenus();
}
}
use of org.pentaho.ui.xul.XulException in project pdi-dataservice-server-plugin by pentaho.
the class ParameterGenerationController method runAutoGenerate.
public void runAutoGenerate() throws XulException {
DataServiceModel dialogModel = model.getDialogModel();
try {
AutoOptimizationService autoOptimizationService = factory.createAutoOptimizationService();
Collection<PushDownOptimizationMeta> found = autoOptimizationService.apply(dialogModel.getDataService());
if (dialogModel.addAll(found)) {
model.updateParameterMap();
}
info(getString(PKG, "ParameterGenerationController.AutoGen.Title"), getString(PKG, "ParameterGenerationController.AutoGen.Message", found.size()));
} catch (Exception e) {
String message = getString(PKG, "ParameterGenerationController.AutoGen.Error");
getLogChannel().logError(message, e);
error(getString(PKG, "ParameterGenerationController.AutoGen.Title"), message);
}
}
use of org.pentaho.ui.xul.XulException in project pdi-dataservice-server-plugin by pentaho.
the class DataServiceRemapNoStepsDialog method open.
void open() throws KettleException {
Document xulDocument;
try {
xulDocument = initXul(parent, new KettleXulLoader(), new SwtXulRunner());
} catch (XulException xulException) {
throw new KettleException("Failed to initialize RemapNoStepsDialog.", xulException);
}
((SwtDialog) xulDocument.getElementById(XUL_DIALOG_ID)).show();
}
Aggregations