use of com.vaadin.ui.HasComponents in project ANNIS by korpling.
the class IDGenerator method assignID.
public static String assignID(Component c, String fieldName) {
String id = null;
if (c != null && fieldName != null && !fieldName.isEmpty()) {
Preconditions.checkArgument(c.isAttached(), "Component " + c.getConnectorId() + " must be attached before it can get an automatic ID.");
id = c.getId();
if (id == null) {
// try to get the parent ID
HasComponents parent = c.getParent();
if (parent == null || parent instanceof UI) {
// use class name as ID
id = fieldName;
} else {
String parentID = parent.getId();
if (parentID == null) {
parentID = assignID(parent);
}
String idBase = parentID + ":" + fieldName;
// check that no other child has the same ID
int counter = 1;
id = idBase;
while (childHasID(parent, id)) {
id = idBase + "." + counter++;
}
}
c.setId(id);
}
}
return id;
}
use of com.vaadin.ui.HasComponents in project ANNIS by korpling.
the class IDGenerator method assignID.
public static String assignID(Component c, String fieldName) {
String id = null;
if (c != null && fieldName != null && !fieldName.isEmpty()) {
Preconditions.checkArgument(c.isAttached(), "Component " + c.getConnectorId() + " must be attached before it can get an automatic ID.");
id = c.getId();
if (id == null) {
// try to get the parent ID
HasComponents parent = c.getParent();
if (parent == null || parent instanceof UI) {
// use class name as ID
id = fieldName;
} else {
String parentID = parent.getId();
if (parentID == null) {
parentID = assignID(parent);
}
String idBase = parentID + "-" + fieldName;
// check that no other child has the same ID
int counter = 1;
id = idBase;
while (childHasID(parent, id)) {
id = idBase + "." + counter++;
}
}
c.setId(id);
}
}
return id;
}
use of com.vaadin.ui.HasComponents in project opencms-core by alkacon.
the class CmsVaadinUtils method visitDescendants.
/**
* Visits all descendants of a given component (including the component itself) and applies a predicate
* to each.<p>
*
* If the predicate returns false for a component, no further descendants will be processed.<p>
*
* @param component the component
* @param handler the predicate
*/
public static void visitDescendants(Component component, Predicate<Component> handler) {
List<Component> stack = Lists.newArrayList();
stack.add(component);
while (!stack.isEmpty()) {
Component currentComponent = stack.get(stack.size() - 1);
stack.remove(stack.size() - 1);
if (!handler.apply(currentComponent)) {
return;
}
if (currentComponent instanceof HasComponents) {
List<Component> children = Lists.newArrayList((HasComponents) currentComponent);
Collections.reverse(children);
stack.addAll(children);
}
}
}
use of com.vaadin.ui.HasComponents in project charts by vaadin.
the class ChartOptions method searchAndNotifyListeners.
private void searchAndNotifyListeners(Component component) {
if (component instanceof HasComponents) {
HasComponents container = (HasComponents) component;
Iterator<Component> iter = container.iterator();
while (iter.hasNext()) {
searchAndNotifyListeners(iter.next());
}
} else if (component instanceof Chart) {
Chart listener = (Chart) component;
listener.drawChart();
}
}
use of com.vaadin.ui.HasComponents in project jmix by jmix-framework.
the class AbstractCanvasLayout method setWeight.
@Override
public void setWeight(int weight) {
Layout unwrapThis = this.unwrap(Layout.class);
HasComponents parent = unwrapThis.getParent();
if (parent instanceof AbstractOrderedLayout) {
for (com.vaadin.ui.Component child : parent) {
if (unwrapThis.equals(child)) {
((AbstractOrderedLayout) parent).setExpandRatio(unwrapThis, weight);
} else if (((AbstractOrderedLayout) parent).getExpandRatio(child) == 0) {
((AbstractOrderedLayout) parent).setExpandRatio(child, 1);
}
}
}
}
Aggregations