Search in sources :

Example 1 with XulException

use of org.pentaho.ui.xul.XulException in project pentaho-kettle by pentaho.

the class AuthProviderController method browse.

public void browse() {
    try {
        XulTextbox filename = (XulTextbox) document.getElementById("keytab");
        XulFileDialog dialog = (XulFileDialog) document.createElement("filedialog");
        XulFileDialog.RETURN_CODE retval = dialog.showOpenDialog();
        if (retval == XulFileDialog.RETURN_CODE.OK) {
            File file = (File) dialog.getFile();
            filename.setValue(file.getAbsolutePath());
        }
    } catch (XulException e) {
        log.logError(resourceBundle.getString("error.file_browse"), e);
    }
}
Also used : XulException(org.pentaho.ui.xul.XulException) XulTextbox(org.pentaho.ui.xul.components.XulTextbox) XulFileDialog(org.pentaho.ui.xul.components.XulFileDialog) File(java.io.File)

Example 2 with XulException

use of org.pentaho.ui.xul.XulException in project pentaho-kettle by pentaho.

the class AuthProviderController method bind.

private void bind() {
    try {
        this.bf.setBindingType(Binding.Type.ONE_WAY);
        // Loads the authorization types into the "Method" combobox
        bf.createBinding(this, "possibleTypes", "method_list", "elements").fireSourceChanged();
        // Manage enabling/disabling layout based on item availability in the main authProvider list.
        bf.createBinding(model.getModelObjects(), "children", "remove_button", "disabled", itemCountBinding).fireSourceChanged();
        bf.createBinding(model.getModelObjects(), "children", "name", "disabled", itemCountBinding).fireSourceChanged();
        bf.createBinding(model.getModelObjects(), "children", "method_list", "disabled", itemCountBinding).fireSourceChanged();
        // Manage enabling/disabling layout based on selection in the main authProvider list.
        bf.createBinding("auth_list", "selectedItem", "name", "!disabled", BindingConvertor.object2Boolean()).fireSourceChanged();
        bf.createBinding("auth_list", "selectedItem", "method_list", "!disabled", BindingConvertor.object2Boolean()).fireSourceChanged();
        bf.createBinding("auth_list", "selectedItem", "remove_button", "!disabled", BindingConvertor.object2Boolean()).fireSourceChanged();
        bf.setBindingType(Binding.Type.BI_DIRECTIONAL);
        // When an authorization entry is selected, select entry in model
        bf.createBinding("auth_list", "selectedItem", this.model, "selectedItem");
        // Syncs elements in the model and lists them in the authorization entry list
        Binding listBinding = this.bf.createBinding(this.model.getModelObjects(), "children", "auth_list", "elements");
        listBinding.fireSourceChanged();
        // Update the entry name textbox when a new entry is selected in the authorization entry list
        bf.createBinding(this.model, "selectedItem", "name", "value", selectedItemsNameBinding).fireSourceChanged();
        // Change the overlay when the user changes the "Method" in the method combobox
        bf.createBinding(this, "newOverlay", "method_list", "selectedItem").fireSourceChanged();
        // Update the method combobox with the appropriate selection for the selected authorization entry
        bf.createBinding(this.model, "selectedItem", "method_list", "selectedItem", selectedItemsItemBinding).fireSourceChanged();
        // Because the programmatic selection of the item in the combobox does not fire events, we need
        // to bind the main authProvider selection to the changing of the overlay
        bf.createBinding(this.model, "selectedItem", this, "newOverlay", selectedItemsItemBinding);
    } catch (XulException e) {
        log.logError(resourceBundle.getString("error.on_bind"), e);
    } catch (InvocationTargetException e) {
        log.logError(resourceBundle.getString("error.on_execution"), e);
    }
}
Also used : Binding(org.pentaho.ui.xul.binding.Binding) XulException(org.pentaho.ui.xul.XulException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 3 with XulException

use of org.pentaho.ui.xul.XulException in project pentaho-kettle by pentaho.

the class XulDatabaseDialog method createDialog.

@SuppressWarnings("deprecation")
private void createDialog() {
    XulDomContainer container = null;
    try {
        databaseDialogInstance = new DatabaseConnectionDialog();
        if (((Shell) this.parentShell).getText().contains("Metadata Editor")) {
            databaseDialogInstance.registerClass(EXTENDED_WIDGET_ID, PMD_WIDGET_CLASSNAME);
        } else {
            databaseDialogInstance.registerClass(EXTENDED_WIDGET_ID, EXTENDED_WIDGET_CLASSNAME);
        }
        /*
       * Attention: onload: loadConnectionData() is called here the first time, see below for second time
       */
        container = databaseDialogInstance.getSwtInstance(new KettleXulLoader(), parentShell);
        container.addEventHandler(EVENT_ID, DataOverrideHandler.class.getName());
        dataHandler = (DataOverrideHandler) container.getEventHandler(EVENT_ID);
        if (databaseMeta != null) {
            dataHandler.setData(databaseMeta);
        }
        dataHandler.setDatabases(databases);
        dataHandler.getControls();
    } catch (XulException e) {
        new ErrorDialog(parentShell, BaseMessages.getString(PKG, "XulDatabaseDialog.Error.Title"), BaseMessages.getString(PKG, "XulDatabaseDialog.Error.HandleXul"), e);
        return;
    }
    try {
        // Inject the button panel that contains the "Feature List" and "Explore" buttons
        XulComponent boxElement = container.getDocumentRoot().getElementById(FRAGMENT_ID);
        XulComponent parentElement = boxElement.getParent();
        ResourceBundle res = null;
        Locale primaryLocale = GlobalMessages.getLocale();
        Locale failOverLocale = LanguageChoice.getInstance().getFailoverLocale();
        try {
            res = GlobalMessages.getBundle(primaryLocale, MESSAGES);
        } catch (MissingResourceException e) {
            try {
                res = GlobalMessages.getBundle(failOverLocale, MESSAGES);
            } catch (MissingResourceException e2) {
                res = null;
                log.logError(BaseMessages.getString(PKG, "XulDatabaseDialog.Error.ResourcesNotFound.Title"), BaseMessages.getString(PKG, "XulDatabaseDialog.Error.ResourcesNotFound", primaryLocale == null ? "" : primaryLocale.toString(), failOverLocale == null ? "" : failOverLocale.toString()), e2);
            }
        }
        XulDomContainer fragmentContainer = null;
        String pkg = getClass().getPackage().getName().replace('.', '/');
        // to check for it here.
        if (res != null) {
            fragmentContainer = container.loadFragment(pkg.concat(DIALOG_FRAGMENT_FILE), res);
        } else {
            fragmentContainer = container.loadFragment(pkg.concat(DIALOG_FRAGMENT_FILE));
        }
        XulComponent newBox = fragmentContainer.getDocumentRoot().getFirstChild();
        parentElement.replaceChild(boxElement, newBox);
    } catch (Exception e) {
        new ErrorDialog(parentShell, BaseMessages.getString(PKG, "XulDatabaseDialog.Error.Title"), BaseMessages.getString(PKG, "XulDatabaseDialog.Error.HandleXul"), e);
        return;
    }
    try {
        xulDialogComponent = (XulDialog) container.getDocumentRoot().getRootElement();
        parentShell.addDisposeListener(new DisposeListener() {

            public void widgetDisposed(DisposeEvent arg0) {
                xulDialogComponent.hide();
            }
        });
    } catch (Exception e) {
        new ErrorDialog(parentShell, BaseMessages.getString(PKG, "XulDatabaseDialog.Error.Title"), BaseMessages.getString(PKG, "XulDatabaseDialog.Error.Dialog"), e);
        return;
    }
}
Also used : Locale(java.util.Locale) DisposeListener(org.eclipse.swt.events.DisposeListener) MissingResourceException(java.util.MissingResourceException) KettleXulLoader(org.pentaho.di.ui.xul.KettleXulLoader) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) DatabaseConnectionDialog(org.pentaho.ui.database.DatabaseConnectionDialog) XulDomContainer(org.pentaho.ui.xul.XulDomContainer) DisposeEvent(org.eclipse.swt.events.DisposeEvent) XulException(org.pentaho.ui.xul.XulException) MissingResourceException(java.util.MissingResourceException) XulException(org.pentaho.ui.xul.XulException) ResourceBundle(java.util.ResourceBundle) XulComponent(org.pentaho.ui.xul.XulComponent)

Example 4 with XulException

use of org.pentaho.ui.xul.XulException in project pentaho-kettle by pentaho.

the class XulDatabaseExplorerController method displayRowCount.

public void displayRowCount() {
    if (this.model.getTable() == null) {
        return;
    }
    try {
        GetTableSizeProgressDialog pd = new GetTableSizeProgressDialog(this.dbExplorerDialog.getShell(), this.model.getDatabaseMeta(), this.model.getTable(), model.getSchema());
        Long theCount = pd.open();
        if (theCount != null) {
            XulMessageBox theMessageBox = (XulMessageBox) document.createElement("messagebox");
            theMessageBox.setModalParent(this.dbExplorerDialog.getShell());
            theMessageBox.setTitle(BaseMessages.getString(PKG, "DatabaseExplorerDialog.TableSize.Title"));
            theMessageBox.setMessage(BaseMessages.getString(PKG, "DatabaseExplorerDialog.TableSize.Message", this.model.getTable(), theCount.toString()));
            theMessageBox.open();
        }
    } catch (XulException e) {
        LogChannel.GENERAL.logError("Error displaying row count", e);
    }
}
Also used : XulMessageBox(org.pentaho.ui.xul.components.XulMessageBox) XulException(org.pentaho.ui.xul.XulException)

Example 5 with XulException

use of org.pentaho.ui.xul.XulException in project pentaho-kettle by pentaho.

the class FragmentHandler method refreshOptions.

/**
 * This method handles the resource-like loading of the XUL fragment definitions based on connection type and access
 * method. If there is a common definition, and no connection specific override definition, then the common definition
 * is used. Connection specific definition resources follow the naming pattern [connection type code]_[access
 * method].xul.
 */
public void refreshOptions() {
    connectionBox = (XulListbox) document.getElementById("connection-type-list");
    accessBox = (XulListbox) document.getElementById("access-type-list");
    Object connectionKey = DataHandler.connectionNametoID.get(connectionBox.getSelectedItem());
    String databaseName = null;
    try {
        databaseName = PluginRegistry.getInstance().getPlugin(DatabasePluginType.class, "" + connectionKey).getIds()[0];
    } catch (Exception e) {
        e.printStackTrace();
    }
    DatabaseInterface database = DataHandler.connectionMap.get(connectionBox.getSelectedItem());
    Object accessKey = accessBox.getSelectedItem();
    int access = DatabaseMeta.getAccessType((String) accessKey);
    String fragment = null;
    DataHandler dataHandler = null;
    try {
        dataHandler = (DataHandler) xulDomContainer.getEventHandler("dataHandler");
        dataHandler.pushCache();
    } catch (XulException e) {
    // TODO not a critical function, but should log a problem...
    }
    switch(access) {
        case DatabaseMeta.TYPE_ACCESS_JNDI:
            fragment = getFragment(database, databaseName, "_jndi.xul", "common_jndi.xul");
            break;
        case DatabaseMeta.TYPE_ACCESS_NATIVE:
            fragment = getFragment(database, databaseName, "_native.xul", "common_native.xul");
            break;
        case DatabaseMeta.TYPE_ACCESS_OCI:
            fragment = getFragment(database, databaseName, "_oci.xul", "common_native.xul");
            break;
        case DatabaseMeta.TYPE_ACCESS_ODBC:
            fragment = getFragment(database, databaseName, "_odbc.xul", "common_odbc.xul");
            break;
        case DatabaseMeta.TYPE_ACCESS_PLUGIN:
            fragment = getFragment(database, databaseName, "_plugin.xul", "common_native.xul");
            break;
        default:
            break;
    }
    try {
        loadDatabaseOptionsFragment(fragment.toLowerCase());
    } catch (XulException e) {
        // TODO should be reporting as an error dialog; need error dialog in XUL framework
        showMessage(Messages.getString("FragmentHandler.USER.CANT_LOAD_OPTIONS", databaseName));
    }
    XulTextbox portBox = (XulTextbox) document.getElementById("port-number-text");
    if (portBox != null) {
        int port = database.getDefaultDatabasePort();
        if (port > 0) {
            portBox.setValue(Integer.toString(port));
        }
    }
    if (dataHandler != null) {
        dataHandler.popCache();
    }
}
Also used : DatabaseInterface(org.pentaho.di.core.database.DatabaseInterface) XulException(org.pentaho.ui.xul.XulException) DatabasePluginType(org.pentaho.di.core.plugins.DatabasePluginType) XulTextbox(org.pentaho.ui.xul.components.XulTextbox) XulException(org.pentaho.ui.xul.XulException)

Aggregations

XulException (org.pentaho.ui.xul.XulException)60 KettleException (org.pentaho.di.core.exception.KettleException)20 Test (org.junit.Test)11 XulMessageBox (org.pentaho.ui.xul.components.XulMessageBox)10 XulComponent (org.pentaho.ui.xul.XulComponent)9 Shell (org.eclipse.swt.widgets.Shell)7 ControllerInitializationException (org.pentaho.di.ui.repository.repositoryexplorer.ControllerInitializationException)7 KettleXulLoader (org.pentaho.di.ui.xul.KettleXulLoader)7 SwtXulRunner (org.pentaho.ui.xul.swt.SwtXulRunner)7 XulDomContainer (org.pentaho.ui.xul.XulDomContainer)6 SwtDialog (org.pentaho.ui.xul.swt.tags.SwtDialog)6 XulRunner (org.pentaho.ui.xul.XulRunner)5 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 Document (org.pentaho.ui.xul.dom.Document)4 ResourceBundle (java.util.ResourceBundle)3 Mockito.doAnswer (org.mockito.Mockito.doAnswer)3 InvocationOnMock (org.mockito.invocation.InvocationOnMock)3 Answer (org.mockito.stubbing.Answer)3 XulLoader (org.pentaho.ui.xul.XulLoader)3 SwtBindingFactory (org.pentaho.ui.xul.swt.SwtBindingFactory)3