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:com.google.gwt.gen2.demo.fasttree.client.FastTreeDemo.java

License:Apache License

private Widget cancelEventTree() {
    final FastTree cancelEventTree = new FastTree();
    FastTreeItem firstBranch = cancelEventTree.addItem("Select Me!");
    firstBranch.addItem("No! Select Me!");
    firstBranch.addItem("No! Select Me!");
    firstBranch.addItem("No! Select Me!");
    FastTreeItem secondBranch = cancelEventTree.addItem("Don't Select me!");
    secondBranch.addItem("Not me!");
    secondBranch.addItem("Not me!");
    secondBranch.addItem("Not me!");

    cancelEventTree.addBeforeSelectionHandler(new BeforeSelectionHandler<FastTreeItem>() {
        public void onBeforeSelection(BeforeSelectionEvent<FastTreeItem> event) {
            if (!Window.confirm("Continue?")) {
                event.cancel();//from w w  w  . ja  va2  s  . c o m
            }
        }
    });

    return cancelEventTree;
}

From source file:com.google.gwt.phono.test.client.model.ConversationModel.java

private void initPhono() {
    phono = new Phono(API_KEY, new PhonoHandler() {

        @Override/*from  w w  w .j av a2s .c o  m*/
        public void onRing(RingEvent event) {
        }

        @Override
        public void onPhonoUnready(PhonoUnreadyEvent event) {
            Window.alert("Phono initialization failed.");
        }

        @Override
        public void onPhonoReady(com.google.gwt.phono.client.event.PhonoReadyEvent event) {
            EVENT_BUS.fireEvent(new PhonoReadyEvent(event.getPhono()));
        }

        @Override
        public void onMessage(MessageEvent event) {
            EVENT_BUS.fireEvent(new MessageReceivedEvent(event.getMessage()));
        }

        @Override
        public void onIncomingCall(IncomingCallEvent event) {
            boolean answer = Window.confirm("Appel, voulez-vous dcrocher?");
            if (answer) {
                event.getCall().answer();
            }
        }

        @Override
        public void onHangup(HangupEvent event) {
            Window.alert("Call ended by remote user ");
        }

        @Override
        public void onError(ErrorEvent event) {
            Window.alert("Error : " + event.getReason());
        }

        @Override
        public void onAnswer(AnswerEvent event) {
            Window.alert("Call answered by remote user ");
        }
    });
}

From source file:com.google.gwt.sample.expenses.client.place.AbstractProxyEditActivity.java

License:Apache License

public void cancelClicked() {
    String unsavedChangesWarning = mayStop();
    if ((unsavedChangesWarning == null) || Window.confirm(unsavedChangesWarning)) {
        editorDriver = null;/* w w  w  . ja v a 2 s  . com*/
        exit(false);
    }
}

From source file:com.google.gwt.sample.feedreader.client.Configuration.java

License:Apache License

/**
 * Add a pipe-delimited set of feed URLs to the configuration.
 * //from  w  ww .  j  a va 2  s.c  o m
 * @return <code>true</code> iff at least one new feed was added.
 */
public boolean importFeeds(String token) {
    Set toAdd = new HashSet(Arrays.asList(token.split("\\|")));
    List feeds = getFeeds();
    Feed toReturn = null;

    out: for (Iterator i = toAdd.iterator(); i.hasNext();) {
        String url = (String) i.next();
        for (Iterator j = feeds.iterator(); j.hasNext();) {
            Feed feed = (Feed) j.next();
            if (feed.getUrl().equals(url)) {
                i.remove();
                if (toReturn == null) {
                    toReturn = feed;
                }
                continue out;
            }
        }
    }

    if (toAdd.size() == 0) {
        return false;
    }

    boolean ok = Window.confirm("Do you wish to import " + toAdd.size() + " feeds?");

    if (ok) {
        for (Iterator i = toAdd.iterator(); i.hasNext();) {
            String url = (String) i.next();
            Feed f = (Feed) GWT.create(Feed.class);

            f.setUrl(url);
            f.setTitle(url);
            f.setLastArticle(0);

            if (toReturn == null) {
                toReturn = f;
            }
            feeds.add(f);
        }
    }

    save();

    return true;
}

From source file:com.google.gwt.sample.feedreader.client.ConfigurationPanel.java

License:Apache License

public ConfigurationPanel(final Configuration configuration, final ManifestPanel parent) {
    super("Configuration", parent);
    this.configuration = configuration;
    this.parent = parent;
    final List feeds = configuration.getFeeds();

    setEditCommand("Reset", "Delete all application settings", new Command() {
        public void execute() {
            if (!Window.confirm("Do you wish to reset the application?")) {
                return;
            }//from w w  w.j  a  va2s .  c  om
            configuration.reset();
            parent.setDirty();
            exit();
        }
    });

    add(new PanelLabel("About...", new Command() {
        public void execute() {
            History.newItem("about");
        }
    }));

    // Create the search option
    {
        UnsunkLabel title = new UnsunkLabel("Search for new feeds...");
        title.addStyleName("title");
        UnsunkLabel info = new UnsunkLabel("Add feeds by searching.");
        info.addStyleName("snippit");

        FlowPanel vp = new FlowPanel();
        vp.add(title);
        vp.add(info);

        add(new PanelLabel(vp, new Command() {
            public void execute() {
                final String query = Window.prompt("Search query", "");
                if ((query != null) && (query.length() > 0)) {
                    History.newItem("search||" + URL.encodeComponent(query));
                }
            }
        }));
    }

    // Add all of the feeds to the panel.
    for (Iterator i = feeds.iterator(); i.hasNext();) {
        final Configuration.Feed feed = (Configuration.Feed) i.next();
        addFeed(feed);
    }
}

From source file:com.google.gwt.sample.feedreader.client.ConfigurationPanel.java

License:Apache License

/**
 * Remove a feed's representation from the UI.
 *///from  ww w  .ja  v a 2  s.co m
protected void remove(Configuration.Feed feed) {
    if (Window.confirm("Do you wish to remove the feed?")) {
        configuration.getFeeds().remove(feed);
        remove((PanelLabel) feedLabels.get(feed));
        parent.setDirty();
    }
}

From source file:com.google.gwt.sample.Marketing.client.Marketing.java

public void onModuleLoad() {

    linkPanel.add(link1);/* ww w . j av  a 2s.c  o  m*/
    linkPanel.add(link2);
    linkPanel.add(link3);
    linkPanel.add(link4);
    adminlinkPanel.add(link5);
    adminlinkPanel.add(link6);
    adminlinkPanel.setVisible(false);

    RootPanel.get("leftnav").add(linkPanel);
    RootPanel.get("leftnav").add(adminlinkPanel);

    History.addValueChangeHandler(this);

    if (History.getToken().isEmpty()) {
        History.newItem("productlist");
    } else {
        changePage(History.getToken());
    }

    addProductFlexTable.setText(0, 0, "Product ID");
    addProductFlexTable.setWidget(0, 1, pidTextBox);
    addProductFlexTable.setText(1, 0, "Model");
    addProductFlexTable.setWidget(1, 1, modelTextBox);
    addProductFlexTable.setText(2, 0, "Price");
    addProductFlexTable.setWidget(2, 1, priceTextBox);
    addProductFlexTable.setText(3, 0, "Discount");
    addProductFlexTable.setWidget(3, 1, discountTextBox);
    addProductFlexTable.setText(4, 0, "Image");
    addProductFlexTable.setWidget(4, 1, imgTextBox);
    addProductFlexTable.setWidget(5, 1, addProductButton);

    addProductFlexTable.setCellPadding(6);

    addProductFlexTable.getCellFormatter().addStyleName(0, 0, "phoneListHeader");
    addProductFlexTable.getCellFormatter().addStyleName(1, 0, "phoneListHeader");
    addProductFlexTable.getCellFormatter().addStyleName(2, 0, "phoneListHeader");
    addProductFlexTable.getCellFormatter().addStyleName(3, 0, "phoneListHeader");
    addProductFlexTable.getCellFormatter().addStyleName(4, 0, "phoneListHeader");
    addProductFlexTable.addStyleName("phoneList");

    addProductButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            insertProduct(Integer.parseInt(pidTextBox.getText()), modelTextBox.getText(),
                    Double.parseDouble(priceTextBox.getText()), Integer.parseInt(discountTextBox.getText()),
                    imgTextBox.getText());

        }
    });

    accountFlexTable.setText(0, 0, "First name");
    accountFlexTable.setWidget(0, 1, firstnameTextBox);
    accountFlexTable.setText(1, 0, "Last name");
    accountFlexTable.setWidget(1, 1, lastnameTextBox);
    accountFlexTable.setText(2, 0, "Email");
    accountFlexTable.setWidget(2, 1, emailTextBox);
    accountFlexTable.setText(3, 0, "Phone number");
    accountFlexTable.setWidget(3, 1, phonenumberTextBox);
    accountFlexTable.setText(4, 0, "Address");
    accountFlexTable.setWidget(4, 1, addressTextBox);
    accountFlexTable.setText(5, 0, "City");
    accountFlexTable.setWidget(5, 1, cityTextBox);
    accountFlexTable.setText(6, 0, "Zip Code");
    accountFlexTable.setWidget(6, 1, zipTextBox);
    accountFlexTable.setText(7, 0, "Username");
    accountFlexTable.setWidget(7, 1, newusernameTextBox);
    accountFlexTable.setText(8, 0, "Password");
    accountFlexTable.setWidget(8, 1, newpasswordTextBox);

    accountFlexTable.getCellFormatter().addStyleName(0, 0, "phoneListHeader");
    accountFlexTable.getCellFormatter().addStyleName(1, 0, "phoneListHeader");
    accountFlexTable.getCellFormatter().addStyleName(2, 0, "phoneListHeader");
    accountFlexTable.getCellFormatter().addStyleName(3, 0, "phoneListHeader");
    accountFlexTable.getCellFormatter().addStyleName(4, 0, "phoneListHeader");
    accountFlexTable.getCellFormatter().addStyleName(5, 0, "phoneListHeader");
    accountFlexTable.getCellFormatter().addStyleName(6, 0, "phoneListHeader");
    accountFlexTable.getCellFormatter().addStyleName(7, 0, "phoneListHeader");
    accountFlexTable.getCellFormatter().addStyleName(8, 0, "phoneListHeader");
    accountFlexTable.addStyleName("phoneList");

    orderFlexTable.setText(0, 0, "Cart type");
    orderFlexTable.setWidget(0, 1, carttypeTextBox);
    orderFlexTable.setText(1, 0, "Holder's name");
    orderFlexTable.setWidget(1, 1, holdernameTextBox);
    orderFlexTable.setText(2, 0, "Card number");
    orderFlexTable.setWidget(2, 1, cardnumberTextBox);
    orderFlexTable.setText(3, 0, "Expiry year");
    orderFlexTable.setWidget(3, 1, expiryyearTextBox);
    orderFlexTable.setText(4, 0, "Expiry month");
    orderFlexTable.setWidget(4, 1, expirymonthTextBox);
    orderFlexTable.setText(5, 0, "Security number");
    orderFlexTable.setWidget(5, 1, securitynumberTextBox);

    orderFlexTable.getCellFormatter().addStyleName(0, 0, "phoneListHeader");
    orderFlexTable.getCellFormatter().addStyleName(1, 0, "phoneListHeader");
    orderFlexTable.getCellFormatter().addStyleName(2, 0, "phoneListHeader");
    orderFlexTable.getCellFormatter().addStyleName(3, 0, "phoneListHeader");
    orderFlexTable.getCellFormatter().addStyleName(4, 0, "phoneListHeader");
    orderFlexTable.getCellFormatter().addStyleName(5, 0, "phoneListHeader");
    orderFlexTable.addStyleName("phoneList");

    loginTable.setText(0, 0, "username");
    loginTable.setWidget(0, 1, usernameTextBox);
    loginTable.setText(1, 0, "password");
    loginTable.setWidget(1, 1, passwordTextBox);
    loginTable.setWidget(2, 0, loginBtn);
    loginTable.setText(3, 0, "Hello: ");
    loginTable.setWidget(3, 1, loginLabel);
    loginTable.setWidget(4, 0, ViewCart);
    loginPanel.add(loginTable);

    loginTable.getCellFormatter().addStyleName(0, 0, "phoneListHeader");
    loginTable.getCellFormatter().addStyleName(1, 0, "phoneListHeader");
    loginTable.addStyleName("phoneList");

    registerButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            if ((newusernameTextBox.getText().trim().equals(""))
                    || (newpasswordTextBox.getText().trim().equals(""))) {
                Window.alert("The username and password are neccesary!");
                newusernameTextBox.setFocus(true);
                newpasswordTextBox.setText("");
            } else if (emailTextBox.getText().trim().equals("")) {
                Window.alert("The email is neccesary!");
            } else {
                insertAccount();
            }
        }
    });

    editProductPanel.add(editProductFlexTable);
    editProductPanel.add(addProductFlexTable);
    editProductPanel.setVisible(false);
    mainPanel.add(editProductPanel);

    deliveredPanel.add(deliveredFlexTable);
    deliveredPanel.setVisible(false);
    mainPanel.add(deliveredPanel);

    registerPanel.add(accountFlexTable);
    registerPanel.add(registerButton);
    registerPanel.setVisible(false);
    mainPanel.add(registerPanel);

    productPanel.add(productFlexTable);
    mainPanel.add(productPanel);

    cartPanel.add(cartFlexTable);
    cartPanel.setVisible(false);
    mainPanel.add(cartPanel);

    orderPanel.add(orderFlexTable);
    orderPanel.add(orderButton);
    orderPanel.setVisible(false);
    mainPanel.add(orderPanel);

    RootPanel.get("leftnav").add(loginPanel);
    RootPanel.get("content").add(mainPanel);

    orderButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            /*if  (!cardnumberTextBox.getText().trim().matches("^[0-9]$")) {
                  Window.alert("'" + cardnumberTextBox.getText() + "' is not a valid card number.");
                  holdernameTextBox.selectAll();
                  return;
             }*/
            if (ShoppingCart.getTotalCount() == 0) {
                Window.alert("There is no item in Shopping cart");
            } else if (carttypeTextBox.getText().trim().equals("")
                    || holdernameTextBox.getText().trim().equals("")
                    || cardnumberTextBox.getText().trim().equals("")
                    || expiryyearTextBox.getText().trim().equals("")
                    || expirymonthTextBox.getText().trim().equals("")
                    || securitynumberTextBox.getText().trim().equals("")) {
                Window.alert("please fill all required fields.");
            } else {
                genID();
            }

        }
    });

    loginBtn.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            if ((account.getUsername() != "Guest") && (ShoppingCart.cart != null) && (Window
                    .confirm("if you login again all the purchases will be ignored! are you sure?") == false)) {
                Window.alert("you can continue purchasing by this user : " + account.getUsername());
                usernameTextBox.setText("");
                passwordTextBox.setText("");
            } else {
                ShoppingCart.cart = null;
                ViewCart.setText("View Cart : 0 , $0");
                account.setUsername(usernameTextBox.getText());
                account.setPassword(passwordTextBox.getText());
                checkPassword();
                passwordTextBox.setText("");
            }
        }
    });

    readProductList();

}

From source file:com.google.livingstories.client.contentmanager.LivingStoryManager.java

License:Apache License

@UiHandler("deleteButton")
void deleteLivingStory(ClickEvent event) {
    boolean delete = Window.confirm("Are you sure you want to delete this living story? "
            + "Doing so will also delete all content that belongs to it.");
    if (delete) {
        final String selectedStoryId = livingStorySelector.getSelectedItemValue();
        AsyncCallback<Void> callback = new AsyncCallback<Void>() {
            public void onSuccess(Void nothing) {
                livingStorySelector.removeItemWithValue(selectedStoryId);
                clearStoryContent();/*  w  ww.j a v  a  2 s. co m*/
                contentPanel.showWidget(0);
                livingStorySelector.clearCoordinatedLivingStoryId();
            }

            public void onFailure(Throwable caught) {
                statusMessage.setText("Deletion failed");
            }
        };

        livingStoryService.deleteLivingStory(Long.valueOf(selectedStoryId), callback);
    }
}

From source file:com.google.mobile.trippy.web.client.presenter.CommentListItemPresenter.java

License:Apache License

/**
 * Method takes the responsibility for handling all the events and firing
 * the events.//from  ww  w  .  j  a v a 2 s  .  co m
 * 
 * Click Handlers:
 * 1) It will have a click handler on Click event of Delete button, which will
 *    send delete request for this comment to comment service.
 */
@Override
public void bind() {
    if (isOwner) {
        handlers.add(display.getDeleteButton().addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                final Toast toast = provider.getToast();
                try {
                    if (Window.confirm(provider.getMessage().confirmCommentDelete())) {
                        toast.showLoading(provider.getMessage().deleting(Constants.COMMENT_LOWER_CASE_STR));
                        provider.getCommentService().deleteComment(comment, new AsyncCallback<Void>() {
                            @Override
                            public void onSuccess(Void result) {
                                toast.hideLoading();
                                toast.showToast(provider.getMessage().commentDeleted());
                            }

                            @Override
                            public void onFailure(Throwable caught) {
                                toast.hideLoading();
                                if (caught instanceof AuthorizationException) {
                                    toast.showToast(provider.getMessage()
                                            .unauthorizedDelete(Constants.COMMENT_LOWER_CASE_STR));
                                } else {
                                    toast.showToast(provider.getMessage().commentDeletionFailed());
                                }
                            }
                        });
                    }
                } catch (AuthorizationException e) {
                    toast.hideLoading();
                    toast.showToast(provider.getMessage().unauthorizedDelete(Constants.COMMENT_LOWER_CASE_STR));
                }
            }
        }));
    }
}

From source file:com.google.mobile.trippy.web.client.presenter.header.TripItemOptionsPresenter.java

License:Apache License

@Override
public void addMenu() {
    menuPresenter.clear();/*from ww  w.  j  a v  a2  s  . com*/
    final Trip trip = singletonComponents.getTripService().getTrip(tripItem.getTripId());
    if (isMapScreen()) {
        // SHOW DETAILS
        menuPresenter.addMenuItem(Constants.SHOW_DETAILS_STR, TrippyBundle.INSTANCE.iconShowDetails(),
                new Runnable() {
                    @Override
                    public void run() {
                        singletonComponents.getEventBus().fireEvent(new ShowTripItemDetailsEvent(tripItem));
                    }
                });
    } else {
        // SHOW ON MAP
        menuPresenter.addMenuItem(Constants.SHOW_ON_MAP_STR, TrippyBundle.INSTANCE.iconShowOnMap(),
                new Runnable() {
                    @Override
                    public void run() {
                        singletonComponents.getEventBus().fireEvent(
                                new ShowTripOnMapEvent(trip, tripItem.getStartDay(), tripItem.getKey()));
                    }
                });
    }

    final boolean isContributor = singletonComponents.getUserUtils().isContributor(trip,
            singletonComponents.getUtils().getUserEmail());

    menuPresenter.addMenuItem(Constants.DELETE_STR, TrippyBundle.INSTANCE.trash(), !isContributor,
            new Runnable() {
                @Override
                public void run() {
                    if (isContributor) {
                        if (Window.confirm(
                                singletonComponents.getMessage().confirmTripItemDelete(tripItem.getName()))) {
                            final Toast toast = singletonComponents.getToast();
                            try {
                                toast.showLoading(
                                        singletonComponents.getMessage().deleting(tripItem.getName()));
                                singletonComponents.getTripItemService().deleteTripItem(tripItem,
                                        new AsyncCallback<Void>() {

                                            @Override
                                            public void onSuccess(Void result) {
                                                toast.hideLoading();
                                                toast.showToast(
                                                        singletonComponents.getMessage().tripItemDeleted());
                                                singletonComponents.getEventBus().fireEvent(new BackEvent());
                                            }

                                            @Override
                                            public void onFailure(Throwable caught) {
                                                toast.hideLoading();
                                                if (caught instanceof AuthorizationException) {
                                                    toast.showToast(singletonComponents.getMessage()
                                                            .unauthorizedDelete(Constants.TRIP_ITEM_STR));
                                                } else {
                                                    toast.showToast(singletonComponents.getMessage()
                                                            .tripItemDeletionFailed());
                                                }
                                            }
                                        });

                            } catch (AuthorizationException e) {
                                toast.hideLoading();
                                toast.showToast(singletonComponents.getMessage().tripItemDeletionFailed());
                            }
                        }
                    } else {
                        singletonComponents.getToast().showToast(singletonComponents.getMessage()
                                .unauthorizedDelete(Constants.SHARED_TRIP_ITEM_STR));
                    }
                }
            });

    // "Share" trip item
    menuPresenter.addMenuItem(Constants.INVITE, TrippyBundle.INSTANCE.shareIcon(), !isContributor,
            new Runnable() {
                @Override
                public void run() {
                    if (isContributor) {
                        singletonComponents.getEventBus().fireEvent(new ShareTripEvent(trip));
                    } else {
                        singletonComponents.getToast()
                                .showToast(singletonComponents.getMessage().unauthorizedShare());
                    }
                }
            });

    // EDIT TRIP ITEM
    menuPresenter.addMenuItem(Constants.RESCHEDULE_STR, TrippyBundle.INSTANCE.editIcon(), !isContributor,
            new Runnable() {
                @Override
                public void run() {
                    if (isContributor) {
                        dayPopupPresenter.showPopup();
                    } else {
                        singletonComponents.getToast().showToast(singletonComponents.getMessage()
                                .unauthorizedEdit(Constants.SHARED_TRIP_ITEM_STR));
                    }
                }
            });
    menuPresenter.setPopupTitle(Constants.TRIP_ITEM_MENU_STR);
    super.addMenu();
}