Search in sources :

Example 1 with IUIDatasourceAdminService

use of org.pentaho.platform.dataaccess.datasource.ui.service.IUIDatasourceAdminService 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);
}
Also used : JdbcDatasourceService(org.pentaho.platform.dataaccess.datasource.ui.service.JdbcDatasourceService) GwtDatasourceEditorEntryPoint(org.pentaho.platform.dataaccess.datasource.wizard.GwtDatasourceEditorEntryPoint) IUIDatasourceAdminService(org.pentaho.platform.dataaccess.datasource.ui.service.IUIDatasourceAdminService) XulException(org.pentaho.ui.xul.XulException) MondrianUIDatasourceService(org.pentaho.platform.dataaccess.datasource.ui.service.MondrianUIDatasourceService) XulMenuitem(org.pentaho.ui.xul.components.XulMenuitem) XulComponent(org.pentaho.ui.xul.XulComponent) DSWUIDatasourceService(org.pentaho.platform.dataaccess.datasource.ui.service.DSWUIDatasourceService) IDatasourceInfo(org.pentaho.platform.dataaccess.datasource.IDatasourceInfo) MetadataUIDatasourceService(org.pentaho.platform.dataaccess.datasource.ui.service.MetadataUIDatasourceService)

Example 2 with IUIDatasourceAdminService

use of org.pentaho.platform.dataaccess.datasource.ui.service.IUIDatasourceAdminService in project data-access by pentaho.

the class DatasourceAdminDialogController method launchNewUI.

@Bindable
public void launchNewUI(String datasourceType) {
    IUIDatasourceAdminService service = manager.getService(datasourceType);
    String newUI = service.getNewUI();
    if (newUI != null && newUI.length() > 0) {
        if (newUI.indexOf("builtin:") >= 0) {
            if (service.getType().equals(JdbcDatasourceService.TYPE)) {
                entryPoint.showDatabaseDialog(adminDatasourceListener);
            } else if (service.getType().equals(MondrianUIDatasourceService.TYPE)) {
                entryPoint.showAnalysisImportDialog(adminDatasourceListener);
            } else if (service.getType().equals(MetadataUIDatasourceService.TYPE)) {
                entryPoint.showMetadataImportDialog(adminDatasourceListener);
            } else if (service.getType().equals(DSWUIDatasourceService.TYPE)) {
                entryPoint.showWizard(true, adminDatasourceListener);
            }
        } else if (newUI.indexOf("javascript:") >= 0) {
            String script = newUI.substring(newUI.indexOf(":") + 1);
            executeJavaScript(script);
        }
    }
}
Also used : IUIDatasourceAdminService(org.pentaho.platform.dataaccess.datasource.ui.service.IUIDatasourceAdminService) Bindable(org.pentaho.ui.xul.stereotype.Bindable)

Aggregations

IUIDatasourceAdminService (org.pentaho.platform.dataaccess.datasource.ui.service.IUIDatasourceAdminService)2 IDatasourceInfo (org.pentaho.platform.dataaccess.datasource.IDatasourceInfo)1 DSWUIDatasourceService (org.pentaho.platform.dataaccess.datasource.ui.service.DSWUIDatasourceService)1 JdbcDatasourceService (org.pentaho.platform.dataaccess.datasource.ui.service.JdbcDatasourceService)1 MetadataUIDatasourceService (org.pentaho.platform.dataaccess.datasource.ui.service.MetadataUIDatasourceService)1 MondrianUIDatasourceService (org.pentaho.platform.dataaccess.datasource.ui.service.MondrianUIDatasourceService)1 GwtDatasourceEditorEntryPoint (org.pentaho.platform.dataaccess.datasource.wizard.GwtDatasourceEditorEntryPoint)1 XulComponent (org.pentaho.ui.xul.XulComponent)1 XulException (org.pentaho.ui.xul.XulException)1 XulMenuitem (org.pentaho.ui.xul.components.XulMenuitem)1 Bindable (org.pentaho.ui.xul.stereotype.Bindable)1