mirror of
https://gitee.com/jmix/cuba.git
synced 2024-12-03 03:38:33 +08:00
PL-8559 Support "tab index" functionality in platform components
This commit is contained in:
parent
8cf633ad43
commit
09f8edcb5e
@ -30,6 +30,7 @@ public class CheckBoxLoader extends AbstractFieldLoader<CheckBox> {
|
||||
public void loadComponent() {
|
||||
super.loadComponent();
|
||||
|
||||
loadTabIndex(resultComponent, element);
|
||||
loadBuffered(resultComponent, element);
|
||||
}
|
||||
}
|
@ -144,6 +144,7 @@ public class DataGridLoader extends ActionsHolderLoader<DataGrid> {
|
||||
|
||||
loadSelectionMode(resultComponent, element);
|
||||
loadFrozenColumnCount(resultComponent, element);
|
||||
loadTabIndex(resultComponent, element);
|
||||
}
|
||||
|
||||
protected void loadColumnsHidingAllowed(DataGrid component, Element element) {
|
||||
|
@ -101,5 +101,6 @@ public class RelatedEntitiesLoader extends AbstractComponentLoader<RelatedEntiti
|
||||
});
|
||||
|
||||
loadFocusable(resultComponent, element);
|
||||
loadTabIndex(resultComponent, element);
|
||||
}
|
||||
}
|
@ -44,6 +44,7 @@ public class TimeFieldLoader extends AbstractFieldLoader<TimeField> {
|
||||
resultComponent.setShowSeconds(Boolean.parseBoolean(showSeconds));
|
||||
}
|
||||
|
||||
loadTabIndex(resultComponent, element);
|
||||
loadBuffered(resultComponent, element);
|
||||
}
|
||||
|
||||
|
@ -70,6 +70,8 @@ public class TwinColumnLoader extends AbstractFieldLoader<TwinColumn> {
|
||||
if (StringUtils.isNotEmpty(multiselect)) {
|
||||
resultComponent.setMultiSelect(Boolean.parseBoolean(multiselect));
|
||||
}
|
||||
|
||||
loadTabIndex(resultComponent, element);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) 2008-2017 Haulmont.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.haulmont.cuba.web.toolkit.ui.client.colorpicker;
|
||||
|
||||
import com.haulmont.cuba.web.toolkit.ui.CubaColorPicker;
|
||||
import com.vaadin.client.communication.StateChangeEvent;
|
||||
import com.vaadin.client.ui.colorpicker.ColorPickerConnector;
|
||||
import com.vaadin.shared.ui.Connect;
|
||||
|
||||
@Connect(CubaColorPicker.class)
|
||||
public class CubaColorPickerConnector extends ColorPickerConnector {
|
||||
|
||||
@Override
|
||||
public CubaColorPickerState getState() {
|
||||
return (CubaColorPickerState) super.getState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStateChanged(StateChangeEvent stateChangeEvent) {
|
||||
super.onStateChanged(stateChangeEvent);
|
||||
|
||||
if (stateChangeEvent.hasPropertyChanged("tabIndex")) {
|
||||
getWidget().setTabIndex(getState().tabIndex);
|
||||
}
|
||||
}
|
||||
}
|
@ -82,10 +82,25 @@ public class CubaSourceCodeEditorWidget extends AceEditorWidget {
|
||||
super.setReadOnly(!enabled || readOnly);
|
||||
|
||||
if (editor != null) {
|
||||
Element textAreaElement = getTextAreaElement();
|
||||
|
||||
if (enabled) {
|
||||
getTextAreaElement().removeAttribute("disabled");
|
||||
textAreaElement.removeAttribute("disabled");
|
||||
} else {
|
||||
getTextAreaElement().setAttribute("disabled", "disabled");
|
||||
textAreaElement.setAttribute("disabled", "disabled");
|
||||
}
|
||||
|
||||
updateTabIndex();
|
||||
}
|
||||
}
|
||||
|
||||
protected void updateTabIndex() {
|
||||
if (editor != null) {
|
||||
Element textAreaElement = getTextAreaElement();
|
||||
if (enabled && !readOnly) {
|
||||
textAreaElement.setTabIndex(tabIndex);
|
||||
} else {
|
||||
textAreaElement.setTabIndex(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -93,6 +108,8 @@ public class CubaSourceCodeEditorWidget extends AceEditorWidget {
|
||||
@Override
|
||||
public void setTabIndex(int index) {
|
||||
this.tabIndex = index;
|
||||
|
||||
updateTabIndex();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -103,12 +120,10 @@ public class CubaSourceCodeEditorWidget extends AceEditorWidget {
|
||||
@Override
|
||||
public void setReadOnly(boolean readOnly) {
|
||||
this.readOnly = readOnly;
|
||||
|
||||
super.setReadOnly(!this.enabled || readOnly);
|
||||
if (readOnly) {
|
||||
getTextAreaElement().setTabIndex(-1);
|
||||
} else {
|
||||
getTextAreaElement().removeAttribute("tabindex");
|
||||
}
|
||||
|
||||
updateTabIndex();
|
||||
}
|
||||
|
||||
public void setHandleTabKey(boolean handleTabKey) {
|
||||
|
@ -45,7 +45,7 @@ public class CubaMaskedFieldWidget extends VTextField {
|
||||
|
||||
protected List<Mask> maskTest;
|
||||
|
||||
protected Map<Character, Mask> maskMap = new HashMap<Character, Mask>();
|
||||
protected Map<Character, Mask> maskMap = new HashMap<>();
|
||||
|
||||
protected boolean maskedMode = false;
|
||||
|
||||
@ -53,8 +53,6 @@ public class CubaMaskedFieldWidget extends VTextField {
|
||||
|
||||
protected MaskedKeyHandler keyHandler;
|
||||
|
||||
protected int tabIndex = 0;
|
||||
|
||||
protected boolean focused = false;
|
||||
|
||||
protected boolean shiftPressed = false;
|
||||
@ -88,15 +86,12 @@ public class CubaMaskedFieldWidget extends VTextField {
|
||||
if (mask != null && nullRepresentation != null && nullRepresentation.equals(super.getText())) {
|
||||
addStyleName("c-focus-move");
|
||||
|
||||
Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
|
||||
@Override
|
||||
public void execute() {
|
||||
if (!isReadOnly() && isEnabled() && focused) {
|
||||
setSelectionRange(getPreviousPos(0), 0);
|
||||
}
|
||||
|
||||
removeStyleName("c-focus-move");
|
||||
Scheduler.get().scheduleDeferred(() -> {
|
||||
if (!isReadOnly() && isEnabled() && focused) {
|
||||
setSelectionRange(getPreviousPos(0), 0);
|
||||
}
|
||||
|
||||
removeStyleName("c-focus-move");
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -164,31 +159,6 @@ public class CubaMaskedFieldWidget extends VTextField {
|
||||
return pos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTabIndex(int index) {
|
||||
if (!isReadOnly()) {
|
||||
super.setTabIndex(index);
|
||||
}
|
||||
|
||||
this.tabIndex = index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTabIndex() {
|
||||
return tabIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReadOnly(boolean readOnly) {
|
||||
super.setReadOnly(readOnly);
|
||||
|
||||
if (readOnly) {
|
||||
super.setTabIndex(-1);
|
||||
} else {
|
||||
super.setTabIndex(tabIndex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setText(String value) {
|
||||
valueBuilder = maskValue(value);
|
||||
@ -265,7 +235,7 @@ public class CubaMaskedFieldWidget extends VTextField {
|
||||
|
||||
this.mask = mask;
|
||||
valueBuilder = new StringBuilder();
|
||||
maskTest = new ArrayList<Mask>();
|
||||
maskTest = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < mask.length(); i++) {
|
||||
char c = mask.charAt(i);
|
||||
@ -282,7 +252,6 @@ public class CubaMaskedFieldWidget extends VTextField {
|
||||
}
|
||||
nullRepresentation = valueBuilder.toString();
|
||||
setText(valueBuilder.toString());
|
||||
// updateCursor(0); // KK: commented out because leads to grab focus
|
||||
}
|
||||
|
||||
protected boolean validateText(String text) {
|
||||
|
@ -25,7 +25,7 @@ import com.vaadin.client.ui.ShortcutActionHandler;
|
||||
import com.vaadin.client.ui.textfield.TextFieldConnector;
|
||||
import com.vaadin.shared.ui.Connect;
|
||||
|
||||
@Connect(value = CubaTextField.class, loadStyle = Connect.LoadStyle.EAGER)
|
||||
@Connect(CubaTextField.class)
|
||||
public class CubaTextFieldConnector extends TextFieldConnector {
|
||||
|
||||
@Override
|
||||
|
@ -19,13 +19,14 @@ package com.haulmont.cuba.web.gui.components;
|
||||
import com.haulmont.cuba.core.global.AppBeans;
|
||||
import com.haulmont.cuba.core.global.Messages;
|
||||
import com.haulmont.cuba.gui.components.ColorPicker;
|
||||
import com.haulmont.cuba.web.toolkit.ui.CubaColorPicker;
|
||||
import com.haulmont.cuba.web.toolkit.ui.CubaColorPickerWrapper;
|
||||
import com.haulmont.cuba.web.toolkit.ui.converters.ColorStringConverter;
|
||||
|
||||
public class WebColorPicker extends WebAbstractField<CubaColorPicker> implements ColorPicker {
|
||||
public class WebColorPicker extends WebAbstractField<CubaColorPickerWrapper> implements ColorPicker {
|
||||
|
||||
public WebColorPicker() {
|
||||
component = new CubaColorPicker();
|
||||
component = new CubaColorPickerWrapper();
|
||||
//noinspection unchecked
|
||||
component.setConverter(new ColorStringConverter());
|
||||
attachListener(component);
|
||||
setCaptions();
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2008-2016 Haulmont.
|
||||
* Copyright (c) 2008-2017 Haulmont.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -16,404 +16,201 @@
|
||||
|
||||
package com.haulmont.cuba.web.toolkit.ui;
|
||||
|
||||
import com.haulmont.cuba.web.toolkit.ui.client.colorpicker.CubaColorPickerState;
|
||||
import com.vaadin.shared.ui.colorpicker.Color;
|
||||
import com.vaadin.ui.ColorPicker;
|
||||
import com.vaadin.ui.Component;
|
||||
import com.vaadin.ui.CustomField;
|
||||
import org.apache.commons.lang.ObjectUtils;
|
||||
|
||||
public class CubaColorPicker extends CustomField {
|
||||
public class CubaColorPicker extends ColorPicker implements Component.Focusable {
|
||||
|
||||
protected ColorPicker field;
|
||||
protected String confirmButtonCaption;
|
||||
protected String cancelButtonCaption;
|
||||
protected String swatchesTabCaption;
|
||||
|
||||
public CubaColorPicker() {
|
||||
initColorPicker();
|
||||
setPrimaryStyleName("c-color-picker");
|
||||
}
|
||||
protected String lookupAllCaption;
|
||||
protected String lookupRedCaption;
|
||||
protected String lookupGreenCaption;
|
||||
protected String lookupBlueCaption;
|
||||
|
||||
protected void initColorPicker() {
|
||||
field = new ColorPicker();
|
||||
field.addColorChangeListener(e ->
|
||||
setValue(e.getColor())
|
||||
);
|
||||
field.setCaption(null);
|
||||
protected String redSliderCaption;
|
||||
protected String greenSliderCaption;
|
||||
protected String blueSliderCaption;
|
||||
protected String hueSliderCaption;
|
||||
protected String saturationSliderCaption;
|
||||
protected String valueSliderCaption;
|
||||
|
||||
@Override
|
||||
protected void createPopupWindow() {
|
||||
window = new CubaColorPickerPopup(color);
|
||||
((CubaColorPickerPopup) window).setConfirmButtonCaption(confirmButtonCaption);
|
||||
((CubaColorPickerPopup) window).setCancelButtonCaption(cancelButtonCaption);
|
||||
((CubaColorPickerPopup) window).setSwatchesTabCaption(swatchesTabCaption);
|
||||
((CubaColorPickerPopup) window).setLookupAllCaption(lookupAllCaption);
|
||||
((CubaColorPickerPopup) window).setLookupRedCaption(lookupRedCaption);
|
||||
((CubaColorPickerPopup) window).setLookupGreenCaption(lookupGreenCaption);
|
||||
((CubaColorPickerPopup) window).setLookupBlueCaption(lookupBlueCaption);
|
||||
window.setRedSliderCaption(redSliderCaption);
|
||||
window.setGreenSliderCaption(greenSliderCaption);
|
||||
window.setBlueSliderCaption(blueSliderCaption);
|
||||
window.setHueSliderCaption(hueSliderCaption);
|
||||
window.setSaturationSliderCaption(saturationSliderCaption);
|
||||
window.setValueSliderCaption(valueSliderCaption);
|
||||
window.setModal(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReadOnly(boolean readOnly) {
|
||||
super.setReadOnly(readOnly);
|
||||
if (field != null) {
|
||||
field.setReadOnly(readOnly);
|
||||
protected void showPopup(boolean open) {
|
||||
super.showPopup(open);
|
||||
|
||||
if (window != null) {
|
||||
window.center();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setInternalValue(Object newValue) {
|
||||
if (!ObjectUtils.equals(field.getColor(), newValue)) {
|
||||
field.setColor((Color) newValue);
|
||||
public void setColor(Color color) {
|
||||
if (color == null) {
|
||||
color = new Color(0,0,0);
|
||||
}
|
||||
|
||||
super.setInternalValue(newValue);
|
||||
super.setColor(color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWidth(float width, Unit unit) {
|
||||
super.setWidth(width, unit);
|
||||
|
||||
if (field != null) {
|
||||
if (width < 0) {
|
||||
field.setWidthUndefined();
|
||||
} else {
|
||||
field.setWidth("100%");
|
||||
}
|
||||
}
|
||||
public void setWindowCaption(String windowCaption) {
|
||||
this.popupCaption = windowCaption;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHeight(float height, Unit unit) {
|
||||
super.setHeight(height, unit);
|
||||
|
||||
if (field != null) {
|
||||
if (height < 0) {
|
||||
field.setHeightUndefined();
|
||||
} else {
|
||||
field.setHeight("100%");
|
||||
}
|
||||
}
|
||||
public String getWindowCaption() {
|
||||
return this.popupCaption;
|
||||
}
|
||||
|
||||
public class ColorPicker extends com.vaadin.ui.ColorPicker {
|
||||
protected String confirmButtonCaption;
|
||||
protected String cancelButtonCaption;
|
||||
protected String swatchesTabCaption;
|
||||
|
||||
protected String lookupAllCaption;
|
||||
protected String lookupRedCaption;
|
||||
protected String lookupGreenCaption;
|
||||
protected String lookupBlueCaption;
|
||||
|
||||
protected String redSliderCaption;
|
||||
protected String greenSliderCaption;
|
||||
protected String blueSliderCaption;
|
||||
protected String hueSliderCaption;
|
||||
protected String saturationSliderCaption;
|
||||
protected String valueSliderCaption;
|
||||
|
||||
@Override
|
||||
protected void createPopupWindow() {
|
||||
window = new CubaColorPickerPopup(color);
|
||||
((CubaColorPickerPopup) window).setConfirmButtonCaption(confirmButtonCaption);
|
||||
((CubaColorPickerPopup) window).setCancelButtonCaption(cancelButtonCaption);
|
||||
((CubaColorPickerPopup) window).setSwatchesTabCaption(swatchesTabCaption);
|
||||
((CubaColorPickerPopup) window).setLookupAllCaption(lookupAllCaption);
|
||||
((CubaColorPickerPopup) window).setLookupRedCaption(lookupRedCaption);
|
||||
((CubaColorPickerPopup) window).setLookupGreenCaption(lookupGreenCaption);
|
||||
((CubaColorPickerPopup) window).setLookupBlueCaption(lookupBlueCaption);
|
||||
window.setRedSliderCaption(redSliderCaption);
|
||||
window.setGreenSliderCaption(greenSliderCaption);
|
||||
window.setBlueSliderCaption(blueSliderCaption);
|
||||
window.setHueSliderCaption(hueSliderCaption);
|
||||
window.setSaturationSliderCaption(saturationSliderCaption);
|
||||
window.setValueSliderCaption(valueSliderCaption);
|
||||
window.setModal(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void showPopup(boolean open) {
|
||||
super.showPopup(open);
|
||||
|
||||
if (window != null) {
|
||||
window.center();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColor(Color color) {
|
||||
if (color == null) {
|
||||
color = new Color(0,0,0);
|
||||
}
|
||||
super.setColor(color);
|
||||
}
|
||||
|
||||
public void setWindowCaption(String windowCaption) {
|
||||
this.popupCaption = windowCaption;
|
||||
}
|
||||
|
||||
public String getWindowCaption() {
|
||||
return this.popupCaption;
|
||||
}
|
||||
|
||||
public void setConfirmButtonCaption(String confirmButtonCaption) {
|
||||
this.confirmButtonCaption = confirmButtonCaption;
|
||||
}
|
||||
|
||||
public String getConfirmButtonCaption() {
|
||||
return this.confirmButtonCaption;
|
||||
}
|
||||
|
||||
public void setCancelButtonCaption(String cancelButtonCaption) {
|
||||
this.cancelButtonCaption = cancelButtonCaption;
|
||||
}
|
||||
|
||||
public String getCancelButtonCaption() {
|
||||
return this.cancelButtonCaption;
|
||||
}
|
||||
|
||||
public void setSwatchesTabCaption(String swatchesTabCaption) {
|
||||
this.swatchesTabCaption = swatchesTabCaption;
|
||||
}
|
||||
|
||||
public String getSwatchesTabCaption() {
|
||||
return this.swatchesTabCaption;
|
||||
}
|
||||
|
||||
public void setLookupAllCaption(String lookupAllCaption) {
|
||||
this.lookupAllCaption = lookupAllCaption;
|
||||
}
|
||||
|
||||
public String getLookupAllCaption() {
|
||||
return this.lookupAllCaption;
|
||||
}
|
||||
|
||||
public void setLookupRedCaption(String lookupRedCaption) {
|
||||
this.lookupRedCaption = lookupRedCaption;
|
||||
}
|
||||
|
||||
public String getLookupRedCaption() {
|
||||
return this.lookupRedCaption;
|
||||
}
|
||||
|
||||
public void setLookupGreenCaption(String lookupGreenCaption) {
|
||||
this.lookupGreenCaption = lookupGreenCaption;
|
||||
}
|
||||
|
||||
public String getLookupGreenCaption() {
|
||||
return this.lookupGreenCaption;
|
||||
}
|
||||
|
||||
public void setLookupBlueCaption(String lookupBlueCaption) {
|
||||
this.lookupBlueCaption = lookupBlueCaption;
|
||||
}
|
||||
|
||||
public String getLookupBlueCaption() {
|
||||
return this.lookupBlueCaption;
|
||||
}
|
||||
|
||||
public String getBlueSliderCaption() {
|
||||
return blueSliderCaption;
|
||||
}
|
||||
|
||||
public void setBlueSliderCaption(String blueSliderCaption) {
|
||||
this.blueSliderCaption = blueSliderCaption;
|
||||
}
|
||||
|
||||
public String getGreenSliderCaption() {
|
||||
return greenSliderCaption;
|
||||
}
|
||||
|
||||
public void setGreenSliderCaption(String greenSliderCaption) {
|
||||
this.greenSliderCaption = greenSliderCaption;
|
||||
}
|
||||
|
||||
public String getRedSliderCaption() {
|
||||
return redSliderCaption;
|
||||
}
|
||||
|
||||
public void setRedSliderCaption(String redSliderCaption) {
|
||||
this.redSliderCaption = redSliderCaption;
|
||||
}
|
||||
|
||||
public String getHueSliderCaption() {
|
||||
return hueSliderCaption;
|
||||
}
|
||||
|
||||
public void setHueSliderCaption(String hueSliderCaption) {
|
||||
this.hueSliderCaption = hueSliderCaption;
|
||||
}
|
||||
|
||||
public String getSaturationSliderCaption() {
|
||||
return saturationSliderCaption;
|
||||
}
|
||||
|
||||
public void setSaturationSliderCaption(String saturationSliderCaption) {
|
||||
this.saturationSliderCaption = saturationSliderCaption;
|
||||
}
|
||||
|
||||
public String getValueSliderCaption() {
|
||||
return valueSliderCaption;
|
||||
}
|
||||
|
||||
public void setValueSliderCaption(String valueSliderCaption) {
|
||||
this.valueSliderCaption = valueSliderCaption;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Component initContent() {
|
||||
return field;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getType() {
|
||||
return Color.class;
|
||||
}
|
||||
|
||||
public void setDefaultCaptionEnabled(boolean value) {
|
||||
field.setDefaultCaptionEnabled(value);
|
||||
}
|
||||
|
||||
public boolean isDefaultCaptionEnabled() {
|
||||
return field.isDefaultCaptionEnabled();
|
||||
}
|
||||
|
||||
public void setButtonCaption(String value) {
|
||||
field.setCaption(value);
|
||||
}
|
||||
|
||||
public String getButtonCaption() {
|
||||
return field.getCaption();
|
||||
}
|
||||
|
||||
public void setHistoryVisible(boolean value) {
|
||||
field.setHistoryVisibility(value);
|
||||
}
|
||||
|
||||
public boolean isHistoryVisible() {
|
||||
return field.getHistoryVisibility();
|
||||
}
|
||||
|
||||
public void setSwatchesVisible(boolean value) {
|
||||
field.setSwatchesVisibility(value);
|
||||
}
|
||||
|
||||
public boolean isSwatchesVisible() {
|
||||
return field.getSwatchesVisibility();
|
||||
}
|
||||
|
||||
public void setRGBVisible(boolean value) {
|
||||
field.setRGBVisibility(value);
|
||||
}
|
||||
|
||||
public boolean isRGBVisible() {
|
||||
return field.getRGBVisibility();
|
||||
}
|
||||
|
||||
public void setHSVVisible(boolean value) {
|
||||
field.setHSVVisibility(value);
|
||||
}
|
||||
|
||||
public boolean isHSVVisible() {
|
||||
return field.getHSVVisibility();
|
||||
}
|
||||
|
||||
public void setPopupCaption(String popupCaption) {
|
||||
field.setWindowCaption(popupCaption);
|
||||
}
|
||||
|
||||
public String getPopupCaption() {
|
||||
return field.getWindowCaption();
|
||||
}
|
||||
|
||||
public void setConfirmButtonCaption(String caption) {
|
||||
field.setConfirmButtonCaption(caption);
|
||||
public void setConfirmButtonCaption(String confirmButtonCaption) {
|
||||
this.confirmButtonCaption = confirmButtonCaption;
|
||||
}
|
||||
|
||||
public String getConfirmButtonCaption() {
|
||||
return field.getConfirmButtonCaption();
|
||||
return this.confirmButtonCaption;
|
||||
}
|
||||
|
||||
public void setCancelButtonCaption(String caption) {
|
||||
field.setCancelButtonCaption(caption);
|
||||
public void setCancelButtonCaption(String cancelButtonCaption) {
|
||||
this.cancelButtonCaption = cancelButtonCaption;
|
||||
}
|
||||
|
||||
public String getCancelButtonCaption() {
|
||||
return field.getCancelButtonCaption();
|
||||
return this.cancelButtonCaption;
|
||||
}
|
||||
|
||||
public void setSwatchesTabCaption(String caption) {
|
||||
field.setSwatchesTabCaption(caption);
|
||||
public void setSwatchesTabCaption(String swatchesTabCaption) {
|
||||
this.swatchesTabCaption = swatchesTabCaption;
|
||||
}
|
||||
|
||||
public String getSwatchesTabCaption() {
|
||||
return field.getSwatchesTabCaption();
|
||||
return this.swatchesTabCaption;
|
||||
}
|
||||
|
||||
public void setLookupAllCaption(String lookupAllCaption) {
|
||||
field.setLookupAllCaption(lookupAllCaption);
|
||||
this.lookupAllCaption = lookupAllCaption;
|
||||
}
|
||||
|
||||
public String getLookupAllCaption() {
|
||||
return field.getLookupAllCaption();
|
||||
return this.lookupAllCaption;
|
||||
}
|
||||
|
||||
public void setLookupRedCaption(String lookupRedCaption) {
|
||||
field.setLookupRedCaption(lookupRedCaption);
|
||||
this.lookupRedCaption = lookupRedCaption;
|
||||
}
|
||||
|
||||
public String getLookupRedCaption() {
|
||||
return field.getLookupRedCaption();
|
||||
return this.lookupRedCaption;
|
||||
}
|
||||
|
||||
public void setLookupGreenCaption(String lookupGreenCaption) {
|
||||
field.setLookupGreenCaption(lookupGreenCaption);
|
||||
this.lookupGreenCaption = lookupGreenCaption;
|
||||
}
|
||||
|
||||
public String getLookupGreenCaption() {
|
||||
return field.getLookupGreenCaption();
|
||||
return this.lookupGreenCaption;
|
||||
}
|
||||
|
||||
public void setLookupBlueCaption(String lookupBlueCaption) {
|
||||
field.setLookupBlueCaption(lookupBlueCaption);
|
||||
this.lookupBlueCaption = lookupBlueCaption;
|
||||
}
|
||||
|
||||
public String getLookupBlueCaption() {
|
||||
return field.getLookupBlueCaption();
|
||||
}
|
||||
|
||||
public void setRedSliderCaption(String redSliderCaption) {
|
||||
field.setRedSliderCaption(redSliderCaption);
|
||||
}
|
||||
|
||||
public String getRedSliderCaption() {
|
||||
return field.getRedSliderCaption();
|
||||
}
|
||||
|
||||
public void setGreenSliderCaption(String greenSliderCaption) {
|
||||
field.setGreenSliderCaption(greenSliderCaption);
|
||||
}
|
||||
|
||||
public String getGreenSliderCaption() {
|
||||
return field.getGreenSliderCaption();
|
||||
}
|
||||
|
||||
public void setBlueSliderCaption(String blueSliderCaption) {
|
||||
field.setBlueSliderCaption(blueSliderCaption);
|
||||
return this.lookupBlueCaption;
|
||||
}
|
||||
|
||||
public String getBlueSliderCaption() {
|
||||
return field.getBlueSliderCaption();
|
||||
return blueSliderCaption;
|
||||
}
|
||||
|
||||
public void setHueSliderCaption(String hueSliderCaption) {
|
||||
field.setHueSliderCaption(hueSliderCaption);
|
||||
public void setBlueSliderCaption(String blueSliderCaption) {
|
||||
this.blueSliderCaption = blueSliderCaption;
|
||||
}
|
||||
|
||||
public String getGreenSliderCaption() {
|
||||
return greenSliderCaption;
|
||||
}
|
||||
|
||||
public void setGreenSliderCaption(String greenSliderCaption) {
|
||||
this.greenSliderCaption = greenSliderCaption;
|
||||
}
|
||||
|
||||
public String getRedSliderCaption() {
|
||||
return redSliderCaption;
|
||||
}
|
||||
|
||||
public void setRedSliderCaption(String redSliderCaption) {
|
||||
this.redSliderCaption = redSliderCaption;
|
||||
}
|
||||
|
||||
public String getHueSliderCaption() {
|
||||
return field.getHueSliderCaption();
|
||||
return hueSliderCaption;
|
||||
}
|
||||
|
||||
public void setSaturationSliderCaption(String saturationSliderCaption) {
|
||||
field.setSaturationSliderCaption(saturationSliderCaption);
|
||||
public void setHueSliderCaption(String hueSliderCaption) {
|
||||
this.hueSliderCaption = hueSliderCaption;
|
||||
}
|
||||
|
||||
public String getSaturationSliderCaption() {
|
||||
return field.getSaturationSliderCaption();
|
||||
return saturationSliderCaption;
|
||||
}
|
||||
|
||||
public void setValueSliderCaption(String valueSliderCaption) {
|
||||
field.setValueSliderCaption(valueSliderCaption);
|
||||
public void setSaturationSliderCaption(String saturationSliderCaption) {
|
||||
this.saturationSliderCaption = saturationSliderCaption;
|
||||
}
|
||||
|
||||
public String getValueSliderCaption() {
|
||||
return field.getValueSliderCaption();
|
||||
return valueSliderCaption;
|
||||
}
|
||||
|
||||
public void setValueSliderCaption(String valueSliderCaption) {
|
||||
this.valueSliderCaption = valueSliderCaption;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void focus() {
|
||||
super.focus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTabIndex() {
|
||||
return getState(false).tabIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTabIndex(int tabIndex) {
|
||||
if (getState(false).tabIndex != tabIndex) {
|
||||
getState().tabIndex = tabIndex;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CubaColorPickerState getState() {
|
||||
return (CubaColorPickerState) super.getState();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CubaColorPickerState getState(boolean markAsDirty) {
|
||||
return (CubaColorPickerState) super.getState(markAsDirty);
|
||||
}
|
||||
}
|
@ -0,0 +1,254 @@
|
||||
/*
|
||||
* Copyright (c) 2008-2016 Haulmont.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.haulmont.cuba.web.toolkit.ui;
|
||||
|
||||
import com.vaadin.shared.ui.colorpicker.Color;
|
||||
import com.vaadin.ui.Component;
|
||||
import com.vaadin.ui.CustomField;
|
||||
import org.apache.commons.lang.ObjectUtils;
|
||||
|
||||
public class CubaColorPickerWrapper extends CustomField {
|
||||
|
||||
protected CubaColorPicker field;
|
||||
|
||||
public CubaColorPickerWrapper() {
|
||||
initColorPicker();
|
||||
setFocusDelegate(field);
|
||||
setPrimaryStyleName("c-color-picker");
|
||||
}
|
||||
|
||||
protected void initColorPicker() {
|
||||
field = new CubaColorPicker();
|
||||
field.addColorChangeListener(e ->
|
||||
setValue(e.getColor())
|
||||
);
|
||||
field.setCaption(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReadOnly(boolean readOnly) {
|
||||
super.setReadOnly(readOnly);
|
||||
if (field != null) {
|
||||
field.setReadOnly(readOnly);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setInternalValue(Object newValue) {
|
||||
if (!ObjectUtils.equals(field.getColor(), newValue)) {
|
||||
field.setColor((Color) newValue);
|
||||
}
|
||||
|
||||
super.setInternalValue(newValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWidth(float width, Unit unit) {
|
||||
super.setWidth(width, unit);
|
||||
|
||||
if (field != null) {
|
||||
if (width < 0) {
|
||||
field.setWidthUndefined();
|
||||
} else {
|
||||
field.setWidth("100%");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHeight(float height, Unit unit) {
|
||||
super.setHeight(height, unit);
|
||||
|
||||
if (field != null) {
|
||||
if (height < 0) {
|
||||
field.setHeightUndefined();
|
||||
} else {
|
||||
field.setHeight("100%");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Component initContent() {
|
||||
return field;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getType() {
|
||||
return Color.class;
|
||||
}
|
||||
|
||||
public void setDefaultCaptionEnabled(boolean value) {
|
||||
field.setDefaultCaptionEnabled(value);
|
||||
}
|
||||
|
||||
public boolean isDefaultCaptionEnabled() {
|
||||
return field.isDefaultCaptionEnabled();
|
||||
}
|
||||
|
||||
public void setButtonCaption(String value) {
|
||||
field.setCaption(value);
|
||||
}
|
||||
|
||||
public String getButtonCaption() {
|
||||
return field.getCaption();
|
||||
}
|
||||
|
||||
public void setHistoryVisible(boolean value) {
|
||||
field.setHistoryVisibility(value);
|
||||
}
|
||||
|
||||
public boolean isHistoryVisible() {
|
||||
return field.getHistoryVisibility();
|
||||
}
|
||||
|
||||
public void setSwatchesVisible(boolean value) {
|
||||
field.setSwatchesVisibility(value);
|
||||
}
|
||||
|
||||
public boolean isSwatchesVisible() {
|
||||
return field.getSwatchesVisibility();
|
||||
}
|
||||
|
||||
public void setRGBVisible(boolean value) {
|
||||
field.setRGBVisibility(value);
|
||||
}
|
||||
|
||||
public boolean isRGBVisible() {
|
||||
return field.getRGBVisibility();
|
||||
}
|
||||
|
||||
public void setHSVVisible(boolean value) {
|
||||
field.setHSVVisibility(value);
|
||||
}
|
||||
|
||||
public boolean isHSVVisible() {
|
||||
return field.getHSVVisibility();
|
||||
}
|
||||
|
||||
public void setPopupCaption(String popupCaption) {
|
||||
field.setWindowCaption(popupCaption);
|
||||
}
|
||||
|
||||
public String getPopupCaption() {
|
||||
return field.getWindowCaption();
|
||||
}
|
||||
|
||||
public void setConfirmButtonCaption(String caption) {
|
||||
field.setConfirmButtonCaption(caption);
|
||||
}
|
||||
|
||||
public String getConfirmButtonCaption() {
|
||||
return field.getConfirmButtonCaption();
|
||||
}
|
||||
|
||||
public void setCancelButtonCaption(String caption) {
|
||||
field.setCancelButtonCaption(caption);
|
||||
}
|
||||
|
||||
public String getCancelButtonCaption() {
|
||||
return field.getCancelButtonCaption();
|
||||
}
|
||||
|
||||
public void setSwatchesTabCaption(String caption) {
|
||||
field.setSwatchesTabCaption(caption);
|
||||
}
|
||||
|
||||
public String getSwatchesTabCaption() {
|
||||
return field.getSwatchesTabCaption();
|
||||
}
|
||||
|
||||
public void setLookupAllCaption(String lookupAllCaption) {
|
||||
field.setLookupAllCaption(lookupAllCaption);
|
||||
}
|
||||
|
||||
public String getLookupAllCaption() {
|
||||
return field.getLookupAllCaption();
|
||||
}
|
||||
|
||||
public void setLookupRedCaption(String lookupRedCaption) {
|
||||
field.setLookupRedCaption(lookupRedCaption);
|
||||
}
|
||||
|
||||
public String getLookupRedCaption() {
|
||||
return field.getLookupRedCaption();
|
||||
}
|
||||
|
||||
public void setLookupGreenCaption(String lookupGreenCaption) {
|
||||
field.setLookupGreenCaption(lookupGreenCaption);
|
||||
}
|
||||
|
||||
public String getLookupGreenCaption() {
|
||||
return field.getLookupGreenCaption();
|
||||
}
|
||||
|
||||
public void setLookupBlueCaption(String lookupBlueCaption) {
|
||||
field.setLookupBlueCaption(lookupBlueCaption);
|
||||
}
|
||||
|
||||
public String getLookupBlueCaption() {
|
||||
return field.getLookupBlueCaption();
|
||||
}
|
||||
|
||||
public void setRedSliderCaption(String redSliderCaption) {
|
||||
field.setRedSliderCaption(redSliderCaption);
|
||||
}
|
||||
|
||||
public String getRedSliderCaption() {
|
||||
return field.getRedSliderCaption();
|
||||
}
|
||||
|
||||
public void setGreenSliderCaption(String greenSliderCaption) {
|
||||
field.setGreenSliderCaption(greenSliderCaption);
|
||||
}
|
||||
|
||||
public String getGreenSliderCaption() {
|
||||
return field.getGreenSliderCaption();
|
||||
}
|
||||
|
||||
public void setBlueSliderCaption(String blueSliderCaption) {
|
||||
field.setBlueSliderCaption(blueSliderCaption);
|
||||
}
|
||||
|
||||
public String getBlueSliderCaption() {
|
||||
return field.getBlueSliderCaption();
|
||||
}
|
||||
|
||||
public void setHueSliderCaption(String hueSliderCaption) {
|
||||
field.setHueSliderCaption(hueSliderCaption);
|
||||
}
|
||||
|
||||
public String getHueSliderCaption() {
|
||||
return field.getHueSliderCaption();
|
||||
}
|
||||
|
||||
public void setSaturationSliderCaption(String saturationSliderCaption) {
|
||||
field.setSaturationSliderCaption(saturationSliderCaption);
|
||||
}
|
||||
|
||||
public String getSaturationSliderCaption() {
|
||||
return field.getSaturationSliderCaption();
|
||||
}
|
||||
|
||||
public void setValueSliderCaption(String valueSliderCaption) {
|
||||
field.setValueSliderCaption(valueSliderCaption);
|
||||
}
|
||||
|
||||
public String getValueSliderCaption() {
|
||||
return field.getValueSliderCaption();
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (c) 2008-2017 Haulmont.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.haulmont.cuba.web.toolkit.ui.client.colorpicker;
|
||||
|
||||
import com.vaadin.shared.annotations.NoLayout;
|
||||
import com.vaadin.shared.ui.colorpicker.ColorPickerState;
|
||||
|
||||
public class CubaColorPickerState extends ColorPickerState {
|
||||
@NoLayout
|
||||
public int tabIndex = 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user