use of com.haulmont.cuba.gui.components.Component.Container in project cuba by cuba-platform.
the class WebWindowManager method showFrame.
@Override
public void showFrame(com.haulmont.cuba.gui.components.Component parent, Frame frame) {
if (parent instanceof Container) {
Container container = (Container) parent;
for (com.haulmont.cuba.gui.components.Component c : container.getComponents()) {
if (c instanceof com.haulmont.cuba.gui.components.Component.Disposable) {
com.haulmont.cuba.gui.components.Component.Disposable disposable = (com.haulmont.cuba.gui.components.Component.Disposable) c;
if (!disposable.isDisposed()) {
disposable.dispose();
}
}
container.remove(c);
}
container.add(frame);
} else {
throw new IllegalStateException("Parent component must be com.haulmont.cuba.gui.components.Component.Container");
}
}
use of com.haulmont.cuba.gui.components.Component.Container in project cuba by cuba-platform.
the class WebComponentsHelper method getShortcutEvent.
public static ShortcutTriggeredEvent getShortcutEvent(com.haulmont.cuba.gui.components.Component source, Component target) {
Component vaadinSource = getVaadinSource(source);
if (vaadinSource == target) {
return new ShortcutTriggeredEvent(source, source);
}
if (source instanceof Container) {
Container container = (Container) source;
com.haulmont.cuba.gui.components.Component childComponent = findChildComponent(container, target);
return new ShortcutTriggeredEvent(source, childComponent);
}
return new ShortcutTriggeredEvent(source, null);
}
use of com.haulmont.cuba.gui.components.Component.Container in project cuba by cuba-platform.
the class WebComponentsHelper method findChildComponent.
protected static com.haulmont.cuba.gui.components.Component findChildComponent(Collection<com.haulmont.cuba.gui.components.Component> components, Component vaadinSource, Component target) {
Component targetComponent = getDirectChildComponent(target, vaadinSource);
for (com.haulmont.cuba.gui.components.Component component : components) {
Component unwrapped = component.unwrapComposition(Component.class);
if (unwrapped == targetComponent) {
com.haulmont.cuba.gui.components.Component child = null;
if (component instanceof Container) {
child = findChildComponent((Container) component, target);
}
if (component instanceof HasButtonsPanel) {
ButtonsPanel buttonsPanel = ((HasButtonsPanel) component).getButtonsPanel();
if (getVaadinSource(buttonsPanel) == target) {
return buttonsPanel;
} else {
child = findChildComponent(buttonsPanel, target);
}
}
if (component instanceof FieldGroup) {
FieldGroup fieldGroup = (FieldGroup) component;
child = findChildComponent(fieldGroup, target);
}
return child != null ? child : component;
}
}
return null;
}
Aggregations