Search in sources :

Example 6 with TemplateVariablesChangedEvent

use of org.drools.workbench.screens.guided.rule.client.editor.events.TemplateVariablesChangedEvent in project drools-wb by kiegroup.

the class ActionInsertFactWidget method doLayout.

private void doLayout() {
    layout.clear();
    layout.setWidget(0, 0, getAssertLabel());
    layout.setWidget(1, 0, new HTML("    "));
    layout.getFlexCellFormatter().setColSpan(0, 0, 2);
    FlexTable inner = new FlexTable();
    int col = 0;
    for (int i = 0; i < model.getFieldValues().length; i++) {
        ActionFieldValue val = model.getFieldValues()[i];
        inner.setWidget(i, 0 + col, fieldSelector(val));
        inner.setWidget(i, 1 + col, valueEditor(val));
        final int idx = i;
        Image remove = GuidedRuleEditorImages508.INSTANCE.DeleteItemSmall();
        remove.addClickHandler(new ClickHandler() {

            public void onClick(ClickEvent event) {
                if (Window.confirm(GuidedRuleEditorResources.CONSTANTS.RemoveThisItem())) {
                    model.removeField(idx);
                    setModified(true);
                    getModeller().refreshWidget();
                    // Signal possible change in Template variables
                    TemplateVariablesChangedEvent tvce = new TemplateVariablesChangedEvent(getModeller().getModel());
                    getEventBus().fireEventFromSource(tvce, getModeller().getModel());
                }
            }
        });
        if (!this.readOnly) {
            inner.setWidget(i, 2 + col, remove);
        }
    }
    layout.setWidget(1, 1, inner);
}
Also used : ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ActionFieldValue(org.drools.workbench.models.datamodel.rule.ActionFieldValue) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) FlexTable(com.google.gwt.user.client.ui.FlexTable) HTML(com.google.gwt.user.client.ui.HTML) Image(com.google.gwt.user.client.ui.Image) TemplateVariablesChangedEvent(org.drools.workbench.screens.guided.rule.client.editor.events.TemplateVariablesChangedEvent)

Aggregations

TemplateVariablesChangedEvent (org.drools.workbench.screens.guided.rule.client.editor.events.TemplateVariablesChangedEvent)6 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)4 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)4 Image (com.google.gwt.user.client.ui.Image)4 FlexTable (com.google.gwt.user.client.ui.FlexTable)3 ActionFieldValue (org.drools.workbench.models.datamodel.rule.ActionFieldValue)2 HTML (com.google.gwt.user.client.ui.HTML)1 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)1