PL-7118 Remove tooltip-indicator support

This commit is contained in:
Yuriy Artamonov 2017-04-25 14:31:20 +04:00
parent a462d2590e
commit 81b2c08fe3
8 changed files with 9 additions and 193 deletions

View File

@ -31,9 +31,6 @@ import com.vaadin.shared.ui.ComponentStateUtil;
public class CubaCaptionWidget extends VCaption {
public static final String CUBA_CLASSNAME = "c-caption";
public static final String TOOLTIP_CLASSNAME = "c-tooltip-button";
protected Element toolTipIndicator;
protected boolean captionPlacedAfterComponentByDefault = true;
@ -144,13 +141,6 @@ public class CubaCaptionWidget extends VCaption {
captionText = null;
}
if (ComponentStateUtil.hasDescription(owner.getState())
&& captionText != null) {
addStyleDependentName("hasdescription");
} else {
removeStyleDependentName("hasdescription");
}
AriaHelper.handleInputRequired(owner.getWidget(), showRequired);
if (showRequired) {
@ -172,24 +162,6 @@ public class CubaCaptionWidget extends VCaption {
requiredFieldIndicator = null;
}
// Description
// Haulmont API
if (ComponentStateUtil.hasDescription(owner.getState())) {
addStyleDependentName("hasdescription");
if (toolTipIndicator == null) {
toolTipIndicator = DOM.createDiv();
toolTipIndicator.setClassName(TOOLTIP_CLASSNAME);
DOM.insertChild(getElement(), toolTipIndicator, getDescriptionInsertPosition());
}
} else {
removeStyleDependentName("hasdescription");
if (toolTipIndicator != null) {
toolTipIndicator.removeFromParent();
toolTipIndicator = null;
}
}
AriaHelper.handleInputInvalid(owner.getWidget(), showError);
if (showError) {
@ -237,9 +209,6 @@ public class CubaCaptionWidget extends VCaption {
if (errorIndicatorElement != null && errorIndicatorElement.getParentElement() == getElement()) {
width += WidgetUtil.getRequiredWidth(errorIndicatorElement);
}
if (toolTipIndicator != null && toolTipIndicator.getParentElement() == getElement()) {
width += WidgetUtil.getRequiredWidth(toolTipIndicator);
}
return width;
}
@ -249,10 +218,6 @@ public class CubaCaptionWidget extends VCaption {
return super.getTextElement();
}
public Element getTooltipElement() {
return toolTipIndicator;
}
public Element getRequiredIndicatorElement() {
return requiredFieldIndicator;
}
@ -261,21 +226,6 @@ public class CubaCaptionWidget extends VCaption {
return errorIndicatorElement;
}
@Override
protected int getInsertPosition(InsertPosition element) {
int pos = super.getInsertPosition(element);
if (toolTipIndicator != null) {
pos++;
}
return pos;
}
protected int getDescriptionInsertPosition() {
return super.getInsertPosition(null);
}
public void setCaptionHolder(CaptionHolder captionHolder) {
this.captionHolder = captionHolder;
}

View File

@ -365,15 +365,6 @@ public class CubaFieldGroupLayoutComponentSlot extends CubaGridLayoutSlot implem
requiredElement = null;
}
if (captionWidget.getTooltipElement() != null) {
captionWidget.getTooltipElement().removeFromParent();
tooltipElement = captionWidget.getTooltipElement();
rightCaption.appendChild(tooltipElement);
} else if (tooltipElement != null) {
tooltipElement.removeFromParent();
tooltipElement = null;
}
if (captionWidget.getErrorIndicatorElement() != null) {
captionWidget.getErrorIndicatorElement().removeFromParent();

View File

@ -43,7 +43,7 @@ public class CubaGridLayoutConnector extends GridLayoutConnector {
// CAUTION copied from GridLayoutConnector.updateCaption(ComponentConnector childConnector)
VGridLayout layout = getWidget();
VGridLayout.Cell cell = layout.widgetToCell.get(childConnector.getWidget());
if (VCaption.isNeeded(childConnector.getState()) || !"".equals(childConnector.getState().description)) {
if (VCaption.isNeeded(childConnector.getState())) {
VLayoutSlot layoutSlot = cell.slot;
VCaption caption = layoutSlot.getCaption();
if (caption == null) {

View File

@ -18,22 +18,14 @@
package com.haulmont.cuba.web.toolkit.ui.client.orderedactionslayout;
import com.haulmont.cuba.web.toolkit.ui.CubaOrderedActionsLayout;
import com.vaadin.client.*;
import com.vaadin.client.ui.AbstractFieldConnector;
import com.vaadin.client.ui.Icon;
import com.vaadin.client.ApplicationConnection;
import com.vaadin.client.Paintable;
import com.vaadin.client.UIDL;
import com.vaadin.client.ui.ShortcutActionHandler;
import com.vaadin.client.ui.aria.AriaHelper;
import com.vaadin.client.ui.orderedlayout.AbstractOrderedLayoutConnector;
import com.vaadin.client.ui.orderedlayout.CaptionPosition;
import com.vaadin.shared.AbstractFieldState;
import com.vaadin.shared.ComponentConstants;
import com.vaadin.shared.communication.URLReference;
import com.vaadin.shared.ui.ComponentStateUtil;
import com.vaadin.shared.ui.Connect;
import java.util.List;
@Connect(value = CubaOrderedActionsLayout.class, loadStyle = Connect.LoadStyle.EAGER)
@Connect(CubaOrderedActionsLayout.class)
public class CubaOrderedActionsLayoutConnector extends AbstractOrderedLayoutConnector implements Paintable {
@Override
@ -54,59 +46,4 @@ public class CubaOrderedActionsLayoutConnector extends AbstractOrderedLayoutConn
}
}
}
@Override
protected void updateCaptionInternal(ComponentConnector child) {
// CAUTION copied from superclass
CubaOrderedLayoutSlot slot = (CubaOrderedLayoutSlot) getWidget().getSlot(child.getWidget());
String caption = child.getState().caption;
URLReference iconUrl = child.getState().resources
.get(ComponentConstants.ICON_RESOURCE);
String iconUrlString = iconUrl != null ? iconUrl.getURL() : null;
Icon icon = child.getConnection().getIcon(iconUrlString);
List<String> styles = child.getState().styles;
String error = child.getState().errorMessage;
boolean showError = error != null;
if (child.getState() instanceof AbstractFieldState) {
AbstractFieldState abstractFieldState = (AbstractFieldState) child
.getState();
showError = showError && !abstractFieldState.hideErrors;
}
boolean required = false;
if (child instanceof AbstractFieldConnector) {
required = ((AbstractFieldConnector) child).isRequired();
}
boolean enabled = child.isEnabled();
if (slot.hasCaption() && null == caption) {
slot.setCaptionResizeListener(null);
}
String description = null;
if (ComponentStateUtil.hasDescription(child.getState())) {
description = child.getState().description;
}
// Haulmont API
slot.setCaption(caption, description, icon, styles, error, showError, required,
enabled, child.getState().captionAsHtml);
AriaHelper.handleInputRequired(child.getWidget(), required);
AriaHelper.handleInputInvalid(child.getWidget(), showError);
AriaHelper.bindCaption(child.getWidget(), slot.getCaptionElement());
if (slot.hasCaption()) {
CaptionPosition pos = slot.getCaptionPosition();
slot.setCaptionResizeListener(slotCaptionResizeListener);
if (child.isRelativeHeight()
&& (pos == CaptionPosition.TOP || pos == CaptionPosition.BOTTOM)) {
getWidget().updateCaptionOffset(slot.getCaptionElement());
} else if (child.isRelativeWidth()
&& (pos == CaptionPosition.LEFT || pos == CaptionPosition.RIGHT)) {
getWidget().updateCaptionOffset(slot.getCaptionElement());
}
}
}
}

View File

@ -35,16 +35,12 @@ import java.util.List;
public class CubaOrderedLayoutSlot extends Slot {
public static final String TOOLTIP_CLASSNAME = "c-tooltip-button";
protected Element tooltipIcon;
protected String descriptionText;
public CubaOrderedLayoutSlot(VAbstractOrderedLayout layout, Widget widget) {
super(layout, widget);
}
public void setCaption(String captionText, String descriptionText, Icon icon, List<String> styles,
@Override
public void setCaption(String captionText, Icon icon, List<String> styles,
String error, boolean showError, boolean required, boolean enabled, boolean captionAsHtml) {
// CAUTION copied from super
// Caption wrappers
@ -52,7 +48,7 @@ public class CubaOrderedLayoutSlot extends Slot {
final Element focusedElement = WidgetUtil.getFocusedElement();
// By default focus will not be lost
boolean focusLost = false;
if (captionText != null || icon != null || error != null || required || descriptionText != null) {
if (captionText != null || icon != null || error != null || required) {
if (caption == null) {
caption = DOM.createDiv();
captionWrap = DOM.createDiv();
@ -138,30 +134,6 @@ public class CubaOrderedLayoutSlot extends Slot {
requiredIcon = null;
}
// Description
// Haulmont API
this.descriptionText = descriptionText;
if (descriptionText != null) {
if (tooltipIcon == null) {
tooltipIcon = DOM.createSpan();
// TODO decide something better (e.g. use CSS to insert the
// character)
tooltipIcon.setInnerHTML("?");
tooltipIcon.setClassName(TOOLTIP_CLASSNAME);
// The star should not be read by the screen reader, as it is
// purely visual. Required state is set at the element level for
// the screen reader.
Roles.getTextboxRole().setAriaHiddenState(tooltipIcon, true);
}
if (caption != null) {
caption.appendChild(tooltipIcon);
}
} else if (this.tooltipIcon != null) {
this.tooltipIcon.removeFromParent();
this.tooltipIcon = null;
}
// Error
if (error != null && showError) {
if (errorIcon == null) {

View File

@ -35,11 +35,6 @@ import com.vaadin.client.ui.gridlayout.GridLayoutConnector;
import com.vaadin.client.ui.layout.ComponentConnectorLayoutSlot;
import com.vaadin.client.ui.orderedlayout.Slot;
import java.util.ArrayList;
import java.util.List;
import static com.haulmont.cuba.web.toolkit.ui.client.caption.CubaCaptionWidget.TOOLTIP_CLASSNAME;
public class CubaTooltip extends VTooltip {
public static final String REQUIRED_INDICATOR = "v-required-field-indicator";
@ -92,7 +87,6 @@ public class CubaTooltip extends VTooltip {
protected boolean isTooltipElement(Element element) {
return (REQUIRED_INDICATOR.equals(element.getClassName())
|| TOOLTIP_CLASSNAME.equals(element.getClassName())
|| ERROR_INDICATOR.equals(element.getClassName()));
}
@ -251,7 +245,6 @@ public class CubaTooltip extends VTooltip {
protected boolean elementIsIndicator(Element relativeElement) {
return relativeElement != null
&& (REQUIRED_INDICATOR.equals(relativeElement.getClassName())
|| TOOLTIP_CLASSNAME.equals(relativeElement.getClassName())
|| ERROR_INDICATOR.equals(relativeElement.getClassName()));
}
@ -296,7 +289,6 @@ public class CubaTooltip extends VTooltip {
if (caption instanceof CubaCaptionWidget) {
CubaCaptionWidget cubaCaptionWidget = (CubaCaptionWidget) caption;
if (cubaCaptionWidget.getRequiredIndicatorElement() != null
|| cubaCaptionWidget.getTooltipElement() != null
|| cubaCaptionWidget.getErrorIndicatorElement() != null) {
return true;
}

View File

@ -25,22 +25,9 @@
}
@if $v-show-required-indicators == false {
.v-required-field-indicator,
.c-tooltip-button {
.v-required-field-indicator {
display: none;
}
} @else {
.c-tooltip-button {
display: inline-block;
font-size: 0;
width: $v-font-size;
}
.c-tooltip-button::before {
font-family: FontAwesome;
content: "\f059";
font-size: $v-font-size;
}
}
.v-gridlayout.c-shrink-empty {

View File

@ -29,19 +29,6 @@
cursor: pointer;
}
.c-tooltip-button {
display: inline-block;
color: transparent;
background: transparent no-repeat top right;
background-image: url(sprites/question.png); /** sprite-ref: components; */
width: 16px;
height: 16px;
}
.c-tooltip-button:hover {
cursor: pointer;
}
.#{$primary-stylename}text {
padding-bottom: 2px;
}