Implement saveAndCreate toolbar button.

This commit is contained in:
Heng Sin Low 2011-02-07 12:01:09 +08:00
parent ac90b69d9e
commit 6170d4bf3a
6 changed files with 69 additions and 7 deletions

View File

@ -25,6 +25,7 @@ import java.util.Iterator;
import java.util.Map;
import java.util.logging.Level;
import org.adempiere.webui.AdempiereIdGenerator;
import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.event.ToolbarListener;
import org.adempiere.webui.session.SessionManager;
@ -65,6 +66,8 @@ public class CWindowToolbar extends FToolbar implements EventListener
private ToolBarButton btnHelp, btnNew, btnCopy, btnDelete, btnDeleteSelection, btnSave;
private ToolBarButton btnSaveAndCreate; // Elaine 2009/03/02 - Save & Create
private ToolBarButton btnRefresh, btnFind, btnLock, btnAttachment;
private ToolBarButton btnGridToggle;
@ -129,16 +132,24 @@ public class CWindowToolbar extends FToolbar implements EventListener
addSeparator();
btnHelp = createButton("Help", "Help","Help");
btnNew = createButton("New", "New", "New");
btnNew.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, "btnNew");
btnCopy = createButton("Copy", "Copy", "Copy");
btnDelete = createButton("Delete", "Delete", "Delete");
btnDeleteSelection = createButton("DeleteSelection", "DeleteSelection", "DeleteSelection");
btnSave = createButton("Save", "Save", "Save");
btnSave.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, "btnSave");
btnSaveAndCreate = createButton("SaveCreate", "SaveCreate", "SaveCreate");
addSeparator();
btnRefresh = createButton("Refresh", "Refresh", "Refresh");
btnFind = createButton("Find", "Find", "Find");
btnAttachment = createButton("Attachment", "Attachment", "Attachment");
btnChat = createButton("Chat", "Chat", "Chat");
btnGridToggle = createButton("Toggle", "Multi", "Multi");
btnGridToggle.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, "btnGridToggle");
btnHistoryRecords = createButton("HistoryRecords", "HistoryX", "History");
addSeparator();
btnParentRecord = createButton("ParentRecord", "Parent", "Parent");
@ -282,6 +293,7 @@ public class CWindowToolbar extends FToolbar implements EventListener
ctrlKeyMap.put(VK_P, btnPrint);
ctrlKeyMap.put(VK_N, btnNew);
ctrlKeyMap.put(VK_S, btnSave);
ctrlKeyMap.put(VK_A, btnSaveAndCreate);
ctrlKeyMap.put(VK_D, btnDelete);
ctrlKeyMap.put(VK_F, btnFind);
}
@ -437,6 +449,18 @@ public class CWindowToolbar extends FToolbar implements EventListener
return !btnSave.isDisabled();
}
// Elaine 2009/03/02 - Save & Create
public void enableSaveAndCreate(boolean enabled)
{
this.btnSaveAndCreate.setDisabled(!enabled);
}
public boolean isSaveAndCreateEnable()
{
return !btnSaveAndCreate.isDisabled();
}
//
// public void enableExit(boolean enabled)
// {
// this.btnExit.setDisabled(!enabled);

View File

@ -95,6 +95,11 @@ public interface ToolbarListener
*/
public void onDelete();
/**
* Delete selected record(s)
*/
public void onDeleteSelection();
/**
* Save current record
*/
@ -140,6 +145,26 @@ public interface ToolbarListener
*/
public void onProductInfo();
/**
* open chat window
*/
public void onChat();
/**
* Personal lock
*/
public void onLock();
/**
* Save and create
*/
public void onSaveCreate();
/**
* Copy current record as a new record
*/
public void onCopy();
/**
* Export grid data
*/

View File

@ -1213,8 +1213,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
{
insertRecord = curTab.isInsertRecord();
}
// toolbar.enabledNew(!changed && insertRecord && !curTab.isSortTab());
toolbar.enabledNew(insertRecord && !curTab.isSortTab());
toolbar.enabledNew(!changed && insertRecord && !curTab.isSortTab());
toolbar.enableCopy(!changed && insertRecord && !curTab.isSortTab());
toolbar.enableRefresh(!changed);
toolbar.enableDelete(!changed && !readOnly && !curTab.isSortTab());
@ -1226,7 +1225,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
}
toolbar.enableIgnore(changed && !readOnly);
toolbar.enableSave(changed && !readOnly);
toolbar.enableSaveAndCreate(changed && !readOnly);
//
// No Rows
if (e.getTotalRows() == 0 && insertRecord)
@ -1541,6 +1540,19 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
//other error will be catch in the dataStatusChanged event
}
/**
* @see ToolbarListener#onSaveCreate()
*/
public void onSaveCreate()
{
boolean retValue = onSave(true);
if(retValue)
{
curTab.dataRefreshAll(true);
onNew();
}
}
/**
* @see ToolbarListener#onDelete()
*/

View File

@ -11,7 +11,7 @@
<listener-class>org.adempiere.webui.session.SessionContextListener
</listener-class>
</listener>
<log>
<description>[Optional] Monitor i3-log.conf and register a
handler for the specified log-base</description>
@ -20,7 +20,8 @@
<!-- change to false to use compress js which is much smaller -->
<client-config>
<debug-js>false</debug-js>
<debug-js>false</debug-js>
<processing-prompt-delay>100</processing-prompt-delay>
</client-config>
<!--
@ -33,7 +34,7 @@
<automatic-timeout/> <!-- the same as <automatic-timeout>true</automatic-timeout> -->
<timeout-uri>/timeout.zul</timeout-uri>
</session-config>
<!--
Turn on the following if used with WebLogic 9.1 <system-config>
<cache-provider-class>org.zkoss.zk.ui.sys.GlobalDesktopCacheProvider</cache-provider-class>
@ -46,7 +47,7 @@
<!--
polling - org.zkoss.zkex.ui.impl.PollingServerPush
comet - org.zkoss.zkmax.ui.comet.CometServerPush ( enterprise edition only )
comet - org.zkoss.zkmax.ui.comet.CometServerPush ( enterprise edition only )
-->
<device-config>
<device-type>ajax</device-type>

Binary file not shown.

After

Width:  |  Height:  |  Size: 634 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 785 B