Ejemplo n.º 1
0
  @Override
  public void paintContent(PaintTarget target) throws PaintException {
    page.paintContent(target);

    if (scrollIntoView != null) {
      target.addAttribute("scrollTo", scrollIntoView);
      scrollIntoView = null;
    }

    if (pendingFocus != null) {
      // ensure focused component is still attached to this main window
      if (pendingFocus.getUI() == this
          || (pendingFocus.getUI() != null && pendingFocus.getUI().getParent() == this)) {
        target.addAttribute("focused", pendingFocus);
      }
      pendingFocus = null;
    }

    if (actionManager != null) {
      actionManager.paintActions(null, target);
    }

    if (isResizeLazy()) {
      target.addAttribute(UIConstants.RESIZE_LAZY, true);
    }
  }
Ejemplo n.º 2
0
  public void paintActions(Object actionTarget, PaintTarget paintTarget) throws PaintException {

    actionMapper = null;

    LinkedHashSet<Action> actions = getActionSet(actionTarget, viewer);

    /*
     * Must repaint whenever there are actions OR if all actions have been
     * removed but still exist on client side
     */
    if (!actions.isEmpty() || clientHasActions) {
      actionMapper = new KeyMapper<Action>();

      paintTarget.addVariable((VariableOwner) viewer, "action", "");
      paintTarget.startTag("actions");

      for (final Action a : actions) {
        paintTarget.startTag("action");
        final String akey = actionMapper.key(a);
        paintTarget.addAttribute("key", akey);
        if (a.getCaption() != null) {
          paintTarget.addAttribute("caption", a.getCaption());
        }
        if (a.getIcon() != null) {
          paintTarget.addAttribute("icon", a.getIcon());
        }
        if (a instanceof ShortcutAction) {
          final ShortcutAction sa = (ShortcutAction) a;
          paintTarget.addAttribute("kc", sa.getKeyCode());

          final int[] modifiers = sa.getModifiers();
          if (modifiers != null) {
            final String[] smodifiers = new String[modifiers.length];
            for (int i = 0; i < modifiers.length; i++) {
              smodifiers[i] = String.valueOf(modifiers[i]);
            }
            paintTarget.addAttribute("mk", smodifiers);
          }
        }
        paintTarget.endTag("action");
      }

      paintTarget.endTag("actions");
    }

    /*
     * Update flag for next repaint so we know if we need to paint empty
     * actions or not (must send actions is client had actions before and
     * all actions were removed).
     */
    clientHasActions = !actions.isEmpty();
  }
Ejemplo n.º 3
0
  @Override
  public void paintContent(PaintTarget target) throws PaintException {
    super.paintContent(target);

    if (inputPrompt != null) {
      target.addAttribute("prompt", inputPrompt);
    }
  }
 @Override
 public void paintContent(PaintTarget target) throws PaintException {
   super.paintContent(target);
   /* Add filter components to UIDL */
   target.startTag("filters");
   target.addAttribute("filtersvisible", filtersVisible);
   target.addAttribute("forceRender", reRenderFilterFields);
   reRenderFilterFields = false;
   if (filtersVisible) {
     for (Object key : getColumnIdToFilterMap().keySet()) {
       /* Do not paint filters which are not children */
       if (columnIdToFilterMap.get(key) != null
           && columnIdToFilterMap.get(key).getParent() == null) {
         continue;
       }
       /* Paint the filter field */
       target.startTag("filtercomponent-" + columnIdMap.key(key));
       target.addAttribute("columnid", columnIdMap.key(key));
       Component c = getColumnIdToFilterMap().get(key);
       LegacyPaint.paint(c, target);
       target.endTag("filtercomponent-" + columnIdMap.key(key));
     }
   }
   target.endTag("filters");
 }
  /* (non-Javadoc)
   * @see fi.jasoft.dragdroplayouts.DDCssLayout#paintContent(com.vaadin.server.PaintTarget)
   */
  @Override
  public void paintContent(PaintTarget target) throws PaintException {
    super.paintContent(target);

    // Override paintContent (vaadin serialization api) to set the
    // horizontal drop ratio to 50% so that we don't have a "CENTER"
    // position to drop things. See
    // VDDCssLayout#getHorizontalDropLocation() and
    // VDDCssLayout#handleCellDropRatioUpdate() for details
    target.addAttribute(Constants.ATTRIBUTE_HORIZONTAL_DROP_RATIO, 0.5f);
  }
Ejemplo n.º 6
0
  @Override
  public void paintContent(PaintTarget target) throws PaintException {
    target.addAttribute(DragAndDropWrapperConstants.DRAG_START_MODE, dragStartMode.ordinal());
    if (getDropHandler() != null) {
      getDropHandler().getAcceptCriterion().paint(target);
    }
    if (receivers != null && receivers.size() > 0) {
      for (Iterator<Entry<String, ProxyReceiver>> it = receivers.entrySet().iterator();
          it.hasNext(); ) {
        Entry<String, ProxyReceiver> entry = it.next();
        String id = entry.getKey();
        ProxyReceiver proxyReceiver = entry.getValue();
        Html5File html5File = proxyReceiver.file;
        if (html5File.getStreamVariable() != null) {
          if (!sentIds.contains(id)) {
            target.addVariable(this, "rec-" + id, new ProxyReceiver(id, html5File));

            /*
             * if a new batch is requested to be uploaded before the
             * last one is done, any remaining ids will be replayed.
             * We want to avoid a new ProxyReceiver to be made since
             * it'll get a new URL, so we need to keep extra track
             * on what has been sent.
             *
             * See #12330.
             */
            sentIds.add(id);

            // these are cleaned from receivers once the upload has
            // started
          }
        } else {
          // instructs the client side not to send the file
          target.addVariable(this, "rec-" + id, (String) null);
          // forget the file from subsequent paints
          it.remove();
        }
      }
    }
    target.addAttribute(DragAndDropWrapperConstants.HTML5_DATA_FLAVORS, html5DataFlavors);
  }
Ejemplo n.º 7
0
 /*
  * (non-Javadoc)
  *
  * @see
  * com.vaadin.event.dd.acceptCriteria.AcceptCriterion#paintResponse(
  * com.vaadin.server.PaintTarget)
  */
 @Override
 public void paintResponse(PaintTarget target) throws PaintException {
   /*
    * send allowed nodes to client so subsequent requests can be
    * avoided
    */
   Object[] array = allowedItemIds.toArray();
   for (int i = 0; i < array.length; i++) {
     String key = tree.key(array[i]);
     array[i] = key;
   }
   target.addAttribute("allowedIds", array);
 }
  @Override
  public void paintContent(PaintTarget target) throws PaintException {

    // Applet class
    if (appletClass == null) {
      // Do not paint anything of class is missing
      return;
    }
    target.addAttribute(VAppletIntegration.ATTR_APPLET_CLASS, appletClass);

    // Applet HTTP Session id
    String sid = getHttpSessionId();
    if (sid != null) {
      target.addAttribute(VAppletIntegration.ATTR_APPLET_SESSION, sid);
    }

    // Applet archives
    if (appletArchives != null) {
      target.addAttribute(
          VAppletIntegration.ATTR_APPLET_ARCHIVES,
          appletArchives.toArray(new String[appletArchives.size()]));
    }

    // Applet codebase
    if (codebase != null) {
      target.addAttribute(VAppletIntegration.ATTR_APPLET_CODEBASE, codebase);
    }

    // Applet name
    if (name != null) {
      target.addAttribute(VAppletIntegration.ATTR_APPLET_NAME, name);
    }

    // Applet parameters
    if (appletParams != null) {
      target.addAttribute(VAppletIntegration.ATTR_APPLET_PARAM_NAMES, appletParams);
    }

    // Commands
    if (command != null) {
      target.addAttribute(VAppletIntegration.ATTR_CMD, command);
      command = null;
    }

    if (commandParams != null) {
      target.addAttribute(VAppletIntegration.ATTR_CMD_PARAMS, commandParams);
      commandParams = null;
    }
  }
Ejemplo n.º 9
0
  /**
   * Paints any needed component-specific things to the given UIDL stream.
   *
   * @see com.vaadin.ui.AbstractComponent#paintContent(PaintTarget)
   */
  @Override
  public void paintContent(PaintTarget target) throws PaintException {
    initialPaint = false;

    if (partialUpdate) {
      target.addAttribute("partialUpdate", true);
      target.addAttribute("rootKey", itemIdMapper.key(expandedItemId));
    } else {
      getCaptionChangeListener().clear();

      // The tab ordering number
      if (getTabIndex() > 0) {
        target.addAttribute("tabindex", getTabIndex());
      }

      // Paint tree attributes
      if (isSelectable()) {
        target.addAttribute("selectmode", (isMultiSelect() ? "multi" : "single"));
        if (isMultiSelect()) {
          target.addAttribute("multiselectmode", multiSelectMode.toString());
        }
      } else {
        target.addAttribute("selectmode", "none");
      }
      if (isNewItemsAllowed()) {
        target.addAttribute("allownewitem", true);
      }

      if (isNullSelectionAllowed()) {
        target.addAttribute("nullselect", true);
      }

      if (dragMode != TreeDragMode.NONE) {
        target.addAttribute("dragMode", dragMode.ordinal());
      }
    }

    // Initialize variables
    final Set<Action> actionSet = new LinkedHashSet<Action>();

    // rendered selectedKeys
    LinkedList<String> selectedKeys = new LinkedList<String>();

    final LinkedList<String> expandedKeys = new LinkedList<String>();

    // Iterates through hierarchical tree using a stack of iterators
    final Stack<Iterator<?>> iteratorStack = new Stack<Iterator<?>>();
    Collection<?> ids;
    if (partialUpdate) {
      ids = getChildren(expandedItemId);
    } else {
      ids = rootItemIds();
    }

    if (ids != null) {
      iteratorStack.push(ids.iterator());
    }

    /*
     * Body actions - Actions which has the target null and can be invoked
     * by right clicking on the Tree body
     */
    if (actionHandlers != null) {
      final ArrayList<String> keys = new ArrayList<String>();
      for (Handler ah : actionHandlers) {

        // Getting action for the null item, which in this case
        // means the body item
        final Action[] aa = ah.getActions(null, this);
        if (aa != null) {
          for (int ai = 0; ai < aa.length; ai++) {
            final String akey = actionMapper.key(aa[ai]);
            actionSet.add(aa[ai]);
            keys.add(akey);
          }
        }
      }
      target.addAttribute("alb", keys.toArray());
    }

    while (!iteratorStack.isEmpty()) {

      // Gets the iterator for current tree level
      final Iterator<?> i = iteratorStack.peek();

      // If the level is finished, back to previous tree level
      if (!i.hasNext()) {

        // Removes used iterator from the stack
        iteratorStack.pop();

        // Closes node
        if (!iteratorStack.isEmpty()) {
          target.endTag("node");
        }
      }

      // Adds the item on current level
      else {
        final Object itemId = i.next();

        // Starts the item / node
        final boolean isNode = areChildrenAllowed(itemId);
        if (isNode) {
          target.startTag("node");
        } else {
          target.startTag("leaf");
        }

        if (itemStyleGenerator != null) {
          String stylename = itemStyleGenerator.getStyle(this, itemId);
          if (stylename != null) {
            target.addAttribute(TreeConstants.ATTRIBUTE_NODE_STYLE, stylename);
          }
        }

        if (itemDescriptionGenerator != null) {
          String description = itemDescriptionGenerator.generateDescription(this, itemId, null);
          if (description != null && !description.equals("")) {
            target.addAttribute("descr", description);
          }
        }

        // Adds the attributes
        target.addAttribute(TreeConstants.ATTRIBUTE_NODE_CAPTION, getItemCaption(itemId));
        final Resource icon = getItemIcon(itemId);
        if (icon != null) {
          target.addAttribute(TreeConstants.ATTRIBUTE_NODE_ICON, getItemIcon(itemId));
          target.addAttribute(
              TreeConstants.ATTRIBUTE_NODE_ICON_ALT, getItemIconAlternateText(itemId));
        }
        final String key = itemIdMapper.key(itemId);
        target.addAttribute("key", key);
        if (isSelected(itemId)) {
          target.addAttribute("selected", true);
          selectedKeys.add(key);
        }
        if (areChildrenAllowed(itemId) && isExpanded(itemId)) {
          target.addAttribute("expanded", true);
          expandedKeys.add(key);
        }

        // Add caption change listener
        getCaptionChangeListener().addNotifierForItem(itemId);

        // Actions
        if (actionHandlers != null) {
          final ArrayList<String> keys = new ArrayList<String>();
          final Iterator<Action.Handler> ahi = actionHandlers.iterator();
          while (ahi.hasNext()) {
            final Action[] aa = ahi.next().getActions(itemId, this);
            if (aa != null) {
              for (int ai = 0; ai < aa.length; ai++) {
                final String akey = actionMapper.key(aa[ai]);
                actionSet.add(aa[ai]);
                keys.add(akey);
              }
            }
          }
          target.addAttribute("al", keys.toArray());
        }

        // Adds the children if expanded, or close the tag
        if (isExpanded(itemId) && hasChildren(itemId) && areChildrenAllowed(itemId)) {
          iteratorStack.push(getChildren(itemId).iterator());
        } else {
          if (isNode) {
            target.endTag("node");
          } else {
            target.endTag("leaf");
          }
        }
      }
    }

    // Actions
    if (!actionSet.isEmpty()) {
      target.addVariable(this, "action", "");
      target.startTag("actions");
      final Iterator<Action> i = actionSet.iterator();
      while (i.hasNext()) {
        final Action a = i.next();
        target.startTag("action");
        if (a.getCaption() != null) {
          target.addAttribute(TreeConstants.ATTRIBUTE_ACTION_CAPTION, a.getCaption());
        }
        if (a.getIcon() != null) {
          target.addAttribute(TreeConstants.ATTRIBUTE_ACTION_ICON, a.getIcon());
        }
        target.addAttribute("key", actionMapper.key(a));
        target.endTag("action");
      }
      target.endTag("actions");
    }

    if (partialUpdate) {
      partialUpdate = false;
    } else {
      // Selected
      target.addVariable(this, "selected", selectedKeys.toArray(new String[selectedKeys.size()]));

      // Expand and collapse
      target.addVariable(this, "expand", new String[] {});
      target.addVariable(this, "collapse", new String[] {});

      // New items
      target.addVariable(this, "newitem", new String[] {});

      if (dropHandler != null) {
        dropHandler.getAcceptCriterion().paint(target);
      }
    }
  }
Ejemplo n.º 10
0
 @Override
 public void paintContent(PaintTarget target) throws PaintException {
   super.paintContent(target);
   target.addAttribute("depth", depthToCheck);
   target.addAttribute("key", key(rootId));
 }
Ejemplo n.º 11
0
 @Override
 public void paintContent(PaintTarget target) throws PaintException {
   target.addAttribute("doubleInfinity", Double.POSITIVE_INFINITY);
 }