IDEMPIERE-395 Insert button enabled when creating a record on zk / refactor duplicated methods - and common behavior buttons

This commit is contained in:
Carlos Ruiz 2012-08-17 15:25:45 -05:00
parent 2f6a80e4b6
commit 3fd9af4e8a
2 changed files with 9 additions and 57 deletions

View File

@ -54,12 +54,12 @@ import org.zkoss.zul.Space;
*/
public class CWindowToolbar extends FToolbar implements EventListener<Event>
{
private static final String BTNPREFIX = "Btn";
/**
*
*/
private static final long serialVersionUID = 5233006056333191551L;
private static final long serialVersionUID = -8640626174604214333L;
private static final String BTNPREFIX = "Btn";
private static final String TOOLBAR_BUTTON_STYLE = "background-color: transparent; display:inline-block; margin-left: 1px; margin-right: 1px; width: 26px; height: 24px;";
@ -440,16 +440,6 @@ public class CWindowToolbar extends FToolbar implements EventListener<Event>
this.btnNext.setDisabled(!enabled);
}
public void enabledNew(boolean enabled)
{
this.btnNew.setDisabled(!enabled);
}
/* public void enableEdit(boolean enabled)
{
this.btnEdit.setEnabled(enabled);
}*/
public void enableRefresh(boolean enabled)
{
this.btnRefresh.setDisabled(!enabled);
@ -458,24 +448,13 @@ public class CWindowToolbar extends FToolbar implements EventListener<Event>
public void enableSave(boolean enabled)
{
this.btnSave.setDisabled(!enabled);
this.btnSaveAndCreate.setDisabled(!enabled);
}
public boolean isSaveEnable() {
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);
@ -484,20 +463,8 @@ public class CWindowToolbar extends FToolbar implements EventListener<Event>
public void enableDelete(boolean enabled)
{
this.btnDelete.setDisabled(!enabled);
}
// Elaine 2008/12/01
public void enableDeleteSelection(boolean enabled)
{
this.btnDeleteSelection.setDisabled(!enabled);
}
//
public void enableChanges(boolean enabled)
{
this.btnNew.setDisabled(!enabled);
this.btnCopy.setDisabled(!enabled);
}
public void enableIgnore(boolean enabled)
{
@ -507,6 +474,7 @@ public class CWindowToolbar extends FToolbar implements EventListener<Event>
public void enableNew(boolean enabled)
{
this.btnNew.setDisabled(!enabled);
this.btnCopy.setDisabled(!enabled);
}
public void enableAttachment(boolean enabled)
@ -529,11 +497,6 @@ public class CWindowToolbar extends FToolbar implements EventListener<Event>
this.btnReport.setDisabled(!enabled);
}
public void enableCopy(boolean enabled)
{
this.btnCopy.setDisabled(!enabled);
}
public void enableFind(boolean enabled)
{
this.btnFind.setDisabled(!enabled);

View File

@ -1224,10 +1224,6 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
private void updateToolbar()
{
toolbar.enableChanges(curTab.isReadOnly());
toolbar.enabledNew(curTab.isInsertRecord());
toolbar.enableCopy(curTab.isInsertRecord());
toolbar.enableTabNavigation(curTabIndex > 0,
curTabIndex < (adTab.getTabCount() - 1));
@ -1345,11 +1341,9 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
{
insertRecord = curTab.isInsertRecord();
}
toolbar.enabledNew(!changed && insertRecord && !curTab.isSortTab());
toolbar.enableCopy(!changed && insertRecord && !curTab.isSortTab());
toolbar.enableNew(!changed && insertRecord && !curTab.isSortTab());
toolbar.enableRefresh(!changed);
toolbar.enableDelete(!changed && !readOnly && !curTab.isSortTab());
toolbar.enableDeleteSelection(!changed && !readOnly && !curTab.isSortTab());
//
if (readOnly && curTab.isAlwaysUpdateField())
{
@ -1378,14 +1372,12 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
}
toolbar.enableSave(changed && !readOnly);
toolbar.enableSaveAndCreate(changed && !readOnly);
//
// No Rows
if (e.getTotalRows() == 0 && insertRecord)
{
toolbar.enabledNew(true);
toolbar.enableNew(true);
toolbar.enableDelete(false);
toolbar.enableDeleteSelection(false);
}
// History (on first Tab only)
@ -1548,9 +1540,8 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
if (newRecord)
{
curTabpanel.dynamicDisplay(0);
toolbar.enableChanges(false);
toolbar.enableNew(false);
toolbar.enableDelete(false);
toolbar.enableDeleteSelection(false);
toolbar.enableNavigation(false);
toolbar.enableTabNavigation(false);
toolbar.enableIgnore(true);
@ -1583,9 +1574,8 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
if (newRecord)
{
curTabpanel.dynamicDisplay(0);
toolbar.enableChanges(false);
toolbar.enableNew(false);
toolbar.enableDelete(false);
toolbar.enableDeleteSelection(false); // Elaine 2008/12/02
toolbar.enableNavigation(false);
toolbar.enableTabNavigation(false);
toolbar.enableIgnore(true);
@ -1719,7 +1709,6 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
if (!onNavigationEvent)
{
toolbar.enableSave(false); // set explicitly
toolbar.enableSaveAndCreate(false);
toolbar.enableIgnore(false);
}
if (callback != null)