Search in sources :

Example 6 with CallFieldValue

use of org.drools.workbench.models.testscenarios.shared.CallFieldValue in project drools-wb by kiegroup.

the class CallMethodWidget method showAddFieldPopup.

protected void showAddFieldPopup(final Widget w) {
    final FormStylePopup popup = new FormStylePopup(TestScenarioAltedImages.INSTANCE.Wizard(), TestScenarioConstants.INSTANCE.ChooseAMethodToInvoke());
    ListBox box = new ListBox();
    box.addItem("...");
    for (int i = 0; i < fieldCompletionTexts.length; i++) {
        box.addItem(fieldCompletionTexts[i], fieldCompletionValues[i]);
    }
    box.setSelectedIndex(0);
    popup.addAttribute(TestScenarioConstants.INSTANCE.ChooseAMethodToInvoke(), box);
    box.addChangeHandler(new ChangeHandler() {

        public void onChange(ChangeEvent event) {
            mCall.setState(ActionCallMethod.TYPE_DEFINED);
            ListBox sourceW = (ListBox) event.getSource();
            final String methodName = sourceW.getItemText(sourceW.getSelectedIndex());
            final String methodNameWithParams = sourceW.getValue(sourceW.getSelectedIndex());
            mCall.setMethodName(methodName);
            oracle.getMethodParams(variableClass, methodNameWithParams, new Callback<List<String>>() {

                @Override
                public void callback(final List<String> fieldList) {
                    // String fieldType = oracle.getFieldType( variableClass, fieldName );
                    int i = 0;
                    for (String fieldParameter : fieldList) {
                        mCall.addFieldValue(new CallFieldValue(methodName, String.valueOf(i), fieldParameter));
                        i++;
                    }
                    parent.renderEditor();
                    popup.hide();
                }
            });
        }
    });
    popup.show();
}
Also used : Callback(org.uberfire.client.callbacks.Callback) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) FormStylePopup(org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup) List(java.util.List) ListBox(org.gwtbootstrap3.client.ui.ListBox) CallFieldValue(org.drools.workbench.models.testscenarios.shared.CallFieldValue)

Aggregations

CallFieldValue (org.drools.workbench.models.testscenarios.shared.CallFieldValue)6 HashMap (java.util.HashMap)3 Cheesery (org.drools.workbench.models.testscenarios.backend.Cheesery)3 CallMethod (org.drools.workbench.models.testscenarios.shared.CallMethod)3 Test (org.junit.Test)3 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)1 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)1 FlexTable (com.google.gwt.user.client.ui.FlexTable)1 List (java.util.List)1 ListBox (org.gwtbootstrap3.client.ui.ListBox)1 Callback (org.uberfire.client.callbacks.Callback)1 FormStylePopup (org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup)1