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.commons.ui.client.popups.file.DeletePopup.java

License:Apache License

public DeletePopup(final CommandWithCommitMessage command) {
    super(CommonImages.INSTANCE.edit(), CommonConstants.INSTANCE.DeletePopupTitle());

    checkNotNull("command", command);

    //Make sure it appears on top of other popups
    getElement().getStyle().setZIndex(Integer.MAX_VALUE);
    setGlassEnabled(true);// w w w  .j ava  2 s  .c  o  m

    checkInCommentTextBox.setTitle(CommonConstants.INSTANCE.CheckInComment());
    checkInCommentTextBox.setWidth("200px");
    addAttribute(CommonConstants.INSTANCE.CheckInCommentColon(), checkInCommentTextBox);

    final HorizontalPanel hp = new HorizontalPanel();
    final Button create = new Button(CommonConstants.INSTANCE.DeletePopupDelete());
    create.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent arg0) {

            if (!Window.confirm(CommonConstants.INSTANCE.DeletePopupRenameNamePrompt())) {
                return;
            }

            hide();
            command.execute(checkInCommentTextBox.getText());
        }
    });
    hp.add(create);

    final Button cancel = new Button("Cancel");
    cancel.addClickHandler(new ClickHandler() {
        public void onClick(final ClickEvent arg0) {
            hide();
        }
    });
    hp.add(new HTML("&nbsp"));
    hp.add(cancel);
    addAttribute("", hp);

}

From source file:org.kie.guvnor.commons.ui.client.save.SavePopup.java

License:Apache License

public SavePopup(final CommandWithCommitMessage command) {
    super(CommonImages.INSTANCE.edit(), "Save this item");

    checkNotNull("command", command);

    checkInCommentTextBox.setTitle(CommonConstants.INSTANCE.AddAnOptionalCheckInComment());
    checkInCommentTextBox.setWidth("200px");
    addAttribute("Check in comment:", checkInCommentTextBox);

    final HorizontalPanel hp = new HorizontalPanel();
    final Button create = new Button("Save");
    create.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent arg0) {

            if (!Window.confirm("Are you sure you want to save this asset?")) {
                return;
            }/*  www  . java2  s .  com*/

            hide();
            command.execute(checkInCommentTextBox.getText());
        }
    });
    hp.add(create);

    Button cancel = new Button("Cancel");
    cancel.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent arg0) {
            hide();
        }
    });
    hp.add(new HTML("&nbsp"));
    hp.add(cancel);
    addAttribute("", hp);
}

From source file:org.kie.guvnor.factmodel.client.editor.FactEditorPopup.java

License:Apache License

public void show() {

    final FormStylePopup pop = new FormStylePopup();
    pop.setTitle(Constants.INSTANCE.Name());
    HorizontalPanel changeName = new HorizontalPanel();
    final TextBox name = new TextBox();
    name.setText(factModel.getName());/*from ww w  . j  av  a  2 s .com*/
    changeName.add(name);

    int selectedIndex = 0;
    lstSuperTypes.addItem(Constants.INSTANCE.DoesNotExtend());

    //Populate super-types
    if (superTypeFactModels != null) {
        Collections.sort(superTypeFactModels, byNameAscendingComparator);
        for (FactMetaModel fmm : superTypeFactModels) {
            if (!fmm.getName().equals(factModel.getName())) {
                lstSuperTypes.addItem(fmm.getName());
                if (factModel.getSuperType() != null && factModel.getSuperType().equals(fmm.getName())) {
                    selectedIndex = lstSuperTypes.getItemCount() - 1;
                }
            }
        }
        lstSuperTypes.setSelectedIndex(selectedIndex);
    }

    //If no super-types available disable drop-down
    if (lstSuperTypes.getItemCount() == 1) {
        lstSuperTypes.setEnabled(false);
    }

    lstSuperTypes.addChangeHandler(new ChangeHandler() {

        public void onChange(ChangeEvent event) {
            if (lstSuperTypes.getSelectedIndex() <= 0) {
                factModel.setSuperType(null);
            } else {
                String oldSuperType = factModel.getSuperType();
                String newSuperType = lstSuperTypes.getItemText(lstSuperTypes.getSelectedIndex());
                factModel.setSuperType(newSuperType);
                if (createsCircularDependency(newSuperType)) {
                    Window.alert(Constants.INSTANCE.CreatesCircularDependency(name.getText()));
                    factModel.setSuperType(oldSuperType);
                    lstSuperTypes.setSelectedIndex(getSelectedIndex(oldSuperType));
                    return;
                } else {
                    factModel.setSuperType(newSuperType);
                }
            }

        }

    });

    Button nameButton = new Button(Constants.INSTANCE.OK());

    nameButton.addKeyPressHandler(new NoSpaceKeyPressHandler());

    nameButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            String factName = name.getText();
            if (!isNameValid(factName)) {
                Window.alert(Constants.INSTANCE.InvalidModelName(factName));
                return;
            }
            if (doesTheNameExist(factName)) {
                Window.alert(Constants.INSTANCE.NameTakenForModel(factName));
                return;
            }
            if (factModelAlreadyHasAName(factName)) {
                if (isTheUserSureHeWantsToChangeTheName()) {
                    setNameAndClose();
                }
            } else {
                setNameAndClose();
            }
        }

        private boolean isNameValid(String name) {
            if (name == null || "".equals(name)) {
                return false;
            }
            return VALID_NAME.test(name);
        }

        private boolean factModelAlreadyHasAName(String name) {
            return factModel.getName() != null && !factModel.getName().equals(name);
        }

        private void setNameAndClose() {
            String oldName = factModel.getName();
            String newName = name.getText();

            modelNameHelper.changeNameInModelNameHelper(oldName, newName);
            factModel.setName(newName);

            okCommand.execute();

            pop.hide();
        }

        private boolean isTheUserSureHeWantsToChangeTheName() {
            return Window.confirm(Constants.INSTANCE.ModelNameChangeWarning());
        }

        private boolean doesTheNameExist(String name) {
            //The name may not have changed
            if (factModel.getName() != null && factModel.getName().equals(name)) {
                return false;
            }
            return !modelNameHelper.isUniqueName(name);
        }
    });

    pop.addAttribute(Constants.INSTANCE.Name(), changeName);
    pop.addAttribute(Constants.INSTANCE.TypeExtends(), lstSuperTypes);
    pop.addRow(nameButton);

    pop.show();
}

From source file:org.kie.guvnor.guided.dtable.client.widget.GuidedDecisionTableWidget.java

License:Apache License

private Widget removeAction(final ActionCol52 c) {
    if (c instanceof LimitedEntryBRLActionColumn) {
        Image image = ImageResources508.INSTANCE.DeleteItemSmall();
        image.setAltText(Constants.INSTANCE.RemoveThisActionColumn());
        return new ImageButton(image, Constants.INSTANCE.RemoveThisActionColumn(), new ClickHandler() {
            public void onClick(ClickEvent w) {
                String cm = Constants.INSTANCE.DeleteActionColumnWarning(c.getHeader());
                if (Window.confirm(cm)) {
                    dtable.deleteColumn((LimitedEntryBRLActionColumn) c);
                    refreshActionsWidget();
                }/* ww  w  . jav a2  s  . c o m*/
            }
        });

    } else if (c instanceof BRLActionColumn) {
        Image image = ImageResources508.INSTANCE.DeleteItemSmall();
        image.setAltText(Constants.INSTANCE.RemoveThisActionColumn());
        return new ImageButton(image, Constants.INSTANCE.RemoveThisActionColumn(), new ClickHandler() {
            public void onClick(ClickEvent w) {
                String cm = Constants.INSTANCE.DeleteActionColumnWarning(c.getHeader());
                if (Window.confirm(cm)) {
                    dtable.deleteColumn((BRLActionColumn) c);
                    refreshActionsWidget();
                }
            }
        });

    }
    Image image = ImageResources508.INSTANCE.DeleteItemSmall();
    image.setAltText(Constants.INSTANCE.RemoveThisActionColumn());
    return new ImageButton(image, Constants.INSTANCE.RemoveThisActionColumn(), new ClickHandler() {
        public void onClick(ClickEvent w) {
            String cm = Constants.INSTANCE.DeleteActionColumnWarning(c.getHeader());
            if (Window.confirm(cm)) {
                dtable.deleteColumn(c);
                refreshActionsWidget();
            }
        }
    });
}

From source file:org.kie.guvnor.guided.dtable.client.widget.GuidedDecisionTableWidget.java

License:Apache License

private Widget removeCondition(final ConditionCol52 c) {
    Image image = ImageResources508.INSTANCE.DeleteItemSmall();
    image.setAltText(Constants.INSTANCE.RemoveThisConditionColumn());
    if (c instanceof LimitedEntryBRLConditionColumn) {
        return new ImageButton(image, Constants.INSTANCE.RemoveThisConditionColumn(), new ClickHandler() {
            public void onClick(ClickEvent w) {
                if (!canConditionBeDeleted((LimitedEntryBRLConditionColumn) c)) {
                    Window.alert(Constants.INSTANCE.UnableToDeleteConditionColumn(c.getHeader()));
                    return;
                }/*from   ww w. j  a  v a 2s  .c om*/
                String cm = Constants.INSTANCE.DeleteConditionColumnWarning(c.getHeader());
                if (Window.confirm(cm)) {
                    dtable.deleteColumn((LimitedEntryBRLConditionColumn) c);
                    refreshConditionsWidget();
                }
            }
        });

    } else if (c instanceof BRLConditionColumn) {
        return new ImageButton(image, Constants.INSTANCE.RemoveThisConditionColumn(), new ClickHandler() {
            public void onClick(ClickEvent w) {
                if (!canConditionBeDeleted((BRLConditionColumn) c)) {
                    Window.alert(Constants.INSTANCE.UnableToDeleteConditionColumn(c.getHeader()));
                    return;
                }
                String cm = Constants.INSTANCE.DeleteConditionColumnWarning(c.getHeader());
                if (Window.confirm(cm)) {
                    dtable.deleteColumn((BRLConditionColumn) c);
                    refreshConditionsWidget();
                }
            }
        });

    }
    return new ImageButton(image, Constants.INSTANCE.RemoveThisConditionColumn(), new ClickHandler() {
        public void onClick(ClickEvent w) {
            if (!canConditionBeDeleted(c)) {
                Window.alert(Constants.INSTANCE.UnableToDeleteConditionColumn(c.getHeader()));
                return;
            }
            String cm = Constants.INSTANCE.DeleteConditionColumnWarning(c.getHeader());
            if (Window.confirm(cm)) {
                dtable.deleteColumn(c);
                refreshConditionsWidget();
            }
        }
    });
}

From source file:org.kie.guvnor.guided.dtable.client.widget.GuidedDecisionTableWidget.java

License:Apache License

private Widget removeAttr(final AttributeCol52 at) {
    Image image = ImageResources508.INSTANCE.DeleteItemSmall();
    image.setAltText(Constants.INSTANCE.RemoveThisAttribute());

    return new ImageButton(image, Constants.INSTANCE.RemoveThisAttribute(), new ClickHandler() {
        public void onClick(ClickEvent w) {
            String ms = Constants.INSTANCE.DeleteActionColumnWarning(at.getAttribute());
            if (Window.confirm(ms)) {
                dtable.deleteColumn(at);
                refreshAttributeWidget();
            }// ww w  .j av  a2  s .  co  m
        }
    });

}

From source file:org.kie.guvnor.guided.dtable.client.widget.GuidedDecisionTableWidget.java

License:Apache License

private Widget removeMeta(final MetadataCol52 md) {
    Image image = ImageResources508.INSTANCE.DeleteItemSmall();
    image.setAltText(Constants.INSTANCE.RemoveThisMetadata());

    return new ImageButton(image, Constants.INSTANCE.RemoveThisMetadata(), new ClickHandler() {
        public void onClick(ClickEvent w) {
            String ms = Constants.INSTANCE.DeleteActionColumnWarning(md.getMetadata());
            if (Window.confirm(ms)) {
                dtable.deleteColumn(md);
                refreshAttributeWidget();
            }/*from   w  w  w. jav  a2s  .  c  o  m*/
        }
    });
}

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

License:Apache License

private Widget wrap(Widget w) {
    HorizontalPanel wrapper = new HorizontalPanel();
    Image clear = GuidedRuleEditorImages508.INSTANCE.DeleteItemSmall();
    clear.setAltText(Constants.INSTANCE.RemoveActionValueDefinition());
    clear.setTitle(Constants.INSTANCE.RemoveActionValueDefinition());
    clear.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            //Reset Constraint's value and value type
            if (Window.confirm(Constants.INSTANCE.RemoveActionValueDefinitionQuestion())) {
                value.setNature(FieldNatureType.TYPE_UNDEFINED);
                value.setValue(null);/*from   ww w  .  j a  va  2 s .  c o m*/
                doTypeChosen();
            }
        }

    });

    wrapper.add(w);
    if (!this.readOnly) {
        wrapper.add(clear);
        wrapper.setCellVerticalAlignment(clear, HasVerticalAlignment.ALIGN_MIDDLE);
    }
    return wrapper;
}

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

License:Apache License

private Widget wrap(Widget w) {
    if (this.readOnly) {
        return w;
    }/*  ww w .  j av  a  2  s .  c om*/
    HorizontalPanel wrapper = new HorizontalPanel();
    Image clear = GuidedRuleEditorImages508.INSTANCE.DeleteItemSmall();
    clear.setTitle(Constants.INSTANCE.RemoveConstraintValueDefinition());
    clear.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            //Reset Constraint's value and value type
            if (Window.confirm(Constants.INSTANCE.RemoveConstraintValueDefinitionQuestion())) {
                constraint.setConstraintValueType(BaseSingleFieldConstraint.TYPE_UNDEFINED);
                constraint.setValue(null);
                constraint.clearParameters();
                constraint.setExpressionValue(new ExpressionFormLine());
                doTypeChosen();
            }
        }

    });

    wrapper.add(w);
    if (!this.readOnly) {
        wrapper.add(clear);
        wrapper.setCellVerticalAlignment(clear, HasVerticalAlignment.ALIGN_MIDDLE);
    }
    return wrapper;
}

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

License:Apache License

private Image getRemoveIcon(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.removeAttribute(idx);
                parent.refreshWidget();//www. j a v a2 s  .c om
            }
        }
    });
    return remove;
}