@Test public void testActionPlugins() throws Exception { reset(actionPlugin); doReturn(ACTION_DESCRIPTION).when(actionPlugin).getActionAddDescription(); doReturn(ACTION_ID).when(actionPlugin).getId(); doReturn(iAction).when(actionPlugin).createIAction(eq(ruleModeller)); popup.getContent(); verify(actionPlugin).createIAction(ruleModeller); verify(actionPlugin).addPluginToActionList(eq(ruleModeller), commandArgumentCaptor.capture()); reset(listBox); commandArgumentCaptor.getValue().execute(); verify(listBox).addItem(eq(ACTION_DESCRIPTION), eq(ACTION_ID)); Assertions.assertThat(popup.cmds).containsKeys(ACTION_ID); reset(listBox); doReturn("123").when(listBox).getValue(anyInt()); popup.cmds.get(ACTION_ID).execute(); verify(model).addRhsItem(iAction, 123); verify(popup).hide(); }
@Override public Widget getContent() { if (position == null) { positionCbo.addItem(GuidedRuleEditorResources.CONSTANTS.Bottom(), String.valueOf(this.model.rhs.length)); positionCbo.addItem(GuidedRuleEditorResources.CONSTANTS.Top(), "0"); for (int i = 1; i < model.rhs.length; i++) { positionCbo.addItem(GuidedRuleEditorResources.CONSTANTS.Line0(i), String.valueOf(i)); } } else { positionCbo.addItem(String.valueOf(position)); positionCbo.setSelectedIndex(0); } if (oracle.getDSLConditions().size() == 0 && oracle.getFactTypes().length == 0) { layoutPanel.addRow(new HTML("<div class='highlight'>" + GuidedRuleEditorResources.CONSTANTS.NoModelTip() + "</div>")); } if (position == null) { HorizontalPanel hp0 = new HorizontalPanel(); hp0.add(new HTML(GuidedRuleEditorResources.CONSTANTS.PositionColon())); hp0.add(positionCbo); hp0.add(new InfoPopup(GuidedRuleEditorResources.CONSTANTS.PositionColon(), GuidedRuleEditorResources.CONSTANTS.ActionPositionExplanation())); layoutPanel.addRow(hp0); layoutPanel.addRow(new HTML("<hr/>")); } final RuleModellerSelectorFilter filterWidget = GWT.create(RuleModellerSelectorFilter.class); filterWidget.setFilterChangeConsumer((filter) -> choicesPanel.setWidget(makeChoicesListBox(filter))); layoutPanel.add(filterWidget); choices = makeChoicesListBox(filterWidget.getFilterText()); choicesPanel.add(choices); layoutPanel.addRow(choicesPanel); if (ruleModeller.isDSLEnabled()) { CheckBox chkOnlyDisplayDSLConditions = new CheckBox(); chkOnlyDisplayDSLConditions.setText(GuidedRuleEditorResources.CONSTANTS.OnlyDisplayDSLActions()); chkOnlyDisplayDSLConditions.setValue(onlyShowDSLStatements); chkOnlyDisplayDSLConditions.addValueChangeHandler(new ValueChangeHandler<Boolean>() { public void onValueChange(ValueChangeEvent<Boolean> event) { onlyShowDSLStatements = event.getValue(); choicesPanel.setWidget(makeChoicesListBox(filterWidget.getFilterText())); } }); layoutPanel.addRow(chkOnlyDisplayDSLConditions); } return layoutPanel; }
RuleModellerActionSelectorPopup extends AbstractRuleModellerSelectorPopup { @Override public Widget getContent() { if (position == null) { positionCbo.addItem(GuidedRuleEditorResources.CONSTANTS.Bottom(), String.valueOf(this.model.rhs.length)); positionCbo.addItem(GuidedRuleEditorResources.CONSTANTS.Top(), "0"); for (int i = 1; i < model.rhs.length; i++) { positionCbo.addItem(GuidedRuleEditorResources.CONSTANTS.Line0(i), String.valueOf(i)); } } else { positionCbo.addItem(String.valueOf(position)); positionCbo.setSelectedIndex(0); } if (oracle.getDSLConditions().size() == 0 && oracle.getFactTypes().length == 0) { layoutPanel.addRow(new HTML("<div class='highlight'>" + GuidedRuleEditorResources.CONSTANTS.NoModelTip() + "</div>")); } if (position == null) { HorizontalPanel hp0 = new HorizontalPanel(); hp0.add(new HTML(GuidedRuleEditorResources.CONSTANTS.PositionColon())); hp0.add(positionCbo); hp0.add(new InfoPopup(GuidedRuleEditorResources.CONSTANTS.PositionColon(), GuidedRuleEditorResources.CONSTANTS.ActionPositionExplanation())); layoutPanel.addRow(hp0); layoutPanel.addRow(new HTML("<hr/>")); } final RuleModellerSelectorFilter filterWidget = GWT.create(RuleModellerSelectorFilter.class); filterWidget.setFilterChangeConsumer((filter) -> choicesPanel.setWidget(makeChoicesListBox(filter))); layoutPanel.add(filterWidget); choices = makeChoicesListBox(filterWidget.getFilterText()); choicesPanel.add(choices); layoutPanel.addRow(choicesPanel); if (ruleModeller.isDSLEnabled()) { CheckBox chkOnlyDisplayDSLConditions = new CheckBox(); chkOnlyDisplayDSLConditions.setText(GuidedRuleEditorResources.CONSTANTS.OnlyDisplayDSLActions()); chkOnlyDisplayDSLConditions.setValue(onlyShowDSLStatements); chkOnlyDisplayDSLConditions.addValueChangeHandler(new ValueChangeHandler<Boolean>() { public void onValueChange(ValueChangeEvent<Boolean> event) { onlyShowDSLStatements = event.getValue(); choicesPanel.setWidget(makeChoicesListBox(filterWidget.getFilterText())); } }); layoutPanel.addRow(chkOnlyDisplayDSLConditions); } return layoutPanel; } }
RuleModellerActionSelectorPopup extends AbstractRuleModellerSelectorPopup { @Override public Widget getContent() { if (position == null) { positionCbo.addItem(GuidedRuleEditorResources.CONSTANTS.Bottom(), String.valueOf(this.model.rhs.length)); positionCbo.addItem(GuidedRuleEditorResources.CONSTANTS.Top(), "0"); for (int i = 1; i < model.rhs.length; i++) { positionCbo.addItem(GuidedRuleEditorResources.CONSTANTS.Line0(i), String.valueOf(i)); } } else { positionCbo.addItem(String.valueOf(position)); positionCbo.setSelectedIndex(0); } if (oracle.getDSLConditions().size() == 0 && oracle.getFactTypes().length == 0) { layoutPanel.addRow(new HTML("<div class='highlight'>" + GuidedRuleEditorResources.CONSTANTS.NoModelTip() + "</div>")); } if (position == null) { HorizontalPanel hp0 = new HorizontalPanel(); hp0.add(new HTML(GuidedRuleEditorResources.CONSTANTS.PositionColon())); hp0.add(positionCbo); hp0.add(new InfoPopup(GuidedRuleEditorResources.CONSTANTS.PositionColon(), GuidedRuleEditorResources.CONSTANTS.ActionPositionExplanation())); layoutPanel.addRow(hp0); layoutPanel.addRow(new HTML("<hr/>")); } final RuleModellerSelectorFilter filterWidget = GWT.create(RuleModellerSelectorFilter.class); filterWidget.setFilterChangeConsumer((filter) -> choicesPanel.setWidget(makeChoicesListBox(filter))); layoutPanel.add(filterWidget); choices = makeChoicesListBox(filterWidget.getFilterText()); choicesPanel.add(choices); layoutPanel.addRow(choicesPanel); if (ruleModeller.isDSLEnabled()) { CheckBox chkOnlyDisplayDSLConditions = new CheckBox(); chkOnlyDisplayDSLConditions.setText(GuidedRuleEditorResources.CONSTANTS.OnlyDisplayDSLActions()); chkOnlyDisplayDSLConditions.setValue(onlyShowDSLStatements); chkOnlyDisplayDSLConditions.addValueChangeHandler(new ValueChangeHandler<Boolean>() { public void onValueChange(ValueChangeEvent<Boolean> event) { onlyShowDSLStatements = event.getValue(); choicesPanel.setWidget(makeChoicesListBox(filterWidget.getFilterText())); } }); layoutPanel.addRow(chkOnlyDisplayDSLConditions); } return layoutPanel; } RuleModellerActionSelectorPopup(final RuleModel model,
                                           final RuleModeller ruleModeller,
                                           final Collection<RuleModellerActionPlugin> actionPlugins,
                                           final Integer position,
                                           final AsyncPackageDataModelOracle oracle); }
RuleModellerActionSelectorPopup extends AbstractRuleModellerSelectorPopup { @Override public Widget getContent() { if (position == null) { positionCbo.addItem(GuidedRuleEditorResources.CONSTANTS.Bottom(), String.valueOf(this.model.rhs.length)); positionCbo.addItem(GuidedRuleEditorResources.CONSTANTS.Top(), "0"); for (int i = 1; i < model.rhs.length; i++) { positionCbo.addItem(GuidedRuleEditorResources.CONSTANTS.Line0(i), String.valueOf(i)); } } else { positionCbo.addItem(String.valueOf(position)); positionCbo.setSelectedIndex(0); } if (oracle.getDSLConditions().size() == 0 && oracle.getFactTypes().length == 0) { layoutPanel.addRow(new HTML("<div class='highlight'>" + GuidedRuleEditorResources.CONSTANTS.NoModelTip() + "</div>")); } if (position == null) { HorizontalPanel hp0 = new HorizontalPanel(); hp0.add(new HTML(GuidedRuleEditorResources.CONSTANTS.PositionColon())); hp0.add(positionCbo); hp0.add(new InfoPopup(GuidedRuleEditorResources.CONSTANTS.PositionColon(), GuidedRuleEditorResources.CONSTANTS.ActionPositionExplanation())); layoutPanel.addRow(hp0); layoutPanel.addRow(new HTML("<hr/>")); } final RuleModellerSelectorFilter filterWidget = GWT.create(RuleModellerSelectorFilter.class); filterWidget.setFilterChangeConsumer((filter) -> choicesPanel.setWidget(makeChoicesListBox(filter))); layoutPanel.add(filterWidget); choices = makeChoicesListBox(filterWidget.getFilterText()); choicesPanel.add(choices); layoutPanel.addRow(choicesPanel); if (ruleModeller.isDSLEnabled()) { CheckBox chkOnlyDisplayDSLConditions = new CheckBox(); chkOnlyDisplayDSLConditions.setText(GuidedRuleEditorResources.CONSTANTS.OnlyDisplayDSLActions()); chkOnlyDisplayDSLConditions.setValue(onlyShowDSLStatements); chkOnlyDisplayDSLConditions.addValueChangeHandler(new ValueChangeHandler<Boolean>() { public void onValueChange(ValueChangeEvent<Boolean> event) { onlyShowDSLStatements = event.getValue(); choicesPanel.setWidget(makeChoicesListBox(filterWidget.getFilterText())); } }); layoutPanel.addRow(chkOnlyDisplayDSLConditions); } return layoutPanel; } RuleModellerActionSelectorPopup(final RuleModel model,
                                           final RuleModeller ruleModeller,
                                           final Collection<RuleModellerActionPlugin> actionPlugins,
                                           final Integer position,
                                           final AsyncPackageDataModelOracle oracle); @Override Widget getContent(); @Override void show(); }
RuleModellerActionSelectorPopup extends AbstractRuleModellerSelectorPopup { @Override public Widget getContent() { if (position == null) { positionCbo.addItem(GuidedRuleEditorResources.CONSTANTS.Bottom(), String.valueOf(this.model.rhs.length)); positionCbo.addItem(GuidedRuleEditorResources.CONSTANTS.Top(), "0"); for (int i = 1; i < model.rhs.length; i++) { positionCbo.addItem(GuidedRuleEditorResources.CONSTANTS.Line0(i), String.valueOf(i)); } } else { positionCbo.addItem(String.valueOf(position)); positionCbo.setSelectedIndex(0); } if (oracle.getDSLConditions().size() == 0 && oracle.getFactTypes().length == 0) { layoutPanel.addRow(new HTML("<div class='highlight'>" + GuidedRuleEditorResources.CONSTANTS.NoModelTip() + "</div>")); } if (position == null) { HorizontalPanel hp0 = new HorizontalPanel(); hp0.add(new HTML(GuidedRuleEditorResources.CONSTANTS.PositionColon())); hp0.add(positionCbo); hp0.add(new InfoPopup(GuidedRuleEditorResources.CONSTANTS.PositionColon(), GuidedRuleEditorResources.CONSTANTS.ActionPositionExplanation())); layoutPanel.addRow(hp0); layoutPanel.addRow(new HTML("<hr/>")); } final RuleModellerSelectorFilter filterWidget = GWT.create(RuleModellerSelectorFilter.class); filterWidget.setFilterChangeConsumer((filter) -> choicesPanel.setWidget(makeChoicesListBox(filter))); layoutPanel.add(filterWidget); choices = makeChoicesListBox(filterWidget.getFilterText()); choicesPanel.add(choices); layoutPanel.addRow(choicesPanel); if (ruleModeller.isDSLEnabled()) { CheckBox chkOnlyDisplayDSLConditions = new CheckBox(); chkOnlyDisplayDSLConditions.setText(GuidedRuleEditorResources.CONSTANTS.OnlyDisplayDSLActions()); chkOnlyDisplayDSLConditions.setValue(onlyShowDSLStatements); chkOnlyDisplayDSLConditions.addValueChangeHandler(new ValueChangeHandler<Boolean>() { public void onValueChange(ValueChangeEvent<Boolean> event) { onlyShowDSLStatements = event.getValue(); choicesPanel.setWidget(makeChoicesListBox(filterWidget.getFilterText())); } }); layoutPanel.addRow(chkOnlyDisplayDSLConditions); } return layoutPanel; } RuleModellerActionSelectorPopup(final RuleModel model,
                                           final RuleModeller ruleModeller,
                                           final Collection<RuleModellerActionPlugin> actionPlugins,
                                           final Integer position,
                                           final AsyncPackageDataModelOracle oracle); @Override Widget getContent(); @Override void show();  }