private Widget getEditorWidget( final RuleAttribute at, final int idx, final boolean isReadOnly ) { Widget editor; if ( at.getAttributeName().equals( ENABLED_ATTR ) || at.getAttributeName().equals( AUTO_FOCUS_ATTR ) || at.getAttributeName().equals( LOCK_ON_ACTIVE_ATTR ) || at.getAttributeName().equals( NO_LOOP_ATTR ) ) { editor = checkBoxEditor( at, isReadOnly ); } else { editor = textBoxEditor( at, isReadOnly ); } DirtyableHorizontalPane horiz = new DirtyableHorizontalPane(); horiz.add( editor ); if ( !isReadOnly ) { horiz.add( getRemoveIcon( idx ) ); } return horiz; }
/** * Marshal model attributes * @param buf * @param model */ protected void marshalAttributes( final StringBuilder buf, final RuleModel model ) { boolean hasDialect = false; for ( int i = 0; i < model.attributes.length; i++ ) { RuleAttribute attr = model.attributes[ i ]; buf.append( "\t" ); buf.append( attr ); buf.append( "\n" ); if ( attr.getAttributeName().equals( "dialect" ) ) { constraintValueBuilder = DRLConstraintValueBuilder.getBuilder( attr.getValue() ); hasDialect = true; } } // Un comment below for mvel if ( !hasDialect ) { RuleAttribute attr = new RuleAttribute( "dialect", DEFAULT_DIALECT ); buf.append( "\t" ); buf.append( attr ); buf.append( "\n" ); } }
private RuleAttribute visitRuleAttribute( RuleAttribute attr ) { RuleAttribute clone = new RuleAttribute(); clone.setAttributeName( attr.getAttributeName() ); clone.setValue( attr.getValue() ); return clone; }
private TextBox textBoxEditor( final RuleAttribute at, final boolean isReadOnly ) { final TextBox box = new TextBox(); box.setEnabled( !isReadOnly ); box.setVisibleLength( ( at.getValue().length() < 3 ) ? 3 : at.getValue().length() ); box.setText( at.getValue() ); box.addChangeHandler( new ChangeHandler() { public void onChange( ChangeEvent event ) { at.setValue( box.getText() ); } } ); if ( at.getAttributeName().equals( DATE_EFFECTIVE_ATTR ) || at.getAttributeName().equals( DATE_EXPIRES_ATTR ) ) { if ( at.getValue() == null || "".equals( at.getValue() ) ) { box.setText( "" ); } box.setVisibleLength( 10 ); } box.addKeyUpHandler( new KeyUpHandler() { public void onKeyUp( KeyUpEvent event ) { int length = box.getText().length(); box.setVisibleLength( length > 0 ? length : 1 ); } } ); return box; }
rm.attributes.length ); assertEquals( "salience", rm.attributes[ 0 ].getAttributeName() ); assertEquals( "a", rm.attributes[ 0 ].getValue() ); rm.attributes.length ); assertEquals( "salience", rm.attributes[ 0 ].getAttributeName() ); assertEquals( "a", rm.attributes[ 0 ].getValue() ); assertEquals( "agenda-group", rm.attributes[ 1 ].getAttributeName() ); assertEquals( "b", rm.attributes[ 1 ].getValue() );
layout.addAttribute( at.getAttributeName(), getEditorWidget( at, i,