List of usage examples for com.vaadin.ui Component getParent
@Override
public HasComponents getParent();
From source file:com.ocs.dynamo.ui.utils.VaadinUtils.java
License:Apache License
/** * Returns the first parent component of the specified component that is a subclass of the * specified class// www. j a va2 s .c om * * @param component * the component * @param clazz * the class * @return */ @SuppressWarnings("unchecked") public static <T extends Component> T getParentOfClass(Component component, Class<T> clazz) { while (component.getParent() != null) { component = component.getParent(); if (clazz.isAssignableFrom(component.getClass())) { return (T) component; } } return null; }
From source file:com.profitsoftware.vaadin.query.matcher.MatchAncestor.java
License:Apache License
public boolean match(Component component) { Component c = component.getParent(); if (c == null) { return false; }//from w w w .j a v a 2s .c o m do { if (matcher.match(c)) { return true; } c = c.getParent(); } while (c != null); return false; }
From source file:com.profitsoftware.vaadin.query.matcher.MatchFirstChild.java
License:Apache License
public boolean match(Component component) { if (!matcher.match(component)) { return false; }/*from w w w . j av a 2 s . c o m*/ Component parent = component.getParent(); if (parent == null) { return true; } if (parent instanceof HasComponents) { HasComponents parentComponents = (HasComponents) parent; Iterator<Component> i = parentComponents.iterator(); if (i.hasNext() && i.next() == component) { return true; } } return false; }
From source file:com.profitsoftware.vaadin.query.matcher.MatchParent.java
License:Apache License
public boolean match(Component component) { return matcher.match(component.getParent()); }
From source file:com.profitsoftware.vaadin.query.matcher.MatchSibling.java
License:Apache License
public boolean match(Component component) { Component parent = component.getParent(); if (parent == null) { return false; }// w ww . j av a 2 s.co m if (parent instanceof HasComponents) { HasComponents components = (HasComponents) parent; Iterator<Component> i = components.iterator(); Component previous = null; while (i.hasNext()) { Component next = i.next(); if (next == component) { return matcher.match(previous); } previous = next; } } return false; }
From source file:edu.nps.moves.mmowgli.modules.actionplans.ActionPlanPageTabImages.java
License:Open Source License
private MediaPanel findImagePanel(Button butt) { Component com = butt; while (!(com instanceof MediaPanel)) { com = com.getParent(); }//from w w w. ja va 2 s . com return (MediaPanel) com; }
From source file:edu.nps.moves.mmowgli.modules.actionplans.ActionPlanPageTabVideos.java
License:Open Source License
private MediaPanel findVideoPanel(Button butt) { Component com = butt; while (!(com instanceof MediaPanel)) { com = com.getParent(); }//from w ww. ja v a2s . c o m return (MediaPanel) com; }
From source file:fi.jasoft.draganddrop.demos.DragDemo.java
License:Apache License
@Override protected Component getDemoContent() { HorizontalLayout hl = new HorizontalLayout(); hl.setSizeFull();/*from ww w .j a va 2 s. com*/ // source-start // Create image Image image = new Image(null, new ThemeResource("graphics/bin.jpg")); // Enable dropping items on image DragAndDrop.enable(image, DragAndDropOperation.DROP) // Set custom drop handler .onDrop(new DropHandler<Image>() { @Override protected void onDrop(Component component) { // Restor trash bin getSource().setSource(new ThemeResource("graphics/bin.jpg")); // Remove item ((ComponentContainer) component.getParent()).removeComponent(component); } }) // Set custom over handler .onOver(new DragOverHandler<Image>() { @Override protected void onOver(Component component) { // Add color to trash bin getSource().setSource(new ThemeResource("graphics/bin2.jpg")); } }) // Set custom out handler .onOut(new DragOutHandler<Image>() { @Override protected void onOut(Component component) { // Restore trash bin getSource().setSource(new ThemeResource("graphics/bin.jpg")); } }); // source-end hl.addComponent(image); hl.setComponentAlignment(image, Alignment.TOP_CENTER); VerticalLayout vl = new VerticalLayout(); vl.setSizeUndefined(); vl.setSpacing(true); hl.addComponent(vl); hl.setComponentAlignment(vl, Alignment.TOP_CENTER); // source-start /* * Create item list to drag from */ for (int i = 0; i < 5; i++) { Label item = new Label("Item " + (i + 1)); item.setStyleName("item"); item.setSizeUndefined(); // Enable dragging the items DragAndDrop.enable(item, DragAndDropOperation.DRAG); vl.addComponent(item); } // source-end return hl; }
From source file:fi.semantum.strategia.Utils.java
License:Open Source License
public static void loseFocus(Component parent) { while (parent != null) { if (parent instanceof Component.Focusable) { ((Component.Focusable) parent).focus(); break; } else {/* www . j a va 2s .c om*/ parent = parent.getParent(); } } }
From source file:info.magnolia.ui.vaadin.dialog.BaseDialog.java
License:Open Source License
/** * Sets a Component/*from ww w.ja v a 2 s . com*/ * <p> * The composition root must be set to non-null value before the component can be used. The composition root can only be set once. * </p> * * @param newContent * the root of the composition component tree. */ protected void adoptComponent(Component newContent) { if (newContent != null) { // set new component if (newContent.getParent() != null) { if (newContent.getParent() == this) { newContent.setParent(null); } else { // If the component already has a parent, try to remove it AbstractSingleComponentContainer.removeFromParent(newContent); } } newContent.setParent(this); } markAsDirty(); }