use of com.haulmont.cuba.gui.components.Component in project cuba by cuba-platform.
the class ScrollBoxLayoutLoader method loadComponent.
@Override
public void loadComponent() {
assignFrame(resultComponent);
assignXmlDescriptor(resultComponent, element);
loadVisible(resultComponent, element);
loadStyleName(resultComponent, element);
loadAlign(resultComponent, element);
loadScrollBars(resultComponent, element);
loadSpacing(resultComponent, element);
loadMargin(resultComponent, element);
loadHeight(resultComponent, element);
loadWidth(resultComponent, element);
loadIcon(resultComponent, element);
loadCaption(resultComponent, element);
loadDescription(resultComponent, element);
loadSubComponents();
for (Component child : resultComponent.getOwnComponents()) {
if (resultComponent.getOrientation() == ScrollBoxLayout.Orientation.VERTICAL && ComponentsHelper.hasFullHeight(child)) {
child.setHeight("-1px");
log.warn("100% height of " + child.getClass().getSimpleName() + " id=" + child.getId() + " inside vertical scrollBox replaced with -1px height");
}
if (resultComponent.getOrientation() == ScrollBoxLayout.Orientation.HORIZONTAL && ComponentsHelper.hasFullWidth(child)) {
child.setWidth("-1px");
log.warn("100% width of " + child.getClass().getSimpleName() + " id=" + child.getId() + " inside horizontal scrollBox replaced with -1px width");
}
}
}
use of com.haulmont.cuba.gui.components.Component in project cuba by cuba-platform.
the class SideMenuLoader method loadSidePanel.
protected void loadSidePanel(SideMenu component, Element element) {
String sidePanelId = element.attributeValue("sidePanel");
if (StringUtils.isNotEmpty(sidePanelId)) {
Component sidePanel = resultComponent.getFrame().getComponent(sidePanelId);
if (sidePanel == null) {
throw new GuiDevelopmentException("Unable to find sidePanel component for SideMenu", context.getFullFrameId(), "sidePanel", sidePanelId);
}
component.setSidePanel(sidePanel);
}
}
use of com.haulmont.cuba.gui.components.Component in project cuba by cuba-platform.
the class SideMenuLoader method loadSidePanelToggleButton.
protected void loadSidePanelToggleButton(SideMenu component, Element element) {
String toggleButtonId = element.attributeValue("sidePanelToggleButton");
if (StringUtils.isNotEmpty(toggleButtonId)) {
Component toggleButton = resultComponent.getFrame().getComponent(toggleButtonId);
if (!(toggleButton instanceof Button)) {
throw new GuiDevelopmentException("Unable to find sidePanelToggleButton for SideMenu", context.getFullFrameId(), "sidePanelToggleButton", toggleButtonId);
}
component.setSidePanelToggleButton((Button) toggleButton);
}
}
use of com.haulmont.cuba.gui.components.Component in project cuba by cuba-platform.
the class LookupPickerFieldDsTest method testUnsubscribeSubscribeOptions.
@Test
public void testUnsubscribeSubscribeOptions() {
LookupPickerField component = (LookupPickerField) factory.createComponent(LookupPickerField.NAME);
CollectionDatasource<Group, UUID> groupsDs = getTestCollectionDatasource();
component.setOptionsDatasource(groupsDs);
List<Group> groups = new ArrayList<>(groupsDs.getItems());
Datasource<User> userDs = getTestUserDatasource();
User user = userDs.getItem();
user.setGroup(groups.get(0));
component.setDatasource(userDs, "group");
// unbind
component.setOptionsDatasource(null);
Datasource.ItemChangeListener<Group> listener = e -> {
throw new RuntimeException("Value was changed externally");
};
groupsDs.addItemChangeListener(listener);
component.setValue(groups.get(1));
// bind
component.setOptionsDatasource(groupsDs);
groupsDs.removeItemChangeListener(listener);
boolean[] valueWasChanged = { false };
listener = e -> valueWasChanged[0] = true;
groupsDs.addItemChangeListener(listener);
component.setValue(groups.get(2));
assertEquals(true, valueWasChanged[0]);
}
use of com.haulmont.cuba.gui.components.Component in project cuba by cuba-platform.
the class LookupPickerFieldDsTest method testOptionsDsUnsubscribe.
@Test
public void testOptionsDsUnsubscribe() {
LookupPickerField component = (LookupPickerField) factory.createComponent(LookupPickerField.NAME);
CollectionDatasource<Group, UUID> groupsDs = getTestCollectionDatasource();
component.setOptionsDatasource(groupsDs);
List<Group> groups = new ArrayList<>(groupsDs.getItems());
Datasource<User> userDs = getTestUserDatasource();
User user = userDs.getItem();
user.setGroup(groups.get(0));
component.setDatasource(userDs, "group");
// unbind
component.setOptionsDatasource(null);
Datasource.ItemChangeListener<Group> listener = e -> {
throw new RuntimeException("Value was changed externally");
};
groupsDs.addItemChangeListener(listener);
component.setValue(groups.get(1));
}
Aggregations