Package com.vaadin.terminal.gwt.client

Examples of com.vaadin.terminal.gwt.client.UIDL$XML


        // Open URL:s
        boolean isClosed = false; // was this window closed?
        while (childIndex < uidl.getChildCount()
                && "open".equals(uidl.getChildUIDL(childIndex).getTag())) {
            final UIDL open = uidl.getChildUIDL(childIndex);
            final String url = open.getStringAttribute("src");
            final String target = open.getStringAttribute("name");
            if (target == null) {
                // source will be opened to this browser window, but we may have
                // to finish rendering this window in case this is a download
                // (and window stays open).
                DeferredCommand.addCommand(new Command() {
                    public void execute() {
                        goTo(url);
                    }
                });
            } else if ("_self".equals(target)) {
                // This window is closing (for sure). Only other opens are
                // relevant in this change. See #3558, #2144
                isClosed = true;
                goTo(url);
            } else {
                String options;
                if (open.hasAttribute("border")) {
                    if (open.getStringAttribute("border").equals("minimal")) {
                        options = "menubar=yes,location=no,status=no";
                    } else {
                        options = "menubar=no,location=no,status=no";
                    }

                } else {
                    options = "resizable=yes,menubar=yes,toolbar=yes,directories=yes,location=yes,scrollbars=yes,status=yes";
                }

                if (open.hasAttribute("width")) {
                    int w = open.getIntAttribute("width");
                    options += ",width=" + w;
                }
                if (open.hasAttribute("height")) {
                    int h = open.getIntAttribute("height");
                    options += ",height=" + h;
                }

                Window.open(url, target, options);
            }
            childIndex++;
        }
        if (isClosed) {
            // don't render the content, something else will be opened to this
            // browser view
            rendering = false;
            return;
        }

        // Draw this application level window
        UIDL childUidl = uidl.getChildUIDL(childIndex);
        final Paintable lo = client.getPaintable(childUidl);

        if (layout != null) {
            if (layout != lo) {
                // remove old
                client.unregisterPaintable(layout);
                // add new
                setWidget((Widget) lo);
                layout = lo;
            }
        } else {
            setWidget((Widget) lo);
            layout = lo;
        }

        layout.updateFromUIDL(childUidl, client);
        if (!childUidl.getBooleanAttribute("cached")) {
            updateParentFrameSize();
        }

        // Save currently open subwindows to track which will need to be closed
        final HashSet<VWindow> removedSubWindows = new HashSet<VWindow>(
                subWindows);

        // Handle other UIDL children
        while ((childUidl = uidl.getChildUIDL(++childIndex)) != null) {
            String tag = childUidl.getTag().intern();
            if (tag == "actions") {
                if (actionHandler == null) {
                    actionHandler = new ShortcutActionHandler(id, client);
                }
                actionHandler.updateActionMap(childUidl);
            } else if (tag == "execJS") {
                String script = childUidl.getStringAttribute("script");
                eval(script);
            } else if (tag == "notifications") {
                for (final Iterator it = childUidl.getChildIterator(); it
                        .hasNext();) {
                    final UIDL notification = (UIDL) it.next();
                    String html = "";
                    if (notification.hasAttribute("icon")) {
                        final String parsedUri = client
                                .translateVaadinUri(notification
                                        .getStringAttribute("icon"));
                        html += "<img src=\"" + parsedUri + "\" />";
                    }
                    if (notification.hasAttribute("caption")) {
                        html += "<h1>"
                                + notification.getStringAttribute("caption")
                                + "</h1>";
                    }
                    if (notification.hasAttribute("message")) {
                        html += "<p>"
                                + notification.getStringAttribute("message")
                                + "</p>";
                    }

                    final String style = notification.hasAttribute("style") ? notification
                            .getStringAttribute("style") : null;
                    final int position = notification
                            .getIntAttribute("position");
                    final int delay = notification.getIntAttribute("delay");
                    new VNotification(delay).show(html, position, style);
                }
            } else {
                // subwindows
                final Paintable w = client.getPaintable(childUidl);
View Full Code Here


        HashSet<String> unrenderedPids = new HashSet<String>(
                pidToComponentWrappper.keySet());

        for (Iterator<Object> childIterator = uidl.getChildIterator(); childIterator
                .hasNext();) {
            UIDL cc = (UIDL) childIterator.next();
            if (cc.getTag().equals("cc")) {
                UIDL componentUIDL = cc.getChildUIDL(0);
                unrenderedPids.remove(componentUIDL.getId());
                getWrapper(client, componentUIDL).updateFromUIDL(cc);
            }
        }

        for (String pid : unrenderedPids) {
View Full Code Here

        public void updateFromUIDL(UIDL componentUIDL) {
            setPosition(componentUIDL.getStringAttribute("css"));
            if (getWidget() != paintable) {
                setWidget((Widget) paintable);
            }
            UIDL childUIDL = componentUIDL.getChildUIDL(0);
            paintable.updateFromUIDL(childUIDL, client);
            if (childUIDL.hasAttribute("cached")) {
                // child may need relative size adjustment if wrapper details
                // have changed this could be optimized (check if wrapper size
                // has changed)
                client.handleComponentRelativeSize((Widget) paintable);
            }
View Full Code Here

                    uidl.hasAttribute("spacing"));

            int i = 0;
            for (final Iterator it = uidl.getChildIterator(); it.hasNext(); i++) {
                prepareCell(i, 1);
                final UIDL childUidl = (UIDL) it.next();
                final Paintable p = client.getPaintable(childUidl);
                Caption caption = componentToCaption.get(p);
                if (caption == null) {
                    caption = new Caption(p, client,
                            getStylesFromUIDL(childUidl));
View Full Code Here

        // Update member references
        id = uidl.getId();
        disabled = uidl.hasAttribute("disabled");

        // Render content
        final UIDL tabs = uidl.getChildUIDL(0);

        // Paintables in the TabSheet before update
        ArrayList oldPaintables = new ArrayList();
        for (Iterator iterator = getPaintableIterator(); iterator.hasNext();) {
            oldPaintables.add(iterator.next());
        }

        // Clear previous values
        tabKeys.clear();
        disabledTabKeys.clear();

        int index = 0;
        for (final Iterator it = tabs.getChildIterator(); it.hasNext();) {
            final UIDL tab = (UIDL) it.next();
            final String key = tab.getStringAttribute("key");
            final boolean selected = tab.getBooleanAttribute("selected");
            final boolean hidden = tab.getBooleanAttribute("hidden");

            if (tab.getBooleanAttribute("disabled")) {
                disabledTabKeys.add(key);
            }

            tabKeys.add(key);
View Full Code Here

      Marker marker = knownMarkers.get(markerId);

      for (final Iterator<Object> it = uidl.getChildIterator(); it
          .hasNext();) {
        final UIDL u = (UIDL) it.next();
        if (!u.getTag().equals("tabs")) {
          continue;
        }

        if (u.getChildCount() == 0) {
          log(1, "No contents for info window");
        } else if (u.getChildCount() == 1) {
          // Only one component in the info window -> no tabbing
          UIDL paintableUIDL = u.getChildUIDL(0).getChildUIDL(0);
          Paintable paintable = client.getPaintable(paintableUIDL);

          map.getInfoWindow().open(marker.getLatLng(),
              new InfoWindowContent((Widget) paintable));

          // Update components in the info window after adding them to
          // DOM so that size calculations can succeed
          paintable.updateFromUIDL(paintableUIDL, client);
        } else {
          int tabs = u.getChildCount();
          // More than one component, show them in info window tabs
          InfoWindowContent.InfoWindowTab[] infoTabs = new InfoWindowContent.InfoWindowTab[tabs];

          Paintable[] paintables = new Paintable[tabs];
          UIDL[] uidls = new UIDL[tabs];

          int selectedId = 0;
          for (int i = 0; i < u.getChildCount(); i++) {
            UIDL childUIDL = u.getChildUIDL(i);
            if (selectedId == 0
                && childUIDL.getBooleanAttribute("selected")) {
              selectedId = i;
            }

            String label = childUIDL.getStringAttribute("label");

            UIDL paintableUIDL = childUIDL.getChildUIDL(0);
            Paintable paintable = client
                .getPaintable(paintableUIDL);

            paintables[i] = paintable;
            uidls[i] = paintableUIDL;

            infoTabs[i] = new InfoWindowContent.InfoWindowTab(
                label, (Widget) paintable);
          }

          map.getInfoWindow().open(marker.getLatLng(),
              new InfoWindowContent(infoTabs, selectedId));

          // Update paintables after adding them to DOM so that
          // size calculations can succeed
          for (int i = 0; i < paintables.length; i++) {
            paintables[i].updateFromUIDL(uidls[i], client);
          }
        }
      }
    }

    if (uidl.hasAttribute("clearMapTypes")) {
      for (MapType type : map.getMapTypes()) {
        map.removeMapType(type);
      }
    }

    Map<Integer, Overlay> newPolys = new HashMap<Integer, Overlay>();

    // Process polygon/polyline overlays and map types
    for (final Iterator<Object> it = uidl.getChildIterator(); it.hasNext();) {
      final UIDL u = (UIDL) it.next();
      if (u.getTag().equals("overlays")) {

        long nodeStart = System.currentTimeMillis();

        for (final Iterator<Object> iter = u.getChildIterator(); iter
            .hasNext();) {
          final UIDL polyUIDL = (UIDL) iter.next();

          Overlay poly = null;
          if (polyUIDL.hasAttribute("fillcolor")) {
            poly = polygonFromUIDL(polyUIDL);
          } else {
            poly = polylineFromUIDL(polyUIDL);
          }

          if (poly != null) {
            newPolys.put(polyUIDL.getIntAttribute("id"), poly);
          }
        }

        log(1,
            "Polygon overlays processed in "
View Full Code Here

        paintableId = uidl.getId();

        // Get all Child UIDLs and iterate through them
        Iterator<Object> childUIDL = uidl.getChildIterator();
        while (childUIDL.hasNext()) {
            UIDL child = (UIDL) childUIDL.next();

            if (child.getTag().equals("options")) {
                width = child.getIntAttribute("width");
                height = child.getIntAttribute("height");

                // Percentual width
                if (child.hasAttribute("widthpercentage")) {
                    width = getElement().getParentElement().getClientWidth();
                    wpercent = true;
                } else {
                    wpercent = false;
                }
                // Percentual height
                if (child.hasAttribute("heightpercentage")) {
                    height = getElement().getParentElement().getClientHeight();
                    hpercent = true;
                } else {
                    hpercent = false;
                }
                if (child.hasAttribute("rows")) {
                    setRows(child.getIntAttribute("rows"));
                }
                if (child.hasAttribute("columns")) {
                    setColumns(child.getIntAttribute("columns"));
                }
                if (child.hasAttribute("moveFrom")) {
                    setDirection(child.getBooleanAttribute("moveFrom"));
                }
                if (child.hasAttribute("animate")) {
                    animate = child.getBooleanAttribute("animate");
                }
                if (child.hasAttribute("selected")) {
                    selected = child.getIntAttribute("selected");
                }
                if (child.hasAttribute("useArrows")) {
                    useArrows = child.getBooleanAttribute("useArrows");
                    if (!useArrows) {
                        if (getElement().isOrHasChild(left)) {
                            getElement().removeChild(left);
                        }
                        if (getElement().isOrHasChild(right)) {
                            getElement().removeChild(right);
                        }
                    } else {
                        if (!getElement().isOrHasChild(left)) {
                            getElement().appendChild(left);
                        }
                        if (!getElement().isOrHasChild(right)) {
                            getElement().appendChild(right);
                        }
                    }
                }
                // Set left/right arrow styles
                if (child.hasAttribute("leftArrow")) {
                    left.setClassName(child.getStringAttribute("leftArrow"));
                }
                if (child.hasAttribute("rightArrow")) {
                    right.setClassName(child.getStringAttribute("rightArrow"));
                }

            } else if (child.getTag().equals("item")) {
                UIDL item = child;
                VMenuButton current = null;
                String itemCaption = item.getStringAttribute("caption");
                final int itemId = item.getIntAttribute("id");
                boolean found = false;
                for (VMenuButton button : items) {
                    if (button.getId() == itemId) {
                        found = true;
                    }
                }

                if (!found) {
                    final Command cmd;

                    if (item.hasAttribute("command")) {
                        cmd = new Command() {
                            public void execute() {
                                hostReference.onMenuClick(itemId);
                            }
                        };
                    } else {
                        cmd = null;
                    }

                    String icon = null;
                    if (item.hasAttribute("icon")) {
                        icon = client.translateVaadinUri(item
                                .getStringAttribute("icon"));
                    }

                    current = addMenuItem(itemCaption, icon, cmd, itemId);

                    if (item.hasAttribute("style")) {
                        String styleName = item.getStringAttribute("style");
                        current.setStyle(styleName);
                    }
                    current.setSize(item.getStringAttribute("buttonsize"));
                }
            }
            if (child.getTag().equals("updateItem")) {
                // Update item data
                UIDL item = child;
                VMenuButton current = null;
                String itemCaption = item.getStringAttribute("caption");
                final int itemId = item.getIntAttribute("id");

                for (VMenuButton button : items) {
                    if (button.getId() == itemId) {
                        current = button;
                        break;
                    }
                }
                current.setCaption(itemCaption);

                if (item.hasAttribute("icon")) {
                    current.setIcon(client.translateVaadinUri(item
                            .getStringAttribute("icon")));
                }

                if (item.hasAttribute("style")) {
                    current.setStyle(item.getStringAttribute("style"));
                }

                if (item.hasAttribute("buttonsize")) {
                    current.setSize(item.getStringAttribute("buttonsize"));
                }
            } else if (child.getTag().equals("removeItem")) {
                removeButton(child.getIntAttribute("id"));
            }
        }
View Full Code Here

     *            Tag name of the data.
     * @return true if something was copied. False otherwise.
     */
    public static boolean updateJavaScriptObject(JavaScriptObject toObject,
            UIDL uidl, String nodeTag) {
        UIDL node = uidl.getChildByTagName(nodeTag);
        if (node != null) {
            Set<String> keys = node.getAttributeNames();
            JavaScriptObject fromObject = getUIDLAttributes(node);
            for (String key : keys) {
                copyJavaScriptAttribute(key, fromObject, toObject);
            }
            return !keys.isEmpty();
View Full Code Here

            callsFromServer = postponedCallsFromServer; // append
        } else {
            callsFromServer = new ArrayList<MethodCall>();
        }
        while (i.hasNext()) {
            UIDL callData = (UIDL) i.next();
            String methodName = callData.getStringAttribute("n");

            // Client init immediately (before anything else is called)
            if (CLIENT_INIT.equals(methodName)) {
                d("Init received from server");
                requestInitFromServer = false; // cancel the pending init request,
View Full Code Here

        setEventResizeAllowed(client.hasEventListeners(this,
                CalendarEventId.EVENTRESIZE));
        setEventMoveAllowed(client.hasEventListeners(this,
                CalendarEventId.EVENTMOVE));

        UIDL daysUidl = uidl.getChildUIDL(0);
        int daysCount = daysUidl.getChildCount();
        boolean monthView = daysCount > 7;
        if (monthView) {
            updateMonthView(uidl, daysUidl);
        } else {
            updateWeekView(uidl, daysUidl);
        }

        // check for DD -related access criteria
        Iterator<Object> childIterator = uidl.getChildIterator();
        while (childIterator.hasNext()) {
            UIDL child = (UIDL) childIterator.next();

            // Drag&drop
            if (ACCESSCRITERIA.equals(child.getTag())) {
                if (monthView
                        && !(getDropHandler() instanceof CalendarMonthDropHandler)) {
                    setDropHandler(new CalendarMonthDropHandler());

                } else if (!monthView
                        && !(getDropHandler() instanceof CalendarWeekDropHandler)) {
                    setDropHandler(new CalendarWeekDropHandler());
                }

                getDropHandler().setCalendarPaintable(this);
                getDropHandler().updateAcceptRules(child);

            } else {
                setDropHandler(null);
            }

            // Actions
            if ("actions".equals(child.getTag())) {
                updateActionMap(child);
            }
        }
    }
View Full Code Here

TOP

Related Classes of com.vaadin.terminal.gwt.client.UIDL$XML

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.