Commit 46b2a955833dd55a0531e36312d2f86e68605238

Authored by Carlos Picanco
1 parent 10aade72
Exists in master

fix bug on load contingencies

experiment_designer/form_main.lfm
... ... @@ -554,6 +554,7 @@ object FormDesigner: TFormDesigner
554 554 ChildSizing.ControlsPerLine = 1
555 555 ClientHeight = 583
556 556 ClientWidth = 650
  557 + Enabled = False
557 558 object ComboCurrentContingency: TComboBox
558 559 Left = 0
559 560 Height = 27
... ...
experiment_designer/form_main.pas
... ... @@ -351,6 +351,7 @@ begin
351 351 ListBoxContingencies.Items.Text := ComboCurrentContingency.Items.Text;
352 352 RGPointsClick(RGPoints);
353 353 RGEndCriteriaStyleClick(RGEndCriteriaStyle);
  354 + TabSheetContingencies.Enabled := ComboCurrentCondition.Items.Count > 0;
354 355 end;
355 356  
356 357 procedure TFormDesigner.XMLPropStorageSavingProperties(Sender: TObject);
... ... @@ -871,40 +872,44 @@ end;
871 872 procedure TFormDesigner.LoadSectionCondition(LS: string);
872 873 begin
873 874 with FExperiment do
874   - begin
875   - EditConditionName.Text := ReadString(LS, KEY_COND_NAME, LS);
876   - SpinEditTurnValue.Value := ReadInteger(LS, KEY_TURN_VALUE, 2);
877   - SpinEditOnConditionBegin.Value := ReadInteger(LS, KEY_POINTS_ONSTART,0);
878   - SpinEditCyclesValue.Value := ReadInteger(LS, KEY_CYCLES_VALUE, 2);
879   -
880   - CheckBoxShouldAskQuestion.Checked := False;
881   - if ValueExists(LS, KEY_PROMPT_STYLE) and ValueExists(LS, KEY_PROMPT_MESSAGE) then
882 875 begin
883   - EditQuestion.Text := ReadString(LS, KEY_PROMPT_MESSAGE, '');
884   - SetCGQuestion(ReadString(LS, KEY_PROMPT_STYLE, ''));
885   - if (EditQuestion.Text <> '') or (ReadString(LS, KEY_PROMPT_STYLE, '') <> '') then
886   - CheckBoxShouldAskQuestion.Checked := True;
887   - end;
  876 + EditConditionName.Text := ReadString(LS, KEY_COND_NAME, LS);
  877 + SpinEditTurnValue.Value := ReadInteger(LS, KEY_TURN_VALUE, 2);
  878 + SpinEditOnConditionBegin.Value := ReadInteger(LS, KEY_POINTS_ONSTART,0);
  879 + SpinEditCyclesValue.Value := ReadInteger(LS, KEY_CYCLES_VALUE, 2);
888 880  
889   - SetRGEndCriteriaStyle(ReadString(LS, KEY_ENDCRITERIA, 'O QUE OCORRER PRIMEIRO'));
890   - SpinEditEndCriteriaAbsCycles.Value := ReadInteger(LS, KEY_ENDCRITERIA_CYCLES, 20);
891   - SpinEditEndCriteriaLastCycles.Value :=
892   - GetEndCriteriaLastCyclesFromString(ReadString(LS, KEY_ENDCRITERIA_PORCENTAGE, '80,20'));
893   - SpinEditEndCriteriaInterlockingPorcentage.Value :=
894   - GetEndCriteriaPorcentageFromString(ReadString(LS, KEY_ENDCRITERIA_PORCENTAGE, '80,20'));
895   - end;
  881 + CheckBoxShouldAskQuestion.Checked := False;
  882 + if ValueExists(LS, KEY_PROMPT_STYLE) and ValueExists(LS, KEY_PROMPT_MESSAGE) then
  883 + begin
  884 + EditQuestion.Text := ReadString(LS, KEY_PROMPT_MESSAGE, '');
  885 + SetCGQuestion(ReadString(LS, KEY_PROMPT_STYLE, ''));
  886 + if (EditQuestion.Text <> '') or (ReadString(LS, KEY_PROMPT_STYLE, '') <> '') then
  887 + CheckBoxShouldAskQuestion.Checked := True;
  888 + end;
  889 +
  890 + SetRGEndCriteriaStyle(ReadString(LS, KEY_ENDCRITERIA, 'O QUE OCORRER PRIMEIRO'));
  891 + SpinEditEndCriteriaAbsCycles.Value := ReadInteger(LS, KEY_ENDCRITERIA_CYCLES, 20);
  892 + SpinEditEndCriteriaLastCycles.Value :=
  893 + GetEndCriteriaLastCyclesFromString(ReadString(LS, KEY_ENDCRITERIA_PORCENTAGE, '80,20'));
  894 + SpinEditEndCriteriaInterlockingPorcentage.Value :=
  895 + GetEndCriteriaPorcentageFromString(ReadString(LS, KEY_ENDCRITERIA_PORCENTAGE, '80,20'));
  896 + end;
896 897 end;
897 898  
898 899 procedure TFormDesigner.LoadContingency(LS, LC: string);
  900 +var
  901 + Temp: String;
899 902 begin
  903 + CheckBoxIsMeta.OnChange := nil;
900 904 if Pos(KEY_METACONTINGENCY, LC) > 0 then
901 905 CheckBoxIsMeta.Checked := True
902 906 else
903 907 CheckBoxIsMeta.Checked := False;
904   -
  908 + CheckBoxIsMeta.OnChange:=@CheckBoxIsMetaChange;
905 909 with FExperiment do
906 910 if ValueExists(LS, LC + KEY_CONSEQUE) and ValueExists(LS, LC + KEY_CRITERIA) then
907 911 begin
  912 + Temp := ReadString(LS, LC + KEY_CONT_NAME, '');
908 913 EditContingencyName.Text := ReadString(LS, LC + KEY_CONT_NAME, '');
909 914 SetContingencyCriteria(ReadString(LS, LC + KEY_CRITERIA, ''));
910 915 SetContingencyStyle(ReadString(LS, LC + KEY_CONSEQUE, ''));
... ... @@ -1057,6 +1062,7 @@ begin
1057 1062 ComboCurrentCondition.ItemIndex := i;
1058 1063 SaveSectionCondition(SEC_CONDITION + IntToStr(i + 1));
1059 1064 ListBoxConditions.Items.Text := ComboCurrentCondition.Items.Text;
  1065 + TabSheetContingencies.Enabled := ComboCurrentCondition.Items.Count > 0;
1060 1066 end;
1061 1067  
1062 1068 procedure TFormDesigner.BtnAppendContingencyClick(Sender: TObject);
... ... @@ -1124,6 +1130,7 @@ begin
1124 1130 ComboCurrentCondition.ItemIndex := i -1;
1125 1131 end;
1126 1132 ListBoxContingencies.Items.Text := ComboCurrentCondition.Items.Text;
  1133 + TabSheetContingencies.Enabled := ComboCurrentCondition.Items.Count > 0;
1127 1134 end;
1128 1135  
1129 1136 procedure TFormDesigner.BtnRemoveContingencyClick(Sender: TObject);
... ... @@ -1259,19 +1266,17 @@ begin
1259 1266 LabelIf.Caption := 'SE O PARTICIPANTE ESCOLHER';
1260 1267 end;
1261 1268  
1262   -
1263   - if Sender = CheckBoxIsMeta then
1264   - if ComboCurrentCondition.Items.Count > 0 then
1265   - if ComboCurrentContingency.Items.Count > 0 then
1266   - begin
1267   - LS := ExtractDelimited(1,ComboCurrentCondition.Text,['|']);
1268   - LC := ExtractDelimited(1, ComboCurrentContingency.Text,['|']);
1269   - EraseContingency(LS,LC);
1270   - LC := GetLC(TCheckBox(Sender).Checked,False);
1271   - SaveContingency(LS,LC);
1272   - ComboCurrentContingency.Items[ComboCurrentContingency.ItemIndex] := LC +'|'+ EditContingencyName.Text;
1273   - ListBoxContingencies.Items.Text := ComboCurrentContingency.Items.Text;
1274   - end;
  1269 + if ComboCurrentCondition.Items.Count > 0 then
  1270 + if ComboCurrentContingency.Items.Count > 0 then
  1271 + begin
  1272 + LS := ExtractDelimited(1,ComboCurrentCondition.Text,['|']);
  1273 + LC := ExtractDelimited(1, ComboCurrentContingency.Text,['|']);
  1274 + EraseContingency(LS,LC);
  1275 + LC := GetLC(TCheckBox(Sender).Checked,False);
  1276 + SaveContingency(LS,LC);
  1277 + ComboCurrentContingency.Items[ComboCurrentContingency.ItemIndex] := LC +'|'+ EditContingencyName.Text;
  1278 + ListBoxContingencies.Items.Text := ComboCurrentContingency.Items.Text;
  1279 + end;
1275 1280 end;
1276 1281  
1277 1282 procedure TFormDesigner.CheckBoxColorsRowsChange(Sender: TObject);
... ...