Java Code Examples for consulo.ui.Component#getParent()

The following examples show how to use consulo.ui.Component#getParent() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TraverseUtil.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nullable
@Contract("null -> null")
public static Window getWindowAncestor(@Nullable Component c) {
  if (c == null) {
    return null;
  }

  if (c instanceof Window) {
    return (Window)c;
  }

  for (Component p = c.getParent(); p != null; p = p.getParent()) {
    if (p instanceof Window) {
      return (Window)p;
    }
  }
  return null;
}
 
Example 2
Source File: WebDockLayoutImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
void placeAt(@Nonnull Component uiComponent, DockLayoutState.Constraint constraint) {
  com.vaadin.ui.Component component = TargetVaddin.to(uiComponent);

  Component parentComponent = uiComponent.getParent();
  // remove from old parent
  if (parentComponent instanceof Layout) {
    ((Layout)parentComponent).remove(uiComponent);
  }

  com.vaadin.ui.Component oldComponent = myChildren.remove(constraint);
  if (oldComponent != null) {
    removeComponent(oldComponent);
  }

  myChildren.put(constraint, component);

  addComponent(component);

  getState().myConstraints = new ArrayList<>(myChildren.keySet());
}