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

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

Introduction

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

Prototype

@Override
    public void setWidget(Widget w) 

Source Link

Usage

From source file:$.HelloPlugins.java

License:Apache License

@Override
    public void onModuleLoad() {
        Image img = new Image("http://code.google.com/webtoolkit/logo-185x175.png");
        Button button = new Button("Click me");

        VerticalPanel vPanel = new VerticalPanel();
        vPanel.setWidth("100%");
        vPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);
        vPanel.add(img);//from www  .j ava  2s .com
        vPanel.add(button);

        RootPanel.get().add(vPanel);

        // Create the dialog box
        final DialogBox dialogBox = new DialogBox();

        // The content of the dialog comes from a User specified Preference
        dialogBox.setText("Hello from GWT Gerrit UI plugin");
        dialogBox.setAnimationEnabled(true);
        Button closeButton = new Button("Close");
        VerticalPanel dialogVPanel = new VerticalPanel();
        dialogVPanel.setWidth("100%");
        dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);
        dialogVPanel.add(closeButton);

        closeButton.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                dialogBox.hide();
            }
        });

        // Set the contents of the Widget
        dialogBox.setWidget(dialogVPanel);

        button.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                dialogBox.center();
                dialogBox.show();
            }
        });
    }

From source file:asquare.gwt.tests.coordinates.client.Demo.java

License:Apache License

public void onModuleLoad() {
    DialogBox dialog = new DialogBox() {
        {/*from ww w  .  j av a  2  s.co  m*/
            addDomHandler(new MouseDownHandler() {
                public void onMouseDown(MouseDownEvent event) {
                    Debug.println("DialogBox.onMouseDown(" + event.getX() + "," + event.getY() + ")");
                }
            }, MouseDownEvent.getType());
        }
    };
    dialog.setText("Dialog Caption");
    Image image = new Image("one.gif");
    DOM.setStyleAttribute(image.getElement(), "height", "100px");
    DOM.setStyleAttribute(image.getElement(), "width", "200px");

    dialog.setWidget(image);
    dialog.show();
    dialog.setPopupPosition(200, 200);

    Debug.enable();
    if (!GWT.isScript())
        DebugConsole.getInstance().disable();

    new DebugHierarchyInspector().install();
    new DebugElementDumpInspector().install();
    new DebugEventListener('a', Event.ONMOUSEDOWN, "Absolute position inspector") {
        protected void doEvent(Event event) {
            Element target = DOM.eventGetTarget(event);
            Debug.println(getTagName(target) + "[absLeft=" + DOM.getAbsoluteLeft(target) + ",absTop="
                    + DOM.getAbsoluteTop(target) + "]");
        }
    }.install();

    new DebugEventListener('o', Event.ONMOUSEDOWN, "Offset hierarchy inspector") {
        protected void doEvent(Event event) {
            Element target = DOM.eventGetTarget(event);
            printOffsetHierarchy(target);
        }
    }.install();

    new DebugEventListener().install();
}

From source file:bingo.client.Bingo.java

License:Open Source License

private void initAdminGrid(final String userId, final BingoGrid bingoGrid, final boolean hasFinished) {
    final Timer timer = new Timer() {
        int totalParticipants = 0;

        @Override//  ww w  . ja v a  2  s  . c  o m
        public void run() {
            bingoService.getTotalParticipants(userId, new AsyncCallback<Integer>() {
                @Override
                public void onFailure(Throwable caught) {
                }

                @Override
                public void onSuccess(Integer result) {
                    totalParticipants = result.intValue();
                }
            });

            bingoService.getVotes(userId, new AsyncCallback<int[][]>() {
                @Override
                public void onFailure(Throwable caught) {
                    message.setText(caught.getMessage());
                }

                @Override
                public void onSuccess(int[][] result) {
                    if (result == null) {
                        result = new int[BingoGrid.ROW][BingoGrid.COL];
                        for (int i = 0; i < BingoGrid.ROW; i++)
                            for (int j = 0; j < BingoGrid.COL; j++)
                                result[i][j] = 0;
                    }

                    for (int row = 0; row < BingoGrid.ROW; ++row)
                        for (int col = 0; col < BingoGrid.COL; ++col) {
                            bingoGrid.setVoteString(row, col, String.valueOf(result[row][col]),
                                    String.valueOf(totalParticipants));
                        }
                }
            });
        }
    };

    // If the game is not finished, repeat; if so, run once
    if (!hasFinished)
        timer.scheduleRepeating(ADMIN_TIMER);
    else
        timer.run();

    HorizontalPanel panel = new HorizontalPanel();
    panel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    final Button finishButton = new Button();

    // If the game is not finished, allow finishing it; if so, allow download data
    if (!hasFinished)
        finishButton.setText(strings.finishBingo());
    else
        finishButton.setText(strings.download());

    finishButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            if (!hasFinished)
                bingoService.finishBingo(userId, new AsyncCallback<Void>() {
                    @Override
                    public void onFailure(Throwable caught) {
                        message.setText(caught.getMessage());
                    }

                    @Override
                    public void onSuccess(Void result) {
                        message.setText(strings.finishedBingo());
                        finishButton.setText(strings.download());
                        timer.cancel();
                    }
                });

            bingoService.getVotes(userId, new AsyncCallback<int[][]>() {
                @Override
                public void onFailure(Throwable caught) {
                    message.setText(caught.getMessage());
                }

                @Override
                public void onSuccess(int[][] result) {
                    // Create a popup dialog box
                    final DialogBox box = new DialogBox();
                    box.setText(strings.info());
                    box.setAnimationEnabled(true);

                    final Button boxAcceptButton = new Button(strings.accept());
                    boxAcceptButton.addClickHandler(new ClickHandler() {
                        @Override
                        public void onClick(ClickEvent event) {
                            box.hide();
                        }
                    });

                    Label boxLabel = new Label();
                    boxLabel.setText(strings.finishMessage());
                    HTML voteData = new HTML();
                    if (result == null) {
                        result = new int[BingoGrid.ROW][BingoGrid.COL];
                        for (int i = 0; i < BingoGrid.ROW; i++)
                            for (int j = 0; j < BingoGrid.COL; j++)
                                result[i][j] = 0;
                    }

                    String cellKey = "";
                    String cellString = "";
                    String voteDataString = "";
                    for (int row = 0; row < BingoGrid.ROW; ++row)
                        for (int col = 0; col < BingoGrid.COL; ++col) {
                            cellKey = "cell" + row + col;
                            cellString = strings.map().get(cellKey);
                            voteDataString += "&nbsp;&nbsp;&nbsp;" + cellString + " = " + result[row][col]
                                    + "<br>";
                        }
                    voteData.setHTML(voteDataString);
                    voteData.addStyleName("boxData");

                    VerticalPanel boxPanel = new VerticalPanel();
                    boxPanel.addStyleName("boxPanel");
                    boxPanel.add(boxLabel);
                    boxPanel.add(voteData);

                    HorizontalPanel buttonsPanel = new HorizontalPanel();
                    buttonsPanel.add(boxAcceptButton);
                    boxPanel.add(buttonsPanel);
                    boxPanel.setCellHorizontalAlignment(buttonsPanel, HasHorizontalAlignment.ALIGN_CENTER);

                    box.setWidget(boxPanel);
                    box.center();
                }
            });
        }
    });
    panel.add(finishButton);

    final Button terminateButton = new Button(strings.terminateButton());
    terminateButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            // Create a popup dialog box
            final DialogBox box = new DialogBox();
            box.setText(strings.warning());
            box.setAnimationEnabled(true);

            final Button boxCancelButton = new Button(strings.cancel());
            boxCancelButton.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    box.hide();
                }
            });
            final Button boxAcceptButton = new Button(strings.accept());
            boxAcceptButton.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    bingoService.terminateBingo(userId, new AsyncCallback<Void>() {
                        @Override
                        public void onFailure(Throwable caught) {
                            message.setText(caught.getMessage());
                        }

                        @Override
                        public void onSuccess(Void result) {
                            message.setText(strings.terminatedBingo());
                            timer.cancel();
                        }

                    });
                    box.hide();
                }
            });

            final Label boxLabel = new Label();
            boxLabel.setText(strings.terminateMessage());

            VerticalPanel boxPanel = new VerticalPanel();

            boxPanel.addStyleName("boxPanel");
            boxPanel.add(boxLabel);

            HorizontalPanel buttonsPanel = new HorizontalPanel();
            buttonsPanel.add(boxCancelButton);
            buttonsPanel.add(boxAcceptButton);
            boxPanel.add(buttonsPanel);

            box.setWidget(boxPanel);
            box.center();
        }
    });
    panel.add(terminateButton);

    RootPanel.get("buttons").clear();
    RootPanel.get("buttons").add(panel);
}

From source file:ch.unifr.pai.twice.layout.client.eclipseLayout.MiceSplitLayoutPanel.java

License:Apache License

/**
 * Removes the widget from the root layout and presents it in a dialog box.
 * //from  w  w  w .j ava  2 s .  c o m
 * @param w
 */
private void toDialog(ResizableDecoratorPanel w) {
    if (isInFullscreenMode) {
        w = originSlotOfCurrentFullscreenWidget;
        releaseFullScreen();
    }
    final ResizableDecoratorPanel finalSlot = w;
    MiceDialogCaption caption;
    final DialogBox dbox = new DialogBox(false, false, (caption = new MiceDialogCaption()));
    caption.setHandlers(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            closeDialog(dbox);
            makeFullScreen(finalSlot);
        }
    }, new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            closeDialog(dbox);
        }
    });
    dialogs.put(dbox, w);
    dbox.setPopupPosition(w.getAbsoluteLeft(), w.getAbsoluteTop());
    Widget element = slots.get(w);
    dbox.setWidget(element);
    widthOfDialogsOriginalSlots.put(w, getSizeForWidget(w));
    dbox.show();
    if (getWidgetDirection(w) == Direction.CENTER) {
        ResizableDecoratorPanel lastAddedDecoratorPanel = getLastAddedNonDialogSlot();
        if (lastAddedDecoratorPanel != null) {
            setWidgetToSlot((ResizableDecoratorPanel) getCenter(), slots.get(lastAddedDecoratorPanel));
            setWidgetSize(lastAddedDecoratorPanel, 0);
            originsOfCenterReplacements.put(lastAddedDecoratorPanel, getSizeForWidget(lastAddedDecoratorPanel));
        }
    } else {
        setWidgetSize(w, 0);
    }
    onResize();
}

From source file:client.Tetris.java

License:Apache License

public static void gameOverEx() {
    // Create the dialog box
    final DialogBox dialogBox = new DialogBox();
    final String gameOverText = "You just lost <a href='http://www.google.com/"
            + "search?q=lost+the+game'>The Game</a>";
    dialogBox.setHTML(gameOverText);/*from  ww w.j  a va 2 s.  c o  m*/
    dialogBox.setAnimationEnabled(true);
    HTML html = new HTML("<u>Controls</u><br/>" + "<b>Right Left Down</b>: move around<br/>"
            + "<b>Up</b>: rotate clockwise<br/>" + "<b>Space</b>: drop");
    Button button = new Button("New Game");
    VerticalPanel dialogVPanel = new VerticalPanel();
    dialogVPanel.setWidth("100%");
    dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);
    dialogVPanel.add(html);
    dialogVPanel.add(button);

    button.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            dialogBox.hide();
            newGame();
        }
    });

    // Set the contents of the Widget
    dialogBox.setWidget(dialogVPanel);
    dialogBox.center();
    dialogBox.show();
}

From source file:com.akjava.gwt.subplayer.client.SubPlayer.java

License:Apache License

private void loadSrt(final int selectIndex) {
    final String text = loadPanel.getText();

    final DialogBox dialog = new DialogBox();

    //dialog.setSize("200px", "200px");
    dialog.setText("Subtitle Parsing");
    //GWT.log(loadImg.getUrl());
    //loadImg.setVisible(true);
    VerticalPanel vpanel = new VerticalPanel();
    //Image img=new Image("../img/loadanime.gif");
    //GWT.log(img.getUrl());
    //loadImg.setVisible(true);
    vpanel.add(loadImg);//  ww w .  ja v a 2  s.c  o  m
    dialog.setWidget(vpanel);
    dialog.setModal(true);
    dialog.setGlassEnabled(true);
    dialog.show();
    dialog.center();

    Timer timer = new Timer() {

        @Override
        public void run() {

            SRTParser parser = new SRTParser();
            SRTList list = parser.parse(text.split("\n"));
            dialog.hide();

            playerWidget.setSubLength(list.size());
            if (list.size() > 0) {
                preference.setSrtText(text);
                preference.setSrtSelectIndex(0);
                playerWidget.setSubIndex(0);
            }
            itemPanel.clear();
            for (int i = 0; i < list.size(); i++) {
                SRTObject srt = list.getSRTObjectAt(i);
                SRTItemPanel panel = new SRTItemPanel(srt);
                panel.addClickHandler(selectWidgetHandler);
                itemPanel.add(panel);
            }
            initPlayerSettings();
            tab.selectTab(0);//switch to view
            //label mode
            updateNoSubtitleWarning();
            selectWidget(selectIndex);
        }
    };
    timer.schedule(100);

}

From source file:com.appspot.socialinquirer.client.activity.TopicsActivity.java

License:Apache License

@Override
public void onTagCloudClicked() {
    final EverScribeConstants constants = clientFactory.getConstants();
    clientFactory.getUserService().getUserTags(50, new AsyncCallback<ArrayList<Tag>>() {

        @Override/*from   w ww  .  j a  va  2 s. c  o m*/
        public void onFailure(Throwable caught) {
            UiUtils.showErrorDialog(constants, caught.getLocalizedMessage());
        }

        @Override
        public void onSuccess(ArrayList<Tag> result) {
            TagCloud tagCloud = new TagCloud();
            tagCloud.setColored(true);

            for (Tag tag : result) {
                WordTag word = new WordTag(tag.getTag());
                word.setNumberOfOccurences(tag.getFreqency());
                tagCloud.addWord(word);
            }

            final DialogBox dialogBox = new DialogBox();
            dialogBox.setText(constants.titleDialogBoxTagCloud());
            dialogBox.setAnimationEnabled(true);
            VerticalPanel dialogVPanel = new VerticalPanel();
            dialogVPanel.setHorizontalAlignment(HasAlignment.ALIGN_CENTER);
            dialogVPanel.add(tagCloud);
            final Button closeButton = new Button(constants.closeButton());
            // We can set the id of a widget by accessing its
            // Element
            closeButton.getElement().setId("closeButton");
            dialogVPanel.add(closeButton);
            dialogBox.setWidget(dialogVPanel);

            closeButton.addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent event) {
                    dialogBox.hide();
                }
            });
            dialogBox.center();
        }
    });
}

From source file:com.appspot.socialinquirer.client.util.UiUtils.java

License:Apache License

/**
 * Show settings saved dialog.//from ww w.j  a  v  a 2 s .  co  m
 *
 * @param constants the constants
 */
public static void showSettingsSavedDialog(EverScribeConstants constants) {
    final DialogBox dialogBox = new DialogBox();
    dialogBox.setText(constants.titleDialogBoxOperationSuccessful());
    dialogBox.setAnimationEnabled(true);
    VerticalPanel dialogVPanel = new VerticalPanel();
    dialogVPanel.setHorizontalAlignment(HasAlignment.ALIGN_CENTER);
    dialogVPanel.add(new Label(constants.settingsSaved()));
    final Button closeButton = new Button(constants.closeButton());
    closeButton.getElement().setId("closeButton");
    dialogVPanel.add(closeButton);
    dialogBox.setWidget(dialogVPanel);

    closeButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            dialogBox.hide();
        }
    });
    dialogBox.center();
}

From source file:com.appspot.socialinquirer.client.util.UiUtils.java

License:Apache License

/**
 * Show error dialog./*from   w w w  . j  a  v  a2  s  .  c o m*/
 *
 * @param constants the constants
 * @param message the message
 */
public static void showErrorDialog(EverScribeConstants constants, String message) {
    final DialogBox dialogBox = new DialogBox();
    dialogBox.setText(constants.titleDialogBoxError());
    dialogBox.setAnimationEnabled(true);
    VerticalPanel dialogVPanel = new VerticalPanel();
    dialogVPanel.setHorizontalAlignment(HasAlignment.ALIGN_CENTER);
    dialogVPanel.add(new Label(message));
    final Button closeButton = new Button(constants.closeButton());
    closeButton.getElement().setId("closeButton");
    dialogVPanel.add(closeButton);
    dialogBox.setWidget(dialogVPanel);

    closeButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            dialogBox.hide();
        }
    });
    dialogBox.center();
}

From source file:com.appspot.socialinquirer.client.util.UiUtils.java

License:Apache License

/**
 * Show help dialog.//from w ww . ja va  2  s  .co m
 *
 * @param clientFactory the client factory
 * @param name the name
 */
public static void showHelpDialog(ClientFactory clientFactory, String name) {
    final EverScribeConstants constants = clientFactory.getConstants();
    clientFactory.getContentService().getHelpText(name, new AsyncCallback<String>() {

        @Override
        public void onFailure(Throwable caught) {
            UiUtils.showErrorDialog(constants, caught.getLocalizedMessage());
        }

        @Override
        public void onSuccess(String result) {
            final DialogBox dialogBox = new DialogBox();
            dialogBox.setText(constants.titleDialogBoxHelp());
            dialogBox.setAnimationEnabled(true);
            dialogBox.setWidth("400px");
            dialogBox.setHeight("200px");
            VerticalPanel dialogVPanel = new VerticalPanel();
            dialogVPanel.add(new HTML(result));
            final Button closeButton = new Button(constants.closeButton());
            // We can set the id of a widget by accessing its
            // Element
            closeButton.getElement().setId("closeButton");
            dialogVPanel.add(closeButton);
            dialogBox.setWidget(dialogVPanel);

            closeButton.addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent event) {
                    dialogBox.hide();
                }
            });
            dialogBox.center();
        }
    });
}