Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2012 JBoss Inc
   * 
   * Licensed under the Apache License, Version 2.0 (the "License"); you may not
   * use this file except in compliance with the License. You may obtain a copy of
   * the License at
   * 
   * http://www.apache.org/licenses/LICENSE-2.0
   * 
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  * License for the specific language governing permissions and limitations under
  * the License.
  */
 package org.drools.workbench.screens.guided.dtable.client.widget.table;
 
 import java.util.Map;
 import java.util.Set;
 
Specific implementation for Limited Entry Decision Table definition (i.e. for use with NewGuidedDecisionTableWizard or GuidedDecisionTableWidget)
 
         implements
 
     protected final PackageDataModelOracle oracle;
     protected final GuidedDecisionTable52 model;
     protected final DTCellValueUtilities utilities;
 
     public LimitedEntryDropDownManagerfinal GuidedDecisionTable52 model,
                                         final PackageDataModelOracle oracle ) {
         if ( model == null ) {
             throw new IllegalArgumentException"model cannot be null" );
         }
         if ( oracle == null ) {
             throw new IllegalArgumentException"oracle cannot be null" );
         }
         this. = new DTCellValueUtilitiesmodel,
                                                    oracle );
         this. = model;
         this. = oracle;
     }

    
The Context contains the Pattern and Column for which the enumerations need to be ascertained. It is not possible to lookup the Pattern from the Model as, when editing column definitions in GuidedDecisionTableWidget the column is cloned (for editing) and hence is not the same (identity-wise) as that held in the model
 
     public static class Context {
 
         private final Pattern52 basePattern;
 
         private final BaseColumn baseColumn;
 
         public Contextfinal Pattern52 basePattern,
                         final ConditionCol52 baseColumn ) {
             this. = basePattern;
             this. = baseColumn;
         }
 
         public Contextfinal Pattern52 basePattern,
                         final ActionSetFieldCol52 baseColumn ) {
             this. = basePattern;
             this. = baseColumn;
         }
 
         public Contextfinal ActionInsertFactCol52 baseColumn ) {
             this. = null;
             this. = baseColumn;
         }
 
         public Pattern52 getBasePattern() {
             return ;
         }
 
         public BaseColumn getBaseColumn() {
             return ;
         }
 
     }
    @Override
    public Map<StringStringgetCurrentValueMapContext context ) {
        Map<StringStringcurrentValueMap = new HashMap<StringString>();
        final Pattern52 basePattern = context.getBasePattern();
        final BaseColumn baseColumn = context.getBaseColumn();
        //Get values for all Constraints or Actions on the same pattern as the baseColumn
        if ( baseColumn instanceof ConditionCol52 ) {
            for ( ConditionCol52 cc : basePattern.getChildColumns() ) {
                if ( cc instanceof LimitedEntryCol ) {
                    currentValueMap.putcc.getFactField(),
                                         getValue( (LimitedEntryColcc ) );
                }
            }
        } else if ( baseColumn instanceof ActionSetFieldCol52 ) {
            ActionSetFieldCol52 baseActionColumn = (ActionSetFieldCol52baseColumn;
            final String binding = baseActionColumn.getBoundName();
            for ( ActionCol52 ac : this..getActionCols() ) {
                if ( ac instanceof ActionSetFieldCol52 ) {
                    final ActionSetFieldCol52 asf = (ActionSetFieldCol52ac;
                    if ( asf.getBoundName().equalsbinding ) ) {
                        if ( asf instanceof LimitedEntryCol ) {
                            currentValueMap.putasf.getFactField(),
                                                 getValue( (LimitedEntryColasf ) );
                        }
                    }
                }
            }
        } else if ( baseColumn instanceof ActionInsertFactCol52 ) {
            ActionInsertFactCol52 baseActionColumn = (ActionInsertFactCol52baseColumn;
            final String binding = baseActionColumn.getBoundName();
            for ( ActionCol52 ac : this..getActionCols() ) {
                if ( ac instanceof ActionInsertFactCol52 ) {
                    final ActionInsertFactCol52 aif = (ActionInsertFactCol52ac;
                    if ( aif.getBoundName().equalsbinding ) ) {
                        if ( aif instanceof LimitedEntryCol ) {
                            currentValueMap.putaif.getFactField(),
                                                 getValue( (LimitedEntryColaif ) );
                        }
                    }
                }
            }
        }
        return currentValueMap;
    }
    private String getValueLimitedEntryCol lec ) {
        if ( lec == null || lec.getValue() == null ) {
            return "";
        }
        final DTCellValue52 lev = lec.getValue();
        return .asStringlev );
    }
    @Override
    public Set<IntegergetDependentColumnIndexesContext context ) {
        final Set<IntegerdependentColumnIndexes = new HashSet<Integer>();
        final Pattern52 basePattern = context.getBasePattern();
        final BaseColumn baseColumn = context.getBaseColumn();
        //Get values for all Constraints or Actions on the same pattern as the baseColumn
        if ( baseColumn instanceof ConditionCol52 ) {
            final ConditionCol52 baseConditionColumn = (ConditionCol52baseColumn;
            for ( ConditionCol52 cc : basePattern.getChildColumns() ) {
                if ( .isDependentEnumbasePattern.getFactType(),
                                             baseConditionColumn.getFactField(),
                                             cc.getFactField() ) ) {
                    dependentColumnIndexes.add.getExpandedColumns().indexOfcc ) );
                }
            }
        } else if ( baseColumn instanceof ActionSetFieldCol52 ) {
            final ActionSetFieldCol52 baseActionColumn = (ActionSetFieldCol52baseColumn;
            final String binding = baseActionColumn.getBoundName();
            for ( ActionCol52 ac : this..getActionCols() ) {
                if ( ac instanceof ActionSetFieldCol52 ) {
                    final ActionSetFieldCol52 asf = (ActionSetFieldCol52ac;
                    if ( asf.getBoundName().equalsbinding ) ) {
                        if ( .isDependentEnumbasePattern.getFactType(),
                                                     baseActionColumn.getFactField(),
                                                     asf.getFactField() ) ) {
                            dependentColumnIndexes.add.getExpandedColumns().indexOfac ) );
                        }
                    }
                }
            }
        } else if ( baseColumn instanceof ActionInsertFactCol52 ) {
            final ActionInsertFactCol52 baseActionColumn = (ActionInsertFactCol52baseColumn;
            final String binding = baseActionColumn.getBoundName();
            for ( ActionCol52 ac : this..getActionCols() ) {
                if ( ac instanceof ActionInsertFactCol52 ) {
                    final ActionInsertFactCol52 aif = (ActionInsertFactCol52ac;
                    if ( aif.getBoundName().equalsbinding ) ) {
                        if ( .isDependentEnumbaseActionColumn.getFactType(),
                                                     baseActionColumn.getFactField(),
                                                     aif.getFactField() ) ) {
                            dependentColumnIndexes.add.getExpandedColumns().indexOfac ) );
                        }
                    }
                }
            }
        }
        return dependentColumnIndexes;
    }
New to GrepCode? Check out our FAQ X