- don't prompt save ignored - auto focus to error field - messagebox should always be modal
This commit is contained in:
parent
a8793b1fad
commit
30e7e53baa
|
@ -27,6 +27,7 @@ import org.compiere.model.GridTable;
|
||||||
import org.compiere.model.MSysConfig;
|
import org.compiere.model.MSysConfig;
|
||||||
import org.compiere.util.DisplayType;
|
import org.compiere.util.DisplayType;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
|
import org.zkoss.zk.au.out.AuFocus;
|
||||||
import org.zkoss.zk.au.out.AuScript;
|
import org.zkoss.zk.au.out.AuScript;
|
||||||
import org.zkoss.zk.ui.Component;
|
import org.zkoss.zk.ui.Component;
|
||||||
import org.zkoss.zk.ui.event.Event;
|
import org.zkoss.zk.ui.event.Event;
|
||||||
|
@ -498,4 +499,17 @@ public class GridPanel extends Borderlayout implements EventListener
|
||||||
renderer.setFocusToEditor();
|
renderer.setFocusToEditor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
Clients.response(new AuFocus(editor.getComponent()));
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -226,23 +226,12 @@ public class Messagebox extends Window implements EventListener
|
||||||
|
|
||||||
init();
|
init();
|
||||||
|
|
||||||
if (icon.equals(QUESTION))
|
|
||||||
{
|
|
||||||
this.setTitle(title);
|
this.setTitle(title);
|
||||||
this.setWidth("500px");
|
this.setWidth("500px");
|
||||||
this.setPosition("center");
|
this.setPosition("center");
|
||||||
this.setClosable(true);
|
this.setClosable(true);
|
||||||
this.setAttribute(Window.MODE_KEY, Window.MODE_MODAL);
|
this.setAttribute(Window.MODE_KEY, Window.MODE_MODAL);
|
||||||
this.setSizable(true);
|
this.setSizable(true);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.setTitle(title);
|
|
||||||
this.setAttribute(Window.MODE_KEY, Window.MODE_OVERLAPPED);
|
|
||||||
this.setWidth("500px");
|
|
||||||
this.setClosable(true);
|
|
||||||
this.setSizable(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setVisible(true);
|
this.setVisible(true);
|
||||||
AEnv.showCenterScreen(this);
|
AEnv.showCenterScreen(this);
|
||||||
|
|
|
@ -478,4 +478,8 @@ public abstract class WEditor implements EventListener, PropertyChangeListener
|
||||||
public boolean isHasFocus() {
|
public boolean isHasFocus() {
|
||||||
return hasFocus;
|
return hasFocus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setHasFocus(boolean b) {
|
||||||
|
hasFocus = b;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1062,6 +1062,23 @@ DataStatusListener, IADTabpanel, VetoableChangeListener
|
||||||
listPanel.focus();
|
listPanel.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setFocusToField(String columnName) {
|
||||||
|
if (formComponent.isVisible()) {
|
||||||
|
boolean found = false;
|
||||||
|
for (WEditor editor : editors) {
|
||||||
|
if (found)
|
||||||
|
editor.setHasFocus(false);
|
||||||
|
else if (columnName.equals(editor.getColumnName())) {
|
||||||
|
editor.setHasFocus(true);
|
||||||
|
Clients.response(new AuFocus(editor.getComponent()));
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
listPanel.setFocusToField(columnName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see IADTabpanel#onEnterKey()
|
* @see IADTabpanel#onEnterKey()
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -928,6 +928,17 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
|
||||||
// Confirm Error
|
// Confirm Error
|
||||||
if (e.isError() && !e.isConfirmed())
|
if (e.isError() && !e.isConfirmed())
|
||||||
{
|
{
|
||||||
|
//focus to error field
|
||||||
|
ADTabpanel tabPanel = (ADTabpanel) getADTab().getSelectedTabpanel();
|
||||||
|
GridField[] fields = curTab.getFields();
|
||||||
|
for (GridField field : fields)
|
||||||
|
{
|
||||||
|
if (field.isError())
|
||||||
|
{
|
||||||
|
tabPanel.setFocusToField(field.getColumnName());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
FDialog.error(curWindowNo, null, e.getAD_Message(), e.getInfo());
|
FDialog.error(curWindowNo, null, e.getAD_Message(), e.getInfo());
|
||||||
e.setConfirmed(true); // show just once - if MTable.setCurrentRow is involved the status event is re-issued
|
e.setConfirmed(true); // show just once - if MTable.setCurrentRow is involved the status event is re-issued
|
||||||
}
|
}
|
||||||
|
@ -1244,8 +1255,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
|
||||||
String msg = CLogger.retrieveErrorString(null);
|
String msg = CLogger.retrieveErrorString(null);
|
||||||
if (msg != null)
|
if (msg != null)
|
||||||
FDialog.error(curWindowNo, parent, null, msg);
|
FDialog.error(curWindowNo, parent, null, msg);
|
||||||
else
|
|
||||||
FDialog.error(curWindowNo, parent, "SaveIgnored");
|
|
||||||
//actual error will prompt in the dataStatusChanged event
|
//actual error will prompt in the dataStatusChanged event
|
||||||
statusBar.setStatusLine(Msg.getMsg(Env.getCtx(), "SaveIgnored"), true);
|
statusBar.setStatusLine(Msg.getMsg(Env.getCtx(), "SaveIgnored"), true);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue