@Override public void setImportRulesToValidate( ImportRules importRules ) { this.importRules = importRules; hasRules = ( importRules != null && !importRules.getRules().isEmpty() ); }
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 ); } }
public String getXML() { StringBuilder xml = new StringBuilder(); xml.append( XMLHandler.openTag( XML_TAG ) ).append( Const.CR ).append( Const.CR ); for ( ImportRuleInterface rule : getRules() ) { PluginInterface plugin = PluginRegistry.getInstance().getPlugin( ImportRulePluginType.class, rule.getId() ); xml.append( "<!-- " ).append( plugin.getName() ).append( " : " ).append( plugin.getDescription() ).append( Const.CR ).append( " -->" ).append( Const.CR ); xml.append( rule.getXML() ); xml.append( Const.CR ).append( Const.CR ); } xml.append( XMLHandler.closeTag( XML_TAG ) ); return xml.toString(); }
/** * Perform a deep clone * * @return a deep copy of the all the import rules. */ @Override public ImportRules clone() { ImportRules importRules = new ImportRules(); for ( ImportRuleInterface rule : rules ) { importRules.getRules().add( rule.clone() ); } return importRules; }
public void removeRule() { MessageBox box = new MessageBox( shell, SWT.ICON_WARNING | SWT.APPLICATION_MODAL | SWT.SHEET | SWT.YES | SWT.NO ); box.setText( "Warning" ); box.setMessage( "Are you sure you want to remove the selected rules from the list?" ); int answer = box.open(); if ( answer != SWT.YES ) { return; } int[] indices = table.getSelectionIndices(); Arrays.sort( indices ); for ( int i = indices.length - 1; i >= 0; i-- ) { importRules.getRules().remove( indices[i] ); } // Refresh the whole list.. // getCompositesData(); }
public void loadXML( Node rulesNode ) throws KettleException { List<Node> ruleNodes = XMLHandler.getNodes( rulesNode, BaseImportRule.XML_TAG ); for ( Node ruleNode : ruleNodes ) { String id = XMLHandler.getTagValue( ruleNode, "id" ); PluginRegistry registry = PluginRegistry.getInstance(); PluginInterface plugin = registry.findPluginWithId( ImportRulePluginType.class, id ); if ( plugin == null ) { throw new KettleException( "The import rule of type '" + id + "' could not be found in the plugin registry." ); } ImportRuleInterface rule = (ImportRuleInterface) registry.loadClass( plugin ); rule.loadXML( ruleNode ); getRules().add( rule ); } }
public static void main( String[] args ) throws Exception { Display display = new Display(); KettleEnvironment.init(); PropsUI.init( display, PropsUI.TYPE_PROPERTIES_SPOON ); Shell shell = new Shell( display ); ImportRules importRules = new ImportRules(); importRules.loadXML( XMLHandler.getSubNode( XMLHandler.loadXMLFile( "bin/import-rules.xml" ), ImportRules.XML_TAG ) ); ImportRulesDialog dialog = new ImportRulesDialog( shell, importRules ); if ( dialog.open() ) { for ( ImportRuleInterface rule : importRules.getRules() ) { System.out.println( " - " + rule.toString() ); } } }
for ( ImportRuleInterface rule : importRules.getRules() ) { try { TableItem item = new TableItem( table, SWT.NONE );
if ( !importRules.getRules().isEmpty() ) { MessageBox box = new MessageBox( shell, SWT.ICON_WARNING | SWT.APPLICATION_MODAL | SWT.SHEET | SWT.YES | SWT.NO );