[ 2691063 ] Add SaveAndCreate toolbar button
- Implemented the alternative suggested in forum, user can press 'New' to save current record and create new blank record for editing.
This commit is contained in:
parent
d128fdf5a5
commit
e306eb1cc6
|
@ -143,6 +143,9 @@ public class AdempiereWebUI extends Window implements EventListener, IWebClient
|
|||
Env.setContext(ctx, "#ShowAcct", true);
|
||||
Env.setContext(ctx, "#ShowAdvanced", true);
|
||||
|
||||
String autoCommit = userPreference.getProperty(UserPreference.P_AUTO_COMMIT);
|
||||
Env.setAutoCommit(ctx, "true".equalsIgnoreCase(autoCommit) || "y".equalsIgnoreCase(autoCommit));
|
||||
|
||||
IDesktop d = (IDesktop) currSess.getAttribute("application.desktop");
|
||||
if (d != null && d instanceof IDesktop)
|
||||
{
|
||||
|
|
|
@ -915,7 +915,8 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
|
|||
{
|
||||
insertRecord = curTab.isInsertRecord();
|
||||
}
|
||||
toolbar.enabledNew(!changed && insertRecord && !curTab.isSortTab());
|
||||
// toolbar.enabledNew(!changed && insertRecord && !curTab.isSortTab());
|
||||
toolbar.enabledNew(insertRecord && !curTab.isSortTab());
|
||||
toolbar.enableCopy(!changed && insertRecord && !curTab.isSortTab());
|
||||
toolbar.enableRefresh(!changed);
|
||||
toolbar.enableDelete(!changed && !readOnly && !curTab.isSortTab());
|
||||
|
@ -1030,6 +1031,10 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
|
|||
return;
|
||||
}
|
||||
|
||||
if (!autoSave()) {
|
||||
return;
|
||||
}
|
||||
|
||||
newRecord = curTab.dataNew(false);
|
||||
if (newRecord)
|
||||
{
|
||||
|
@ -1050,6 +1055,23 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
|
|||
focusToActivePanel();
|
||||
}
|
||||
|
||||
private boolean autoSave() {
|
||||
// has anything changed?
|
||||
if (curTab.needSave(true, false))
|
||||
{ // do we have real change
|
||||
if (curTab.needSave(true, true))
|
||||
{
|
||||
if (!onSave(false))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else // new record, but nothing changed
|
||||
curTab.dataIgnore();
|
||||
} // there is a change
|
||||
return true;
|
||||
}
|
||||
|
||||
// Elaine 2008/11/19
|
||||
/**
|
||||
* @see ToolbarListener#onCopy()
|
||||
|
@ -1148,21 +1170,22 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
|
|||
/**
|
||||
* @param onSaveEvent
|
||||
*/
|
||||
private void onSave(boolean onSaveEvent)
|
||||
private boolean onSave(boolean onSaveEvent)
|
||||
{
|
||||
if (curTab.isSortTab())
|
||||
{
|
||||
((ADSortTab)curTabpanel).saveData();
|
||||
toolbar.enableSave(true); // set explicitly
|
||||
toolbar.enableIgnore(false);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (curTab.getCommitWarning() != null && curTab.getCommitWarning().trim().length() > 0)
|
||||
if (onSaveEvent && curTab.getCommitWarning() != null && curTab.getCommitWarning().trim().length() > 0)
|
||||
{
|
||||
if (!FDialog.ask(curWindowNo, this.getComponent(), "SaveChanges?", curTab.getCommitWarning()))
|
||||
{
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
boolean retValue = curTab.dataSave(onSaveEvent);
|
||||
|
@ -1172,9 +1195,11 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
|
|||
//actual error will prompt in the dataStatusChanged event
|
||||
// FDialog.error(curWindowNo, parent, "SaveIgnored");
|
||||
statusBar.setStatusLine(Msg.getMsg(Env.getCtx(), "SaveIgnored"), true);
|
||||
return false;
|
||||
}
|
||||
curTabpanel.dynamicDisplay(0);
|
||||
curTabpanel.afterSave(onSaveEvent);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -50,6 +50,10 @@ public final class UserPreference implements Serializable {
|
|||
public static final String P_WAREHOUSE = "Warehouse";
|
||||
private static final String DEFAULT_WAREHOUSE = "";
|
||||
|
||||
/** Auto Commit */
|
||||
public static final String P_AUTO_COMMIT = "AutoCommit";
|
||||
private static final String DEFAULT_AUTO_COMMIT = "Y";
|
||||
|
||||
/** Language Name Context **/
|
||||
public static final String LANGUAGE_NAME = "#LanguageName";
|
||||
|
||||
|
@ -59,14 +63,16 @@ public final class UserPreference implements Serializable {
|
|||
P_ROLE,
|
||||
P_CLIENT,
|
||||
P_ORG,
|
||||
P_WAREHOUSE };
|
||||
P_WAREHOUSE,
|
||||
P_AUTO_COMMIT};
|
||||
/** Ini Property Values */
|
||||
private static final String[] VALUES = new String[] {
|
||||
DEFAULT_LANGUAGE,
|
||||
DEFAULT_ROLE,
|
||||
DEFAULT_CLIENT,
|
||||
DEFAULT_ORG,
|
||||
DEFAULT_WAREHOUSE };
|
||||
DEFAULT_WAREHOUSE,
|
||||
DEFAULT_AUTO_COMMIT};
|
||||
|
||||
/** Container for Properties */
|
||||
private Properties props = new Properties();
|
||||
|
|
Loading…
Reference in New Issue