Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Copyright 2012 JBoss Inc
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  *       http://www.apache.org/licenses/LICENSE-2.0
  *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.drools.workbench.screens.testscenario.client;
public class FieldSelectorWidget
        implements IsWidgetClickHandler {
    private final Field field;
    private final FieldConstraintHelper helper;
    private final ScenarioParentWidget parent;
    private final Image clickMe;
    public FieldSelectorWidget(Field field,
                               FieldConstraintHelper helper,
                               ScenarioParentWidget parent) {
        this. = field;
        this. = helper;
        this. = parent;
        this. = ..Edit();
        this..addClickHandler(this);
    }
    @Override
    public Widget asWidget() {
        return ;
    }
    @Override
    public void onClick(ClickEvent event) {
        TypeChoiceFormPopup typeChoiceForm = new TypeChoiceFormPopup();
        typeChoiceForm.addSelectionHandler(new SelectionHandler<Integer>() {
            @Override
            public void onSelection(SelectionEvent<IntegerselectionEvent) {
                .replaceFieldWith(createField(selectionEvent));
                .renderEditor();
            }
        });
        typeChoiceForm.show();
    }
    private Field createField(SelectionEvent<IntegerselectionEvent) {
        if (selectionEvent.getSelectedItem() == .) {
            return new FactAssignmentField(.getName(), .getFieldType());
        } else {
            if (selectionEvent.getSelectedItem() == .) {
                CollectionFieldData collectionFieldData = new CollectionFieldData();
                collectionFieldData.setName(.getName());
                return collectionFieldData;
            } else {
                FieldData fieldData = new FieldData(.getName(), "");
                fieldData.setNature(selectionEvent.getSelectedItem());
                return fieldData;
            }
        }
    }
New to GrepCode? Check out our FAQ X