mirror of
https://gitee.com/jmix/cuba.git
synced 2024-12-05 04:38:10 +08:00
PL-8359 Responsive property for all components
This commit is contained in:
parent
68b7b8da5b
commit
64253dd60d
@ -64,6 +64,7 @@ public abstract class DesktopAbstractComponent<C extends JComponent>
|
||||
|
||||
protected boolean visible = true;
|
||||
protected boolean enabled = true;
|
||||
protected boolean responsive = false;
|
||||
|
||||
protected boolean parentEnabled = true;
|
||||
|
||||
@ -182,6 +183,16 @@ public abstract class DesktopAbstractComponent<C extends JComponent>
|
||||
updateEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isResponsive() {
|
||||
return responsive;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setResponsive(boolean responsive) {
|
||||
this.responsive = responsive;
|
||||
}
|
||||
|
||||
protected void updateEnabled() {
|
||||
getComposition().setEnabled(isEnabledWithParent());
|
||||
|
||||
|
@ -198,6 +198,16 @@ public class AbstractFrame implements Frame, Frame.Wrapper, Component.Wrapper, C
|
||||
return frame.getCaption();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isResponsive() {
|
||||
return frame.isResponsive();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setResponsive(boolean responsive) {
|
||||
frame.setResponsive(responsive);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCaption(String caption) {
|
||||
frame.setCaption(caption);
|
||||
|
@ -80,6 +80,18 @@ public interface Component {
|
||||
/** Set component enabled state */
|
||||
void setEnabled(boolean enabled);
|
||||
|
||||
/**
|
||||
* Is the component responsive?
|
||||
*/
|
||||
boolean isResponsive();
|
||||
/**
|
||||
* Set component to be responsive by width and height.
|
||||
*
|
||||
* If responsive flag is true then you can use conditional CSS rules that respond to size changes in the browser.
|
||||
* You can set specific rules using "width-range" or "height-range" properties in CSS files.
|
||||
*/
|
||||
void setResponsive(boolean responsive);
|
||||
|
||||
/**
|
||||
* Are the component and its parent visible?
|
||||
*/
|
||||
|
@ -20,12 +20,4 @@ package com.haulmont.cuba.gui.components;
|
||||
public interface CssLayout extends Component.OrderedContainer, Component.BelongToFrame, Component.HasCaption, Component.HasIcon {
|
||||
|
||||
String NAME = "cssLayout";
|
||||
|
||||
boolean isResponsive();
|
||||
|
||||
/**
|
||||
* Set layout component to be responsive by width and height.
|
||||
* "width-range" and "height-range" are set in scss theme files.
|
||||
*/
|
||||
void setResponsive(boolean responsive);
|
||||
}
|
@ -726,6 +726,15 @@ public interface Table<E extends Entity>
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isResponsive() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setResponsive(boolean responsive) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return true;
|
||||
|
@ -209,6 +209,15 @@ public class ParamWrapper implements Component.HasValue {
|
||||
public void setEnabled(boolean enabled) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isResponsive() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setResponsive(boolean responsive) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return false;
|
||||
|
@ -697,6 +697,10 @@
|
||||
<xs:attribute name="enable" type="xs:boolean"/>
|
||||
</xs:attributeGroup>
|
||||
|
||||
<xs:attributeGroup name="hasResponsiveProp">
|
||||
<xs:attribute name="responsive" type="xs:boolean"/>
|
||||
</xs:attributeGroup>
|
||||
|
||||
<xs:attributeGroup name="hasDatasource">
|
||||
<xs:attribute name="datasource" type="xs:string"/>
|
||||
<xs:attribute name="property" type="xs:string"/>
|
||||
@ -983,6 +987,7 @@
|
||||
<xs:attributeGroup ref="hasVisibility"/>
|
||||
<xs:attributeGroup ref="hasAlign"/>
|
||||
<xs:attributeGroup ref="hasEnableProp"/>
|
||||
<xs:attributeGroup ref="hasResponsiveProp"/>
|
||||
</xs:complexType>
|
||||
|
||||
<!-- BaseField -->
|
||||
|
@ -44,5 +44,6 @@ public abstract class AbstractBoxLoader<T extends BoxLayout> extends ContainerLo
|
||||
loadDescription(resultComponent, element);
|
||||
|
||||
loadSubComponentsAndExpand(resultComponent, element);
|
||||
loadResponsive(resultComponent, element);
|
||||
}
|
||||
}
|
@ -152,6 +152,13 @@ public abstract class AbstractComponentLoader<T extends Component> implements Co
|
||||
}
|
||||
}
|
||||
|
||||
protected void loadResponsive(Component component, Element element) {
|
||||
String responsive = element.attributeValue("responsive");
|
||||
if (StringUtils.isNotEmpty(responsive)) {
|
||||
component.setResponsive(Boolean.parseBoolean(responsive));
|
||||
}
|
||||
}
|
||||
|
||||
protected void assignXmlDescriptor(Component component, Element element) {
|
||||
if (component instanceof Component.HasXmlDescriptor) {
|
||||
((Component.HasXmlDescriptor) component).setXmlDescriptor(element);
|
||||
|
@ -48,6 +48,7 @@ public abstract class AbstractFieldLoader<T extends Field> extends AbstractDatas
|
||||
loadHeight(resultComponent, element);
|
||||
loadWidth(resultComponent, element);
|
||||
loadAlign(resultComponent, element);
|
||||
loadResponsive(resultComponent, element);
|
||||
}
|
||||
|
||||
protected void loadRequired(Field component, Element element) {
|
||||
|
@ -94,6 +94,7 @@ public abstract class AbstractTableLoader<T extends Table> extends ActionsHolder
|
||||
loadColumnHeaderVisible(resultComponent, element);
|
||||
loadShowSelection(resultComponent, element);
|
||||
loadTextSelectionEnabled(resultComponent, element);
|
||||
loadResponsive(resultComponent, element);
|
||||
|
||||
Element columnsElement = element.element("columns");
|
||||
Element rowsElement = element.element("rows");
|
||||
|
@ -49,6 +49,7 @@ public abstract class AbstractUploadFieldLoader<T extends UploadField> extends A
|
||||
loadPermittedExtensions(resultComponent, element);
|
||||
|
||||
loadDropZone(resultComponent, element);
|
||||
loadResponsive(resultComponent, element);
|
||||
|
||||
String fileSizeLimit = element.attributeValue("fileSizeLimit");
|
||||
if (StringUtils.isNotEmpty(fileSizeLimit)) {
|
||||
|
@ -75,6 +75,7 @@ public class AccordionLoader extends ContainerLoader<Accordion> {
|
||||
loadIcon(resultComponent, element);
|
||||
loadCaption(resultComponent, element);
|
||||
loadDescription(resultComponent, element);
|
||||
loadResponsive(resultComponent, element);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Element> tabElements = element.elements("tab");
|
||||
|
@ -39,5 +39,6 @@ public class AppMenuLoader extends AbstractComponentLoader<AppMenu> {
|
||||
|
||||
loadWidth(resultComponent, element);
|
||||
loadHeight(resultComponent, element);
|
||||
loadResponsive(resultComponent, element);
|
||||
}
|
||||
}
|
@ -51,6 +51,7 @@ public class AppWorkAreaLoader extends ContainerLoader<AppWorkArea> {
|
||||
|
||||
loadWidth(resultComponent, element);
|
||||
loadHeight(resultComponent, element);
|
||||
loadResponsive(resultComponent, element);
|
||||
|
||||
initialLayoutLoader.loadComponent();
|
||||
}
|
||||
|
@ -83,6 +83,7 @@ public class BulkEditorLoader extends AbstractComponentLoader<BulkEditor> {
|
||||
|
||||
loadWidth(resultComponent, element);
|
||||
loadAlign(resultComponent, element);
|
||||
loadResponsive(resultComponent, element);
|
||||
|
||||
if (!userSessionSource.getUserSession().isSpecificPermitted(BulkEditor.PERMISSION)) {
|
||||
resultComponent.setVisible(false);
|
||||
|
@ -76,6 +76,7 @@ public class ButtonLoader extends AbstractComponentLoader<Button> {
|
||||
|
||||
loadFocusable(resultComponent, element);
|
||||
loadDisableOnClick(resultComponent, element);
|
||||
loadResponsive(resultComponent, element);
|
||||
}
|
||||
|
||||
protected void loadDisableOnClick(Button component, Element element) {
|
||||
|
@ -60,6 +60,7 @@ public class ButtonsPanelLoader extends ContainerLoader<ButtonsPanel> {
|
||||
loadIcon(resultComponent, element);
|
||||
loadCaption(resultComponent, element);
|
||||
loadDescription(resultComponent, element);
|
||||
loadResponsive(resultComponent, element);
|
||||
|
||||
if (!element.elements().isEmpty()) {
|
||||
loadSubComponents();
|
||||
|
@ -58,6 +58,7 @@ public class CalendarLoader extends AbstractComponentLoader<Calendar> {
|
||||
loadTimeFormat(resultComponent, element);
|
||||
loadEndDate(resultComponent, element);
|
||||
loadStartDate(resultComponent, element);
|
||||
loadResponsive(resultComponent, element);
|
||||
loadNavigationButtonsVisible(resultComponent, element);
|
||||
}
|
||||
|
||||
|
@ -50,6 +50,7 @@ public class ColorPickerLoader extends AbstractFieldLoader<ColorPicker>{
|
||||
|
||||
loadPopupCaption(resultComponent, element);
|
||||
loadSwatchesTabCaption(resultComponent, element);
|
||||
loadResponsive(resultComponent, element);
|
||||
}
|
||||
|
||||
protected void loadPopupCaption(ColorPicker component, Element element) {
|
||||
|
@ -57,6 +57,8 @@ public class LabelLoader extends AbstractDatasourceComponentLoader<Label> {
|
||||
loadWidth(resultComponent, element, Component.AUTO_SIZE);
|
||||
loadHeight(resultComponent, element, Component.AUTO_SIZE);
|
||||
|
||||
loadResponsive(resultComponent, element);
|
||||
|
||||
resultComponent.setFormatter(loadFormatter(element));
|
||||
}
|
||||
}
|
@ -68,6 +68,7 @@ public class TokenListLoader extends AbstractFieldLoader<TokenList> {
|
||||
loadClearButton(resultComponent, element);
|
||||
|
||||
loadRefreshOptionsOnLookupClose(resultComponent, element);
|
||||
loadResponsive(resultComponent, element);
|
||||
}
|
||||
|
||||
protected void loadRefreshOptionsOnLookupClose(TokenList component, Element element) {
|
||||
|
@ -872,6 +872,21 @@ public class WebWindow implements Window, Component.Wrapper,
|
||||
component.setEnabled(enabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isResponsive() {
|
||||
if (component instanceof AbstractComponent) {
|
||||
return ((AbstractComponent) component).isResponsive();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setResponsive(boolean responsive) {
|
||||
if (component instanceof AbstractComponent) {
|
||||
((AbstractComponent) component).setResponsive(responsive);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return true;
|
||||
|
@ -88,6 +88,16 @@ public abstract class WebAbstractComponent<T extends com.vaadin.ui.AbstractCompo
|
||||
assignAutoDebugId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isResponsive() {
|
||||
return component.isResponsive();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setResponsive(boolean responsive) {
|
||||
component.setResponsive(responsive);
|
||||
}
|
||||
|
||||
public void assignAutoDebugId() {
|
||||
AppUI ui = AppUI.getCurrent();
|
||||
if (ui != null && ui.isTestMode()) {
|
||||
|
Loading…
Reference in New Issue
Block a user