use of com.haulmont.cuba.gui.screen.FrameOwner in project cuba by cuba-platform.
the class TwinColumnLoader method loadOptionsContainer.
protected void loadOptionsContainer(TwinColumn component, Element element) {
String containerId = element.attributeValue("optionsContainer");
if (containerId != null) {
FrameOwner frameOwner = getComponentContext().getFrame().getFrameOwner();
ScreenData screenData = UiControllerUtils.getScreenData(frameOwner);
InstanceContainer container = screenData.getContainer(containerId);
if (!(container instanceof CollectionContainer)) {
throw new GuiDevelopmentException("Not a CollectionContainer: " + containerId, context);
}
// noinspection unchecked
component.setOptions(new ContainerOptions((CollectionContainer) container));
}
}
use of com.haulmont.cuba.gui.screen.FrameOwner in project cuba by cuba-platform.
the class LookupFieldLoader method loadNewOptionHandler.
protected void loadNewOptionHandler(LookupField component, Element element) {
String newOptionAllowed = element.attributeValue("newOptionAllowed");
if (StringUtils.isNotEmpty(newOptionAllowed)) {
component.setNewOptionAllowed(Boolean.parseBoolean(newOptionAllowed));
}
String newOptionHandlerMethod = element.attributeValue("newOptionHandler");
if (StringUtils.isNotEmpty(newOptionHandlerMethod)) {
FrameOwner controller = getComponentContext().getFrame().getFrameOwner();
Class<? extends FrameOwner> windowClass = controller.getClass();
Method newOptionHandler;
try {
newOptionHandler = windowClass.getMethod(newOptionHandlerMethod, LookupField.class, String.class);
} catch (NoSuchMethodException e) {
Map<String, Object> params = ParamsMap.of("LookupField Id", component.getId(), "Method name", newOptionHandlerMethod);
throw new GuiDevelopmentException("Unable to find new option handler method for lookup field", context, params);
}
component.setNewOptionHandler(caption -> {
try {
newOptionHandler.invoke(controller, component, caption);
} catch (IllegalAccessException | InvocationTargetException e) {
throw new RuntimeException("Unable to invoke new option handler", e);
}
});
}
}
use of com.haulmont.cuba.gui.screen.FrameOwner in project cuba by cuba-platform.
the class WebSuggestionField method showSuggestions.
protected void showSuggestions(List<V> suggestions, boolean userOriginated) {
FrameOwner frameOwner = getFrame().getFrameOwner();
Collection<Screen> dialogScreens = UiControllerUtils.getScreenContext(frameOwner).getScreens().getOpenedScreens().getDialogScreens();
Screen lastDialog = null;
for (Screen dialogScreen : dialogScreens) {
lastDialog = dialogScreen;
}
if (frameOwner instanceof ScreenFragment) {
frameOwner = ComponentsHelper.getScreen((ScreenFragment) frameOwner);
}
if (lastDialog == null || Objects.equals(frameOwner, lastDialog)) {
component.showSuggestions(suggestions, userOriginated);
}
}
use of com.haulmont.cuba.gui.screen.FrameOwner in project cuba by cuba-platform.
the class DynamicAttributesPanelLoader method loadDataContainer.
protected void loadDataContainer(DynamicAttributesPanel resultComponent, Element element) {
String containerId = element.attributeValue("dataContainer");
if (Strings.isNullOrEmpty(containerId)) {
throw new GuiDevelopmentException("DynamicAttributesPanel element doesn't have 'dataContainer' attribute", context, "DynamicAttributesPanel ID", element.attributeValue("id"));
}
FrameOwner frameOwner = getComponentContext().getFrame().getFrameOwner();
ScreenData screenData = UiControllerUtils.getScreenData(frameOwner);
InstanceContainer container = screenData.getContainer(containerId);
// noinspection unchecked
resultComponent.setInstanceContainer(container);
}
use of com.haulmont.cuba.gui.screen.FrameOwner in project cuba by cuba-platform.
the class TestCommentaryPanelLoader method loadDataContainer.
@SuppressWarnings("unchecked")
private void loadDataContainer(TestCommentaryPanel resultComponent, Element element) {
String containerId = this.element.attributeValue("dataContainer");
if (Strings.isNullOrEmpty(containerId)) {
throw new GuiDevelopmentException("CommentaryPanel element doesn't have 'dataContainer' attribute", context, "CommentaryPanel ID", element.attributeValue("id"));
}
FrameOwner frameOwner = getComponentContext().getFrame().getFrameOwner();
ScreenData screenData = UiControllerUtils.getScreenData(frameOwner);
InstanceContainer container = screenData.getContainer(containerId);
if (container instanceof CollectionContainer) {
resultComponent.setDataContainer((CollectionContainer) container);
} else {
throw new GuiDevelopmentException("Not a CollectionContainer: " + containerId, context);
}
}
Aggregations