/** * Check if an element need to change from a style group to another. * * <p>When an element can have potentially changed style due to some of its attributes (ui.class * for example), instead of removing it then reading it, use this method to move the element from * its current style group to a potentially different style group. * * <p>Explanation of this method : checking the style of an element may be done by removing it * ({@link #removeElement(Element)}) and then re-adding it ( {@link #addElement(Element)}). This * must be done by the element since it knows when to check this. However you cannot only remove * and add, since the style group inside which the element is can have events occurring on it, and * these events must be passed from its old style to its new style. This method does all this * information passing. * * @param element The element to move. */ public void checkElementStyleGroup(Element element) { StyleGroup oldGroup = getGroup(getElementGroup(element)); // Get the old element "dynamic" status. boolean isDyn = oldGroup.isElementDynamic(element); // Get the old event set for the given element. StyleGroup.ElementEvents events = null; if (oldGroup != null) events = oldGroup.getEventsFor(element); // Remove the element from its old style and add it to insert it in the // correct style. removeElement(element); addElement_(element); // Eventually push the events on the new style group. StyleGroup newGroup = getGroup(getElementGroup(element)); if (newGroup != null && events != null) { for (String event : events.events) pushEventFor(element, event); } for (StyleGroupListener listener : listeners) listener.elementStyleChanged(element, oldGroup, newGroup); // Eventually set the element as dynamic, if it was. if (newGroup != null && isDyn) newGroup.pushElementAsDynamic(element); }
/** * Specify the given element has dynamic style attribute values. This is normally done * automatically by the graphic element. * * @param element The element to add to the dynamic subset. */ public void pushElementAsDynamic(Element element) { StyleGroup group = getGroup(getElementGroup(element)); if (group != null) group.pushElementAsDynamic(element); }