mirror of
https://gitee.com/jmix/cuba.git
synced 2024-12-05 04:38:10 +08:00
Ability to set focus on disabled text field #PL-4813 Fixed Fix versions: 5.4.0
This commit is contained in:
parent
ee75567b9b
commit
40fc3ccb49
@ -1,31 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2008-2013 Haulmont. All rights reserved.
|
||||
* Use is subject to license terms, see http://www.cuba-platform.com/license for details.
|
||||
*/
|
||||
|
||||
package com.haulmont.cuba.web.toolkit.ui.client.textfield;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
import com.haulmont.cuba.web.toolkit.ui.CubaPickerTextField;
|
||||
import com.vaadin.client.ui.textfield.TextFieldConnector;
|
||||
import com.vaadin.shared.ui.Connect;
|
||||
|
||||
/**
|
||||
* @author devyatkin
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
@Connect(value = CubaPickerTextField.class, loadStyle = Connect.LoadStyle.EAGER)
|
||||
public class CubaPickerTextFieldConnector extends TextFieldConnector {
|
||||
|
||||
@Override
|
||||
public CubaPickerTextFieldWidget getWidget() {
|
||||
return (CubaPickerTextFieldWidget) super.getWidget();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Widget createWidget() {
|
||||
return GWT.create(CubaPickerTextFieldWidget.class);
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2008-2013 Haulmont. All rights reserved.
|
||||
* Use is subject to license terms, see http://www.cuba-platform.com/license for details.
|
||||
*/
|
||||
|
||||
package com.haulmont.cuba.web.toolkit.ui.client.textfield;
|
||||
|
||||
import com.vaadin.client.ui.VTextField;
|
||||
|
||||
/**
|
||||
* @author devyatkin
|
||||
* @version $Id$
|
||||
*/
|
||||
public class CubaPickerTextFieldWidget extends VTextField {
|
||||
@Override
|
||||
public void setReadOnly(boolean readOnly) {
|
||||
getElement().setPropertyBoolean("readOnly", readOnly);
|
||||
String readOnlyStyle = "readonly";
|
||||
if (readOnly) {
|
||||
addStyleDependentName(readOnlyStyle);
|
||||
} else {
|
||||
removeStyleDependentName(readOnlyStyle);
|
||||
}
|
||||
}
|
||||
}
|
@ -10,6 +10,8 @@ import com.google.gwt.user.client.ui.Widget;
|
||||
import com.haulmont.cuba.web.toolkit.ui.CubaTextField;
|
||||
import com.vaadin.client.ApplicationConnection;
|
||||
import com.vaadin.client.UIDL;
|
||||
import com.vaadin.client.annotations.OnStateChange;
|
||||
import com.vaadin.client.communication.StateChangeEvent;
|
||||
import com.vaadin.client.ui.ShortcutActionHandler;
|
||||
import com.vaadin.client.ui.textfield.TextFieldConnector;
|
||||
import com.vaadin.shared.ui.Connect;
|
||||
@ -26,6 +28,11 @@ public class CubaTextFieldConnector extends TextFieldConnector {
|
||||
return GWT.create(CubaTextFieldWidget.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CubaTextFieldState getState() {
|
||||
return (CubaTextFieldState) super.getState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CubaTextFieldWidget getWidget() {
|
||||
return (CubaTextFieldWidget) super.getWidget();
|
||||
@ -49,4 +56,9 @@ public class CubaTextFieldConnector extends TextFieldConnector {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@OnStateChange("readOnlyFocusable")
|
||||
void updateReadOnlyFocusable() {
|
||||
getWidget().setReadOnlyFocusable(getState().readOnlyFocusable);
|
||||
}
|
||||
}
|
@ -22,6 +22,8 @@ public class CubaTextFieldWidget extends VTextField implements ShortcutActionHan
|
||||
|
||||
protected ShortcutActionHandler shortcutHandler;
|
||||
|
||||
protected boolean readOnlyFocusable = false;
|
||||
|
||||
public CubaTextFieldWidget() {
|
||||
// handle shortcuts
|
||||
DOM.sinkEvents(getElement(), Event.ONKEYDOWN);
|
||||
@ -64,4 +66,32 @@ public class CubaTextFieldWidget extends VTextField implements ShortcutActionHan
|
||||
public boolean remove(Widget w) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* If {@code readOnlyFocusable} property is set then component is focusable
|
||||
* in readOnly mode
|
||||
*/
|
||||
@Override
|
||||
public void setReadOnly(boolean readOnly) {
|
||||
if (!readOnlyFocusable) {
|
||||
super.setReadOnly(readOnly);
|
||||
} else {
|
||||
setTabIndex(0);
|
||||
getElement().setPropertyBoolean("readOnly", readOnly);
|
||||
String readOnlyStyle = "readonly";
|
||||
if (readOnly) {
|
||||
addStyleDependentName(readOnlyStyle);
|
||||
} else {
|
||||
removeStyleDependentName(readOnlyStyle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isReadOnlyFocusable() {
|
||||
return readOnlyFocusable;
|
||||
}
|
||||
|
||||
public void setReadOnlyFocusable(boolean readOnlyFocusable) {
|
||||
this.readOnlyFocusable = readOnlyFocusable;
|
||||
}
|
||||
}
|
@ -70,7 +70,8 @@ public class CubaPickerField extends com.vaadin.ui.CustomField implements Action
|
||||
}
|
||||
|
||||
protected void initTextField() {
|
||||
field = new CubaPickerTextField();
|
||||
field = new CubaTextField();
|
||||
((CubaTextField) field).setReadOnlyFocusable(true);
|
||||
|
||||
field.setImmediate(true);
|
||||
field.setReadOnly(true);
|
||||
|
@ -1,13 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2008-2013 Haulmont. All rights reserved.
|
||||
* Use is subject to license terms, see http://www.cuba-platform.com/license for details.
|
||||
*/
|
||||
|
||||
package com.haulmont.cuba.web.toolkit.ui;
|
||||
|
||||
/**
|
||||
* @author devyatkin
|
||||
* @version $Id$
|
||||
*/
|
||||
public class CubaPickerTextField extends CubaTextField {
|
||||
}
|
@ -5,6 +5,7 @@
|
||||
|
||||
package com.haulmont.cuba.web.toolkit.ui;
|
||||
|
||||
import com.haulmont.cuba.web.toolkit.ui.client.textfield.CubaTextFieldState;
|
||||
import com.vaadin.event.Action;
|
||||
import com.vaadin.event.ActionManager;
|
||||
import com.vaadin.event.ShortcutListener;
|
||||
@ -88,4 +89,26 @@ public class CubaTextField extends TextField implements Action.Container {
|
||||
public void removeActionHandler(Action.Handler actionHandler) {
|
||||
getActionManager().removeActionHandler(actionHandler);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CubaTextFieldState getState() {
|
||||
return (CubaTextFieldState) super.getState();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CubaTextFieldState getState(boolean markAsDirty) {
|
||||
return (CubaTextFieldState) super.getState(markAsDirty);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether a text field will be focusable in readOnly mode
|
||||
*/
|
||||
public void setReadOnlyFocusable(boolean readOnlyFocusable) {
|
||||
getState(true).readOnlyFocusable = readOnlyFocusable;
|
||||
}
|
||||
|
||||
public boolean isReadOnlyFocusable() {
|
||||
return getState(false).readOnlyFocusable;
|
||||
}
|
||||
|
||||
}
|
@ -5,13 +5,11 @@
|
||||
|
||||
package com.haulmont.cuba.web.toolkit.ui.client.textfield;
|
||||
|
||||
import com.vaadin.shared.ui.textfield.AbstractTextFieldState;
|
||||
|
||||
/**
|
||||
* @author artamonov
|
||||
* @version $Id$
|
||||
*/
|
||||
public class CubaMaskedTextFieldState extends AbstractTextFieldState {
|
||||
public class CubaMaskedTextFieldState extends CubaTextFieldState {
|
||||
{
|
||||
primaryStyleName = "cuba-maskedfield";
|
||||
}
|
||||
|
@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright (c) 2008-2015 Haulmont. All rights reserved.
|
||||
* Use is subject to license terms, see http://www.cuba-platform.com/license for details.
|
||||
*/
|
||||
|
||||
package com.haulmont.cuba.web.toolkit.ui.client.textfield;
|
||||
|
||||
import com.vaadin.shared.ui.textfield.AbstractTextFieldState;
|
||||
|
||||
/**
|
||||
* @author gorbunkov
|
||||
* @version $Id$
|
||||
*/
|
||||
public class CubaTextFieldState extends AbstractTextFieldState {
|
||||
|
||||
public boolean readOnlyFocusable;
|
||||
}
|
Loading…
Reference in New Issue
Block a user