/** * Edit the condition in a separate dialog box... * * @param condition * The condition to be edited */ private void editCondition( int nr ) { if ( active_condition.isComposite() ) { parents.add( active_condition ); active_condition = active_condition.getCondition( nr ); } }
@Override public void widgetSelected( SelectionEvent e ) { Condition up = active_condition.getCondition( cond_nr ); active_condition.removeCondition( cond_nr ); active_condition.addCondition( cond_nr - 1, up ); widget.redraw(); } } );
@Override public void widgetSelected( SelectionEvent e ) { Condition down = active_condition.getCondition( cond_nr ); active_condition.removeCondition( cond_nr ); active_condition.addCondition( cond_nr + 1, down ); widget.redraw(); } } );
@Override public void widgetSelected( SelectionEvent e ) { // Move the condition lower: this means delete the condition from the active_condition. // After that, move it to the parent. Condition up = active_condition.getCondition( cond_nr ); active_condition.removeCondition( cond_nr ); Condition parent = parents.get( getLevel() - 1 ); parent.addCondition( up ); // Take a look upward... goUp(); widget.redraw(); } } );
/** * This method moves up atomic conditions if there is only one sub-condition. * * @return true if there was a simplification. */ public boolean simplify() { if ( nrConditions() == 1 ) { Condition condition = getCondition( 0 ); if ( condition.isAtomic() ) { return simplify( condition, this ); } } boolean changed = false; for ( int i = 0; i < nrConditions(); i++ ) { Condition condition = getCondition( i ); changed |= condition.simplify(); if ( i == 0 ) { condition.setOperator( OPERATOR_NONE ); } } return changed; }
public void getUsedFields( Hashtable<String, String> fields ) { if ( isAtomic() ) { if ( getLeftValuename() != null ) { fields.put( getLeftValuename(), "-" ); } if ( getRightValuename() != null ) { fields.put( getRightValuename(), "-" ); } } else { for ( int i = 0; i < nrConditions(); i++ ) { Condition subc = getCondition( i ); subc.getUsedFields( fields ); } } }
@Override public void widgetSelected( SelectionEvent e ) { Condition c = active_condition.getCondition( cond_nr ); try { String xml = c.getXML(); GUIResource.getInstance().toClipboard( xml ); widget.redraw(); } catch ( Exception ex ) { new ErrorDialog( shell, "Error", "Error encoding to XML", ex ); } } } );
@Override public void widgetSelected( SelectionEvent e ) { // Move the condition lower: this means create a subcondition and put the condition there in the list. // Condition down = active_condition.getCondition( cond_nr ); Condition c = new Condition(); c.setOperator( down.getOperator() ); down.setOperator( Condition.OPERATOR_NONE ); active_condition.setCondition( cond_nr, c ); c.addCondition( down ); widget.redraw(); } } );
public ObjectId saveCondition( Condition condition, ObjectId id_condition_parent ) throws KettleException { try { condition.setObjectId( insertCondition( id_condition_parent, condition ) ); for ( int i = 0; i < condition.nrConditions(); i++ ) { Condition subc = condition.getCondition( i ); repository.saveCondition( subc, condition.getObjectId() ); } return condition.getObjectId(); } catch ( KettleException dbe ) { throw new KettleException( "Error saving condition to the repository.", dbe ); } }
@Override public Object clone() { Condition retval = null; retval = new Condition(); retval.negate = negate; retval.operator = operator; if ( isComposite() ) { for ( int i = 0; i < nrConditions(); i++ ) { Condition c = getCondition( i ); Condition cCopy = (Condition) c.clone(); retval.addCondition( cCopy ); } } else { retval.negate = negate; retval.left_valuename = left_valuename; retval.operator = operator; retval.right_valuename = right_valuename; retval.function = function; if ( right_exact != null ) { retval.right_exact = (ValueMetaAndData) right_exact.clone(); } else { retval.right_exact = null; } } return retval; }
public void removeCondition( int nr ) { if ( isComposite() ) { Condition c = list.get( nr ); list.remove( nr ); // Nothing left or only one condition left: move it to the parent: make it atomic. boolean moveUp = isAtomic() || nrConditions() == 1; if ( nrConditions() == 1 ) { c = getCondition( 0 ); } if ( moveUp ) { setLeftValuename( c.getLeftValuename() ); setFunction( c.getFunction() ); setRightValuename( c.getRightValuename() ); setRightExact( c.getRightExact() ); setNegated( isNegated() ^ c.isNegated() ); } } }
Point to = drawCondition( gc, basex, basey, i, active_condition.getCondition( i ) ); basey += size_and_not.height + to.y + 15;
public String getXML( int level ) throws KettleValueException { String retval = ""; String indent1 = Const.rightPad( " ", level ); String indent2 = Const.rightPad( " ", level + 1 ); String indent3 = Const.rightPad( " ", level + 2 ); retval += indent1 + XMLHandler.openTag( XML_TAG ) + Const.CR; retval += indent2 + XMLHandler.addTagValue( "negated", isNegated() ); if ( getOperator() != OPERATOR_NONE ) { retval += indent2 + XMLHandler.addTagValue( "operator", Const.rtrim( getOperatorDesc() ) ); } if ( isAtomic() ) { retval += indent2 + XMLHandler.addTagValue( "leftvalue", getLeftValuename() ); retval += indent2 + XMLHandler.addTagValue( "function", getFunctionDesc() ); retval += indent2 + XMLHandler.addTagValue( "rightvalue", getRightValuename() ); if ( getRightExact() != null ) { retval += indent2 + getRightExact().getXML(); } } else { retval += indent2 + "<conditions>" + Const.CR; for ( int i = 0; i < nrConditions(); i++ ) { Condition c = getCondition( i ); retval += c.getXML( level + 2 ); } retval += indent3 + "</conditions>" + Const.CR; } retval += indent2 + XMLHandler.closeTag( XML_TAG ) + Const.CR; return retval; }
BaseMessages.getString( PKG, "ConditionEditor.SelectOperator.Label" ) ); esd.setAvoidQuickSearch(); Condition selcond = active_condition.getCondition( operator ); String def = selcond.getOperatorDesc(); int defnr = esd.getSelectionNr( Const.trim( def ) ); if ( selection != null ) { int opnr = Condition.getOperator( selection ); active_condition.getCondition( operator ).setOperator( opnr ); setModified();
final Condition sub = active_condition.getCondition( cond_nr ); if ( sub.getLeftValuename() != null ) { miAdd = new MenuItem( mPop, SWT.CASCADE );