private void makeLiteral( final StringBuilder sb, final ConditionCol52 condition ) { appendHeader( sb, condition ); sb.append( condition.getFactField() ); }
private void makePredicate( final StringBuilder sb, final ConditionCol52 condition ) { appendHeader( sb, condition ); sb.append( condition.getFactField() ); }
private void makeFormula( final StringBuilder sb, final ConditionCol52 condition ) { appendHeader( sb, condition ); sb.append( condition.getFactField() ); }
@Override public boolean hasEnum( final Pattern52 selectedPattern, final ConditionCol52 selectedCondition ) { final String factType = selectedPattern.getFactType(); final String factField = selectedCondition.getFactField(); return oracle.hasEnums( factType, factField ); }
@Override public String[] getOperatorCompletions( final Pattern52 selectedPattern, final ConditionCol52 selectedCondition ) { final String factType = selectedPattern.getFactType(); final String factField = selectedCondition.getFactField(); final String[] ops = this.oracle.getOperatorCompletions( factType, factField ); //Operators "in" and "not in" are only allowed if the Calculation Type is a Literal final List<String> filteredOps = new ArrayList<String>(); for ( String op : ops ) { filteredOps.add( op ); } if ( BaseSingleFieldConstraint.TYPE_LITERAL != selectedCondition.getConstraintValueType() ) { filteredOps.remove( "in" ); } //But remove "in" if the Fact\Field is enumerated if ( oracle.hasEnums( factType, factField ) ) { filteredOps.remove( "in" ); } final String[] displayOps = new String[ filteredOps.size() ]; filteredOps.toArray( displayOps ); return displayOps; }
@Override public boolean requiresValueList( final Pattern52 selectedPattern, final ConditionCol52 selectedCondition ) { //Don't show a Value List if either the Fact\Field is empty final String factType = selectedPattern.getFactType(); final String factField = selectedCondition.getFactField(); boolean enableValueList = !( ( factType == null || "".equals( factType ) ) || ( factField == null || "".equals( factField ) ) ); //Don't show Value List if operator does not accept one if ( enableValueList ) { enableValueList = validator.doesOperatorAcceptValueList( selectedCondition ); } //Don't show a Value List if the Fact\Field has an enumeration if ( enableValueList ) { enableValueList = !oracle.hasEnums( factType, factField ); } return enableValueList; }
public Set<String> getBindings( String className ) { //For some reason, Fact Pattern data-types use the leaf name of the fully qualified Class Name //whereas Fields use the fully qualified Class Name. We don't use the generic fieldType (see //SuggestionCompletionEngine.TYPE) as we can't distinguish between different numeric types String simpleClassName = className; if ( simpleClassName != null && simpleClassName.lastIndexOf( "." ) > 0 ) { simpleClassName = simpleClassName.substring( simpleClassName.lastIndexOf( "." ) + 1 ); } Set<String> bindings = new HashSet<String>(); for ( Pattern52 p : this.model.getPatterns() ) { if ( className == null || p.getFactType().equals( simpleClassName ) ) { String binding = p.getBoundName(); if ( !( binding == null || "".equals( binding ) ) ) { bindings.add( binding ); } } for ( ConditionCol52 c : p.getChildColumns() ) { if ( c.isBound() ) { String fieldDataType = oracle.getFieldClassName( p.getFactType(), c.getFactField() ); if ( fieldDataType.equals( className ) ) { bindings.add( c.getBinding() ); } } } } return bindings; }
private void doFieldLabel() { if ( editingCol.getConstraintValueType() == BaseSingleFieldConstraint.TYPE_PREDICATE ) { if ( this.editingCol.getFactField() == null || this.editingCol.getFactField().equals( "" ) ) { fieldLabel.setText( Constants.INSTANCE.notNeededForPredicate() ); } else { fieldLabel.setText( this.editingCol.getFactField() ); } fieldLabelInterpolationInfo.setVisible( true ); } else if ( nil( editingPattern.getFactType() ) ) { fieldLabel.setText( Constants.INSTANCE.pleaseSelectAPatternFirst() ); fieldLabelInterpolationInfo.setVisible( false ); } else if ( nil( editingCol.getFactField() ) ) { fieldLabel.setText( Constants.INSTANCE.pleaseSelectAField() ); fieldLabelInterpolationInfo.setVisible( false ); } else { fieldLabel.setText( this.editingCol.getFactField() ); } }
ColumnDynamicValues( final List<ColumnValues> columns, final DataModelOracle oracle, final LimitedEntryDropDownManager.Context context, final DTCellValue52 defaultValue ) { super( columns, EMPTY_VALUE, defaultValue ); this.oracle = oracle; this.context = context; //Check if there is an enumeration final DropDownData dd = oracle.getEnums( context.getBasePattern().getFactType(), ( (ConditionCol52) context.getBaseColumn() ).getFactField(), new HashMap<String, String>() ); if ( dd != null ) { this.values = convertValueList( getSplitValues( dd.getFixedList() ) ); this.originalValues = this.values; this.initialiseValueList = false; this.isAllValuesUsed = false; } //Initialise value to the first in the list this.iterator = this.values.iterator(); this.value = iterator.next(); }
private List<ConditionCol52> findAvailableColumnsToExpand() { final List<ConditionCol52> availableColumns = new ArrayList<ConditionCol52>(); for ( CompositeColumn<?> cc : model.getPatterns() ) { if ( cc instanceof Pattern52 ) { final Pattern52 p = (Pattern52) cc; for ( ConditionCol52 c : p.getChildColumns() ) { switch ( model.getTableFormat() ) { case EXTENDED_ENTRY: if ( modelUtils.hasValueList( c ) ) { final String[] values = modelUtils.getValueList( c ); if ( values != null && values.length > 1 ) { availableColumns.add( c ); } } else if ( oracle.hasEnums( p.getFactType(), c.getFactField() ) ) { availableColumns.add( c ); } break; case LIMITED_ENTRY: availableColumns.add( c ); } } } } return availableColumns; }
private void doValueList() { if ( model.getTableFormat() == TableFormat.LIMITED_ENTRY ) { return; } //Don't show a Value List if either the Fact\Field is empty final String factType = editingPattern.getFactType(); final String factField = editingCol.getFactField(); boolean enableValueList = !( ( factType == null || "".equals( factType ) ) || ( factField == null || "".equals( factField ) ) ); //Don't show Value List if operator does not accept one if ( enableValueList ) { enableValueList = validator.doesOperatorAcceptValueList( editingCol ); } //Don't show a Value List if the Fact\Field has an enumeration if ( enableValueList ) { enableValueList = !oracle.hasEnums( factType, factField ); } valueListWidget.setEnabled( enableValueList ); if ( !enableValueList ) { valueListWidget.setText( "" ); } }
private DecoratedGridCellValueAdaptor<? extends Comparable<?>> derieveCellFromCondition( ConditionCol52 col ) { //Operators "is null" and "is not null" require a boolean cell if ( col.getOperator() != null && ( col.getOperator().equals( "== null" ) || col.getOperator().equals( "!= null" ) ) ) { return makeBooleanCell(); } //Check if the column has a "Value List" or an enumeration. Value List takes precedence final String factType = model.getPattern( col ).getFactType(); final String fieldName = col.getFactField(); if ( utils.hasValueList( col ) ) { return makeValueListCell( col ); } else if ( oracle.hasEnums( factType, fieldName ) ) { return makeEnumCell( factType, fieldName ); } return derieveCellFromModel( col ); }
currentValueMap.put( cc.getFactField(), getValue( cc ) );
private void doCalculationType() { if ( model.getTableFormat() == TableFormat.LIMITED_ENTRY ) { return; } //Disable Formula and Predicate if the Fact\Field has enums final String factType = editingPattern.getFactType(); final String factField = editingCol.getFactField(); final boolean hasEnums = oracle.hasEnums( factType, factField ); this.literal.setEnabled( hasEnums || !isReadOnly ); this.formula.setEnabled( !( hasEnums || isReadOnly ) ); this.predicate.setEnabled( !( hasEnums || isReadOnly ) ); //If Fact\Field has enums the Value Type has to be a literal if ( hasEnums ) { this.editingCol.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL ); } }
public void onClick( ClickEvent w ) { editingCol.setFactField( box.getItemText( box.getSelectedIndex() ) ); editingCol.setFieldType( oracle.getFieldType( editingPattern.getFactType(), editingCol.getFactField() ) ); //Clear Operator when field changes editingCol.setOperator( null ); //Setup UI doFieldLabel(); doValueList(); doCalculationType(); makeLimitedValueWidget(); makeDefaultValueWidget(); doOperatorLabel(); pop.hide(); } } );
private void addExtendedEntryColumn( final Pattern52 p, final ConditionCol52 c ) { ColumnValues cv = null; String[] values = new String[]{ }; if ( modelUtils.hasValueList( c ) ) { values = modelUtils.getValueList( c ); values = getSplitValues( values ); cv = new ColumnValues( columns, convertValueList( values ), c.getDefaultValue() ); } else if ( oracle.hasEnums( p.getFactType(), c.getFactField() ) ) { final LimitedEntryDropDownManager.Context context = new LimitedEntryDropDownManager.Context( p, c ); cv = new ColumnDynamicValues( columns, oracle, context, c.getDefaultValue() ); } else { cv = new ColumnValues( columns, convertValueList( values ), c.getDefaultValue() ); } if ( cv != null ) { this.expandedColumns.put( c, cv ); this.columns.add( cv ); } }
private void doOperatorLabel() { if ( editingCol.getConstraintValueType() == BaseSingleFieldConstraint.TYPE_PREDICATE ) { operatorLabel.setText( Constants.INSTANCE.notNeededForPredicate() ); } else if ( nil( editingPattern.getFactType() ) ) { operatorLabel.setText( Constants.INSTANCE.pleaseSelectAPatternFirst() ); } else if ( nil( editingCol.getFactField() ) ) { operatorLabel.setText( Constants.INSTANCE.pleaseChooseAFieldFirst() ); } else if ( nil( editingCol.getOperator() ) ) { operatorLabel.setText( Constants.INSTANCE.pleaseSelectAField() ); } else { operatorLabel.setText( HumanReadable.getOperatorDisplayName(editingCol.getOperator()) ); } }
return; if ( nil( editingCol.getFactField() ) ) { setAttributeVisibility( defaultValueWidgetContainerIndex, false );
private void populateModelColumn( final ConditionCol52 col, final ConditionCol52 editingCol ) { col.setConstraintValueType( editingCol.getConstraintValueType() ); col.setFactField( editingCol.getFactField() ); col.setFieldType( editingCol.getFieldType() ); col.setHeader( editingCol.getHeader() ); col.setOperator( editingCol.getOperator() ); col.setValueList( editingCol.getValueList() ); col.setDefaultValue( editingCol.getDefaultValue() ); col.setHideColumn( editingCol.isHideColumn() ); col.setParameters( editingCol.getParameters() ); col.setBinding( editingCol.getBinding() ); if ( col instanceof LimitedEntryCol && editingCol instanceof LimitedEntryCol ) { ( (LimitedEntryCol) col ).setValue( ( (LimitedEntryCol) editingCol ).getValue() ); } }
private ConditionCol52 cloneConditionColumn( ConditionCol52 col ) { ConditionCol52 clone = null; if ( col instanceof LimitedEntryConditionCol52 ) { clone = new LimitedEntryConditionCol52(); DTCellValue52 dcv = cloneLimitedEntryValue( ( (LimitedEntryCol) col ).getValue() ); ( (LimitedEntryCol) clone ).setValue( dcv ); } else { clone = new ConditionCol52(); } clone.setConstraintValueType( col.getConstraintValueType() ); clone.setFactField( col.getFactField() ); clone.setFieldType( col.getFieldType() ); clone.setHeader( col.getHeader() ); clone.setOperator( col.getOperator() ); clone.setValueList( col.getValueList() ); clone.setDefaultValue( new DTCellValue52( col.getDefaultValue() ) ); clone.setHideColumn( col.isHideColumn() ); clone.setParameters( col.getParameters() ); clone.setWidth( col.getWidth() ); clone.setBinding( col.getBinding() ); return clone; }