Search in sources :

Example 1 with ImportRuleCompositeInterface

use of org.pentaho.di.ui.imp.rule.ImportRuleCompositeInterface in project pentaho-kettle by pentaho.

the class ImportRulesDialog method getCompositesData.

protected void getCompositesData() {
    for (TableItem item : table.getItems()) {
        item.dispose();
    }
    table.clearAll();
    // Fill the table items in the table with data from importRules:
    // 
    compositesList = new ArrayList<ImportRuleCompositeInterface>();
    for (ImportRuleInterface rule : importRules.getRules()) {
        try {
            TableItem item = new TableItem(table, SWT.NONE);
            item.setChecked(rule.isEnabled());
            PluginRegistry registry = PluginRegistry.getInstance();
            PluginInterface plugin = registry.getPlugin(ImportRulePluginType.class, rule);
            item.setText(1, Const.NVL(plugin.getName(), rule.getClass().getName()));
            // Put a composite in the 3rd column...
            // 
            // First get the composite generating class...
            // 
            ImportRuleCompositeInterface importRuleComposite = getImportRuleComposite(rule);
            compositesList.add(importRuleComposite);
            final Composite composite = importRuleComposite.getComposite(table, rule);
            composite.layout(true, true);
            final TableEditor editor = new TableEditor(table);
            editor.grabHorizontal = true;
            editor.grabVertical = true;
            editor.setEditor(composite, item, 2);
            // Put actual data onto the composite
            // 
            importRuleComposite.setCompositeData(rule);
            item.addDisposeListener(new DisposeListener() {

                public void widgetDisposed(DisposeEvent event) {
                    composite.dispose();
                }
            });
        } catch (Exception e) {
            new ErrorDialog(shell, "Error", "Error displaying rule options for rule: " + rule.toString(), e);
            compositesList.add(null);
        }
    }
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) ImportRuleCompositeInterface(org.pentaho.di.ui.imp.rule.ImportRuleCompositeInterface) Composite(org.eclipse.swt.widgets.Composite) ImportRuleInterface(org.pentaho.di.imp.rule.ImportRuleInterface) TableItem(org.eclipse.swt.widgets.TableItem) PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) DisposeEvent(org.eclipse.swt.events.DisposeEvent) TableEditor(org.eclipse.swt.custom.TableEditor) KettleException(org.pentaho.di.core.exception.KettleException)

Example 2 with ImportRuleCompositeInterface

use of org.pentaho.di.ui.imp.rule.ImportRuleCompositeInterface in project pentaho-kettle by pentaho.

the class ImportRulesDialog method getImportRuleComposite.

public ImportRuleCompositeInterface getImportRuleComposite(ImportRuleInterface rule) throws KettleException {
    String compositeClassName = rule.getCompositeClassName();
    Class<?> compositeClass;
    Class<?>[] paramClasses = new Class<?>[] {};
    Object[] paramArgs = new Object[] {};
    Constructor<?> compositeConstructor;
    try {
        compositeClass = rule.getClass().getClassLoader().loadClass(compositeClassName);
        compositeConstructor = compositeClass.getConstructor(paramClasses);
        return (ImportRuleCompositeInterface) compositeConstructor.newInstance(paramArgs);
    } catch (Exception e) {
        throw new KettleException(e);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) ImportRuleCompositeInterface(org.pentaho.di.ui.imp.rule.ImportRuleCompositeInterface) KettleException(org.pentaho.di.core.exception.KettleException)

Example 3 with ImportRuleCompositeInterface

use of org.pentaho.di.ui.imp.rule.ImportRuleCompositeInterface in project pentaho-kettle by pentaho.

the class ImportRulesDialog method getInfo.

protected void getInfo(ImportRules ir) {
    ir.getRules().clear();
    for (int i = 0; i < importRules.getRules().size(); i++) {
        ImportRuleInterface rule = importRules.getRules().get(i);
        ImportRuleCompositeInterface importRuleComposite = compositesList.get(i);
        TableItem tableItem = table.getItem(i);
        importRuleComposite.getCompositeData(rule);
        rule.setEnabled(tableItem.getChecked());
        ir.getRules().add(rule);
    }
}
Also used : ImportRuleCompositeInterface(org.pentaho.di.ui.imp.rule.ImportRuleCompositeInterface) ImportRuleInterface(org.pentaho.di.imp.rule.ImportRuleInterface) TableItem(org.eclipse.swt.widgets.TableItem)

Aggregations

ImportRuleCompositeInterface (org.pentaho.di.ui.imp.rule.ImportRuleCompositeInterface)3 TableItem (org.eclipse.swt.widgets.TableItem)2 KettleException (org.pentaho.di.core.exception.KettleException)2 ImportRuleInterface (org.pentaho.di.imp.rule.ImportRuleInterface)2 TableEditor (org.eclipse.swt.custom.TableEditor)1 DisposeEvent (org.eclipse.swt.events.DisposeEvent)1 DisposeListener (org.eclipse.swt.events.DisposeListener)1 Composite (org.eclipse.swt.widgets.Composite)1 PluginInterface (org.pentaho.di.core.plugins.PluginInterface)1 PluginRegistry (org.pentaho.di.core.plugins.PluginRegistry)1 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)1