IDEMPIERE-786 ZK: Remove onFocus and onBlur server side event for field editor.
This commit is contained in:
parent
b2063cc784
commit
8af496019d
|
@ -48,7 +48,7 @@ import org.adempiere.webui.editor.WImageEditor;
|
|||
import org.adempiere.webui.editor.WPaymentEditor;
|
||||
import org.adempiere.webui.editor.WebEditorFactory;
|
||||
import org.adempiere.webui.event.ContextMenuListener;
|
||||
import org.adempiere.webui.session.SessionManager;
|
||||
import org.adempiere.webui.panel.HelpController;
|
||||
import org.adempiere.webui.util.GridTabDataBinder;
|
||||
import org.adempiere.webui.util.TreeUtils;
|
||||
import org.adempiere.webui.window.FDialog;
|
||||
|
@ -527,8 +527,11 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer
|
|||
|
||||
if (editor != null) // Not heading
|
||||
{
|
||||
editor.getComponent().addEventListener(Events.ON_FOCUS, this);
|
||||
editor.getComponent().addEventListener(Events.ON_BLUR, this);
|
||||
editor.getComponent().setWidgetOverride("fieldHeader", HelpController.escapeJavascriptContent(field.getHeader()));
|
||||
editor.getComponent().setWidgetOverride("fieldDescription", HelpController.escapeJavascriptContent(field.getDescription()));
|
||||
editor.getComponent().setWidgetOverride("fieldHelp", HelpController.escapeJavascriptContent(field.getHelp()));
|
||||
editor.getComponent().setWidgetListener("onFocus", "zWatch.fire('onFieldTooltip', this, null, this.fieldHeader, this.fieldDescription, this.fieldHelp);");
|
||||
editor.getComponent().setWidgetListener("onBlur", "zWatch.fire('onFieldTooltip', this);");
|
||||
|
||||
editor.setGridTab(this.getGridTab());
|
||||
field.addPropertyChangeListener(editor);
|
||||
|
@ -968,7 +971,7 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer
|
|||
public void focusToFirstEditor() {
|
||||
WEditor toFocus = null;
|
||||
for (WEditor editor : editors) {
|
||||
if (editor.isHasFocus() && editor.isVisible() && editor.getComponent().getParent() != null) {
|
||||
if (editor.isVisible() && editor.getComponent().getParent() != null) {
|
||||
toFocus = editor;
|
||||
break;
|
||||
}
|
||||
|
@ -1047,26 +1050,6 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer
|
|||
Env.getCtx().setProperty("P"+windowId+"|"+adTabId+"|DetailPane.IsOpen", value ? "Y" : "N");
|
||||
}
|
||||
}
|
||||
else if (event.getName().equals(Events.ON_FOCUS)) {
|
||||
for (WEditor editor : editors)
|
||||
{
|
||||
if (editor.isComponentOfEditor(event.getTarget()))
|
||||
{
|
||||
SessionManager.getAppDesktop().updateHelpTooltip(editor.getGridField());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (event.getName().equals(Events.ON_BLUR)) {
|
||||
for (WEditor editor : editors)
|
||||
{
|
||||
if (editor.isComponentOfEditor(event.getTarget()))
|
||||
{
|
||||
SessionManager.getAppDesktop().updateHelpTooltip(null);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void onSouthEvent(SouthEvent event) {
|
||||
|
@ -1351,14 +1334,10 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer
|
|||
*/
|
||||
public void setFocusToField(String columnName) {
|
||||
if (formContainer.isVisible()) {
|
||||
boolean found = false;
|
||||
for (WEditor editor : editors) {
|
||||
if (found)
|
||||
editor.setHasFocus(false);
|
||||
else if (columnName.equals(editor.getColumnName())) {
|
||||
editor.setHasFocus(true);
|
||||
if (columnName.equals(editor.getColumnName())) {
|
||||
Clients.response(new AuFocus(editor.getComponent()));
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.adempiere.webui.editor.WebEditorFactory;
|
|||
import org.adempiere.webui.event.ActionEvent;
|
||||
import org.adempiere.webui.event.ActionListener;
|
||||
import org.adempiere.webui.event.ContextMenuListener;
|
||||
import org.adempiere.webui.panel.HelpController;
|
||||
import org.adempiere.webui.session.SessionManager;
|
||||
import org.adempiere.webui.util.GridTabDataBinder;
|
||||
import org.compiere.model.GridField;
|
||||
|
@ -376,6 +377,12 @@ public class GridTabRowRenderer implements RowRenderer<Object[]>, RowRendererExt
|
|||
WEditor readOnlyEditor = WebEditorFactory.getEditor(gridPanelFields[i], true);
|
||||
readOnlyEditor.setReadWrite(false);
|
||||
readOnlyEditors.put(gridPanelFields[i], readOnlyEditor);
|
||||
|
||||
editor.getComponent().setWidgetOverride("fieldHeader", HelpController.escapeJavascriptContent(gridPanelFields[i].getHeader()));
|
||||
editor.getComponent().setWidgetOverride("fieldDescription", HelpController.escapeJavascriptContent(gridPanelFields[i].getDescription()));
|
||||
editor.getComponent().setWidgetOverride("fieldHelp", HelpController.escapeJavascriptContent(gridPanelFields[i].getHelp()));
|
||||
editor.getComponent().setWidgetListener("onFocus", "zWatch.fire('onFieldTooltip', this, null, this.fieldHeader, this.fieldDescription, this.fieldHelp);");
|
||||
editor.getComponent().setWidgetListener("onBlur", "zWatch.fire('onFieldTooltip', this);");
|
||||
}
|
||||
|
||||
if (!gridPanelFields[i].isDisplayedGrid() || gridPanelFields[i].isToolbarButton()) {
|
||||
|
@ -578,7 +585,7 @@ public class GridTabRowRenderer implements RowRenderer<Object[]>, RowRendererExt
|
|||
WEditor toFocus = null;
|
||||
WEditor firstEditor = null;
|
||||
for (WEditor editor : getEditors()) {
|
||||
if (editor.isHasFocus() && editor.isVisible() && editor.getComponent().getParent() != null) {
|
||||
if (editor.isVisible() && editor.getComponent().getParent() != null) {
|
||||
toFocus = editor;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -796,12 +796,8 @@ public class GridView extends Vbox implements EventListener<Event>, IdSpace, IFi
|
|||
* @param columnName
|
||||
*/
|
||||
public void setFocusToField(String columnName) {
|
||||
boolean found = false;
|
||||
for (WEditor editor : renderer.getEditors()) {
|
||||
if (found)
|
||||
editor.setHasFocus(false);
|
||||
else if (columnName.equals(editor.getColumnName())) {
|
||||
editor.setHasFocus(true);
|
||||
if (columnName.equals(editor.getColumnName())) {
|
||||
Component c = editor.getComponent();
|
||||
if (c instanceof EditorBox) {
|
||||
c = ((EditorBox)c).getTextbox();
|
||||
|
@ -809,7 +805,7 @@ public class GridView extends Vbox implements EventListener<Event>, IdSpace, IFi
|
|||
c = ((NumberBox)c).getDecimalbox();
|
||||
}
|
||||
Clients.response(new AuFocus(c));
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -331,7 +331,6 @@ public class WCreateFromShipmentUI extends CreateFromShipment implements EventLi
|
|||
}
|
||||
}
|
||||
upcField.setValue("");
|
||||
upcField.setHasFocus(true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -88,8 +88,6 @@ public abstract class WEditor implements EventListener<Event>, PropertyChangeLis
|
|||
|
||||
private String columnName;
|
||||
|
||||
protected boolean hasFocus;
|
||||
|
||||
protected WEditorPopupMenu popupMenu;
|
||||
|
||||
private boolean tableEditor;
|
||||
|
@ -230,18 +228,8 @@ public abstract class WEditor implements EventListener<Event>, PropertyChangeLis
|
|||
{
|
||||
component.addEventListener(event, this);
|
||||
}
|
||||
component.addEventListener(Events.ON_FOCUS, new EventListener<Event>() {
|
||||
public void onEvent(Event event) throws Exception {
|
||||
hasFocus = true;
|
||||
}
|
||||
|
||||
});
|
||||
component.addEventListener(Events.ON_BLUR, new EventListener<Event>() {
|
||||
public void onEvent(Event event) throws Exception {
|
||||
hasFocus = false;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
component.setAttribute("idempiere.editor", this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -545,14 +533,6 @@ public abstract class WEditor implements EventListener<Event>, PropertyChangeLis
|
|||
}
|
||||
}
|
||||
|
||||
public boolean isHasFocus() {
|
||||
return hasFocus;
|
||||
}
|
||||
|
||||
public void setHasFocus(boolean b) {
|
||||
hasFocus = b;
|
||||
}
|
||||
|
||||
public void updateLabelStyle() {
|
||||
if (getLabel() != null) {
|
||||
String style = (isZoomable() ? STYLE_ZOOMABLE_LABEL : "") + (isMandatoryStyle() ? STYLE_EMPTY_MANDATORY_LABEL : STYLE_NORMAL_LABEL);
|
||||
|
|
|
@ -40,7 +40,9 @@ import org.compiere.util.Env;
|
|||
import org.compiere.util.Msg;
|
||||
import org.compiere.wf.MWFNode;
|
||||
import org.compiere.wf.MWorkflow;
|
||||
import org.zkoss.zk.au.out.AuScript;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.util.Clients;
|
||||
import org.zkoss.zul.Anchorchildren;
|
||||
import org.zkoss.zul.Anchorlayout;
|
||||
import org.zkoss.zul.Html;
|
||||
|
@ -95,6 +97,15 @@ public class HelpController
|
|||
Panelchildren content = new Panelchildren();
|
||||
pnlToolTip.appendChild(content);
|
||||
content.appendChild(htmlToolTip = new Html());
|
||||
htmlToolTip.setWidgetOverride("defaultMessage", "'"+Msg.getMsg(Env.getCtx(), "PlaceCursorIntoField")+"'");
|
||||
htmlToolTip.setWidgetOverride("onFieldTooltip", "function(origin,opts,header,description,help)" +
|
||||
"{var s='<html><body><div class=\"help-content\">';" +
|
||||
"if (typeof header == 'undefined') {s=s+'<i>'+this.defaultMessage+'</i>';} " +
|
||||
"else {s=s+'<b>'+header+'</b>';" +
|
||||
"if (typeof description=='string' && description.length > 0) {s=s+'<br><br><i>'+description+'</i>';}" +
|
||||
"if (typeof help=='string' && help.length > 0) {s=s+'<br><br>'+help;}}" +
|
||||
"s=s+'</div></body></html>';this.setContent(s);}");
|
||||
Clients.response(new AuScript(htmlToolTip, "var w=zk.Widget.$('#"+htmlToolTip.getUuid()+"');zWatch.listen({onFieldTooltip: w});"));
|
||||
|
||||
pnlContextHelp = new Panel();
|
||||
pnlContextHelp.setSclass("dashboard-widget");
|
||||
|
@ -106,7 +117,7 @@ public class HelpController
|
|||
dashboardColumnLayout.appendChild(pnlContextHelp);
|
||||
content = new Panelchildren();
|
||||
pnlContextHelp.appendChild(content);
|
||||
content.appendChild(htmlContextHelp = new Html());
|
||||
content.appendChild(htmlContextHelp = new Html());
|
||||
|
||||
renderToolTip(null);
|
||||
renderCtxHelp(X_AD_CtxHelp.CTXTYPE_Home, 0);
|
||||
|
@ -424,4 +435,40 @@ public class HelpController
|
|||
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param content content
|
||||
* @return masked content or empty string if the <code>content</code> is null
|
||||
*/
|
||||
public static String escapeJavascriptContent(String content)
|
||||
{
|
||||
// If the content is null, then return ''
|
||||
if (content == null)
|
||||
return "''";
|
||||
//
|
||||
StringBuilder out = new StringBuilder("'");
|
||||
char[] chars = content.toCharArray();
|
||||
for (int i = 0; i < chars.length; i++)
|
||||
{
|
||||
char c = chars[i];
|
||||
switch (c)
|
||||
{
|
||||
case '\r':
|
||||
out.append ("");
|
||||
break;
|
||||
case '\'':
|
||||
out.append ("\\'");
|
||||
break;
|
||||
case '\n':
|
||||
out.append ("<br>");
|
||||
break;
|
||||
//
|
||||
default:
|
||||
out.append(c);
|
||||
break;
|
||||
}
|
||||
}
|
||||
out.append("'");
|
||||
return out.toString();
|
||||
} // maskHTML
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue