/** Pops up the fact selector. */ protected void showFactTypeSelector(final Widget w) { PackageDataModelOracle completions = this.getModeller().getSuggestionCompletions(); final ListBox box = new ListBox(); String[] facts = completions.getFactTypes(); box.addItem(Constants.INSTANCE.Choose()); for (int i = 0; i < facts.length; i++) { box.addItem(facts[i]); } box.setSelectedIndex(0); final FormStylePopup popup = new FormStylePopup(); popup.setTitle(Constants.INSTANCE.NewFactPattern()); popup.addAttribute(Constants.INSTANCE.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(); }
/** Pops up the fact selector. */ protected void showFactTypeSelector(final Widget w) { final ListBox box = new ListBox(); DataModelOracle completions = this.getModeller().getSuggestionCompletions(); String[] facts = completions.getFactTypes(); box.addItem(Constants.INSTANCE.Choose()); for (int i = 0; i < facts.length; i++) { box.addItem(facts[i]); } box.setSelectedIndex(0); final FormStylePopup popup = new FormStylePopup(); popup.setTitle(Constants.INSTANCE.NewFactPattern()); popup.addAttribute(Constants.INSTANCE.chooseFactType(), box); box.addChangeHandler( new ChangeHandler() { public void onChange(ChangeEvent event) { pattern.addFactPattern(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()); ClickHandler btnsClickHandler = new ClickHandler() { public void onClick(ClickEvent event) { Widget sender = (Widget) event.getSource(); if (sender == fromBtn) { pattern.addFactPattern(new FromCompositeFactPattern()); } else if (sender == fromAccumulateBtn) { pattern.addFactPattern(new FromAccumulateCompositeFactPattern()); } else if (sender == fromCollectBtn) { pattern.addFactPattern(new FromCollectCompositeFactPattern()); } else { throw new IllegalArgumentException("Unknown sender: " + sender); } setModified(true); getModeller().refreshWidget(); popup.hide(); } }; fromBtn.addClickHandler(btnsClickHandler); fromAccumulateBtn.addClickHandler(btnsClickHandler); fromCollectBtn.addClickHandler(btnsClickHandler); popup.addAttribute("", fromBtn); popup.addAttribute("", fromAccumulateBtn); popup.addAttribute("", fromCollectBtn); popup.show(); }