mirror of
https://gitee.com/jmix/cuba.git
synced 2024-12-02 19:27:57 +08:00
Adjust field indicators width for ordered layouts #PL-2566
This commit is contained in:
parent
bc8bc4d8c9
commit
2dd5ab9dad
@ -6,7 +6,7 @@
|
||||
|
||||
package com.haulmont.cuba.web.toolkit.ui.client.fieldgrouplayout;
|
||||
|
||||
import com.haulmont.cuba.web.toolkit.ui.client.gridlayout.CubaGridLayoutComponentSlot;
|
||||
import com.haulmont.cuba.web.toolkit.ui.client.gridlayout.CubaGridLayoutSlot;
|
||||
import com.vaadin.client.ComponentConnector;
|
||||
import com.vaadin.client.ui.ManagedLayout;
|
||||
|
||||
@ -16,7 +16,7 @@ import com.vaadin.client.ui.ManagedLayout;
|
||||
* @author artamonov
|
||||
* @version $Id$
|
||||
*/
|
||||
public class CubaFieldGroupLayoutComponentSlot extends CubaGridLayoutComponentSlot {
|
||||
public class CubaFieldGroupLayoutComponentSlot extends CubaGridLayoutSlot {
|
||||
|
||||
public CubaFieldGroupLayoutComponentSlot(String baseClassName, ComponentConnector child, ManagedLayout layout) {
|
||||
super(baseClassName, child, layout);
|
||||
|
@ -23,7 +23,7 @@ import com.vaadin.shared.ui.AlignmentInfo;
|
||||
* @author devyatkin
|
||||
* @version $Id$
|
||||
*/
|
||||
public class CubaGridLayoutComponentSlot extends ComponentConnectorLayoutSlot implements CaptionHolder {
|
||||
public class CubaGridLayoutSlot extends ComponentConnectorLayoutSlot implements CaptionHolder {
|
||||
|
||||
protected static final String INDICATORS_CLASSNAME = "caption-indicators";
|
||||
|
||||
@ -33,7 +33,7 @@ public class CubaGridLayoutComponentSlot extends ComponentConnectorLayoutSlot im
|
||||
|
||||
protected Element rightCaption = null;
|
||||
|
||||
public CubaGridLayoutComponentSlot(String baseClassName, ComponentConnector child, ManagedLayout layout) {
|
||||
public CubaGridLayoutSlot(String baseClassName, ComponentConnector child, ManagedLayout layout) {
|
||||
super(baseClassName, child, layout);
|
||||
}
|
||||
|
||||
@ -339,6 +339,7 @@ public class CubaGridLayoutComponentSlot extends ComponentConnectorLayoutSlot im
|
||||
rightCaption.addClassName(INDICATORS_CLASSNAME);
|
||||
rightCaption.getStyle().setDisplay(Style.Display.INLINE_BLOCK);
|
||||
rightCaption.getStyle().setPosition(Style.Position.ABSOLUTE);
|
||||
|
||||
return rightCaption;
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ public class CubaGridLayoutWidget extends VGridLayout {
|
||||
|
||||
@Override
|
||||
protected ComponentConnectorLayoutSlot createComponentConnectorLayoutSlot(ComponentConnector component) {
|
||||
return new CubaGridLayoutComponentSlot(VGridLayout.CLASSNAME, component, getConnector());
|
||||
return new CubaGridLayoutSlot(VGridLayout.CLASSNAME, component, getConnector());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ public class CubaOrderedActionsLayoutConnector extends AbstractOrderedLayoutConn
|
||||
|
||||
@Override
|
||||
protected void updateCaptionInternal(ComponentConnector child) {
|
||||
CubaSlot slot = (CubaSlot) getWidget().getSlot(child.getWidget());
|
||||
CubaOrderedLayoutSlot slot = (CubaOrderedLayoutSlot) getWidget().getSlot(child.getWidget());
|
||||
if (VCaption.isNeeded(child.getState())) {
|
||||
VCaption caption = slot.getCaption();
|
||||
if (caption == null) {
|
||||
@ -50,6 +50,8 @@ public class CubaOrderedActionsLayoutConnector extends AbstractOrderedLayoutConn
|
||||
slot.setCaption(caption);
|
||||
}
|
||||
caption.updateCaption();
|
||||
|
||||
getLayoutManager().setNeedsMeasure(child);
|
||||
} else {
|
||||
slot.setCaption(null);
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ public class CubaOrderedActionsLayoutWidget extends VAbstractOrderedLayout {
|
||||
public Slot getSlot(Widget widget) {
|
||||
Slot slot = widgetToSlot.get(widget);
|
||||
if (slot == null) {
|
||||
slot = new CubaSlot(this, widget);
|
||||
slot = new CubaOrderedLayoutSlot(this, widget);
|
||||
widgetToSlot.put(widget, slot);
|
||||
}
|
||||
return slot;
|
||||
|
@ -12,7 +12,6 @@ import com.google.gwt.user.client.Element;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
import com.haulmont.cuba.web.toolkit.ui.client.caption.CaptionHolder;
|
||||
import com.haulmont.cuba.web.toolkit.ui.client.caption.CubaCaptionWidget;
|
||||
import com.vaadin.client.Util;
|
||||
import com.vaadin.client.VCaption;
|
||||
import com.vaadin.client.ui.VCheckBox;
|
||||
import com.vaadin.client.ui.orderedlayout.Slot;
|
||||
@ -22,7 +21,7 @@ import com.vaadin.client.ui.orderedlayout.VAbstractOrderedLayout;
|
||||
* @author devyatkin
|
||||
* @version $Id$
|
||||
*/
|
||||
public class CubaSlot extends Slot implements CaptionHolder {
|
||||
public class CubaOrderedLayoutSlot extends Slot implements CaptionHolder {
|
||||
|
||||
protected static final String INDICATORS_CLASSNAME = "caption-indicators";
|
||||
|
||||
@ -32,7 +31,7 @@ public class CubaSlot extends Slot implements CaptionHolder {
|
||||
|
||||
protected VCaption caption;
|
||||
|
||||
public CubaSlot(VAbstractOrderedLayout layout, Widget widget) {
|
||||
public CubaOrderedLayoutSlot(VAbstractOrderedLayout layout, Widget widget) {
|
||||
super(layout, widget);
|
||||
}
|
||||
|
||||
@ -62,13 +61,12 @@ public class CubaSlot extends Slot implements CaptionHolder {
|
||||
}
|
||||
|
||||
protected void moveIndicatorsRight(final CubaCaptionWidget captionWidget) {
|
||||
int fakeCaptionWidth = 0;
|
||||
boolean widthChanged = false;
|
||||
if (rightCaption == null) {
|
||||
rightCaption = createRightCaption();
|
||||
getWidget().getElement().getParentElement().insertAfter(rightCaption, getWidget().getElement());
|
||||
}
|
||||
|
||||
if (captionWidget.getRequiredIndicatorElement() != null && requiredElement == null) {
|
||||
if (rightCaption == null) {
|
||||
rightCaption = createRightCaption();
|
||||
getWidget().getElement().getParentElement().insertAfter(rightCaption, getWidget().getElement());
|
||||
}
|
||||
|
||||
captionWidget.getElement().removeChild(captionWidget.getRequiredIndicatorElement());
|
||||
|
||||
@ -80,12 +78,9 @@ public class CubaSlot extends Slot implements CaptionHolder {
|
||||
rightCaption.appendChild(requiredElement);
|
||||
}
|
||||
|
||||
widthChanged = true;
|
||||
|
||||
} else if (captionWidget.getRequiredIndicatorElement() == null && requiredElement != null) {
|
||||
requiredElement.removeFromParent();
|
||||
requiredElement = null;
|
||||
widthChanged = true;
|
||||
}
|
||||
|
||||
if (captionWidget.getTooltipElement() != null && tooltipElement == null) {
|
||||
@ -99,22 +94,9 @@ public class CubaSlot extends Slot implements CaptionHolder {
|
||||
tooltipElement = captionWidget.getTooltipElement();
|
||||
rightCaption.appendChild(tooltipElement);
|
||||
}
|
||||
widthChanged = true;
|
||||
} else if (captionWidget.getTooltipElement() == null && tooltipElement != null) {
|
||||
tooltipElement.removeFromParent();
|
||||
tooltipElement = null;
|
||||
widthChanged = true;
|
||||
}
|
||||
|
||||
if (requiredElement != null) {
|
||||
fakeCaptionWidth += Util.getRequiredWidth(requiredElement);
|
||||
}
|
||||
if (tooltipElement != null) {
|
||||
fakeCaptionWidth += Util.getRequiredWidth(tooltipElement);
|
||||
}
|
||||
|
||||
if (rightCaption != null && widthChanged) {
|
||||
DOM.setStyleAttribute(rightCaption, "width", fakeCaptionWidth + "px");
|
||||
}
|
||||
}
|
||||
|
||||
@ -125,7 +107,6 @@ public class CubaSlot extends Slot implements CaptionHolder {
|
||||
rightCaption.addClassName(INDICATORS_CLASSNAME);
|
||||
rightCaption.getStyle().setDisplay(Style.Display.INLINE_BLOCK);
|
||||
rightCaption.getStyle().setPosition(Style.Position.RELATIVE);
|
||||
rightCaption.getStyle().setRight(0, Style.Unit.PX);
|
||||
|
||||
return rightCaption;
|
||||
}
|
Loading…
Reference in New Issue
Block a user