Example usage for com.google.gwt.user.client.ui DialogBox hide

List of usage examples for com.google.gwt.user.client.ui DialogBox hide

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui DialogBox hide.

Prototype

@Override
    public void hide() 

Source Link

Usage

From source file:net.meddeb.md.admin.client.MenuLauncher.java

License:Open Source License

private void doHelpAbout() {
    final DialogBox aboutBox = new DialogBox();
    String msg = "<b>mdDiradmin</b>, " + mainMsg.appTitle();
    msg = msg + "<p>" + VERSION;
    msg = msg + "<br/>Copyright (C) 2015  Abdelhamid MEDDEB <abdelhamid@meddeb.net></p>";
    msg = msg + "<p>" + mainMsg.gnuLicense() + "</p>";
    msg = msg + "<p>" + mainMsg.noWarranty() + "</p>";
    final HTML aboutMessage = new HTML(msg);
    VerticalPanel aboutPanel = new VerticalPanel();
    final Button closeButton = new Button(mainMsg.close());
    closeButton.getElement().setId("closeButton");
    closeButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            aboutBox.hide();
        }//from   w  w  w  .j a  va 2 s .co m
    });
    aboutBox.setText(mainMsg.helpAbout());
    aboutPanel.addStyleName("dialogPanel");
    aboutPanel.add(aboutMessage);
    aboutPanel.setHorizontalAlignment(VerticalPanel.ALIGN_RIGHT);
    aboutPanel.add(closeButton);
    aboutBox.setWidget(aboutPanel);
    aboutBox.center();
    closeButton.setFocus(true);
}

From source file:net.meddeb.md.admin.client.MenuLauncher.java

License:Open Source License

public void showWarning(String message) {
    final DialogBox warningBox = new DialogBox();
    String msg = "<b>Warning !</b>";
    msg = msg + "<p>" + message + "</p>";
    final HTML warningMessage = new HTML(msg);
    VerticalPanel warningPanel = new VerticalPanel();
    final Button closeButton = new Button(mainMsg.close());
    closeButton.getElement().setId("closeButton");
    closeButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            warningBox.hide();
        }//  w  ww  .  j a  v  a2  s .c o m
    });
    warningBox.setText(mainMsg.helpAbout());
    warningPanel.addStyleName("dialogPanel");
    warningPanel.add(warningMessage);
    warningPanel.setHorizontalAlignment(VerticalPanel.ALIGN_RIGHT);
    warningPanel.add(closeButton);
    warningBox.setWidget(warningPanel);
    warningBox.center();
    closeButton.setFocus(true);
}

From source file:net.meddeb.md.core.presentation.MenuLauncher.java

License:Open Source License

private void doHelpAbout() {
    final DialogBox aboutBox = new DialogBox();
    String msg = "<b>mdCore</b>, " + mainMsg.appTitle();
    msg = msg + "<p>" + VERSION;
    msg = msg + "<br/>Copyright (C) 2015  Abdelhamid MEDDEB <abdelhamid@meddeb.net></p>";
    msg = msg + "<p>" + mainMsg.gnuLicense() + "</p>";
    msg = msg + "<p>" + mainMsg.noWarranty() + "</p>";
    final HTML aboutMessage = new HTML(msg);
    VerticalPanel aboutPanel = new VerticalPanel();
    final Button closeButton = new Button(mainMsg.close());
    closeButton.getElement().setId("closeButton");
    closeButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            aboutBox.hide();
        }//w  w w . j  ava 2  s.c om
    });
    aboutBox.setText(mainMsg.helpAbout());
    aboutPanel.addStyleName("dialogPanel");
    aboutPanel.add(aboutMessage);
    aboutPanel.setHorizontalAlignment(VerticalPanel.ALIGN_RIGHT);
    aboutPanel.add(closeButton);
    aboutBox.setWidget(aboutPanel);
    aboutBox.center();
    closeButton.setFocus(true);
}

From source file:net.officefloor.demo.chat.client.ChatWidget.java

License:Open Source License

/**
 * Enters the chat name.//from www  .j  a  v  a  2  s .  c  om
 * 
 * @param nameText
 *            {@link TextBox} containing the name.
 * @param userDialog
 *            {@link DialogBox} to obtain the name.
 */
private void enterChatName(TextBox nameText, DialogBox userDialog) {

    // Ensure user name provided
    String name = nameText.getText();
    if ((name == null) || (name.trim().length() == 0)) {
        Window.alert("Must provide name!");
        return;
    }

    // Name provided
    this.userName = name;
    userDialog.hide();

    // Provide focus for writing message
    this.messageText.setFocus(true);
}

From source file:net.officefloor.tutorial.cometmanualapp.client.CometManualAppEntryPoint.java

License:Open Source License

@Override
public void onModuleLoad() {

    // Vertically align contents
    RootPanel panel = RootPanel.get("chat");
    VerticalPanel chatPanel = new VerticalPanel();
    panel.add(chatPanel);/*from   w w w  .ja  va  2s  .c o m*/

    // Provide dialog box for user name
    final DialogBox dialogBox = new DialogBox();
    dialogBox.setModal(true);
    HorizontalPanel userNamePanel = new HorizontalPanel();
    dialogBox.add(userNamePanel);
    userNamePanel.add(new Label("Enter user name: "));
    final TextBox userNameTextBox = new TextBox();
    userNamePanel.add(userNameTextBox);
    Button userNameSubmit = new Button("submit");
    userNamePanel.add(userNameSubmit);
    dialogBox.show();
    dialogBox.center();
    userNameSubmit.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            CometManualAppEntryPoint.this.userNameService.login(userNameTextBox.getText(),
                    new AsyncCallback<Void>() {
                        @Override
                        public void onSuccess(Void result) {
                            dialogBox.hide();
                        }

                        @Override
                        public void onFailure(Throwable caught) {
                            Window.alert("Failed to specify user name");
                        }
                    });
        }
    });

    // Provide the text area to contain conversation
    final TextArea conversation = new TextArea();
    conversation.setReadOnly(true);
    conversation.setSize("100%", "300px");
    chatPanel.add(conversation);

    // Handle listening for messages
    OfficeFloorComet.subscribe(ConversationSubscription.class, new ConversationSubscription() {
        @Override
        public void message(ConversationMessage message) {
            conversation.setText(conversation.getText() + "\n" + message.getName() + ": " + message.getText());
        }
    }, null);

    // Provide means to add message
    HorizontalPanel messagePanel = new HorizontalPanel();
    chatPanel.add(messagePanel);
    final TextBox message = new TextBox();
    message.setWidth("80%");
    messagePanel.add(message);
    Button send = new Button("send");
    messagePanel.add(send);

    // Handle submitting a message
    final ConversationSubscription publisher = OfficeFloorComet.createPublisher(ConversationSubscription.class);
    send.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            String messageText = message.getText();
            publisher.message(new ConversationMessage(messageText));
        }
    });
}

From source file:net.s17fabu.vip.gwt.showcase.client.content.popups.CwDialogBox.java

License:Apache License

/**
 * Create the dialog box for this example.
 * /*from   www .  ja v  a 2 s .  c o m*/
 * @return the new dialog box
 */
private DialogBox createDialogBox() {
    // Create a dialog box and set the caption text
    final DialogBox dialogBox = new DialogBox();
    dialogBox.ensureDebugId("cwDialogBox");
    dialogBox.setText(constants.cwDialogBoxCaption());

    // Create a table to layout the content
    VerticalPanel dialogContents = new VerticalPanel();
    dialogContents.setSpacing(4);
    dialogBox.setWidget(dialogContents);

    // Add some text to the top of the dialog
    HTML details = new HTML(constants.cwDialogBoxDetails());
    dialogContents.add(details);
    dialogContents.setCellHorizontalAlignment(details, HasHorizontalAlignment.ALIGN_CENTER);

    // Add an image to the dialog
    Image image = Showcase.images.jimmy().createImage();
    dialogContents.add(image);
    dialogContents.setCellHorizontalAlignment(image, HasHorizontalAlignment.ALIGN_CENTER);

    // Add a close button at the bottom of the dialog
    Button closeButton = new Button(constants.cwDialogBoxClose(), new ClickHandler() {
        public void onClick(ClickEvent event) {
            dialogBox.hide();
        }
    });
    dialogContents.add(closeButton);
    if (LocaleInfo.getCurrentLocale().isRTL()) {
        dialogContents.setCellHorizontalAlignment(closeButton, HasHorizontalAlignment.ALIGN_LEFT);

    } else {
        dialogContents.setCellHorizontalAlignment(closeButton, HasHorizontalAlignment.ALIGN_RIGHT);
    }

    // Return the dialog box
    return dialogBox;
}

From source file:net.sf.mmm.client.ui.gwt.widgets.richtext.RichTextToolbar.java

License:Apache License

/**
 * @param feature is the {@link RichTextFeature} to invoke (e.g. if according button has been clicked).
 *//*  w  w  w.jav a2  s.  com*/
protected void invokeFeature(RichTextFeature feature) {

    switch (feature) {
    case BOLD:
        RichTextToolbar.this.formatter.toggleBold();
        break;
    case ITALIC:
        RichTextToolbar.this.formatter.toggleItalic();
        break;
    case UNDERLINE:
        RichTextToolbar.this.formatter.toggleUnderline();
        break;
    case SUBSCRIPT:
        RichTextToolbar.this.formatter.toggleSubscript();
        break;
    case SUPERSCRIPT:
        RichTextToolbar.this.formatter.toggleSuperscript();
        break;
    case STRIKETHROUGH:
        RichTextToolbar.this.formatter.toggleStrikethrough();
        break;
    case ALIGN_LEFT:
        RichTextToolbar.this.formatter.setJustification(Justification.LEFT);
        break;
    case ALIGN_CENTER:
        RichTextToolbar.this.formatter.setJustification(Justification.CENTER);
        break;
    case ALIGN_RIGHT:
        RichTextToolbar.this.formatter.setJustification(Justification.RIGHT);
        break;
    case UNORDERED_LIST:
        RichTextToolbar.this.formatter.insertUnorderedList();
        break;
    case ORDERED_LIST:
        RichTextToolbar.this.formatter.insertOrderedList();
        break;
    case HORIZONTAL_LINE:
        RichTextToolbar.this.formatter.insertHorizontalRule();
        break;
    case INSERT_IMAGE:
        String url = Window.prompt(this.bundle.labelEnterImageUrl().getLocalizedMessage(), "http://");
        if (url != null) {
            RichTextToolbar.this.formatter.insertImage(url);
        }
        break;
    case INSERT_LINK:
        url = Window.prompt(this.bundle.labelEnterLinkUrl().getLocalizedMessage(), "http://");
        if (url != null) {
            RichTextToolbar.this.formatter.createLink(url);
            // this.linkMode = true;
        }
        break;
    case REMOVE_FORMAT:
        this.formatter.removeFormat();
        this.formatter.removeLink();
        break;
    case FONT_FAMILY:
        final DialogBox popup = new DialogBox();
        popup.setStylePrimaryName("Popup");
        popup.setText("Please choose font");
        Grid content = new Grid(3, 2);
        content.setWidget(0, 0, new Label("Font-Family"));
        final ListBox dropdownFontFamily = new ListBox(false);
        for (String font : JavaScriptUtil.getInstance().getAvailableFonts()) {
            dropdownFontFamily.addItem(font);
        }
        content.setWidget(0, 1, dropdownFontFamily);
        content.setWidget(1, 0, new Label("Font-Size"));
        final ListBox dropdownFontSize = new ListBox(false);
        for (FontSize size : FONT_SIZES) {
            dropdownFontSize.addItem(Integer.toString(size.getNumber()));
        }
        content.setWidget(1, 1, dropdownFontSize);
        Button widget = new Button("OK");
        ClickHandler handler = new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {

                popup.hide();
                String fontFamily = dropdownFontFamily.getValue(dropdownFontFamily.getSelectedIndex());
                RichTextToolbar.this.formatter.setFontName(fontFamily);
                String fontSize = dropdownFontSize.getValue(dropdownFontSize.getSelectedIndex());
                for (FontSize size : FONT_SIZES) {
                    if (Integer.toString(size.getNumber()).equals(fontSize)) {
                        RichTextToolbar.this.formatter.setFontSize(size);
                    }
                }
            }
        };
        widget.addClickHandler(handler);
        content.setWidget(2, 0, widget);
        popup.setGlassEnabled(true);
        popup.setWidget(content);
        popup.center();
        popup.show();
        break;
    case FONT_SIZE:
        JsSelection selection = JavaScriptUtil.getInstance()
                .getSelection(RichTextToolbar.this.richTextArea.getElement());
        Window.alert(selection.getText() + "\n" + selection.getHtml());
        // RichTextToolbar.this.formatter.setFontSize(fontSize);
        break;
    case INDENT:
        RichTextToolbar.this.formatter.rightIndent();
        break;
    case OUTDENT:
        RichTextToolbar.this.formatter.leftIndent();
        break;
    case UNDO:
        RichTextToolbar.this.formatter.undo();
        break;
    case REDO:
        RichTextToolbar.this.formatter.redo();
        break;
    default:
        break;
    }
}

From source file:net.urlgrey.mythpodcaster.client.AddSubscriptionHandler.java

License:Open Source License

@Override
public void onClick(ClickEvent arg0) {
    // Create a dialog box and set the caption text
    final DialogBox dialogBox = new DialogBox();
    dialogBox.ensureDebugId("cwDialogBox");
    dialogBox.setText("Add Transcoding Profile Subscription");

    // Create a table to layout the content
    VerticalPanel dialogContents = new VerticalPanel();
    dialogContents.setSpacing(4);/*w  ww  .j  a v a 2  s  .c o  m*/
    dialogBox.setWidget(dialogContents);

    // Transcoding Profile Selection
    final ListBox profileListBox;
    if (transcodingProfile == null) {
        HorizontalPanel listBoxPanel = new HorizontalPanel();
        listBoxPanel.add(new HTML("Transcoding Profile:&nbsp;"));
        profileListBox = new ListBox();
        listBoxPanel.add(profileListBox);
        dialogContents.add(listBoxPanel);
    } else {
        profileListBox = null;
    }

    final HorizontalPanel mostRecentPanel = new HorizontalPanel();
    mostRecentPanel.add(new HTML("Number of most recent to transcode:&nbsp;"));
    final ListBox mostRecentListBox = new ListBox();
    mostRecentListBox.addItem("1");
    mostRecentListBox.addItem("2");
    mostRecentListBox.addItem("3");
    mostRecentListBox.addItem("4");
    mostRecentListBox.addItem("5");
    mostRecentListBox.addItem("6");
    mostRecentListBox.addItem("7");
    mostRecentListBox.addItem("8");
    mostRecentListBox.addItem("9");
    mostRecentListBox.addItem("10");
    mostRecentPanel.add(mostRecentListBox);
    mostRecentPanel.setVisible(false);

    final HorizontalPanel specificRecordingsPanel = new HorizontalPanel();
    specificRecordingsPanel.add(new HTML("Specific Recordings:&nbsp;"));
    final ListBox recordingsListBox = new ListBox(true);
    recordingsListBox.setVisibleItemCount(5);
    specificRecordingsPanel.add(recordingsListBox);
    specificRecordingsPanel.setVisible(false);

    HorizontalPanel scopePanel = new HorizontalPanel();
    scopePanel.add(new HTML("Scope:&nbsp;"));
    final ListBox scopeListBox = new ListBox();
    scopeListBox.addItem("All recordings", SCOPE_ALL);
    scopeListBox.addItem("Number of Most Recent Recordings", SCOPE_MOST_RECENT);
    scopeListBox.addItem("Specific Recordings", SCOPE_SPECIFIC_RECORDINGS);
    scopePanel.add(scopeListBox);

    scopeListBox.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent arg0) {
            switch (scopeListBox.getSelectedIndex()) {
            case SCOPE_INDEX_ALL:
                mostRecentPanel.setVisible(false);
                specificRecordingsPanel.setVisible(false);
                dialogBox.center();
                break;
            case SCOPE_INDEX_MOST_RECENT:
                mostRecentPanel.setVisible(true);
                specificRecordingsPanel.setVisible(false);
                dialogBox.center();
                break;
            case SCOPE_INDEX_SPECIFIC_RECORDINGS:
                mostRecentPanel.setVisible(false);
                UIControllerServiceAsync service = (UIControllerServiceAsync) GWT
                        .create(UIControllerService.class);

                try {
                    service.listRecordingsForSeries(seriesId, new AsyncCallback<List<String[]>>() {

                        @Override
                        public void onFailure(Throwable arg0) {
                        }

                        @Override
                        public void onSuccess(List<String[]> recordings) {
                            recordingsListBox.clear();
                            final DateTimeFormat format = DateTimeFormat
                                    .getFormat(DateTimeFormat.PredefinedFormat.DATE_MEDIUM);
                            for (String[] recording : recordings) {
                                Date d = new Date(Long.valueOf(recording[2]));
                                final String recordingTitle = (recording[1] != null
                                        && recording[1].trim().length() > 0) ? recording[1] : seriesTitle;
                                final String label = "[" + format.format(d) + "] " + recordingTitle;
                                recordingsListBox.addItem(label, recording[0]);
                            }
                            specificRecordingsPanel.setVisible(true);
                            dialogBox.center();
                        }
                    });
                } catch (Exception e) {
                    e.printStackTrace();
                }

                break;
            }
        }
    });

    dialogContents.add(scopePanel);
    dialogContents.add(mostRecentPanel);
    dialogContents.add(specificRecordingsPanel);

    // Add a cancel button at the bottom of the dialog
    final Button cancelButton = new Button("Cancel", new ClickHandler() {
        public void onClick(ClickEvent event) {
            dialogBox.hide();
        }
    });

    // Add a cancel button at the bottom of the dialog
    final Button okButton = new Button("OK", new ClickHandler() {

        public void onClick(ClickEvent event) {
            UIControllerServiceAsync service = (UIControllerServiceAsync) GWT.create(UIControllerService.class);
            try {
                final FeedSubscriptionItemDTO item = new FeedSubscriptionItemDTO();
                item.setDateAdded(new Date());
                item.setSeriesId(seriesId);
                item.setTitle(seriesTitle);
                if (profileListBox != null) {
                    item.setTranscodeProfile(profileListBox.getValue(profileListBox.getSelectedIndex()));
                } else {
                    item.setTranscodeProfile(transcodingProfile);
                }

                switch (scopeListBox.getSelectedIndex()) {
                case SCOPE_INDEX_MOST_RECENT:
                    item.setScope(SCOPE_MOST_RECENT);
                    item.setNumberOfMostRecentToKeep(
                            Integer.parseInt(mostRecentListBox.getValue(mostRecentListBox.getSelectedIndex())));
                    break;
                case SCOPE_INDEX_SPECIFIC_RECORDINGS:
                    final Set<String> selectedRecordings = new HashSet<String>();
                    final int recordingCount = recordingsListBox.getItemCount();
                    for (int i = 0; i < recordingCount; i++) {
                        if (recordingsListBox.isItemSelected(i)) {
                            selectedRecordings.add(recordingsListBox.getValue(i));
                        }
                    }

                    final String[] result = selectedRecordings.toArray(new String[0]);
                    item.setScope(SCOPE_SPECIFIC_RECORDINGS);
                    item.setRecordedProgramKeys(result);
                    break;
                default:
                    item.setScope(SCOPE_ALL);
                    break;
                }

                // add subscription on the backend
                service.addSubscription(item, new AsyncCallback<Boolean>() {

                    @Override
                    public void onFailure(Throwable arg0) {
                        parent.refreshData();
                    }

                    @Override
                    public void onSuccess(Boolean arg0) {
                        parent.refreshData();
                    }
                });
            } catch (Exception e) {
                e.printStackTrace();
            }

            dialogBox.hide();
        }
    });

    final SimplePanel buttonTopSpacer = new SimplePanel();
    buttonTopSpacer.setHeight("20px");

    final SimplePanel buttonSpacer = new SimplePanel();
    buttonSpacer.setWidth("30px");

    HorizontalPanel buttonRow = new HorizontalPanel();
    buttonRow.add(cancelButton);
    buttonRow.add(buttonSpacer);
    buttonRow.add(okButton);
    dialogContents.add(buttonTopSpacer);
    dialogContents.add(buttonRow);
    dialogContents.setCellHorizontalAlignment(buttonRow, HasHorizontalAlignment.ALIGN_CENTER);
    if (LocaleInfo.getCurrentLocale().isRTL()) {
        dialogContents.setCellHorizontalAlignment(cancelButton, HasHorizontalAlignment.ALIGN_LEFT);

    } else {
        dialogContents.setCellHorizontalAlignment(cancelButton, HasHorizontalAlignment.ALIGN_RIGHT);
    }

    if (profileListBox == null) {
        // populate the dialog with the current settings in the backend

        UIControllerServiceAsync service = (UIControllerServiceAsync) GWT.create(UIControllerService.class);
        try {
            service.retrieveSubscriptionDetails(seriesId, transcodingProfile,
                    new AsyncCallback<FeedSubscriptionItemDTO>() {

                        @Override
                        public void onFailure(Throwable arg0) {

                        }

                        @Override
                        public void onSuccess(final FeedSubscriptionItemDTO item) {
                            if (SCOPE_MOST_RECENT.equals(item.getScope())) {
                                scopeListBox.setSelectedIndex(SCOPE_INDEX_MOST_RECENT);
                                mostRecentListBox.setSelectedIndex(item.getNumberOfMostRecentToKeep() - 1);
                                mostRecentPanel.setVisible(true);
                                specificRecordingsPanel.setVisible(false);
                                dialogBox.center();
                            } else if (SCOPE_SPECIFIC_RECORDINGS.equals(item.getScope())) {
                                scopeListBox.setSelectedIndex(SCOPE_INDEX_SPECIFIC_RECORDINGS);
                                UIControllerServiceAsync service = (UIControllerServiceAsync) GWT
                                        .create(UIControllerService.class);

                                try {
                                    service.listRecordingsForSeries(seriesId,
                                            new AsyncCallback<List<String[]>>() {

                                                @Override
                                                public void onFailure(Throwable arg0) {
                                                }

                                                @Override
                                                public void onSuccess(List<String[]> recordings) {
                                                    recordingsListBox.clear();
                                                    final DateTimeFormat format = DateTimeFormat.getFormat(
                                                            DateTimeFormat.PredefinedFormat.DATE_MEDIUM);
                                                    int i = 0;
                                                    for (String[] recording : recordings) {
                                                        Date d = new Date(Long.valueOf(recording[2]));
                                                        final String recordingTitle = (recording[1] != null
                                                                && recording[1].trim().length() > 0)
                                                                        ? recording[1]
                                                                        : seriesTitle;
                                                        final String label = "[" + format.format(d) + "] "
                                                                + recordingTitle;
                                                        recordingsListBox.addItem(label, recording[0]);
                                                        for (String id : item.getRecordedProgramKeys()) {
                                                            if (id.equals(recording[0])) {
                                                                recordingsListBox.setItemSelected(i, true);
                                                                break;
                                                            }
                                                        }
                                                        i++;
                                                    }

                                                    dialogBox.center();
                                                }
                                            });
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }

                                mostRecentPanel.setVisible(false);
                                specificRecordingsPanel.setVisible(true);
                            } else {
                                scopeListBox.setSelectedIndex(SCOPE_INDEX_ALL);
                                mostRecentPanel.setVisible(false);
                                specificRecordingsPanel.setVisible(false);
                                dialogBox.center();
                            }
                        }
                    });
        } catch (Exception e) {
        }
    } else {
        // configure the dialog to show the transcoding profiles that are not already in use with this
        // program

        UIControllerServiceAsync service = (UIControllerServiceAsync) GWT.create(UIControllerService.class);
        try {
            service.findAvailableTranscodingProfilesForSeries(seriesId, new AsyncCallback<List<String[]>>() {

                @Override
                public void onFailure(Throwable arg0) {

                }

                @Override
                public void onSuccess(List<String[]> profiles) {
                    for (String[] profile : profiles) {
                        profileListBox.addItem(profile[1], profile[0]);
                    }

                    dialogBox.center();
                }
            });
        } catch (Exception e) {
        }
    }
}

From source file:net.urlgrey.mythpodcaster.client.UnsubscribeHandler.java

License:Open Source License

@Override
public void onClick(ClickEvent event) {
    // Create a dialog box and set the caption text
    final DialogBox dialogBox = new DialogBox();
    dialogBox.ensureDebugId("cwDialogBox");
    dialogBox.setText("Unsubscribe?");

    // Create a table to layout the content
    VerticalPanel dialogContents = new VerticalPanel();
    dialogContents.setSpacing(4);// w  ww.j  a v a2 s.  c  o  m
    dialogBox.setWidget(dialogContents);

    // Add some text to the top of the dialog
    HTML details = new HTML("Are you sure you want to unsubscribe?");
    dialogContents.add(details);
    dialogContents.setCellHorizontalAlignment(details, HasHorizontalAlignment.ALIGN_CENTER);

    // Add a cancel button at the bottom of the dialog
    final Button cancelButton = new Button("Cancel", new ClickHandler() {
        public void onClick(ClickEvent event) {
            dialogBox.hide();
        }
    });

    // Add a cancel button at the bottom of the dialog
    final Button okButton = new Button("OK", new ClickHandler() {
        public void onClick(ClickEvent event) {
            UIControllerServiceAsync service = (UIControllerServiceAsync) GWT.create(UIControllerService.class);
            try {
                service.removeSubscription(seriesId, transcodingProfile, new AsyncCallback<Boolean>() {

                    @Override
                    public void onFailure(Throwable arg0) {
                        parent.refreshData();
                    }

                    @Override
                    public void onSuccess(Boolean arg0) {
                        parent.refreshData();
                    }
                });
            } catch (Exception e) {
                e.printStackTrace();
            }

            dialogBox.hide();
        }
    });

    final SimplePanel buttonTopSpacer = new SimplePanel();
    buttonTopSpacer.setHeight("20px");

    final SimplePanel buttonSpacer = new SimplePanel();
    buttonSpacer.setWidth("30px");

    HorizontalPanel buttonRow = new HorizontalPanel();
    buttonRow.add(cancelButton);
    buttonRow.add(buttonSpacer);
    buttonRow.add(okButton);
    dialogContents.add(buttonTopSpacer);
    dialogContents.add(buttonRow);
    dialogContents.setCellHorizontalAlignment(buttonRow, HasHorizontalAlignment.ALIGN_CENTER);
    if (LocaleInfo.getCurrentLocale().isRTL()) {
        dialogContents.setCellHorizontalAlignment(cancelButton, HasHorizontalAlignment.ALIGN_LEFT);

    } else {
        dialogContents.setCellHorizontalAlignment(cancelButton, HasHorizontalAlignment.ALIGN_RIGHT);
    }

    dialogBox.center();
    dialogBox.show();
}

From source file:no.eirikb.bomberman.client.ui.game.GamePanelContainer.java

License:BEER-WARE LICENSE

private void killCheck() {
    game.addGameListener(new GameListener() {

        @Override//w  w w  .  j a  v a  2 s  .  co  m
        public void addSprite(Sprite sprite) {
        }

        @Override
        public void removeSprite(Sprite sprite) {
        }

        @Override
        public void bump(Player player, Sprite sprite) {
        }

        @Override
        public void playerDie(final Player player) {
            if (player == gamePanel.getPlayer()) {
                gameService.died(new AsyncCallback() {

                    @Override
                    public void onFailure(Throwable caught) {
                    }

                    @Override
                    public void onSuccess(Object result) {
                    }
                });
                gamePanel.remove(player.getImage());
                final DialogBox dialogBox = new DialogBox();
                dialogBox.setText("Oh noes!");
                VerticalPanel v = new VerticalPanel();
                v.add(new Image("img/ohnoes.jpg"));
                v.add(new Label("Congratulations! You just died"));
                Button resurectButton = new Button("Resurect!", new ClickHandler() {

                    @Override
                    public void onClick(ClickEvent event) {
                        gameService.resurect(new AsyncCallback() {

                            @Override
                            public void onFailure(Throwable caught) {
                            }

                            @Override
                            public void onSuccess(Object result) {
                            }
                        });
                        player.setX(player.getStartX());
                        player.setY(player.getStartY());
                        game.playerLive(player);
                        dialogBox.setVisible(false);
                        dialogBox.hide();
                        focusPanel.setFocus(true);
                    }
                });
                v.add(resurectButton);
                dialogBox.setWidget(v);
                dialogBox.setAnimationEnabled(true);
                dialogBox.setPopupPosition(
                        gamePanel.getAbsoluteLeft() + (Settings.getInstance().getMapWidth() / 4),
                        gamePanel.getAbsoluteTop() + (Settings.getInstance().getMapHeight() / 4));
                dialogBox.show();
                resurectButton.setFocus(true);
            }
        }

        @Override
        public void playerLive(Player player) {
        }
    });

}