@Test public void testOnChangeCallbackRegisteredForActionValueEditor() throws Exception { final ActionFieldValue value = new ActionFieldValue(); value.setNature(FieldNatureType.TYPE_LITERAL); value.setField("a"); final ActionValueEditor editor = mock(ActionValueEditor.class); doReturn(editor).when(testedWidget).actionValueEditor(anyString(), eq(value), any(), eq(readOnly)); final ActionFieldValue valueTwo = new ActionFieldValue(); valueTwo.setNature(FieldNatureType.TYPE_LITERAL); valueTwo.setField("b"); final ActionValueEditor editorTwo = mock(ActionValueEditor.class); doReturn(editorTwo).when(testedWidget).actionValueEditor(anyString(), eq(valueTwo), any(), eq(readOnly)); testedWidget.valueEditor(value); testedWidget.valueEditor(valueTwo); verify(editor).setOnChangeCommand(commandCaptor.capture()); commandCaptor.getValue().execute(); verify(testedWidget).setModified(true); verify(editorTwo).refresh(); } }
@Test public void testOnChangeCallbackRegisteredForActionValueEditor() throws Exception { final ActionFieldValue value = new ActionFieldValue(); value.setNature(FieldNatureType.TYPE_LITERAL); value.setField("a"); final ActionValueEditor editor = mock(ActionValueEditor.class); doReturn(editor).when(testedWidget).actionValueEditor(anyString(), eq(value), any(), eq(readOnly)); final ActionFieldValue valueTwo = new ActionFieldValue(); valueTwo.setNature(FieldNatureType.TYPE_LITERAL); valueTwo.setField("b"); final ActionValueEditor editorTwo = mock(ActionValueEditor.class); doReturn(editorTwo).when(testedWidget).actionValueEditor(anyString(), eq(valueTwo), any(), eq(readOnly)); testedWidget.valueEditor(value); testedWidget.valueEditor(valueTwo); verify(editor).setOnChangeCommand(commandCaptor.capture()); commandCaptor.getValue().execute(); verify(testedWidget).setModified(true); verify(editorTwo).refresh(); } }
private ActionFieldValue cloneActionFieldValue(ActionFieldValue afv) { ActionFieldValue clone = new ActionFieldValue(); clone.setField(afv.getField()); clone.setNature(afv.getNature()); clone.setType(afv.getType()); clone.setValue(afv.getValue()); return clone; }
@Test public void testOnChangeCallbackRegisteredForActionValueEditor() throws Exception { final ActionFieldValue value = new ActionFieldValue(); value.setNature(FieldNatureType.TYPE_LITERAL); value.setField("a"); final ActionValueEditor editor = mock(ActionValueEditor.class); doReturn(editor).when(testedWidget).actionValueEditor(any(), eq(value), any(), anyBoolean()); final ActionFieldValue valueTwo = new ActionFieldValue(); valueTwo.setNature(FieldNatureType.TYPE_LITERAL); valueTwo.setField("b"); final ActionValueEditor editorTwo = mock(ActionValueEditor.class); doReturn(editorTwo).when(testedWidget).actionValueEditor(any(), eq(valueTwo), any(), anyBoolean()); testedWidget.valueEditor(value); testedWidget.valueEditor(valueTwo); verify(editor).setOnChangeCommand(commandCaptor.capture()); commandCaptor.getValue().execute(); verify(testedWidget).setModified(true); verify(editorTwo).refresh(); } }
@Test public void testOnChangeCallbackRegisteredForActionValueEditor() throws Exception { final ActionFieldValue value = new ActionFieldValue(); value.setNature(FieldNatureType.TYPE_LITERAL); value.setField("a"); final ActionValueEditor editor = mock(ActionValueEditor.class); doReturn(editor).when(testedWidget).actionValueEditor(any(), eq(value), any(), anyBoolean()); final ActionFieldValue valueTwo = new ActionFieldValue(); valueTwo.setNature(FieldNatureType.TYPE_LITERAL); valueTwo.setField("b"); final ActionValueEditor editorTwo = mock(ActionValueEditor.class); doReturn(editorTwo).when(testedWidget).actionValueEditor(any(), eq(valueTwo), any(), anyBoolean()); testedWidget.valueEditor(value); testedWidget.valueEditor(valueTwo); verify(editor).setOnChangeCommand(commandCaptor.capture()); commandCaptor.getValue().execute(); verify(testedWidget).setModified(true); verify(editorTwo).refresh(); } }
private ActionFieldValue cloneActionFieldValue(ActionFieldValue afv) { ActionFieldValue clone = new ActionFieldValue(); clone.setField(afv.getField()); clone.setNature(afv.getNature()); clone.setType(afv.getType()); clone.setValue(afv.getValue()); return clone; }
public void onChange(ChangeEvent event) { String fieldName = box.getItemText(box.getSelectedIndex()); String fieldType = oracle.getFieldType(variableClass, fieldName); model.addFieldValue(new ActionFieldValue(fieldName, "", fieldType)); setModified(true); getModeller().refreshWidget(); popup.hide(); } });
public void onChange(ChangeEvent event) { String fieldName = box.getItemText(box.getSelectedIndex()); String fieldType = oracle.getFieldType(variableClass, fieldName); model.addFieldValue(new ActionFieldValue(fieldName, "", fieldType)); setModified(true); getModeller().refreshWidget(); popup.hide(); } });
public ActionInsertFactCol52ActionInsertLogicalFactAdaptor(final ActionInsertFactCol52 action) { PortablePreconditions.checkNotNull("action", action); this.action = action; this.setFactType(action.getFactType()); final ActionFieldValue afv = new ActionFieldValue(); afv.setField(action.getFactField()); afv.setNature(BaseSingleFieldConstraint.TYPE_LITERAL); afv.setType(action.getType()); super.addFieldValue(afv); }
public void onChange(ChangeEvent event) { String fieldName = box.getItemText(box.getSelectedIndex()); String fieldType = oracle.getFieldType(model.getFactType(), fieldName); model.addFieldValue(new ActionFieldValue(fieldName, "", fieldType)); setModified(true); getModeller().refreshWidget(); popup.hide(); } });
public void onChange(ChangeEvent event) { String fieldName = box.getItemText(box.getSelectedIndex()); String fieldType = oracle.getFieldType(model.getFactType(), fieldName); model.addFieldValue(new ActionFieldValue(fieldName, "", fieldType)); setModified(true); getModeller().refreshWidget(); popup.hide(); } });
public ActionInsertFactCol52ActionInsertFactAdaptor(final ActionInsertFactCol52 action) { PortablePreconditions.checkNotNull("action", action); this.action = action; this.setFactType(action.getFactType()); final ActionFieldValue afv = new ActionFieldValue(); afv.setField(action.getFactField()); afv.setNature(BaseSingleFieldConstraint.TYPE_LITERAL); afv.setType(action.getType()); super.addFieldValue(afv); }
private static ActionFieldValue buildActionFieldValue() { ActionFieldValue afv = new ActionFieldValue(); afv.setField( "field" ); afv.setNature( FieldNatureType.TYPE_LITERAL ); afv.setType( "Type" ); afv.setValue( "value" ); return afv; }
@Test public void filtering() { when(field1.getName()).thenReturn("field1"); when(field2.getName()).thenReturn("field2"); final ActionFieldList afl = new ActionInsertFact(); final ActionFieldValue afv = new ActionFieldValue(); afv.setField("field1"); afl.addFieldValue(afv); final ModelField[] result = ModelFieldUtil.getAvailableFieldCompletions(new ModelField[]{field1, field2}, afl); assertEquals(1, result.length); assertEquals(field2, result[0]); } }
@Test public void filtering() { when(field1.getName()).thenReturn("field1"); when(field2.getName()).thenReturn("field2"); final ActionFieldList afl = new ActionInsertFact(); final ActionFieldValue afv = new ActionFieldValue(); afv.setField("field1"); afl.addFieldValue(afv); final ModelField[] result = ModelFieldUtil.getAvailableFieldCompletions(new ModelField[]{field1, field2}, afl); assertEquals(1, result.length); assertEquals(field2, result[0]); } }
private void addBrlInsertActionToModel(final GuidedDecisionTable52 model, final String factType, final String field) { final BRLActionColumn brlAction = new BRLActionColumn(); final ActionInsertFact aif = new ActionInsertFact(factType); final ActionFieldValue afv = new ActionFieldValue(field, "$var", DataType.TYPE_STRING); afv.setNature(FieldNatureType.TYPE_VARIABLE); aif.addFieldValue(afv); brlAction.setDefinition(Collections.singletonList(aif)); BRLActionVariableColumn variableColumn = new BRLActionVariableColumn("$var", DataType.TYPE_STRING, factType, field); brlAction.getChildColumns().add(variableColumn); model.getActionCols().add(brlAction); }
private void doAction(List<LabelledAction> actions, ActionInsertFactCol52 ac, String cell) { LabelledAction a = findByLabelledAction(actions, ac.getBoundName()); if (a == null) { a = new LabelledAction(); a.boundName = ac.getBoundName(); if (!ac.isInsertLogical()) { ActionInsertFact ins = new ActionInsertFact(ac.getFactType()); ins.setBoundName(ac.getBoundName()); a.action = ins; } else { ActionInsertLogicalFact ins = new ActionInsertLogicalFact(ac.getFactType()); ins.setBoundName(ac.getBoundName()); a.action = ins; } actions.add(a); } ActionInsertFact ins = (ActionInsertFact) a.action; ActionFieldValue val = new ActionFieldValue(ac.getFactField(), cell, ac.getType()); ins.addFieldValue(val); }
private ActionInsertFact visitActionFieldList(ActionInsertFact afl) { ActionInsertFact clone = new ActionInsertFact(); clone.setFactType(afl.getFactType()); clone.setBoundName(afl.getBoundName()); for (ActionFieldValue afv : afl.getFieldValues()) { ActionFieldValue afvClone = new ActionFieldValue(); afvClone.setField(afv.getField()); afvClone.setNature(afv.getNature()); afvClone.setType(afv.getType()); afvClone.setValue(afv.getValue()); clone.addFieldValue(afvClone); } return clone; }
private ActionInsertFact visitActionFieldList(ActionInsertFact afl) { ActionInsertFact clone = new ActionInsertFact(); clone.setFactType(afl.getFactType()); clone.setBoundName(afl.getBoundName()); for (ActionFieldValue afv : afl.getFieldValues()) { ActionFieldValue afvClone = new ActionFieldValue(); afvClone.setField(afv.getField()); afvClone.setNature(afv.getNature()); afvClone.setType(afv.getType()); afvClone.setValue(afv.getValue()); clone.addFieldValue(afvClone); } return clone; }
private void doAction(List<LabelledAction> actions, ActionSetFieldCol52 sf, String cell) { LabelledAction a = findByLabelledAction(actions, sf.getBoundName(), sf.isUpdate()); if (a == null) { a = new LabelledAction(); a.boundName = sf.getBoundName(); a.isUpdate = sf.isUpdate(); if (!sf.isUpdate()) { a.action = new ActionSetField(sf.getBoundName()); } else { a.action = new ActionUpdateField(sf.getBoundName()); } actions.add(a); } else if (sf.isUpdate() && !(a.action instanceof ActionUpdateField)) { // lets swap it out for an update as the user has asked for it. ActionSetField old = (ActionSetField) a.action; ActionUpdateField update = new ActionUpdateField(sf.getBoundName()); update.setFieldValues(old.getFieldValues()); a.action = update; } ActionSetField asf = (ActionSetField) a.action; ActionFieldValue val = new ActionFieldValue(sf.getFactField(), cell, sf.getType()); asf.addFieldValue(val); }