Search in sources :

Example 1 with XulRoot

use of org.pentaho.ui.xul.containers.XulRoot 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();
        }
    }
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) DatabaseConnectionDialog(org.pentaho.ui.database.DatabaseConnectionDialog) XulDomContainer(org.pentaho.ui.xul.XulDomContainer) XulException(org.pentaho.ui.xul.XulException) KettleException(org.pentaho.di.core.exception.KettleException) Shell(org.eclipse.swt.widgets.Shell) XulException(org.pentaho.ui.xul.XulException) XulRoot(org.pentaho.ui.xul.containers.XulRoot) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) XulDialog(org.pentaho.ui.xul.containers.XulDialog) SelectionEvent(org.eclipse.swt.events.SelectionEvent) XulWindow(org.pentaho.ui.xul.containers.XulWindow)

Aggregations

SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 RowLayout (org.eclipse.swt.layout.RowLayout)1 Button (org.eclipse.swt.widgets.Button)1 Label (org.eclipse.swt.widgets.Label)1 Shell (org.eclipse.swt.widgets.Shell)1 KettleException (org.pentaho.di.core.exception.KettleException)1 DatabaseConnectionDialog (org.pentaho.ui.database.DatabaseConnectionDialog)1 XulDomContainer (org.pentaho.ui.xul.XulDomContainer)1 XulException (org.pentaho.ui.xul.XulException)1 XulDialog (org.pentaho.ui.xul.containers.XulDialog)1 XulRoot (org.pentaho.ui.xul.containers.XulRoot)1 XulWindow (org.pentaho.ui.xul.containers.XulWindow)1