/** * Sets the drag mode that controls how Tree behaves as a {@link DragSource} * . * * @param dragMode */ public void setDragMode(TreeDragMode dragMode) { this.dragMode = dragMode; markAsDirty(); }
/** * Removes all action handlers. */ public void removeAllActionHandlers() { actionHandlers = null; actionMapper = null; markAsDirty(); }
/** * Sets the behavior of the multiselect mode. * * @param mode * The mode to set */ public void setMultiselectMode(MultiSelectMode mode) { if (multiSelectMode != mode && mode != null) { multiSelectMode = mode; markAsDirty(); } }
/** * Sets the {@link ItemStyleGenerator} to be used with this tree. * * @param itemStyleGenerator * item style generator or null to remove generator */ public void setItemStyleGenerator(ItemStyleGenerator itemStyleGenerator) { if (this.itemStyleGenerator != itemStyleGenerator) { this.itemStyleGenerator = itemStyleGenerator; markAsDirty(); } }
/** * Set the item description generator which generates tooltips for the tree * items. * * @param generator * The generator to use or null to disable */ public void setItemDescriptionGenerator( ItemDescriptionGenerator generator) { if (generator != itemDescriptionGenerator) { itemDescriptionGenerator = generator; markAsDirty(); } }
/** * Sets whether html is allowed in the item captions. If set to * <code>true</code>, the captions are passed to the browser as html and the * developer is responsible for ensuring no harmful html is used. If set to * <code>false</code>, the content is passed to the browser as plain text. * The default setting is <code>false</code> * * @since 7.6 * @param htmlContentAllowed * <code>true</code> if the captions are used as html, * <code>false</code> if used as plain text */ public void setHtmlContentAllowed(boolean htmlContentAllowed) { this.htmlContentAllowed = htmlContentAllowed; markAsDirty(); }
/** * Sets the selectable state. Selectable determines if the a node can be * selected on the client side. Selectable does not affect * {@link #setValue(Object)} or {@link #select(Object)}. * * <p> * The tree is selectable by default. * </p> * * @param selectable * The new selectable state. */ public void setSelectable(boolean selectable) { if (this.selectable != selectable) { this.selectable = selectable; markAsDirty(); } }
/** * Removes an action handler. * * @see com.vaadin.event.Action.Container#removeActionHandler(Action.Handler) */ @Override public void removeActionHandler(Action.Handler actionHandler) { if (actionHandlers != null && actionHandlers.contains(actionHandler)) { actionHandlers.remove(actionHandler); if (actionHandlers.isEmpty()) { actionHandlers = null; actionMapper = null; } markAsDirty(); } }
/** * Expands an item. * * @param itemId * the item id. * @return True if the expand operation succeeded */ public boolean expandItem(Object itemId) { boolean success = expandItem(itemId, true); markAsDirty(); return success; }
@Override public boolean setParent(Object itemId, Object newParentId) { final boolean success = ((Container.Hierarchical) items) .setParent(itemId, newParentId); if (success) { markAsDirty(); } return success; }
/** * Sets the given Item's capability to have children. * * @see Container.Hierarchical#setChildrenAllowed(Object, boolean) */ @Override public boolean setChildrenAllowed(Object itemId, boolean areChildrenAllowed) { final boolean success = ((Container.Hierarchical) items) .setChildrenAllowed(itemId, areChildrenAllowed); if (success) { markAsDirty(); } return success; }
/** * Adds an action handler. * * @see com.vaadin.event.Action.Container#addActionHandler(Action.Handler) */ @Override public void addActionHandler(Action.Handler actionHandler) { if (actionHandler != null) { if (actionHandlers == null) { actionHandlers = new LinkedList<Action.Handler>(); actionMapper = new KeyMapper<Action>(); } if (!actionHandlers.contains(actionHandler)) { actionHandlers.add(actionHandler); markAsDirty(); } } }
/** * Sets the icon for an item. * * @param itemId * the id of the item to be assigned an icon. * @param icon * the icon to use or null. * * @param altText * the alternative text for the icon */ public void setItemIcon(Object itemId, Resource icon, String altText) { if (itemId != null) { super.setItemIcon(itemId, icon); if (icon == null) { itemIconAlts.remove(itemId); } else if (altText == null) { throw new IllegalArgumentException(NULL_ALT_EXCEPTION_MESSAGE); } else { itemIconAlts.put(itemId, altText); } markAsDirty(); } }
/** * Collapses an item. * * @param itemId * the item id. * @return True if the collapse operation succeeded */ public boolean collapseItem(Object itemId) { // Succeeds if the node is already collapsed if (!isExpanded(itemId)) { return true; } // Collapse expanded.remove(itemId); markAsDirty(); fireCollapseEvent(itemId); return true; }
/** * Handles the selection * * @param variables * The variables sent to the server from the client */ private void handleSelectedItems(Map<String, Object> variables) { // Converts the key-array to id-set final LinkedList<Object> s = new LinkedList<Object>(); for (String key : (String[]) variables.get("selected")) { final Object id = itemIdMapper.get(key); if (!isNullSelectionAllowed() && (id == null || id == getNullSelectionItemId())) { // skip empty selection if nullselection is not allowed markAsDirty(); } else if (id != null && containsId(id)) { s.add(id); } } if (!isNullSelectionAllowed() && s.isEmpty()) { // empty selection not allowed, keep old value markAsDirty(); return; } setValue(s, true); }
/** * Expands the items recursively * * Expands all the children recursively starting from an item. Operation * succeeds only if all expandable items are expanded. * * @param startItemId * @return True if the expand operation succeeded */ public boolean expandItemsRecursively(Object startItemId) { boolean result = true; // Initial stack final Stack<Object> todo = new Stack<Object>(); todo.add(startItemId); // Expands recursively while (!todo.isEmpty()) { final Object id = todo.pop(); if (areChildrenAllowed(id) && !expandItem(id, false)) { result = false; } if (hasChildren(id)) { todo.addAll(getChildren(id)); } } markAsDirty(); return result; }
/** * Expands an item. * * @param itemId * the item id. * @param sendChildTree * flag to indicate if client needs subtree or not (may be * cached) * @return True if the expand operation succeeded */ private boolean expandItem(Object itemId, boolean sendChildTree) { // Succeeds if the node is already expanded if (isExpanded(itemId)) { return true; } // Nodes that can not have children are not expandable if (!areChildrenAllowed(itemId)) { return false; } // Expands expanded.add(itemId); expandedItemId = itemId; if (initialPaint) { markAsDirty(); } else if (sendChildTree) { requestPartialRepaint(); } fireExpandEvent(itemId); return true; }