Example usage for com.google.gwt.user.client Window confirm

List of usage examples for com.google.gwt.user.client Window confirm

Introduction

In this page you can find the example usage for com.google.gwt.user.client Window confirm.

Prototype

public static boolean confirm(String msg) 

Source Link

Usage

From source file:org.kie.guvnor.guided.rule.client.editor.RuleAttributeWidget.java

License:Apache License

private Image getRemoveMetaIcon(final int idx) {
    Image remove = new Image(ItemImages.INSTANCE.deleteItemSmall());
    remove.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            if (Window.confirm(Constants.INSTANCE.RemoveThisRuleOption())) {
                model.removeMetadata(idx);
                parent.refreshWidget();/*from   www.  j a  v a  2s.co m*/
            }
        }
    });
    return remove;
}

From source file:org.kie.guvnor.guided.rule.client.editor.RuleModeller.java

License:Apache License

/**
 * This adds the widget to the UI, also adding the remove icon.
 *///from  w ww  . j  ava2  s . co  m
private Widget wrapLHSWidget(final RuleModel model, int i, RuleModellerWidget w) {
    final DirtyableFlexTable wrapper = new DirtyableFlexTable();
    final Image remove = GuidedRuleEditorImages508.INSTANCE.DeleteItemSmall();
    remove.setTitle(Constants.INSTANCE.RemoveThisENTIREConditionAndAllTheFieldConstraintsThatBelongToIt());
    final int idx = i;
    remove.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            if (Window.confirm(Constants.INSTANCE.RemoveThisEntireConditionQ())) {
                if (model.removeLhsItem(idx)) {
                    refreshWidget();

                    //Signal possible change in Template variables
                    TemplateVariablesChangedEvent tvce = new TemplateVariablesChangedEvent(model);
                    eventBus.fireEventFromSource(tvce, model);
                } else {
                    ErrorPopup.showMessage(
                            Constants.INSTANCE.CanTRemoveThatItemAsItIsUsedInTheActionPartOfTheRule());
                }
            }
        }
    });

    wrapper.getColumnFormatter().setWidth(0, "100%");
    w.setWidth("100%");
    wrapper.setWidget(0, 0, w);
    if (!(this.lockLHS() || w.isReadOnly()) || !w.isFactTypeKnown()) {
        wrapper.setWidget(0, 1, remove);
        wrapper.getColumnFormatter().setWidth(1, "20px");
    }

    return wrapper;
}

From source file:org.kie.guvnor.guided.rule.client.editor.RuleModeller.java

License:Apache License

/**
 * This adds the widget to the UI, also adding the remove icon.
 *//*w ww.  ja va 2  s  .  co m*/
private Widget wrapRHSWidget(final RuleModel model, int i, RuleModellerWidget w) {
    final DirtyableFlexTable wrapper = new DirtyableFlexTable();
    final Image remove = GuidedRuleEditorImages508.INSTANCE.DeleteItemSmall();
    remove.setTitle(Constants.INSTANCE.RemoveThisAction());
    final int idx = i;
    remove.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            if (Window.confirm(Constants.INSTANCE.RemoveThisItem())) {
                model.removeRhsItem(idx);
                refreshWidget();

                //Signal possible change in Template variables
                TemplateVariablesChangedEvent tvce = new TemplateVariablesChangedEvent(model);
                eventBus.fireEventFromSource(tvce, model);
            }
        }
    });

    //        if ( !(w instanceof ActionRetractFactWidget) ) {
    //            w.setWidth( "100%" );
    //            horiz.setWidth( "100%" );
    //        }

    wrapper.getColumnFormatter().setWidth(0, "100%");
    w.setWidth("100%");
    wrapper.setWidget(0, 0, w);

    if (!(this.lockRHS() || w.isReadOnly()) || !w.isFactTypeKnown()) {
        wrapper.setWidget(0, 1, remove);
        wrapper.getColumnFormatter().setWidth(1, "20px");
    }

    return wrapper;
}

From source file:org.kie.guvnor.guided.rule.client.widget.ActionInsertFactWidget.java

License:Apache License

private void doLayout() {
    layout.clear();//w  w w  . j a  va  2  s  .  com
    layout.setWidget(0, 0, getAssertLabel());
    layout.setWidget(1, 0, new HTML("    "));
    layout.getFlexCellFormatter().setColSpan(0, 0, 2);

    DirtyableFlexTable inner = new DirtyableFlexTable();
    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(Constants.INSTANCE.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);

}

From source file:org.kie.guvnor.guided.rule.client.widget.ActionSetFieldWidget.java

License:Apache License

private void doLayout() {
    layout.clear();//from  ww  w  .j  a  v  a 2 s.c o  m

    for (int i = 0; i < model.getFieldValues().length; i++) {
        ActionFieldValue val = model.getFieldValues()[i];

        layout.setWidget(i, 0, getSetterLabel());
        layout.setWidget(i, 1, fieldSelector(val));
        layout.setWidget(i, 2, valueEditor(val));
        final int idx = i;
        Image remove = GuidedRuleEditorImages508.INSTANCE.DeleteItemSmall();
        remove.addClickHandler(new ClickHandler() {

            public void onClick(ClickEvent event) {
                if (Window.confirm(Constants.INSTANCE.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) {
            layout.setWidget(i, 3, remove);
        }

    }

    if (model.getFieldValues().length == 0) {
        HorizontalPanel h = new HorizontalPanel();
        h.add(getSetterLabel());
        if (!this.readOnly) {
            Image image = GuidedRuleEditorImages508.INSTANCE.Edit();
            image.setAltText(Constants.INSTANCE.AddFirstNewField());
            image.setTitle(Constants.INSTANCE.AddFirstNewField());
            image.addClickHandler(new ClickHandler() {

                public void onClick(ClickEvent sender) {
                    showAddFieldPopup(sender);
                }
            });
            h.add(image);
        }
        layout.setWidget(0, 0, h);
    }

    //layout.setWidget( 0, 1, inner );

}

From source file:org.kie.guvnor.guided.rule.client.widget.CompositeFactPatternWidget.java

License:Apache License

/**
 * Wraps a RuleModellerWidget with an icon to delete the pattern
 *///from  w  ww  . ja  v  a  2  s. c om
private Widget wrapLHSWidget(final CompositeFactPattern model, int i, RuleModellerWidget w) {
    DirtyableHorizontalPane horiz = new DirtyableHorizontalPane();

    final Image remove = GuidedRuleEditorImages508.INSTANCE.DeleteItemSmall();
    remove.setTitle(Constants.INSTANCE.RemoveThisENTIREConditionAndAllTheFieldConstraintsThatBelongToIt());
    final int idx = i;
    remove.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            if (Window.confirm(Constants.INSTANCE.RemoveThisEntireConditionQ())) {
                if (pattern.removeFactPattern(idx)) {
                    getModeller().refreshWidget();
                }
            }
        }
    });

    horiz.setWidth("100%");
    w.setWidth("100%");

    horiz.add(w);
    if (!(getModeller().lockLHS() || w.isReadOnly())) {
        horiz.add(remove);
    }

    return horiz;
}

From source file:org.kie.guvnor.guided.rule.client.widget.FactPatternWidget.java

License:Apache License

/**
 * This will show the constraint editor - allowing field constraints to be
 * nested etc.//from   w w w. ja  va  2s  .co m
 */
private Widget compositeFieldConstraintEditor(final CompositeFieldConstraint constraint) {
    FlexTable t = new FlexTable();
    String desc = null;

    ClickHandler click = new ClickHandler() {

        public void onClick(ClickEvent event) {
            popupCreator.showPatternPopupForComposite((Widget) event.getSource(), constraint);
        }
    };

    if (constraint.getCompositeJunctionType().equals(CompositeFieldConstraint.COMPOSITE_TYPE_AND)) {
        desc = Constants.INSTANCE.AllOf() + ":";
    } else {
        desc = Constants.INSTANCE.AnyOf() + ":";
    }

    t.setWidget(0, 0, new ClickableLabel(desc, click, !this.readOnly));
    t.getFlexCellFormatter().setColSpan(0, 0, 2);

    FieldConstraint[] nested = constraint.getConstraints();
    DirtyableFlexTable inner = new DirtyableFlexTable();
    if (nested != null) {
        for (int i = 0; i < nested.length; i++) {
            this.renderFieldConstraint(inner, i, nested[i], constraint, true, 0);
            //add in remove icon here...
            final int currentRow = i;
            Image clear = GuidedRuleEditorImages508.INSTANCE.DeleteItemSmall();
            clear.setTitle(Constants.INSTANCE.RemoveThisNestedRestriction());
            clear.addClickHandler(new ClickHandler() {

                public void onClick(ClickEvent event) {
                    if (Window.confirm(Constants.INSTANCE.RemoveThisItemFromNestedConstraint())) {
                        setModified(true);
                        constraint.removeConstraint(currentRow);
                        getModeller().refreshWidget();
                    }
                }
            });
            if (!this.readOnly) {
                //This used to be 5 and Connectives were not rendered
                inner.setWidget(i, 6, clear);
            }
        }
    }

    t.setWidget(1, 1, inner);
    t.setWidget(1, 0, new HTML("&nbsp;&nbsp;&nbsp;&nbsp;"));
    return t;
}

From source file:org.kie.guvnor.guided.scorecard.client.editor.GuidedScoreCardEditor.java

License:Apache License

private void removeCharacteristic(final DirtyableFlexTable selectedTable) {
    if (selectedTable != null) {
        final TextBox tbName = (TextBox) selectedTable.getWidget(0, 1);
        String name = tbName.getValue();
        if (name == null || name.trim().length() == 0) {
            name = "Untitled";
        }//from ww  w.ja  v a  2 s  . co  m
        final String msg = Constants.INSTANCE.promptDeleteCharacteristic0(name);
        if (Window.confirm(msg)) {
            characteristicsTables.remove(selectedTable);
            characteristicsAttrMap.remove(selectedTable);
            final Widget parent = selectedTable.getParent().getParent();
            final int i = characteristicsPanel.getWidgetIndex(parent);
            characteristicsPanel.remove(parent);
            characteristicsPanel.remove(i);
        }
    }
}

From source file:org.kie.guvnor.guided.scorecard.client.editor.GuidedScoreCardEditor.java

License:Apache License

private Widget addAttributeCellTable(final DirtyableFlexTable cGrid, final Characteristic characteristic) {
    final CellTable<Attribute> attributeCellTable = new CellTable<Attribute>();
    final List<String> operators = new ArrayList<String>();
    String dataType;/*from  ww w.  j  a va2  s  . c o  m*/
    if (characteristic == null) {
        dataType = "String";
    } else {
        dataType = characteristic.getDataType();
    }

    if ("String".equalsIgnoreCase(dataType)) {
        operators.addAll(Arrays.asList(stringOperators));
    } else if ("boolean".equalsIgnoreCase(dataType)) {
        operators.addAll(Arrays.asList(booleanOperators));
    } else {
        operators.addAll(Arrays.asList(numericOperators));
    }

    //Operators column
    final DynamicSelectionCell categoryCell = new DynamicSelectionCell(operators);
    final Column<Attribute, String> operatorColumn = new Column<Attribute, String>(categoryCell) {
        public String getValue(final Attribute object) {
            return object.getOperator();
        }
    };
    operatorColumn.setFieldUpdater(new FieldUpdater<Attribute, String>() {
        public void update(int index, Attribute object, String value) {
            object.setOperator(value);
            attributeCellTable.redraw();
        }
    });

    //Value column
    final Column<Attribute, String> valueColumn = new Column<Attribute, String>(new CustomEditTextCell()) {
        public String getValue(final Attribute attribute) {
            return attribute.getValue();
        }
    };
    valueColumn.setFieldUpdater(new FieldUpdater<Attribute, String>() {
        public void update(int index, Attribute object, String value) {
            object.setValue(value);
            attributeCellTable.redraw();
        }
    });

    //Partial Score column
    final EditTextCell partialScoreCell = new EditTextCell();
    final Column<Attribute, String> partialScoreColumn = new Column<Attribute, String>(partialScoreCell) {
        public String getValue(final Attribute attribute) {
            return "" + attribute.getPartialScore();
        }
    };
    partialScoreColumn.setFieldUpdater(new FieldUpdater<Attribute, String>() {
        public void update(int index, Attribute object, String value) {
            try {
                double d = Double.parseDouble(value);
                object.setPartialScore(d);
            } catch (Exception e1) {
                partialScoreCell.clearViewData(object);
            }
            attributeCellTable.redraw();
        }
    });

    //Reason Code column
    final Column<Attribute, String> reasonCodeColumn = new Column<Attribute, String>(new EditTextCell()) {
        public String getValue(final Attribute attribute) {
            return attribute.getReasonCode();
        }
    };
    reasonCodeColumn.setFieldUpdater(new FieldUpdater<Attribute, String>() {
        public void update(int index, Attribute object, String value) {
            object.setReasonCode(value);
            attributeCellTable.redraw();
        }
    });

    final ActionCell.Delegate<Attribute> delegate = new ActionCell.Delegate<Attribute>() {
        public void execute(final Attribute attribute) {
            if (Window.confirm(Constants.INSTANCE.promptDeleteAttribute())) {
                final List<Attribute> list = characteristicsAttrMap.get(cGrid).getList();
                list.remove(attribute);
                ((ListBox) cGrid.getWidget(2, 0)).setEnabled(list.size() == 0);
                ((ListBox) cGrid.getWidget(2, 1)).setEnabled(list.size() == 0);
                ((Button) cGrid.getWidget(0, 3)).setEnabled(list.size() != 2);
                attributeCellTable.redraw();
            }
        }
    };

    final Cell<Attribute> actionCell = new ActionCell<Attribute>(Constants.INSTANCE.remove(), delegate);
    final Column<Attribute, String> actionColumn = new IdentityColumn(actionCell);

    // Add the columns.
    attributeCellTable.addColumn(operatorColumn, Constants.INSTANCE.operator());
    attributeCellTable.addColumn(valueColumn, Constants.INSTANCE.value());
    attributeCellTable.addColumn(partialScoreColumn, Constants.INSTANCE.partialScore());
    attributeCellTable.addColumn(reasonCodeColumn, Constants.INSTANCE.reasonCode());
    attributeCellTable.addColumn(actionColumn, Constants.INSTANCE.actions());
    attributeCellTable.setWidth("100%", true);

    attributeCellTable.setColumnWidth(operatorColumn, 5.0, Style.Unit.PCT);
    attributeCellTable.setColumnWidth(valueColumn, 10.0, Style.Unit.PCT);
    attributeCellTable.setColumnWidth(partialScoreColumn, 10.0, Style.Unit.PCT);
    attributeCellTable.setColumnWidth(reasonCodeColumn, 10.0, Style.Unit.PCT);
    attributeCellTable.setColumnWidth(actionColumn, 5.0, Style.Unit.PCT);

    ListDataProvider<Attribute> dataProvider = new ListDataProvider<Attribute>();
    dataProvider.addDataDisplay(attributeCellTable);
    characteristicsAttrMap.put(cGrid, dataProvider);
    return (attributeCellTable);
}

From source file:org.kie.guvnor.m2repo.client.editor.JarListEditor.java

License:Apache License

@UiHandler("deleteSelectedJarButton")
void deleteSelectedJar(ClickEvent e) {
    if (getSelectedJars() == null) {
        Window.alert("Please Select A Jar To Delete");
        return;/* w ww.j a va 2  s.  c o  m*/
    }
    if (!Window.confirm("AreYouSureYouWantToDeleteTheseItems")) {
        return;
    }
    m2RepoService.call(new RemoteCallback<Void>() {
        @Override
        public void callback(Void v) {
            Window.alert("Deleted successfully");
            pagedJarTable.refresh();
        }
    }).deleteJar(getSelectedJars());
}