Package com.vaadin.terminal.gwt.client

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


        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

    /** Transforms uidl to list of CalendarEvents */
    protected ArrayList<CalendarEvent> getEvents(UIDL childUIDL) {
        int eventCount = childUIDL.getChildCount();
        ArrayList<CalendarEvent> events = new ArrayList<CalendarEvent>();
        for (int i = 0; i < eventCount; i++) {
            UIDL eventUIDL = childUIDL.getChildUIDL(i);

            int index = eventUIDL.getIntAttribute(ATTR_INDEX);
            String caption = eventUIDL.getStringAttribute(ATTR_CAPTION);
            String datefrom = eventUIDL.getStringAttribute(ATTR_DATEFROM);
            String dateto = eventUIDL.getStringAttribute(ATTR_DATETO);
            String timefrom = eventUIDL.getStringAttribute(ATTR_TIMEFROM);
            String timeto = eventUIDL.getStringAttribute(ATTR_TIMETO);
            String desc = eventUIDL.getStringAttribute(ATTR_DESCRIPTION);
            String style = eventUIDL.getStringAttribute(ATTR_STYLE);
            boolean allDay = eventUIDL.getBooleanAttribute(ATTR_ALLDAY);

            CalendarEvent e = new CalendarEvent();

            e.setCaption(caption);
            e.setDescription(desc);
View Full Code Here

    }

    private List<Day> getDaysFromUIDL(UIDL daysUIDL){
        List<Day> days = new ArrayList<VCalendar.Day>();
        for (int i = 0; i < daysUIDL.getChildCount(); i++) {
            UIDL dayUidl = daysUIDL.getChildUIDL(i);
            String date = dayUidl.getStringAttribute(ATTR_DATE);
            String localized_date_format = dayUidl
                    .getStringAttribute(ATTR_FDATE);
            int dayOfWeek = dayUidl.getIntAttribute(ATTR_DOW);
            int week = dayUidl.getIntAttribute(ATTR_WEEK);
            days.add(new Day(date,localized_date_format,dayOfWeek,week));
        }
        return days;
    }
View Full Code Here

TOP

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

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.