Adjust field indicators width for ordered layouts #PL-2566

This commit is contained in:
Yuriy Artamonov 2013-09-09 15:44:07 +00:00
parent bc8bc4d8c9
commit 2dd5ab9dad
6 changed files with 17 additions and 33 deletions

View File

@ -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);

View File

@ -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;
}

View File

@ -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());
}
}

View File

@ -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);
}

View File

@ -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;

View File

@ -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;
}