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.freemedsoftware.gwt.client.widget.CustomActionBar.java

License:Open Source License

public void onClick(ClickEvent evt) {
    Widget sender = (Widget) evt.getSource();
    int action = -1;
    if (sender == addImage) {
        action = HandleCustomAction.ADD;
    } else if (sender == deleteImage) {
        if (locked && !haveAllRights) {
            Window.alert(_("You can't delete a locked item."));
            return;
        }/*from   w  w w . ja  v a 2s  .  c om*/
        if (Window.confirm(_("Are you sure to delete this record?"))) {
            action = HandleCustomAction.DELETE;
        }
    } else if (sender == modifyImage) {
        if (locked && !haveAllRights) {
            Window.alert(_("You can't modify a locked item."));
            return;
        }
        action = HandleCustomAction.MODIFY;
    } else if (sender == viewImage) {
        action = HandleCustomAction.VIEW;
    } else if (sender == printImage) {
        action = HandleCustomAction.PRINT;
    } else if (sender == cloneImage) {
        action = HandleCustomAction.CLONE;
    } else if (sender == lockedImage) {
        Window.alert(_("This record has been locked, and can no longer be modified."));
        return;
    } else if (sender == lockImage) {
        if (Window.confirm(_("Are you sure to lock this record?"))) {
            action = HandleCustomAction.LOCK;
        } else
            return;
    }

    if (handleCustomAction != null && action != -1) {
        handleCustomAction.handleAction(internalId, data, action);
    }
}

From source file:org.freemedsoftware.gwt.client.widget.PatientTagsWidget.java

License:Open Source License

/**
 * Actual addition of tag to display.//from  ww  w .  ja va  2  s .c o m
 * 
 * @param tag
 */
protected void addTagToDisplay(String tag) {
    JsonUtil.debug("addTagToDisplay(" + tag + ")");
    HorizontalPanel p = new HorizontalPanel();
    p.setTitle(tag);
    final String oldTagName = tag.trim();
    final HTML r = new HTML("<sup>X</sup>");
    final Anchor tagLabel = new Anchor(tag);
    tagLabel.setStylePrimaryName("freemed-PatientTag");
    JsonUtil.debug("addclicklistener");
    tagLabel.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent evt) {
            final Widget w = (Widget) evt.getSource();
            final PopupPanel p = new PopupPanel(true);
            final FlexTable fT = new FlexTable();
            fT.setWidget(0, 0, new HTML("<b>" + oldTagName + "</b>"));
            fT.setWidget(1, 0, new Label(_("Rename Tag")));
            final TextBox newTagName = new TextBox();
            fT.setWidget(2, 0, newTagName);
            final CustomButton changeTagButton = new CustomButton(_("Change"), AppConstants.ICON_MODIFY);
            fT.setWidget(2, 1, changeTagButton);
            changeTagButton.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent bEvt) {
                    if (newTagName.getText().trim().length() > 0) {
                        if (Util.getProgramMode() == ProgramMode.STUBBED) {
                            // Stubbed mode
                            p.hide();
                            p.removeFromParent();
                            ((HorizontalPanel) w.getParent()).removeFromParent();
                            addTagToDisplay(newTagName.getText().trim());
                        } else if (Util.getProgramMode() == ProgramMode.JSONRPC) {
                            String[] params = { oldTagName, newTagName.getText().trim() };
                            RequestBuilder builder = new RequestBuilder(RequestBuilder.POST,
                                    URL.encode(Util.getJsonRequest(
                                            "org.freemedsoftware.module.PatientTag.ChangeTag", params)));
                            try {
                                builder.sendRequest(null, new RequestCallback() {
                                    public void onError(Request request, Throwable ex) {
                                    }

                                    public void onResponseReceived(Request request, Response response) {
                                        if (200 == response.getStatusCode()) {
                                            Boolean r = (Boolean) JsonUtil.shoehornJson(
                                                    JSONParser.parseStrict(response.getText()), "Boolean");
                                            if (r != null) {
                                                p.hide();
                                                p.removeFromParent();
                                                ((HorizontalPanel) w.getParent()).removeFromParent();
                                                addTagToDisplay(newTagName.getText().trim());
                                            }
                                        } else {
                                        }
                                    }
                                });
                            } catch (RequestException e) {
                            }
                        } else {
                            getProxy().ChangeTag(oldTagName, newTagName.getText().trim(),
                                    new AsyncCallback<Boolean>() {
                                        public void onSuccess(Boolean o) {
                                            p.hide();
                                            p.removeFromParent();
                                            ((HorizontalPanel) w.getParent()).removeFromParent();
                                            addTagToDisplay(newTagName.getText().trim());
                                        }

                                        public void onFailure(Throwable t) {
                                            GWT.log("Exception", t);
                                        }
                                    });
                        }
                    }
                }
            });
            final CustomButton searchButton = new CustomButton(_("Search"), AppConstants.ICON_SEARCH);
            fT.setWidget(2, 2, searchButton);
            searchButton.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent evt) {
                    PatientTagSearchScreen searchScreen = new PatientTagSearchScreen();
                    searchScreen.setTagValue(oldTagName);
                    Util.spawnTab(_("Tag Search"), searchScreen);
                    p.hide();
                }
            });
            p.add(fT);
            p.setPopupPosition(tagLabel.getAbsoluteLeft() + 5, tagLabel.getAbsoluteTop() - 10);
            p.setStyleName("freemed-PatientTagPopup");
            p.show();
        }
    });
    p.add(tagLabel);
    p.add(r);
    p.setStyleName("freemed-PatientTag");
    r.addStyleName("freemed-PatientTagRemove");
    r.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent evt) {
            if (Window.confirm("Are you sure you want to remove this tag?")) {
                HorizontalPanel container = (HorizontalPanel) ((Widget) evt.getSource()).getParent();
                removeTag(container.getTitle(), container);
            }
        }
    });
    flowPanel.add(p);
}

From source file:org.fusesource.restygwt.client.callback.FilterawareRetryingCallback.java

License:Apache License

public void handleErrorGracefully(Request request, Response response, RequestCallback requestCallback) {
    // error handling...:
    if (currentRetryCounter < numberOfRetries) {
        if (LogConfiguration.loggingIsEnabled()) {
            Logger.getLogger(FilterawareRetryingCallback.class.getName())
                    .severe("error handling in progress for: " + method.builder.getHTTPMethod() + " "
                            + method.builder.getUrl());
        }/*  w ww .j  a  va 2  s .c o m*/

        currentRetryCounter++;

        Timer t = new Timer() {
            public void run() {
                try {
                    method.builder.send();
                } catch (RequestException ex) {
                    if (LogConfiguration.loggingIsEnabled()) {
                        Logger.getLogger(FilterawareRetryingCallback.class.getName()).severe(ex.getMessage());
                    }
                }
            }
        };

        t.schedule(gracePeriod);
        gracePeriod = gracePeriod * 2;
    } else {
        if (LogConfiguration.loggingIsEnabled()) {
            Logger.getLogger(FilterawareRetryingCallback.class.getName())
                    .severe("Request failed: " + method.builder.getHTTPMethod() + " " + method.builder.getUrl()
                            + " after " + currentRetryCounter + " tries.");
        }

        if (null != request && null != response && null != requestCallback) {
            // got the original callback, call error here
            requestCallback.onError(request,
                    new RuntimeException("Response " + response.getStatusCode() + " for "
                            + method.builder.getHTTPMethod() + " " + method.builder.getUrl() + " after "
                            + numberOfRetries + " retries."));
        } else {
            // got no callback - well, goodbye
            if (Window.confirm("error")) {
                // Super severe error.
                // reload app or redirect.
                // ===> this breaks the app but that's by intention.
                Window.Location.reload();
            }
        }
    }
}

From source file:org.fusesource.restygwt.client.callback.RetryingFilterawareRequestCallback.java

License:Apache License

private void handleErrorGracefully(Request request, Response response, RequestCallback requestCallback) {
    // error handling...:
    if (currentRetryCounter < numberOfRetries) {
        if (GWT.isClient() && LogConfiguration.loggingIsEnabled()) {
            Logger.getLogger(RetryingFilterawareRequestCallback.class.getName())
                    .severe("error handling in progress for: " + method.builder.getHTTPMethod() + " "
                            + method.builder.getUrl());
        }/*from ww  w  .j  a  va 2s  . co m*/

        currentRetryCounter++;

        Timer t = new Timer() {
            @Override
            public void run() {
                try {
                    method.builder.send();
                } catch (RequestException ex) {
                    if (GWT.isClient() && LogConfiguration.loggingIsEnabled()) {
                        Logger.getLogger(RetryingFilterawareRequestCallback.class.getName())
                                .severe(ex.getMessage());
                    }
                }
            }
        };

        t.schedule(gracePeriod);
        gracePeriod = gracePeriod * 2;
    } else {
        if (GWT.isClient() && LogConfiguration.loggingIsEnabled()) {
            Logger.getLogger(RetryingFilterawareRequestCallback.class.getName())
                    .severe("Request failed: " + method.builder.getHTTPMethod() + " " + method.builder.getUrl()
                            + " after " + currentRetryCounter + " tries.");
        }

        if (null != request && null != response && null != requestCallback) {
            // got the original callback, call error here
            requestCallback.onError(request,
                    new RuntimeException("Response " + response.getStatusCode() + " for "
                            + method.builder.getHTTPMethod() + " " + method.builder.getUrl() + " after "
                            + numberOfRetries + " retries."));
        } else {
            // got no callback - well, goodbye
            if (Window.confirm("something severly went wrong - error - reload page ?")) {
                // Super severe error.
                // reload app or redirect.
                // ===> this breaks the app but that's by intention.
                Window.Location.reload();
            }
        }
    }
}

From source file:org.fusesource.restygwt.client.dispatcher.AbstractRetryingCallback.java

License:Apache License

public void handleErrorGracefully() {

    // error handling...:
    if (currentRetryCounter < numberOfRetries) {
        GWT.log("error handling in progress...");

        currentRetryCounter++;//  w ww .j  ava 2  s.c om

        Timer t = new Timer() {

            public void run() {

                try {
                    requestBuilder.send();
                } catch (RequestException ex) {
                    logger.severe(ex.getMessage());
                }
            }
        };

        t.schedule(gracePeriod);

        gracePeriod = gracePeriod * 2;

    } else {
        // Super severe error.
        // reload app or redirect.
        // ===> this breaks the app but that's by intention.
        if (Window.confirm("error")) {

            Window.Location.reload();

        }
    }

}

From source file:org.gk.ui.client.com.form.gkFileUploadField.java

License:Open Source License

private void refreshLinkPanel(List links) {

    linkPanel.removeAll();//from w w  w . j a  v a2  s . c om

    if (isReadOnly() || !isEnabled()) {
        uploadButton.disable();
    }

    for (int i = 0; i < links.size(); i++) {
        Map map = (Map) links.get(i);
        String fileName = (String) map.get("name");
        String filePath = (String) map.get("path");
        final String id;
        if (filePath != null) {
            id = filePath + fileName;
        } else {
            id = fileName;
        }

        gkImageField image = new gkImageField(Icons.get.cross().getSafeUri().asString());

        if (!isReadOnly() && isEnabled()) {
            image.addListener(Events.OnClick, new Listener<BaseEvent>() {

                @Override
                public void handleEvent(BaseEvent be) {
                    if (Window.confirm(Msg.get.areuSure() + Msg.get.delete() + "?")) {
                        EventBus.get().publishRemote(
                                new EventObject(beanName + gkFileUploadPanel.Event.DELETE, id),
                                new EventProcess() {

                                    @Override
                                    public void execute(String eventId, EventObject eo) {
                                        loadFileList();
                                    }
                                });
                    }
                }
            });
        } else {
            image = new gkImageField(Icons.get.text().getSafeUri().asString()) {
                @Override
                protected void onMouseOver(ComponentEvent ce) {
                    //
                }
            };
        }

        Anchor anchor = new Anchor(fileName);
        if (isEnabled()) {
            anchor.setHref("event/put/def/" + beanName + gkFileUploadPanel.Event.DOWNLOAD + ".go?id=" + id);
            anchor.setTarget("_blank");
        }
        linkPanel.add(image);
        linkPanel.add(anchor);
    }
    hp.layout();
}

From source file:org.glimpse.client.AggregatorTabOptions.java

License:Open Source License

public AggregatorTabOptions(AggregatorTabPanel tabPanel) {
    this.tabPanel = tabPanel;

    FlowPanel mainPanel = new FlowPanel();
    mainPanel.setWidth("100%");
    SimplePanel closePanel = new SimplePanel();
    closePanel.setStylePrimaryName("taboptions-close");
    mainPanel.add(closePanel);/*from w w w  .j  a  va2 s. c  o  m*/
    FocusPanel closeButton = new FocusPanel();
    closePanel.add(closeButton);
    closeButton.setWidget(new Image(Aggregator.TRANSPARENT_IMAGE));
    closeButton.setStylePrimaryName("taboptions-close-button");
    closeButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            AggregatorTabOptions.this.tabPanel.hideOptions();
        }
    });

    HorizontalPanelExt panel = new HorizontalPanelExt();
    mainPanel.add(panel);
    panel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);

    HorizontalPanel movePanel = new HorizontalPanel();
    movePanel.setSpacing(0);
    panel.add(movePanel);
    FocusPanel moveLeft = new FocusPanel();
    movePanel.add(moveLeft);
    moveLeft.setWidget(new Image(Aggregator.TRANSPARENT_IMAGE));
    moveLeft.setStylePrimaryName("move-tab-left");
    moveLeft.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            AggregatorTabOptions.this.tabPanel.moveVisibleLeft();
            Aggregator.getInstance().update();
        }
    });
    FocusPanel moveRight = new FocusPanel();
    movePanel.add(moveRight);
    moveRight.setWidget(new Image(Aggregator.TRANSPARENT_IMAGE));
    moveRight.setStylePrimaryName("move-tab-right");
    moveRight.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            AggregatorTabOptions.this.tabPanel.moveVisibleRight();
            Aggregator.getInstance().update();
        }
    });

    FlexTable titleTable = new FlexTable();
    titleTable.setText(0, 0, constants.title());
    titleInput = new TextBox();
    titleTable.setWidget(0, 1, titleInput);
    Button titleButton = new Button(constants.ok());
    titleButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            AggregatorTabOptions.this.tabPanel.setTitle(AggregatorTabOptions.this.tabPanel.getVisibleTab(),
                    titleInput.getValue());
            Aggregator.getInstance().update();
        }
    });
    titleTable.setWidget(0, 2, titleButton);
    panel.add(titleTable);
    panel.setCellVerticalAlignment(titleTable, VerticalPanel.ALIGN_MIDDLE);

    FlexTable columnTable = new FlexTable();
    columnTable.setText(0, 0, constants.numberOfColumns());
    columnList = new ListBox();
    columnList.addItem("1");
    columnList.addItem("2");
    columnList.addItem("3");
    columnList.addItem("4");
    columnList.addChangeHandler(new ChangeHandler() {
        public void onChange(ChangeEvent event) {
            AggregatorTab tab = AggregatorTabOptions.this.tabPanel
                    .getTab(AggregatorTabOptions.this.tabPanel.getVisibleTab());
            int newNumber = Integer.valueOf(columnList.getValue(columnList.getSelectedIndex()));
            List<AggregatorColumn> columns = tab.getColumns();
            boolean confirm = false;
            while (columns.size() < newNumber) {
                columns.add(new AggregatorColumn());
            }
            while (columns.size() > newNumber) {
                AggregatorColumn removed = columns.remove(columns.size() - 1);
                if (removed.getComponentCount() > 0) {
                    confirm = true;
                }
            }
            if (confirm && !Window.confirm(constants.removeColumnWarning())) {
                return;
            }
            tab.setColumns(columns);
            Aggregator.getInstance().update();
        }
    });
    columnTable.setWidget(0, 1, columnList);
    panel.add(columnTable);
    panel.setCellVerticalAlignment(columnTable, VerticalPanel.ALIGN_MIDDLE);

    Button delButton = new Button(constants.deleteTab());
    delButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            if (Window.confirm(constants.deleteTabConfirm())) {
                AggregatorTabOptions.this.tabPanel.remove(AggregatorTabOptions.this.tabPanel.getVisibleTab());
                Aggregator.getInstance().update();
            }
        }
    });
    panel.add(delButton);
    panel.setCellVerticalAlignment(delButton, VerticalPanel.ALIGN_MIDDLE);

    initWidget(mainPanel);
}

From source file:org.glimpse.client.Component.java

License:Open Source License

public Component(Map<String, String> properties) {
    this.properties = new HashMap<String, String>(properties);

    SimplePanel mainPanel = new SimplePanel();
    mainPanel.setStylePrimaryName("component");

    SimplePanel frame = new SimplePanel();
    frame.setWidth("100%");
    mainPanel.add(frame);/*w  w  w. ja  v  a2s. c o m*/

    VerticalPanelExt panel = new VerticalPanelExt();
    panel.setWidth("100%");
    frame.add(panel);

    HorizontalPanelExt topPanel = new HorizontalPanelExt();
    topPanel.setWidth("100%");
    topPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);

    Image titleLeft = new Image(Aggregator.TRANSPARENT_IMAGE);
    topPanel.add(titleLeft);
    topPanel.setCellClass(titleLeft, "component-title-left");

    titlePanel = new SimplePanel();
    topPanel.add(titlePanel);
    topPanel.setCellClass(titlePanel, "component-title-content");

    actionsPanel = new HorizontalPanelExt();
    actionsPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);

    if (Aggregator.getInstance().isModifiable()) {
        dragHandle = new FocusPanel(new Image(Aggregator.TRANSPARENT_IMAGE));
        dragHandle.setStylePrimaryName("component-action-move");
        actionsPanel.add(dragHandle);
        actionsPanel.setCellClass(dragHandle, "component-action");

        FocusPanel deleteButton = new FocusPanel(new Image(Aggregator.TRANSPARENT_IMAGE));
        deleteButton.setTitle(constants.delete());
        deleteButton.setStylePrimaryName("component-action-delete");
        deleteButton.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                if (Window.confirm(constants.deleteComponentConfirm())) {
                    removeFromParent();
                    Aggregator.getInstance().update();
                }
            }
        });
        actionsPanel.add(deleteButton);
        actionsPanel.setCellClass(deleteButton, "component-action");
    }

    topPanel.add(actionsPanel);
    topPanel.setCellHorizontalAlignment(actionsPanel, HorizontalPanel.ALIGN_RIGHT);
    topPanel.setCellClass(actionsPanel, "component-title-actions");

    Image titleRight = new Image(Aggregator.TRANSPARENT_IMAGE);
    topPanel.add(titleRight);
    topPanel.setCellClass(titleRight, "component-title-right");

    HorizontalPanelExt center = new HorizontalPanelExt();
    center.setWidth("100%");

    Image left = new Image(Aggregator.TRANSPARENT_IMAGE);
    center.add(left);
    center.setCellClass(left, "component-left");

    contentPanel = new SimplePanel();
    contentPanel.setWidth("100%");
    center.add(contentPanel);
    center.setCellClass(contentPanel, "component-content");

    Image right = new Image(Aggregator.TRANSPARENT_IMAGE);
    center.add(right);
    center.setCellClass(right, "component-right");

    HorizontalPanelExt bottom = new HorizontalPanelExt();
    bottom.setWidth("100%");

    Image bottomLeft = new Image(Aggregator.TRANSPARENT_IMAGE);
    bottom.add(bottomLeft);
    bottom.setCellClass(bottomLeft, "component-bottom-left");

    Image bottomCenter = new Image(Aggregator.TRANSPARENT_IMAGE);
    bottom.add(bottomCenter);
    bottom.setCellClass(bottomCenter, "component-bottom-center");

    Image bottomRight = new Image(Aggregator.TRANSPARENT_IMAGE);
    bottom.add(bottomRight);
    bottom.setCellClass(bottomRight, "component-bottom-right");

    panel.add(topPanel);
    panel.add(center);
    panel.add(bottom);

    initWidget(mainPanel);

    if (Aggregator.getInstance().isModifiable()) {
        Aggregator.getInstance().getDragController().makeDraggable(this);
    }
}

From source file:org.guvnor.asset.management.client.editors.repository.wizard.CreateRepositoryWizard.java

License:Apache License

private void doComplete() {
    repositoryService.call(new RemoteCallback<String>() {
        @Override/*  w w w .  j  av a2 s .com*/
        public void callback(final String normalizedName) {
            if (!model.getRepositoryName().equals(normalizedName)) {
                if (!Window.confirm(CoreConstants.INSTANCE.RepositoryNameInvalid() + " \"" + normalizedName
                        + "\". " + CoreConstants.INSTANCE.DoYouAgree())) {
                    return;
                }
                String unNormalizedName = model.getRepositoryName();
                model.setRepositoryName(normalizedName);
                if (unNormalizedName.equals(model.getProjectName())) {
                    model.setProjectName(normalizedName);
                }
                if (unNormalizedName.equals(model.getArtifactId())) {
                    model.setArtifactId(normalizedName);
                }
            }

            if (model.isManged()) {

                showBusyIndicator(Constants.INSTANCE.ValidatingProjectGAV());

                final GAV gav = new GAV(model.getGroupId(), model.getArtifactId(), model.getVersion());
                repositoryResolverService.call(new RemoteCallback<Set<MavenRepositoryMetadata>>() {
                    @Override
                    public void callback(final Set<MavenRepositoryMetadata> metadatas) {
                        if (metadatas.isEmpty()) {
                            doRepositoryCreation(DeploymentMode.VALIDATED);
                        } else {
                            hideBusyIndicator();
                            conflictingRepositoriesPopup.setContent(gav, metadatas, new Command() {
                                @Override
                                public void execute() {
                                    conflictingRepositoriesPopup.hide();
                                    doRepositoryCreation(DeploymentMode.FORCED);
                                }
                            });
                            conflictingRepositoriesPopup.show();
                        }
                    }
                }).getRepositoriesResolvingArtifact(gav);
            } else {
                doRepositoryCreation(DeploymentMode.VALIDATED);
            }
        }

    }).normalizeRepositoryName(model.getRepositoryName());

}

From source file:org.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;/*from   www .  java  2  s  .c o  m*/
    }
    if (!Window.confirm(Constants.INSTANCE.AreYouSureYouWantToDeleteTheseItems())) {
        return;
    }
    m2RepoService.call(new RemoteCallback<Void>() {
        @Override
        public void callback(Void v) {
            Window.alert("Deleted successfully");
            pagedJarTable.refresh();
        }
    }).deleteJar(getSelectedJars());
}