Example usage for com.google.gwt.user.client.ui PopupPanel setTitle

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

Introduction

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

Prototype

@Override
    public void setTitle(String title) 

Source Link

Usage

From source file:com.google.gwt.sample.stockwatcher.client.SitePage.java

private static void renderControllerPopups() {
    for (String site : Data.siteControllerList.keySet()) {
        ArrayList<PopupPanel> popups = new ArrayList<>();

        for (String controller : Data.siteControllerList.get(site)) {
            ArrayList<String> attributes = Data.controllerAttributeList.get(controller);

            final String name = attributes.get(0);
            final double x = Double.parseDouble(attributes.get(2));
            final double y = Double.parseDouble(attributes.get(3));

            Controller cToggle = new Controller(controller);

            final PopupPanel container = new PopupPanel();

            controllerIcons.add(container);

            container.add(cToggle);//from   w  w  w  .  j av a  2 s .co m
            container.getElement().getStyle().setBackgroundColor("rgba(255,0,0,0.0)");
            container.getElement().getStyle().setBorderWidth(0, Unit.PX);
            container.setTitle(name);

            container.setPopupPositionAndShow(new PopupPanel.PositionCallback() {
                public void setPosition(int offsetWidth, int offsetHeight) {
                    int left = sitePic.getAbsoluteLeft() + (int) (x * (double) sitePic.getWidth());
                    int top = sitePic.getAbsoluteTop() + (int) (y * (double) sitePic.getHeight());
                    container.setPopupPosition(left, top);
                }
            });
            container.setVisible(false);
            popups.add(container);
        }
        siteControllerPopupList.put(site, popups);
    }
}

From source file:com.nitrous.gwt.earth.client.demo.ShimDemo.java

License:Apache License

/**
 * This is how to display a GWT PopupPanel over the top of the Google Earth
 * Plug-in using the 'shim' technique. The shim technique places an IFrame
 * in-front of the earth plug-in but behind the PopupPanel by configuring
 * the absolute position, size and z-index of the IFrame.
 *///from  w  w w  .  j  a v  a 2  s.  c o  m
private void showPopupWindow() {

    // the HTML content to be rendered inside the PopupPanel
    HTML content = new HTML("<b>Window test</b><br>"
            + "This PopupPanel is visible since we have an IFrame (shim) between the PopupPanel and the Google Earth Plugin. "
            + "View source code <a href=\""
            + "http://code.google.com/p/gwt-earth-3/source/browse/trunk/src/com/nitrous/gwt/earth/client/demo/ShimDemo.java\""
            + " target=\"new\">here</a>");

    // configure the PopupPanel size and position
    final PopupPanel window = new PopupPanel(false, false);
    window.setTitle("Shim test");
    window.add(content);
    final int width = 300;
    final int height = 80;
    window.setSize(width + "px", height + "px");
    window.center();
    final int left = window.getPopupLeft();
    final int top = window.getPopupTop();

    // Configure the z-index of the PopupPanel HTML content so that it is rendered in-front of everything (highest z-index)
    content.getElement().setAttribute("style", "z-index: " + (Integer.MAX_VALUE) + ";" + " width: " + width
            + "px;" + " height: " + height + "px;");

    // PopupPanel is to be displayed immediately behind content (slightly lower z-index)
    window.getElement().setAttribute("style", "z-index: " + (Integer.MAX_VALUE - 1) + ";"
            + " position: absolute;" + " left: " + left + "px;" + " top: " + top + "px;");

    window.show();

    // Allow some time for the browser to render the window and then configure the IFrame shim
    Scheduler.get().scheduleDeferred(new ScheduledCommand() {
        @Override
        public void execute() {
            final IFrameElement iframe = Document.get().createIFrameElement();

            // Initialize the IFrame to be the same size and position as the
            // window but with a smaller z-index value.
            // The size of the IFrame is tweaked by +9px to allow the border of the PopupPanel to be rendered correctly.
            iframe.setAttribute("style",
                    "z-index: " + (Integer.MAX_VALUE - 2) + ";" + " width: " + (width + 9) + "px;" + " height: "
                            + (height + 9) + "px;" + " position: absolute;" + " left: " + left + "px;"
                            + " top: " + top + "px;");

            // add the IFrame to the document body
            Document.get().getBody().appendChild(iframe);

            // remove the IFrame when the PopupPanel is closed
            window.addCloseHandler(new CloseHandler<PopupPanel>() {
                @Override
                public void onClose(CloseEvent<PopupPanel> event) {
                    iframe.removeFromParent();
                }
            });
        }
    });
}

From source file:com.xpn.xwiki.watch.client.ui.articles.ArticleListWidget.java

License:Open Source License

protected PopupPanel buildPopup() {
    final PopupPanel popup = new PopupPanel(true);
    popup.setStyleName(watch.getCSSPrefix() + "-add-annotation-popup");
    FlowPanel contents = new FlowPanel();
    popup.setTitle("Add Annotation");
    final TextArea ta = new TextArea();

    Button cancel = new Button("Cancel", new ClickListener() {
        public void onClick(Widget arg0) {
            popup.hide();/*from   w w  w  . ja v  a2 s .  co  m*/
        }
    });
    Button annotate = new Button("Annotate", new ClickListener() {
        public void onClick(Widget arg0) {
            if (selection != null) {
                watch.getXWatchServiceInstance().addAnnotation(selection, ta.getText(),
                        currentArticle.getPageName(), new AsyncCallback<String>() {
                            public void onSuccess(String arg0) {
                                watch.refreshArticleList();
                            }

                            public void onFailure(Throwable arg0) {
                                Window.alert("FAILURE : " + arg0.toString());
                            }
                        });
            }
            popup.hide();
        }
    });
    FlowPanel taPanel = new FlowPanel();
    taPanel.addStyleName("popup-textarea");
    taPanel.add(ta);
    contents.add(taPanel);
    FlowPanel holder = new FlowPanel();
    holder.add(cancel);
    holder.add(annotate);
    holder.setStyleName("popup-panel-footer");
    contents.add(holder);
    popup.setWidget(contents);
    return popup;
}

From source file:de.lilawelt.zmachine.client.MachineInterface.java

License:Open Source License

public void fatal(String errmsg) {
    outer.clear();//w  w w. j a v a 2s .  c o m
    PopupPanel popup = new PopupPanel(false);
    popup.setTitle("Fatal error:");
    popup.setWidget(new Label(errmsg));
    popup.center();
    popup.show();
    throw new RuntimeException(errmsg);
}

From source file:org.primordion.xholon.io.AbstractXholonGui.java

License:Open Source License

/**
 * Create a GUI to interact with the attributes of an IXholon node.
 * @param node An IXholon node./*from   w  ww .ja  v  a2  s.c  o m*/
 * @param modal Whether or not the attributes GUI is modal.
 */
protected void createAttributesGui(IXholon node, boolean modal) {
    final IReflection ir = ReflectionFactory.instance();
    Object rowData[][] = null;
    if ("Application".equals(node.getRoleName())) {
        node = app;
    }
    final IXholon attrNode = node;
    rowData = ir.getAttributes(attrNode);

    Object columnNames[] = new Object[2];
    columnNames[0] = "Name";
    columnNames[1] = "Value";
    final Grid attrTable = new Grid(rowData.length + 1, 2); // (rowData, columnNames);
    attrTable.setText(0, 0, (String) columnNames[0]);
    attrTable.setText(0, 1, (String) columnNames[1]);
    for (int i = 0; i < rowData.length; i++) {
        attrTable.setText(i + 1, 0, (String) rowData[i][0]);
        if (rowData[i][1] == null) {
            attrTable.setText(i + 1, 1, "");
        } else {
            attrTable.setText(i + 1, 1, rowData[i][1].toString());
        }
    }

    attrTable.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            Cell cell = attrTable.getCellForEvent(event);
            if (cell != null) {
                int cellIndex = cell.getCellIndex();
                if (cellIndex == 0) {
                    return;
                }
                final int rowIndex = cell.getRowIndex();
                if ((attrNode != app) && (app.getAppSpecificAttribute(attrNode,
                        (Class<IXholon>) attrNode.getClass(), attrTable.getText(rowIndex, 0)) == null)) {
                    // this is a non-editable attribute
                    return;
                }
                Element ele = cell.getElement();
                String text = ele.getInnerText();
                //System.out.println(text);

                final TextBox textBox = new TextBox();
                // style it like a label so it looks like the original Element
                //textBox.setStylePrimaryName("gwt-Label"); // does nothing
                // set the style manually so it looks like the original Element
                textBox.getElement().setAttribute("style",
                        "border-width: 0px; padding-top: 0px; padding-bottom: 0px;");
                int textLen = text.length();
                textBox.setVisibleLength(textLen == 0 ? 5 : textLen); // can't be 0
                textBox.setText(text); // or setValue( ?
                attrTable.setWidget(rowIndex, 1, textBox);
                textBox.setFocus(true);
                // add a ChangeHandler to tell when user has finished editing
                textBox.addChangeHandler(new ChangeHandler() {
                    public void onChange(ChangeEvent event) {
                        if (attrNode == app) {
                            // change the value of an Application parameter
                            //ir.setParam(attrTable.getText(rowIndex, 0), textBox.getText(), app);
                            app.setParam(attrTable.getText(rowIndex, 0), textBox.getText());
                        } else {
                            // change the value of the Xholon node
                            app.setAppSpecificAttribute(attrNode, (Class<IXholon>) attrNode.getClass(),
                                    attrTable.getText(rowIndex, 0), textBox.getText());
                        }
                        // set the changed text back into the Attributes panel
                        attrTable.setText(rowIndex, 1, textBox.getText());
                    }
                });
                // add a BlurHandler
                textBox.addBlurHandler(new BlurHandler() {
                    public void onBlur(BlurEvent event) {
                        attrTable.setText(rowIndex, 1, textBox.getText());
                    }
                });
            }
        }

    });

    ScrollPanel scrollPanel = new ScrollPanel(attrTable);
    scrollPanel.setSize("500px", "500px");

    PopupPanel popup = new PopupPanel(true);
    popup.setTitle("Atttributes of " + attrNode.getName());
    popup.add(scrollPanel);
    popup.center();
}

From source file:org.qualipso.factory.ui.service.oslc.client.view.CreateOSLCCheckerView.java

License:Open Source License

public void showErrorPopupPanel(String message) {
    PopupPanel errorPopup = new PopupPanel();
    errorPopup.setAnimationEnabled(true);
    errorPopup.setGlassEnabled(true);/*w w  w  . java2 s. co m*/
    errorPopup.setTitle("An error occured");
    Label label = new Label();
    label.setText(message);
    errorPopup.setWidget(label);
    errorPopup.show();
}