/** Pops up the fact selector. */ @Override protected void showFactTypeSelector(final Widget w) { final ListBox box = new ListBox(); AsyncPackageDataModelOracle oracle = this.getModeller().getDataModelOracle(); String[] facts = oracle.getFactTypes(); box.addItem(GuidedRuleEditorResources.CONSTANTS.Choose()); for (int i = 0; i < facts.length; i++) { box.addItem(facts[i]); } box.setSelectedIndex(0); final FormStylePopup popup = new FormStylePopup(GuidedRuleEditorResources.CONSTANTS.NewFactPattern()); popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.chooseFactType(), box); box.addChangeHandler( new ChangeHandler() { public void onChange(ChangeEvent event) { pattern.setFactPattern(new FactPattern(box.getItemText(box.getSelectedIndex()))); setModified(true); getModeller().refreshWidget(); popup.hide(); } }); popup.show(); }
private Widget valueEditor(final CallFieldValue val) { String type = ""; if (oracle.isGlobalVariable(this.mCall.getVariable())) { type = oracle.getGlobalVariable(this.mCall.getVariable()); } else { Map<String, String> mFactTypes = scenario.getVariableTypes(); type = mFactTypes.get(this.mCall.getVariable()); } DropDownData enums = oracle.getEnums(type, val.field, this.mCall.getCallFieldValuesMap()); return new MethodParameterCallValueEditor( val, enums, executionTrace, scenario, val.type, new Command() { public void execute() { makeDirty(); } }); }
@Before public void setUp() throws Exception { Map<String, String> preferences = new HashMap<String, String>(); preferences.put(ApplicationPreferences.DATE_FORMAT, "dd-MMM-yyyy"); ApplicationPreferences.setUp(preferences); when(oracle.getFieldType("LoanApplication", "amount")) .thenReturn(DataType.TYPE_NUMERIC_INTEGER); when(oracle.getFieldType("LoanApplication", "lengthYears")) .thenReturn(DataType.TYPE_NUMERIC_INTEGER); when(oracle.getFieldType("LoanApplication", "deposit")) .thenReturn(DataType.TYPE_NUMERIC_INTEGER); when(oracle.getFieldType("LoanApplication", "approved")).thenReturn(DataType.TYPE_BOOLEAN); when(oracle.getFieldType("LoanApplication", "insuranceCost")) .thenReturn(DataType.TYPE_NUMERIC_INTEGER); when(oracle.getFieldType("LoanApplication", "approvedRate")) .thenReturn(DataType.TYPE_NUMERIC_INTEGER); when(oracle.getFieldType("IncomeSource", "type")).thenReturn(DataType.TYPE_STRING); when(oracle.getFieldType("Person", "name")).thenReturn(DataType.TYPE_STRING); }
/** Pops up the fact selector. */ protected void showSourcePatternSelector(final Widget w) { final ListBox box = new ListBox(); AsyncPackageDataModelOracle oracle = this.getModeller().getDataModelOracle(); String[] facts = oracle.getFactTypes(); box.addItem(GuidedRuleEditorResources.CONSTANTS.Choose()); for (int i = 0; i < facts.length; i++) { box.addItem(facts[i]); } box.setSelectedIndex(0); final FormStylePopup popup = new FormStylePopup(GuidedRuleEditorResources.CONSTANTS.NewFactPattern()); popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.chooseFactType(), box); box.addChangeHandler( new ChangeHandler() { public void onChange(ChangeEvent event) { getFromAccumulatePattern() .setSourcePattern(new FactPattern(box.getItemText(box.getSelectedIndex()))); setModified(true); getModeller().refreshWidget(); popup.hide(); } }); final Button fromBtn = new Button(HumanReadableConstants.INSTANCE.From()); final Button fromAccumulateBtn = new Button(HumanReadableConstants.INSTANCE.FromAccumulate()); final Button fromCollectBtn = new Button(HumanReadableConstants.INSTANCE.FromCollect()); final Button fromEntryPointBtn = new Button(HumanReadableConstants.INSTANCE.FromEntryPoint()); ClickHandler btnsClickHandler = new ClickHandler() { public void onClick(ClickEvent event) { Widget sender = (Widget) event.getSource(); if (sender == fromBtn) { getFromAccumulatePattern().setSourcePattern(new FromCompositeFactPattern()); } else if (sender == fromAccumulateBtn) { getFromAccumulatePattern().setSourcePattern(new FromAccumulateCompositeFactPattern()); } else if (sender == fromCollectBtn) { getFromAccumulatePattern().setSourcePattern(new FromCollectCompositeFactPattern()); } else if (sender == fromEntryPointBtn) { getFromAccumulatePattern().setSourcePattern(new FromEntryPointFactPattern()); } else { throw new IllegalArgumentException("Unknown sender: " + sender); } setModified(true); getModeller().refreshWidget(); popup.hide(); } }; fromBtn.addClickHandler(btnsClickHandler); fromAccumulateBtn.addClickHandler(btnsClickHandler); fromCollectBtn.addClickHandler(btnsClickHandler); fromEntryPointBtn.addClickHandler(btnsClickHandler); popup.addAttribute("", fromBtn); popup.addAttribute("", fromAccumulateBtn); popup.addAttribute("", fromCollectBtn); popup.addAttribute("", fromEntryPointBtn); popup.show(); }