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);
}
}
}
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);
}
}
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);
}
}
Aggregations