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

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

Introduction

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

Prototype

public DialogBox(Caption captionWidget) 

Source Link

Document

Creates an empty dialog box specifying its Caption .

Usage

From source file:org.vectomatic.svg.samples.client.Main.java

License:Open Source License

@Override
public void onModuleLoad() {
    GWT.setUncaughtExceptionHandler(new GWT.UncaughtExceptionHandler() {
        public void onUncaughtException(Throwable throwable) {
            String text = "Uncaught exception: ";
            while (throwable != null) {
                StackTraceElement[] stackTraceElements = throwable.getStackTrace();
                text += throwable.toString() + "\n";
                for (int i = 0; i < stackTraceElements.length; i++) {
                    text += "    at " + stackTraceElements[i] + "\n";
                }/*w ww  . j a v  a2s.  c o  m*/
                throwable = throwable.getCause();
                if (throwable != null) {
                    text += "Caused by: ";
                }
            }
            DialogBox dialogBox = new DialogBox(true);
            DOM.setStyleAttribute(dialogBox.getElement(), "backgroundColor", "#ABCDEF");
            System.err.print(text);
            text = text.replaceAll(" ", "&nbsp;");
            dialogBox.setHTML("<pre>" + text + "</pre>");
            dialogBox.center();
        }
    });
    mainBundle.css().ensureInjected();

    // Generate the source code for the examples
    GWT.create(GeneratorInfo.class);
    SplitLayoutPanel panel = binder.createAndBindUi(this);

    // Populate the sample tree
    TreeItem shapesSample = tree
            .addItem(AbstractImagePrototype.create(mainBundle.treeItem()).getHTML() + " shapes");
    shapesSample.setUserObject(new ShapesSample());
    TreeItem eventSample = tree
            .addItem(AbstractImagePrototype.create(mainBundle.treeItem()).getHTML() + " events");
    eventSample.setUserObject(new EventSample());
    TreeItem parserSample = tree
            .addItem(AbstractImagePrototype.create(mainBundle.treeItem()).getHTML() + " parser");
    parserSample.setUserObject(new ParserSample());
    TreeItem featuresSample = tree
            .addItem(AbstractImagePrototype.create(mainBundle.treeItem()).getHTML() + " features");
    featuresSample.setUserObject(new FeaturesSample());
    TreeItem widgetsSample = tree
            .addItem(AbstractImagePrototype.create(mainBundle.treeItem()).getHTML() + " widgets");
    widgetsSample.setUserObject(new WidgetsSample());
    TreeItem smilSample = tree
            .addItem(AbstractImagePrototype.create(mainBundle.treeItem()).getHTML() + " SMIL animation");
    smilSample.setUserObject(new SmilSample());
    TreeItem xpathSample = tree
            .addItem(AbstractImagePrototype.create(mainBundle.treeItem()).getHTML() + " XPath");
    xpathSample.setUserObject(new XPathSample());
    TreeItem about = tree.addItem(AbstractImagePrototype.create(mainBundle.treeItem()).getHTML() + " about");
    about.setUserObject(new AboutSample());
    tree.addSelectionHandler(new SelectionHandler<TreeItem>() {
        @Override
        public void onSelection(SelectionEvent<TreeItem> event) {
            SampleBase currentSample = (SampleBase) event.getSelectedItem().getUserObject();
            selectSample(currentSample.getPanel());
        }

    });
    tree.setSelectedItem(shapesSample);

    RootLayoutPanel.get().add(panel);
}

From source file:thothbot.parallax.demo.client.Demo.java

License:Open Source License

public void onModuleLoad() {
    GWT.setUncaughtExceptionHandler(new GWT.UncaughtExceptionHandler() {
        public void onUncaughtException(Throwable throwable) {
            Log.error("Uncaught exception", throwable);
            if (!GWT.isScript()) {
                String text = "Uncaught exception: ";
                while (throwable != null) {
                    StackTraceElement[] stackTraceElements = throwable.getStackTrace();
                    text += throwable.toString() + "\n";

                    for (int i = 0; i < stackTraceElements.length; i++)
                        text += "    at " + stackTraceElements[i] + "\n";

                    throwable = throwable.getCause();
                    if (throwable != null)
                        text += "Caused by: ";
                }/*from  w  ww  . jav  a  2  s.  c  om*/

                DialogBox dialogBox = new DialogBox(true);
                DOM.setStyleAttribute(dialogBox.getElement(), "backgroundColor", "#ABCDEF");
                text = text.replaceAll(" ", "&nbsp;");
                dialogBox.setHTML("<pre>" + text + "</pre>");
                dialogBox.center();
            }
        }
    });

    // Generate the source code for examples
    GWT.create(GenerateSourceSignal.class);

    // Generate the demo file
    GWT.create(GenerateFacebookSignal.class);

    resources.css().ensureInjected();

    // Create the application shell.
    final SingleSelectionModel<ContentWidget> selectionModel = new SingleSelectionModel<ContentWidget>();
    final DataModel treeModel = new DataModel(selectionModel);
    Set<ContentWidget> contentWidgets = treeModel.getAllContentWidgets();

    index = new Index();
    // Hide loading panel
    RootPanel.get("loading").getElement().getStyle().setVisibility(Visibility.HIDDEN);
    // Attach index panel
    RootLayoutPanel.get().add(index);

    index.getTabIndex().addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            displayIndex();
        }
    });

    indexWidget = new IndexWidget(treeModel);
    shell = new DemoShell(treeModel, index);

    // Prefetch examples when opening the Category tree nodes.
    final List<Category> prefetched = new ArrayList<Category>();
    final CellTree mainMenu = shell.getMainMenu();

    mainMenu.addOpenHandler(new OpenHandler<TreeNode>() {
        public void onOpen(OpenEvent<TreeNode> event) {
            Object value = event.getTarget().getValue();
            if (!(value instanceof Category))
                return;

            Category category = (Category) value;
            if (!prefetched.contains(category)) {
                prefetched.add(category);
                Prefetcher.prefetch(category.getSplitPoints());
            }
        }
    });

    // Always prefetch.
    Prefetcher.start();

    // Change the history token when a main menu item is selected.
    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
        public void onSelectionChange(SelectionChangeEvent event) {
            ContentWidget selected = selectionModel.getSelectedObject();
            if (selected != null) {
                index.setContentWidget(shell);
                History.newItem("!" + selected.getContentWidgetToken(), true);
            }
        }
    });

    // Setup a history handler to reselect the associate menu item.
    final ValueChangeHandler<String> historyHandler = new ValueChangeHandler<String>() {
        public void onValueChange(ValueChangeEvent<String> event) {
            // Get the content widget associated with the history token.
            ContentWidget contentWidget = treeModel
                    .getContentWidgetForToken(event.getValue().replaceFirst("!", ""));

            if (contentWidget == null)
                return;

            // Expand the tree node associated with the content.
            Category category = treeModel.getCategoryForContentWidget(contentWidget);
            TreeNode node = mainMenu.getRootTreeNode();
            int childCount = node.getChildCount();
            for (int i = 0; i < childCount; i++) {
                if (node.getChildValue(i) == category) {
                    node.setChildOpen(i, true, true);
                    break;
                }
            }

            // Display the content widget.
            displayContentWidget(contentWidget);

            //Add GA statistics
            trackPageview(Window.Location.getHref());

            // Select the node in the tree.
            selectionModel.setSelected(contentWidget, true);
        }
    };

    History.addValueChangeHandler(historyHandler);

    // Show the initial example.
    if (History.getToken().length() > 0)
        History.fireCurrentHistoryState();

    // Use the first token available.
    else
        displayIndex();

    // Generate a site map.
    createSiteMap(contentWidgets);
}

From source file:tv.dyndns.kishibe.qmaclone.client.creation.CreationUi.java

License:Open Source License

private void showRepeatedPostWarning() {
    final DialogBox dialogBox = new DialogBox(true);

    VerticalPanel panel = new VerticalPanel();
    panel.add(//  w ww  .  ja va 2 s  .  com
            new HTML(new SafeHtmlBuilder()
                    .appendEscapedLines(
                            "????????\n"
                                    + "???????????????\n"
                                    + "??????????")
                    .toSafeHtml()));
    panel.add(new Button("OK", new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            dialogBox.hide();
        }
    }));
    dialogBox.setWidget(panel);
    dialogBox.setAnimationEnabled(true);
    dialogBox.setGlassEnabled(true);
    dialogBox.setHTML(SafeHtmlUtils.fromString("?"));
    dialogBox.setPopupPosition(100, 100);
    dialogBox.show();
}