- don't prompt save ignored
- auto focus to error field
- messagebox should always be modal
This commit is contained in:
Heng Sin Low 2009-05-19 09:01:35 +00:00
parent a8793b1fad
commit 30e7e53baa
5 changed files with 177 additions and 143 deletions

View File

@ -27,6 +27,7 @@ import org.compiere.model.GridTable;
import org.compiere.model.MSysConfig;
import org.compiere.util.DisplayType;
import org.compiere.util.Env;
import org.zkoss.zk.au.out.AuFocus;
import org.zkoss.zk.au.out.AuScript;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.event.Event;
@ -498,4 +499,17 @@ public class GridPanel extends Borderlayout implements EventListener
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;
}
}
}
}

View File

@ -226,23 +226,12 @@ public class Messagebox extends Window implements EventListener
init();
if (icon.equals(QUESTION))
{
this.setTitle(title);
this.setWidth("500px");
this.setPosition("center");
this.setClosable(true);
this.setAttribute(Window.MODE_KEY, Window.MODE_MODAL);
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.setTitle(title);
this.setWidth("500px");
this.setPosition("center");
this.setClosable(true);
this.setAttribute(Window.MODE_KEY, Window.MODE_MODAL);
this.setSizable(true);
this.setVisible(true);
AEnv.showCenterScreen(this);

View File

@ -478,4 +478,8 @@ public abstract class WEditor implements EventListener, PropertyChangeListener
public boolean isHasFocus() {
return hasFocus;
}
public void setHasFocus(boolean b) {
hasFocus = b;
}
}

View File

@ -1062,6 +1062,23 @@ DataStatusListener, IADTabpanel, VetoableChangeListener
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()
*/

View File

@ -928,6 +928,17 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
// Confirm Error
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());
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);
if (msg != null)
FDialog.error(curWindowNo, parent, null, msg);
else
FDialog.error(curWindowNo, parent, "SaveIgnored");
//actual error will prompt in the dataStatusChanged event
statusBar.setStatusLine(Msg.getMsg(Env.getCtx(), "SaveIgnored"), true);
}