Changeset 2110


Ignore:
Timestamp:
07/12/10 20:17:02 (19 months ago)
Author:
tolteque
Message:

o LOMEFC2

Location:
trunk/lomefc2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/lomefc2/me_predicates.lua

    r2103 r2110  
    10961096 
    10971097-- add rules to the list 
    1098 function rulesToList(list, rules, cdata) 
     1098function rulesToList(list, rules, cdata, idx) 
     1099  local itemToMonit = nil 
    10991100  list:clear() 
     1101   
    11001102  if rules then 
     1103      local color 
     1104      local level  = 0 
     1105      local curIdx = 1 
    11011106      for _tmp, v in ipairs(rules) do 
    1102           local item = U.addListBoxItem(list, getRuleAsText(v, cdata), nil, v) 
    1103           local color 
     1107          if  v.decoration == ")" then 
     1108              if level ~= 0 then 
     1109                  level = level - 1 
     1110              end 
     1111          end 
     1112           
     1113          local itemIndent = string.rep("  ", level) 
     1114          local item = U.addListBoxItem(list, itemIndent .. getRuleAsText(v, cdata), nil, v) 
     1115          item.indent = itemIndent 
     1116           
    11041117          if v.decoration then 
    1105               if v.decoration == "(" or v.decoration == ")" then 
     1118              if v.decoration == "(" then 
     1119                  color = Color.red 
     1120                  level = level + 1 
     1121              elseif v.decoration == ")" then 
    11061122                  color = Color.red 
    11071123              else 
     
    11131129              item:setTheme(theme)   
    11141130          end 
    1115  
     1131          if idx and ( curIdx == idx) then 
     1132              itemToMonit = item 
     1133              list:selectItem( item) 
     1134          end 
     1135          curIdx = curIdx + 1 
    11161136      end 
    11171137  end 
    1118   list:onChange(nil) 
     1138  list:onChange( itemToMonit) 
    11191139end 
    11201140 
     
    11681188-- update row in list 
    11691189function updateListRow(list, displayFunc) 
     1190    base.print("updateListRow()") 
    11701191    local item = list:getSelectedItem() 
    11711192    if item then 
    11721193        local struct = item.itemId 
    1173         item:setText(displayFunc(struct)) 
     1194        if not item.indent then 
     1195            item.indent = "" 
     1196        end 
     1197        item:setText( item.indent .. displayFunc(struct)) 
     1198         
    11741199    end 
    11751200end 
  • trunk/lomefc2/me_trigrules.lua

    r2103 r2110  
    864864            predicates.rulesToList(window.rulesList, trigger.rules, cdata) 
    865865            window.triggerTypeCombo.selectedItem = trigger 
    866             window.triggerTypeCombo:setText(predicates.getPredicateName(trigger.predicate,  
    867                         cdata)) 
     866            window.triggerTypeCombo:setText(predicates.getPredicateName(trigger.predicate, cdata)) 
    868867            createTriggerArgumentsWidgets(window, trigger, cdata) 
    869868        else 
     
    986985    function window.newRuleBtn:onChange() 
    987986--        base.print('newRuleBtn:onChange())') 
    988         op_and = { name       = "op_and", 
    989                    fields     = {}, 
    990                    decoration = true 
    991                  } 
    992987        local currentGoal = window.triggersList:getSelectedItem() 
    993988        local goal = currentGoal.itemId 
     
    1004999            local rule = predicates.createRule(rulesDescr[1]) 
    10051000            base.table.insert(currentGoal.itemId.rules, idx, rule) 
    1006             local item = U.addListBoxItem( window.rulesList 
    1007                                          , predicates.getRuleAsText( rule, cdata) 
    1008                                          , nil 
    1009                                          , rule 
    1010                                          , idx 
    1011                                          ) 
    1012             window.rulesList:selectItem(item) 
    1013             window.rulesList:onChange(item) 
     1001 
     1002            predicates.rulesToList(window.rulesList, currentGoal.itemId.rules, cdata, idx) 
     1003 
    10141004        end 
    10151005    end 
     
    10291019                idx = idx - 1 
    10301020            end 
    1031             item = window.rulesList:getChildren()[idx] 
    1032             window.rulesList:selectItem(item) 
    1033             window.rulesList:onChange(item) 
     1021 
     1022            predicates.rulesToList( window.rulesList, currentGoal.itemId.rules, cdata, idx) 
     1023 
     1024--            item = window.rulesList:getChildren()[idx] 
     1025--            window.rulesList:selectItem(item) 
     1026--            window.rulesList:onChange(item) 
    10341027        end 
    10351028    end 
     
    10751068            local rule = predicates.createRule( decoRuleDesc) 
    10761069            base.table.insert(currentGoal.itemId.rules, idx, rule) 
    1077             local item = U.addListBoxItem( window.rulesList 
    1078                                          , predicates.getRuleAsText( rule, cdata) 
    1079                                          , nil 
    1080                                          , rule 
    1081                                          , idx 
    1082                                          ) 
    1083                                           
    1084             -- Set color for this decoration 
    1085             local theme = item:getTheme() 
    1086             local color 
    1087             if rule.predicate.decoration == "(" or rule.predicate.decoration == ")" then 
    1088                 color = Color.red 
    1089             else 
    1090                 color = Color.blue 
    1091             end 
    1092             theme.normalTheme.text.color = color 
    1093             theme.selectedTheme.text.color = color 
    1094             item:setTheme(theme)   
    10951070             
    1096             window.rulesList:selectItem(item) 
    1097             window.rulesList:onChange(item) 
     1071            predicates.rulesToList(window.rulesList, currentGoal.itemId.rules, cdata, idx) 
     1072 
    10981073        end 
    10991074    end 
     
    11011076    -- if predicate type was changed  
    11021077    function window.ruleTypeCombo:onChange(item) 
    1103                 --base.print('ruleTypeCombo:onChange(item)') 
     1078--                  base.print('ruleTypeCombo:onChange(item)') 
    11041079        self.selectedItem = item.itemId 
    11051080        local selectedItem = window.rulesList:getSelectedItem() 
Note: See TracChangeset for help on using the changeset viewer.