diff --git a/migration/360lts-release/oracle/930_IDEMPIERE-369.sql b/migration/360lts-release/oracle/930_IDEMPIERE-369.sql new file mode 100644 index 0000000000..ecef75aeab --- /dev/null +++ b/migration/360lts-release/oracle/930_IDEMPIERE-369.sql @@ -0,0 +1,8 @@ +-- Sep 12, 2012 6:08:38 PM MYT +-- IDEMPIERE-369 Master Detail layout improvements +UPDATE AD_Field SET IsDisplayed='N', IsActive='N', IsDisplayedGrid='N',Updated=TO_DATE('2012-09-12 18:08:38','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=6432 +; + +SELECT register_migration_script('930_IDEMPIERE-369.sql') FROM dual +; + diff --git a/migration/360lts-release/oracle/931_IDEMPIERE-375.sql b/migration/360lts-release/oracle/931_IDEMPIERE-375.sql new file mode 100644 index 0000000000..139291030e --- /dev/null +++ b/migration/360lts-release/oracle/931_IDEMPIERE-375.sql @@ -0,0 +1,32 @@ +-- Oct 10, 2012 4:12:00 PM SGT +-- IDEMPIERE-375 Implement Forgot my Password +INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Client_ID,AD_Org_ID,Created) VALUES ('I','Forgot My Password',200074,'D','edbc8af4-43a1-4966-8ee5-c609cf01a90c','ForgotMyPassword','Y',TO_DATE('2012-10-10 16:11:57','YYYY-MM-DD HH24:MI:SS'),100,100,0,0,TO_DATE('2012-10-10 16:11:57','YYYY-MM-DD HH24:MI:SS')) +; + +-- Oct 10, 2012 4:12:00 PM SGT +-- IDEMPIERE-375 Implement Forgot my Password +INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Message_Trl_UU ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200074 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID) +; + +-- Oct 10, 2012 4:29:44 PM SGT +-- IDEMPIERE-375 Implement Forgot my Password +INSERT INTO AD_Message (MsgType,MsgText,MsgTip,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Client_ID,AD_Org_ID,Created) VALUES ('I','Passwords for all tenants using ({0}) as email have been reset',' ',200075,'D','51b49e9a-4c26-486a-ac83-e506ce282ab7','PasswordsForAllTenantsReset','Y',TO_DATE('2012-10-10 16:29:43','YYYY-MM-DD HH24:MI:SS'),100,100,0,0,TO_DATE('2012-10-10 16:29:43','YYYY-MM-DD HH24:MI:SS')) +; + +-- Oct 10, 2012 4:29:44 PM SGT +-- IDEMPIERE-375 Implement Forgot my Password +INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Message_Trl_UU ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200075 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID) +; + +-- Oct 10, 2012 4:31:02 PM SGT +-- IDEMPIERE-375 Implement Forgot my Password +INSERT INTO AD_Message (MsgType,MsgText,MsgTip,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Client_ID,AD_Org_ID,Created) VALUES ('I','The new password is now valid for all tenants',' ',200076,'D','be10802e-1a38-45cf-afd9-5bbe1776fead','NewPasswordValidForAllTenants','Y',TO_DATE('2012-10-10 16:31:01','YYYY-MM-DD HH24:MI:SS'),100,100,0,0,TO_DATE('2012-10-10 16:31:01','YYYY-MM-DD HH24:MI:SS')) +; + +-- Oct 10, 2012 4:31:02 PM SGT +-- IDEMPIERE-375 Implement Forgot my Password +INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Message_Trl_UU ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200076 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID) +; + +SELECT register_migration_script('931_IDEMPIERE-375.sql') FROM dual +; diff --git a/migration/360lts-release/postgresql/930_IDEMPIERE-369.sql b/migration/360lts-release/postgresql/930_IDEMPIERE-369.sql new file mode 100644 index 0000000000..84df939894 --- /dev/null +++ b/migration/360lts-release/postgresql/930_IDEMPIERE-369.sql @@ -0,0 +1,8 @@ +-- Sep 12, 2012 6:08:38 PM MYT +-- IDEMPIERE-369 Master Detail layout improvements +UPDATE AD_Field SET IsDisplayed='N', IsActive='N', IsDisplayedGrid='N',Updated=TO_TIMESTAMP('2012-09-12 18:08:38','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=6432 +; + +SELECT register_migration_script('930_IDEMPIERE-369.sql') FROM dual +; + diff --git a/migration/360lts-release/postgresql/931_IDEMPIERE-375.sql b/migration/360lts-release/postgresql/931_IDEMPIERE-375.sql new file mode 100644 index 0000000000..11a53f0b16 --- /dev/null +++ b/migration/360lts-release/postgresql/931_IDEMPIERE-375.sql @@ -0,0 +1,32 @@ +-- Oct 10, 2012 4:12:00 PM SGT +-- IDEMPIERE-375 Implement Forgot my Password +INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Client_ID,AD_Org_ID,Created) VALUES ('I','Forgot My Password',200074,'D','edbc8af4-43a1-4966-8ee5-c609cf01a90c','ForgotMyPassword','Y',TO_TIMESTAMP('2012-10-10 16:11:57','YYYY-MM-DD HH24:MI:SS'),100,100,0,0,TO_TIMESTAMP('2012-10-10 16:11:57','YYYY-MM-DD HH24:MI:SS')) +; + +-- Oct 10, 2012 4:12:00 PM SGT +-- IDEMPIERE-375 Implement Forgot my Password +INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Message_Trl_UU ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200074 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID) +; + +-- Oct 10, 2012 4:29:44 PM SGT +-- IDEMPIERE-375 Implement Forgot my Password +INSERT INTO AD_Message (MsgType,MsgText,MsgTip,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Client_ID,AD_Org_ID,Created) VALUES ('I','Passwords for all tenants using ({0}) as email have been reset',' ',200075,'D','51b49e9a-4c26-486a-ac83-e506ce282ab7','PasswordsForAllTenantsReset','Y',TO_TIMESTAMP('2012-10-10 16:29:43','YYYY-MM-DD HH24:MI:SS'),100,100,0,0,TO_TIMESTAMP('2012-10-10 16:29:43','YYYY-MM-DD HH24:MI:SS')) +; + +-- Oct 10, 2012 4:29:44 PM SGT +-- IDEMPIERE-375 Implement Forgot my Password +INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Message_Trl_UU ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200075 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID) +; + +-- Oct 10, 2012 4:31:02 PM SGT +-- IDEMPIERE-375 Implement Forgot my Password +INSERT INTO AD_Message (MsgType,MsgText,MsgTip,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Client_ID,AD_Org_ID,Created) VALUES ('I','The new password is now valid for all tenants',' ',200076,'D','be10802e-1a38-45cf-afd9-5bbe1776fead','NewPasswordValidForAllTenants','Y',TO_TIMESTAMP('2012-10-10 16:31:01','YYYY-MM-DD HH24:MI:SS'),100,100,0,0,TO_TIMESTAMP('2012-10-10 16:31:01','YYYY-MM-DD HH24:MI:SS')) +; + +-- Oct 10, 2012 4:31:02 PM SGT +-- IDEMPIERE-375 Implement Forgot my Password +INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Message_Trl_UU ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200076 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID) +; + +SELECT register_migration_script('931_IDEMPIERE-375.sql') FROM dual +; diff --git a/org.adempiere.base/src/org/compiere/model/GridTab.java b/org.adempiere.base/src/org/compiere/model/GridTab.java index 85199c4b98..07720180c1 100644 --- a/org.adempiere.base/src/org/compiere/model/GridTab.java +++ b/org.adempiere.base/src/org/compiere/model/GridTab.java @@ -1006,11 +1006,6 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable } fireStateChangeEvent(new StateChangeEvent(this, StateChangeEvent.DATA_SAVE)); - if (retValue) { - // refresh parent tabs - refreshParents(); - } - return retValue; } catch (Exception e) @@ -1059,28 +1054,6 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable return false; } - private void refreshParents() { - if (isDetail()) { - // get parent tab - // the parent tab is the first tab above with level = this_tab_level-1 - int level = m_vo.TabLevel; - for (int i = m_window.getTabIndex(this) - 1; i >= 0; i--) { - GridTab parentTab = m_window.getTab(i); - if (parentTab.m_vo.TabLevel == level-1) { - parentTab.dataRefresh(false); - // search for the next parent - if (parentTab.isDetail()) { - level = parentTab.m_vo.TabLevel; - } else { - break; - } - } - } - // refresh this tab - dataRefresh(false); - } - } - /** * Do we need to Save? * @param rowChange row change @@ -2514,7 +2487,7 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable * @param fireEvents fire events * @return current row */ - private int setCurrentRow (int newCurrentRow, boolean fireEvents) + public int setCurrentRow (int newCurrentRow, boolean fireEvents) { int oldCurrentRow = m_currentRow; m_currentRow = verifyRow (newCurrentRow); @@ -3250,4 +3223,8 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable return col; } + + public boolean isNew() { + return isOpen() && getCurrentRow() >= 0 && getCurrentRow() == m_mTable.getNewRow(); + } } // GridTab diff --git a/org.adempiere.base/src/org/compiere/model/GridTable.java b/org.adempiere.base/src/org/compiere/model/GridTable.java index 1894cb78f0..cf5258adf3 100644 --- a/org.adempiere.base/src/org/compiere/model/GridTable.java +++ b/org.adempiere.base/src/org/compiere/model/GridTable.java @@ -42,7 +42,6 @@ import javax.swing.event.TableModelListener; import javax.swing.table.AbstractTableModel; import org.adempiere.exceptions.DBException; -import org.adempiere.util.ContextRunnable; import org.adempiere.util.ServerContext; import org.compiere.Adempiere; import org.compiere.util.CLogMgt; @@ -619,13 +618,8 @@ public class GridTable extends AbstractTableModel m_sort = new ArrayList(m_rowCount+10); if (m_rowCount > 0) { - if (m_rowCount < 1000) - m_loader.run(); - else - { - m_loader.setContext(ServerContext.getCurrentInstance()); - m_loaderFuture = Adempiere.getThreadPoolExecutor().submit(m_loader); - } + m_loader.setContext(ServerContext.getCurrentInstance()); + m_loaderFuture = Adempiere.getThreadPoolExecutor().submit(m_loader); } else m_loader.close(); diff --git a/org.adempiere.ui.zk/META-INF/MANIFEST.MF b/org.adempiere.ui.zk/META-INF/MANIFEST.MF index 4da72e9bd6..6f00ad4d6b 100644 --- a/org.adempiere.ui.zk/META-INF/MANIFEST.MF +++ b/org.adempiere.ui.zk/META-INF/MANIFEST.MF @@ -44,7 +44,8 @@ Export-Package: metainfo.zk, org.adempiere.webui.session, org.adempiere.webui.theme, org.adempiere.webui.util, - org.adempiere.webui.window + org.adempiere.webui.window, + metainfo.zk Require-Bundle: org.adempiere.report.jasper;bundle-version="1.0.0", org.adempiere.base;bundle-version="1.0.0", org.adempiere.report.jasper.library;bundle-version="1.0.0", diff --git a/org.adempiere.ui.zk/metainfo/zk/lang-addon.xml b/org.adempiere.ui.zk/WEB-INF/src/metainfo/zk/lang-addon.xml similarity index 95% rename from org.adempiere.ui.zk/metainfo/zk/lang-addon.xml rename to org.adempiere.ui.zk/WEB-INF/src/metainfo/zk/lang-addon.xml index 3219dbe872..0ccedf0dbc 100644 --- a/org.adempiere.ui.zk/metainfo/zk/lang-addon.xml +++ b/org.adempiere.ui.zk/WEB-INF/src/metainfo/zk/lang-addon.xml @@ -38,6 +38,7 @@ Copyright (C) 2007 Ashley G Ramdass (ADempiere WebUI). + diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/AdempiereIdGenerator.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/AdempiereIdGenerator.java index 2af4bc4987..e5aa5792ea 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/AdempiereIdGenerator.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/AdempiereIdGenerator.java @@ -20,6 +20,7 @@ import java.util.regex.Pattern; import org.zkoss.zk.ui.Component; import org.zkoss.zk.ui.Desktop; import org.zkoss.zk.ui.Page; +import org.zkoss.zk.ui.metainfo.ComponentInfo; import org.zkoss.zk.ui.sys.IdGenerator; public class AdempiereIdGenerator implements IdGenerator { @@ -33,7 +34,7 @@ public class AdempiereIdGenerator implements IdGenerator { public static final String ZK_COMPONENT_PREFIX_ATTRIBUTE = "zk_component_prefix"; @Override - public String nextComponentUuid(Desktop desktop, Component comp) { + public String nextComponentUuid(Desktop desktop, Component comp, ComponentInfo compInfo) { String prefix = (String) comp.getAttribute(ZK_COMPONENT_PREFIX_ATTRIBUTE); if (prefix == null || prefix.length() == 0) prefix = DEFAULT_ZK_COMP_PREFIX; diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/LayoutUtils.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/LayoutUtils.java index ebcfb6a8f1..b2e9ea0f86 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/LayoutUtils.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/LayoutUtils.java @@ -103,4 +103,25 @@ public final class LayoutUtils { window.doPopup(); Clients.response("_openPopupWindow_", new AuScript(window, script.toString())); } + + /** + * open popup window relative to the ref component + * @param ref + * @param window + * @param position + */ + public static void openOverlappedWindow(Component ref, Window window, String position) { + if (window.getPage() == null) + window.setPage(ref.getPage()); + StringBuilder script = new StringBuilder(); + script.append("_idempiere_popup_window('#") + .append(ref.getUuid()) + .append("','#") + .append(window.getUuid()) + .append("','") + .append(position) + .append("');"); + window.doOverlapped(); + Clients.response("_openPopupWindow_", new AuScript(window, script.toString())); + } } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/WLogin.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/WLogin.java index adad7a1c8a..26fa854291 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/WLogin.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/WLogin.java @@ -69,7 +69,6 @@ public class WLogin extends AbstractUIPart Center center = new Center(); center.setParent(layout); center.setBorder("none"); - center.setFlex(true); center.setAutoscroll(true); center.setStyle("border: none; background-color: transparent;"); @@ -80,6 +79,8 @@ public class WLogin extends AbstractUIPart vb.setPack("center"); vb.setAlign("center"); vb.setStyle("background-color: transparent;"); + vb.setHflex("1"); + vb.setVflex("1"); loginWindow = new LoginWindow(app); loginWindow.setParent(vb); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/WRequest.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/WRequest.java index 84cfa27bf6..1800482da7 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/WRequest.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/WRequest.java @@ -18,8 +18,8 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.logging.Level; +import org.adempiere.webui.adwindow.ADWindow; import org.adempiere.webui.session.SessionManager; -import org.adempiere.webui.window.ADWindow; import org.compiere.model.GridTab; import org.compiere.model.MAsset; import org.compiere.model.MBPartner; @@ -212,7 +212,7 @@ public class WRequest implements EventListener // New - set Table/Record if (e.getTarget() == m_new) { - GridTab tab = frame.getADWindowPanel().getActiveGridTab(); + GridTab tab = frame.getADWindowContent().getActiveGridTab(); tab.dataNew (false); tab.setValue("AD_Table_ID", new Integer(m_AD_Table_ID)); tab.setValue("Record_ID", new Integer(m_Record_ID)); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/acct/WAcctViewer.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/acct/WAcctViewer.java index 53dc3f2070..f2391deb3e 100755 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/acct/WAcctViewer.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/acct/WAcctViewer.java @@ -511,13 +511,14 @@ public class WAcctViewer extends Window implements EventListener result.appendChild(resultPanel); Center resultCenter = new Center(); - resultCenter.setFlex(true); resultPanel.appendChild(resultCenter); table.setHflex("1"); table.setVflex(true); table.setHeight("99%"); table.setStyle("position: absolute;"); resultCenter.appendChild(table); + table.setHflex("1"); + table.setVflex("1"); pagingPanel = new South(); resultPanel.appendChild(pagingPanel); @@ -564,17 +565,18 @@ public class WAcctViewer extends Window implements EventListener Center center = new Center(); center.setParent(layout); - center.setFlex(true); center.setStyle("background-color: transparent; padding: 2px;"); tabbedPane.setParent(center); + tabbedPane.setHflex("1"); + tabbedPane.setVflex("1"); South south = new South(); south.setParent(layout); - south.setFlex(true); south.setStyle("background-color: transparent"); south.setHeight("36px"); southPanel.setParent(south); southPanel.setVflex("1"); + southPanel.setHflex("1"); this.setTitle(TITLE); this.setClosable(true); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/ADSortTab.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADSortTab.java similarity index 94% rename from org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/ADSortTab.java rename to org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADSortTab.java index e1641dd27a..178db7c3e6 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/ADSortTab.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADSortTab.java @@ -14,7 +14,7 @@ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * * or via info@compiere.org or http://www.compiere.org/license.html * *****************************************************************************/ -package org.adempiere.webui.panel; +package org.adempiere.webui.adwindow; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -101,7 +101,7 @@ public class ADSortTab extends Panel implements IADTabpanel private boolean m_IdentifierTranslated = false; private String m_ParentColumnName = null; - private AbstractADWindowPanel adWindowPanel = null; + private AbstractADWindowContent adWindowPanel = null; // UI variables private Label noLabel = new Label(); @@ -137,6 +137,8 @@ public class ADSortTab extends Panel implements IADTabpanel private GridTab gridTab; private boolean uiCreated; + private boolean active = false; + private boolean isChanged; /** * Dynamic Init @@ -493,12 +495,17 @@ public class ADSortTab extends Panel implements IADTabpanel * @param value */ private void setIsChanged(boolean value) { + isChanged = value; if (adWindowPanel != null) { adWindowPanel.getToolbar().enableSave(value); adWindowPanel.getToolbar().enableIgnore(value); } } + public boolean isChanged() { + return isChanged; + } + /** * @param event */ @@ -613,7 +620,7 @@ public class ADSortTab extends Panel implements IADTabpanel /* (non-Javadoc) * @see org.compiere.grid.APanelTab#registerAPanel(APanel) */ - public void registerAPanel (AbstractADWindowPanel panel) + public void registerAPanel (AbstractADWindowContent panel) { adWindowPanel = panel; } // registerAPanel @@ -835,6 +842,7 @@ public class ADSortTab extends Panel implements IADTabpanel } public void activate(boolean b) { + active = b; if (b && !uiCreated) createUI(); } @@ -912,5 +920,19 @@ public class ADSortTab extends Panel implements IADTabpanel public boolean onEnterKey() { return false; } + + @Override + public boolean isGridView() { + return false; + } + + @Override + public boolean isActive() { + return active; + } + + @Override + public void setDetailPaneMode(boolean detailMode, boolean vflex) { + } } //ADSortTab diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/ADTabpanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADTabpanel.java similarity index 90% rename from org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/ADTabpanel.java rename to org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADTabpanel.java index 9510a7620c..30eec5d36b 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/ADTabpanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADTabpanel.java @@ -1,5 +1,5 @@ /****************************************************************************** - * Product: Posterita Ajax UI * +f * Product: Posterita Ajax UI * * Copyright (C) 2007 Posterita Ltd. All Rights Reserved. * * This program is free software; you can redistribute it and/or modify it * * under the terms version 2 of the GNU General Public License as published * @@ -15,7 +15,7 @@ * or via info@posterita.org or http://www.posterita.org/ * *****************************************************************************/ -package org.adempiere.webui.panel; +package org.adempiere.webui.adwindow; import java.util.ArrayList; import java.util.HashMap; @@ -31,7 +31,6 @@ import org.adempiere.webui.component.Column; import org.adempiere.webui.component.Columns; import org.adempiere.webui.component.EditorBox; import org.adempiere.webui.component.Grid; -import org.adempiere.webui.component.GridPanel; import org.adempiere.webui.component.Group; import org.adempiere.webui.component.Label; import org.adempiere.webui.component.NumberBox; @@ -72,10 +71,10 @@ import org.zkoss.zul.Borderlayout; import org.zkoss.zul.Center; import org.zkoss.zul.DefaultTreeNode; import org.zkoss.zul.Div; -import org.zkoss.zul.Groupfoot; import org.zkoss.zul.Separator; import org.zkoss.zul.Space; import org.zkoss.zul.Treeitem; +import org.zkoss.zul.Vlayout; import org.zkoss.zul.West; import org.zkoss.zul.impl.XulElement; @@ -114,11 +113,11 @@ DataStatusListener, IADTabpanel @SuppressWarnings("unused") private GridWindow gridWindow; - private AbstractADWindowPanel windowPanel; + private AbstractADWindowContent windowPanel; private int windowNo; - private Grid grid; + private Grid form; private ArrayList editors = new ArrayList(); @@ -126,7 +125,7 @@ DataStatusListener, IADTabpanel private boolean uiCreated = false; - private GridPanel listPanel; + private GridView listPanel; private Map> fieldGroupContents = new HashMap>(); @@ -136,19 +135,20 @@ DataStatusListener, IADTabpanel List allCollapsibleGroups = new ArrayList(); - private Component formComponent = null; + private Component formContainer = null; private ADTreePanel treePanel = null; private GridTabDataBinder dataBinder; - private Map includedTab = new HashMap(); - private Map includedTabFooter = new HashMap(); - private boolean active = false; private Group currentGroup; + private Component detailPane; + + public static final String ON_TOGGLE_EVENT = "onToggle"; + public ADTabpanel() { init(); @@ -164,16 +164,46 @@ DataStatusListener, IADTabpanel { LayoutUtils.addSclass("adtab-content", this); - grid = new Grid(); - //have problem moving the following out as css class - grid.setHflex("1"); - grid.setHeight("100%"); - grid.setVflex(true); - grid.setSclass("grid-layout"); + this.setWidth("100%"); + + form = new Grid(); + form.setHflex("1"); + form.setHeight(null); + form.setVflex(false); + form.setSclass("grid-layout"); - listPanel = new GridPanel(); + listPanel = new GridView(); listPanel.getListbox().addEventListener(Events.ON_DOUBLE_CLICK, this); } + + public void addDetails(Component component) { + if (formContainer.isVisible()) { + detailPane = component; + if (formContainer instanceof Borderlayout) { + form.getParent().appendChild(detailPane); + } else { + formContainer.appendChild(component); + } + } else { + listPanel.addDetails(component); + } + } + + public Component removeDetails() { + Component details = null; + if (listPanel.isVisible()) { + details = listPanel.removeDetails(); + } else { + if (detailPane != null) { + if (detailPane.getParent() != null) { + details = detailPane; + detailPane.detach(); + } + detailPane = null; + } + } + return details; + } /** * @@ -182,7 +212,7 @@ DataStatusListener, IADTabpanel * @param gridTab * @param gridWindow */ - public void init(AbstractADWindowPanel winPanel, int windowNo, GridTab gridTab, + public void init(AbstractADWindowContent winPanel, int windowNo, GridTab gridTab, GridWindow gridWindow) { this.windowNo = windowNo; @@ -214,12 +244,15 @@ DataStatusListener, IADTabpanel layout.appendChild(west); Center center = new Center(); - center.setFlex(true); - center.appendChild(grid); - center.setSclass("adtab-form"); + Vlayout div = new Vlayout(); + div.appendChild(form); + center.appendChild(div); + div.setVflex("1"); + div.setHflex("1"); + div.setSclass("adtab-form"); layout.appendChild(center); - formComponent = layout; + formContainer = layout; treePanel.getTree().addEventListener(Events.ON_SELECT, this); if (AEnv.isTablet()) @@ -230,16 +263,18 @@ DataStatusListener, IADTabpanel } else { - Div div = new Div(); + Vlayout div = new Vlayout(); div.setSclass("adtab-form"); - div.appendChild(grid); + div.appendChild(form); + div.setVflex("1"); + div.setWidth("100%"); this.appendChild(div); - formComponent = div; + formContainer = div; if (AEnv.isTablet()) { LayoutUtils.addSclass("tablet-scrolling", div); - } + } } this.appendChild(listPanel); listPanel.setVisible(false); @@ -264,7 +299,7 @@ DataStatusListener, IADTabpanel // set size in percentage per column leaving a MARGIN on right Columns columns = new Columns(); - grid.appendChild(columns); + form.appendChild(columns); String numColsS=String.valueOf(numCols); int equalWidth = 98 / numCols; @@ -274,7 +309,7 @@ DataStatusListener, IADTabpanel columns.appendChild(col); } - Rows rows = grid.newRows(); + Rows rows = form.newRows(); GridField fields[] = gridTab.getFields(); Row row = new Row(); int actualxpos = 0; @@ -286,55 +321,6 @@ DataStatusListener, IADTabpanel if (!field.isDisplayed()) continue; - //included tab - if (field.getIncluded_Tab_ID() > 0) - { - // NOT CHANGING INCLUDED TAB AS THIS IS BEING REDESIGNED WITH - // IDEMPIERE-369 Master Detail layout improvements - if (row.getChildren().size() == 2) - { - row.appendChild(createSpacer()); - row.appendChild(createSpacer()); - row.appendChild(createSpacer()); - rows.appendChild(row); - if (rowList != null) - rowList.add(row); - } else if (row.getChildren().size() > 0) - { - rows.appendChild(row); - if (rowList != null) - rowList.add(row); - } - - //end current field group - if (currentGroup != null) { - Groupfoot rowg = new Groupfoot(); - rows.appendChild(rowg); - currentGroup = null; - currentFieldGroup = null; - } - - row = new Row(); - row.setSpans("5"); - row.appendChild(new Separator()); - rows.appendChild(row); - - Group rowg = new Group(); - rowg.setSpans("2,3"); - rows.appendChild(rowg); - includedTab.put(field.getIncluded_Tab_ID(), (Group)rowg); - Groupfoot rowgf = new Groupfoot(); - rows.appendChild(rowgf); - includedTabFooter.put(field.getIncluded_Tab_ID(), (Groupfoot)rowgf); - - row = new Row(); - row.setSpans("5"); - row.appendChild(new Separator()); - rows.appendChild(row); - - row = new Row(); - continue; - } // field group String fieldGroup = field.getFieldGroup(); if (!Util.isEmpty(fieldGroup) && !fieldGroup.equals(currentFieldGroup)) // group changed @@ -569,7 +555,7 @@ DataStatusListener, IADTabpanel } // all components //hide row if all editor within the row is invisible - List rows = grid.getRows().getChildren(); + List rows = form.getRows().getChildren(); for (Component comp : rows) { if (comp instanceof Row) { @@ -759,7 +745,7 @@ DataStatusListener, IADTabpanel listPanel.deactivate(); } else { if (activate) { - formComponent.setVisible(activate); + formContainer.setVisible(activate); setFocusToField(); } } @@ -767,6 +753,9 @@ DataStatusListener, IADTabpanel if (gridTab.getRecord_ID() > 0 && gridTab.isTreeTab() && treePanel != null) { setSelectedNode(gridTab.getRecord_ID()); } + + Event event = new Event("onActivate", this, activate); + Events.sendEvent(event); } /** @@ -806,11 +795,7 @@ DataStatusListener, IADTabpanel { if (event.getTarget() == listPanel.getListbox()) { - if (windowPanel != null) { - windowPanel.onToggle(); - } else { - this.switchRowPresentation(); - } + Events.sendEvent(this, new Event(ON_TOGGLE_EVENT, this)); } else if (event.getTarget() == treePanel.getTree()) { Treeitem item = treePanel.getTree().getSelectedItem(); @@ -820,7 +805,7 @@ DataStatusListener, IADTabpanel if (gridTab.getRecord_ID() > 0 && gridTab.isTreeTab() && treePanel != null) { setSelectedNode(gridTab.getRecord_ID()); } - } + } } private void navigateTo(DefaultTreeNode value) { @@ -995,19 +980,25 @@ DataStatusListener, IADTabpanel * Toggle between form and grid view */ public void switchRowPresentation() { - if (formComponent.isVisible()) { - formComponent.setVisible(false); + Component details = removeDetails(); + if (formContainer.isVisible()) { + formContainer.setVisible(false); } else { - formComponent.setVisible(true); - formComponent.getParent().invalidate(); + formContainer.setVisible(true); + formContainer.getParent().invalidate(); } - listPanel.setVisible(!formComponent.isVisible()); + listPanel.setVisible(!formContainer.isVisible()); if (listPanel.isVisible()) { listPanel.refresh(gridTab); listPanel.scrollToCurrentRow(); } else { listPanel.deactivate(); } + + if (details != null) + addDetails(details); + + Events.sendEvent(this, new Event("onSwitchView", this)); } class ZoomListener implements EventListener { @@ -1035,14 +1026,14 @@ DataStatusListener, IADTabpanel @Override public void focus() { - if (formComponent.isVisible()) + if (formContainer.isVisible()) this.setFocusToField(); else listPanel.focus(); } public void setFocusToField(String columnName) { - if (formComponent.isVisible()) { + if (formContainer.isVisible()) { boolean found = false; for (WEditor editor : editors) { if (found) @@ -1079,8 +1070,23 @@ DataStatusListener, IADTabpanel * * @return GridPanel */ - public GridPanel getGridView() { + public GridView getGridView() { return listPanel; } + + public boolean isActive() { + return active; + } + + @Override + public void setDetailPaneMode(boolean detailPaneMode, boolean vflex) { + if (detailPaneMode) { + detailPane = null; + this.setVflex("true"); + } else { + this.setVflex(Boolean.toString(vflex)); + } + listPanel.setDetailPaneMode(detailPaneMode, vflex); + } } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/ADTreePanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADTreePanel.java similarity index 98% rename from org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/ADTreePanel.java rename to org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADTreePanel.java index cfc44e64d5..fb71ce0c9e 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/ADTreePanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADTreePanel.java @@ -11,11 +11,12 @@ * with this program; if not, write to the Free Software Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * *****************************************************************************/ -package org.adempiere.webui.panel; +package org.adempiere.webui.adwindow; import org.adempiere.webui.component.SimpleTreeModel; import org.adempiere.webui.component.ToolBarButton; +import org.adempiere.webui.panel.TreeSearchPanel; import org.adempiere.webui.util.TreeUtils; import org.compiere.util.Env; import org.compiere.util.Msg; diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/ADWindow.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADWindow.java similarity index 86% rename from org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/ADWindow.java rename to org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADWindow.java index ac5de152fa..4b706350c4 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/ADWindow.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADWindow.java @@ -15,12 +15,11 @@ * or via info@posterita.org or http://www.posterita.org/ * *****************************************************************************/ -package org.adempiere.webui.window; +package org.adempiere.webui.adwindow; import java.util.Properties; import org.adempiere.webui.desktop.IDesktop; -import org.adempiere.webui.panel.ADWindowPanel; import org.adempiere.webui.part.AbstractUIPart; import org.adempiere.webui.session.SessionManager; import org.compiere.model.MQuery; @@ -34,7 +33,7 @@ import org.zkoss.zk.ui.Component; */ public class ADWindow extends AbstractUIPart { - private ADWindowPanel windowPanel; + private ADWindowContent windowContent; private Properties ctx; private int adWindowId; private String _title; @@ -63,7 +62,7 @@ public class ADWindow extends AbstractUIPart private void init() { - windowPanel = new ADWindowPanel(ctx, windowNo); + windowContent = new ADWindowContent(ctx, windowNo); } public String getTitle() @@ -73,12 +72,12 @@ public class ADWindow extends AbstractUIPart protected Component doCreatePart(Component parent) { - windowPanelComponent = windowPanel.createPart(parent); + windowPanelComponent = windowContent.createPart(parent); windowPanelComponent.setAttribute("ADWindow", this); windowPanelComponent.setAttribute(IDesktop.WINDOWNO_ATTRIBUTE, windowNo); - if (windowPanel.initPanel(adWindowId, query)) + if (windowContent.initPanel(adWindowId, query)) { - _title = windowPanel.getTitle(); + _title = windowContent.getTitle(); return windowPanelComponent; } else @@ -93,9 +92,9 @@ public class ADWindow extends AbstractUIPart } /** - * @return ADWindowPanel + * @return ADWindowContent */ - public ADWindowPanel getADWindowPanel() { - return windowPanel; + public ADWindowContent getADWindowContent() { + return windowContent; } } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/ADWindowPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADWindowContent.java similarity index 73% rename from org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/ADWindowPanel.java rename to org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADWindowContent.java index 14b05a7882..29a0b287bc 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/ADWindowPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADWindowContent.java @@ -21,17 +21,16 @@ * - Idalica Corporation * *****************************************************************************/ -package org.adempiere.webui.panel; +package org.adempiere.webui.adwindow; import java.util.List; import java.util.Properties; import org.adempiere.webui.LayoutUtils; -import org.adempiere.webui.component.CompositeADTab; -import org.adempiere.webui.component.IADTab; import org.adempiere.webui.component.Tabbox; import org.adempiere.webui.component.Tabpanel; import org.adempiere.webui.component.Tabs; +import org.adempiere.webui.panel.ITabOnCloseHandler; import org.adempiere.webui.part.ITabOnSelectHandler; import org.adempiere.webui.session.SessionManager; import org.adempiere.webui.util.UserPreference; @@ -48,6 +47,7 @@ import org.zkoss.zk.ui.event.Events; import org.zkoss.zk.ui.event.KeyEvent; import org.zkoss.zul.Borderlayout; import org.zkoss.zul.Center; +import org.zkoss.zul.Div; import org.zkoss.zul.East; import org.zkoss.zul.North; import org.zkoss.zul.South; @@ -64,10 +64,10 @@ import org.zkoss.zul.West; * @date Feb 25, 2007 * @version $Revision: 0.10 $ */ -public class ADWindowPanel extends AbstractADWindowPanel +public class ADWindowContent extends AbstractADWindowContent { @SuppressWarnings("unused") - private static final CLogger logger = CLogger.getCLogger(ADWindowPanel.class); + private static final CLogger logger = CLogger.getCLogger(ADWindowContent.class); private Borderlayout layout; @@ -77,15 +77,14 @@ public class ADWindowPanel extends AbstractADWindowPanel private East east; - private Keylistener keyListener; + private Keylistener keyListener; - public ADWindowPanel(Properties ctx, int windowNo) + public ADWindowContent(Properties ctx, int windowNo) { super(ctx, windowNo); } - - protected Component doCreatePart(Component parent) + protected Component doCreatePart(Component parent) { layout = new Borderlayout(); if (parent != null) { @@ -100,8 +99,15 @@ public class ADWindowPanel extends AbstractADWindowPanel n.setParent(layout); n.setCollapsible(false); n.setSclass("adwindow-north"); - toolbar.setParent(n); + Div div = new Div(); + div.setHflex("1"); + div.setVflex("1"); + n.appendChild(div); + toolbar.setParent(div); toolbar.setWindowNo(getWindowNo()); + breadCrumb = new BreadCrumb(getWindowNo()); + breadCrumb.setToolbarListener(this); + div.appendChild(breadCrumb); //status bar South s = new South(); @@ -112,51 +118,10 @@ public class ADWindowPanel extends AbstractADWindowPanel LayoutUtils.addSclass("adwindow-status", statusBar); - if (adTab.isUseExternalSelection()) - { - String tabPlacement = SessionManager.getSessionApplication().getUserPreference().getProperty(UserPreference.P_WINDOW_TAB_PLACEMENT); - if (tabPlacement == null || "left".equalsIgnoreCase(tabPlacement)) - { - west = new West(); - layout.appendChild(west); - west.setSplittable(false); - west.setAutoscroll(true); - west.setFlex(true); - LayoutUtils.addSclass("adwindow-nav adwindow-left-nav", west); - adTab.setTabplacement(IADTab.LEFT); - adTab.getTabSelectionComponent().setParent(west); - - if (SessionManager.getSessionApplication().getUserPreference().isPropertyBool(UserPreference.P_WINDOW_TAB_COLLAPSIBLE)) - { - west.setTitle(Msg.getElement(Env.getCtx(), "AD_Tab_ID")); - west.setCollapsible(true); - } - } - else - { - east = new East(); - layout.appendChild(east); - east.setSplittable(false); - east.setAutoscroll(true); - east.setFlex(true); - LayoutUtils.addSclass("adwindow-nav adwindow-right-nav", east); - adTab.setTabplacement(IADTab.RIGHT); - adTab.getTabSelectionComponent().setParent(east); - - if (SessionManager.getSessionApplication().getUserPreference().isPropertyBool(UserPreference.P_WINDOW_TAB_COLLAPSIBLE)) - { - east.setTitle(Msg.getElement(Env.getCtx(), "AD_Tab_ID")); - east.setCollapsible(true); - } - } - LayoutUtils.addSclass("adwindow-nav-content", (HtmlBasedComponent) adTab.getTabSelectionComponent()); - } - contentArea = new Center(); contentArea.setParent(layout); contentArea.setAutoscroll(true); - contentArea.setFlex(true); - adTab.createPart(contentArea); + adTabbox.createPart(contentArea); if (parent instanceof Tabpanel) { TabOnCloseHanlder handler = new TabOnCloseHanlder(); @@ -174,7 +139,7 @@ public class ADWindowPanel extends AbstractADWindowPanel layout.setAttribute(ITabOnSelectHandler.ATTRIBUTE_KEY, new ITabOnSelectHandler() { public void onSelect() { - IADTab adTab = getADTab(); + IADTabbox adTab = getADTab(); if (adTab != null) { IADTabpanel iadTabpanel = adTab.getSelectedTabpanel(); if (iadTabpanel != null && iadTabpanel instanceof ADTabpanel) { @@ -191,9 +156,9 @@ public class ADWindowPanel extends AbstractADWindowPanel return layout; } - protected IADTab createADTab() + protected IADTabbox createADTab() { - CompositeADTab composite = new CompositeADTab(); + CompositeADTabbox composite = new CompositeADTabbox(); return composite; } @@ -206,7 +171,7 @@ public class ADWindowPanel extends AbstractADWindowPanel @Override public boolean initPanel(int adWindowId, MQuery query) { boolean retValue = super.initPanel(adWindowId, query); - if (adTab.getTabCount() == 1) { + if (adTabbox.getTabCount() == 1) { if (west != null) west.setVisible(false); else if (east != null) @@ -225,7 +190,7 @@ public class ADWindowPanel extends AbstractADWindowPanel KeyEvent keyEvent = (KeyEvent) event; //enter == 13 if (keyEvent.getKeyCode() == 13 && this.getComponent().getParent().isVisible()) { - IADTabpanel panel = adTab.getSelectedTabpanel(); + IADTabpanel panel = adTabbox.getSelectedTabpanel(); if (panel != null) { if (panel.onEnterKey()) { keyEvent.stopPropagation(); @@ -240,7 +205,7 @@ public class ADWindowPanel extends AbstractADWindowPanel class TabOnCloseHanlder implements ITabOnCloseHandler { public void onClose(Tabpanel tabPanel) { - if (ADWindowPanel.this.onExit()) { + if (ADWindowContent.this.onExit()) { Tab tab = tabPanel.getLinkedTab(); Tabbox tabbox = (Tabbox) tab.getTabbox(); if (tabbox.getSelectedTab() == tab) { diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/CWindowToolbar.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADWindowToolbar.java similarity index 92% rename from org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/CWindowToolbar.java rename to org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADWindowToolbar.java index 14bd500e44..7d1a47ca06 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/CWindowToolbar.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADWindowToolbar.java @@ -15,7 +15,7 @@ * or via info@posterita.org or http://www.posterita.org/ * *****************************************************************************/ -package org.adempiere.webui.component; +package org.adempiere.webui.adwindow; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -28,6 +28,8 @@ import java.util.logging.Level; import org.adempiere.webui.AdempiereIdGenerator; import org.adempiere.webui.LayoutUtils; +import org.adempiere.webui.component.FToolbar; +import org.adempiere.webui.component.ToolBarButton; import org.adempiere.webui.event.ToolbarListener; import org.adempiere.webui.session.SessionManager; import org.compiere.model.MRole; @@ -52,7 +54,7 @@ import org.zkoss.zul.Space; * @author Cristina Ghita, www.arhipac.ro *
  • FR [ 2076330 ] Add new methods in CWindowToolbar class */ -public class CWindowToolbar extends FToolbar implements EventListener +public class ADWindowToolbar extends FToolbar implements EventListener { /** * @@ -61,7 +63,7 @@ public class CWindowToolbar extends FToolbar implements EventListener private static final String BTNPREFIX = "Btn"; - private static CLogger log = CLogger.getCLogger(CWindowToolbar.class); + private static CLogger log = CLogger.getCLogger(ADWindowToolbar.class); private ToolBarButton btnIgnore; @@ -75,8 +77,6 @@ public class CWindowToolbar extends FToolbar implements EventListener private ToolBarButton btnParentRecord, btnDetailRecord; - private ToolBarButton btnFirst, btnPrevious, btnNext, btnLast; - private ToolBarButton btnReport, btnArchive, btnPrint; private ToolBarButton btnZoomAcross, btnActiveWorkflows, btnRequests, btnProductInfo; @@ -114,12 +114,12 @@ public class CWindowToolbar extends FToolbar implements EventListener // public int lastModifiers; // - public CWindowToolbar() + public ADWindowToolbar() { this(0); } - public CWindowToolbar(int windowNo) { + public ADWindowToolbar(int windowNo) { setWindowNo(windowNo); init(); } @@ -145,11 +145,7 @@ public class CWindowToolbar extends FToolbar implements EventListener btnGridToggle = createButton("Toggle", "Multi", "Multi"); addSeparator(); btnParentRecord = createButton("ParentRecord", "Parent", "Parent"); - btnDetailRecord = createButton("DetailRecord", "Detail", "Detail"); - btnFirst = createButton("First", "First", "First"); - btnPrevious = createButton("Previous", "Previous", "Previous"); - btnNext = createButton("Next", "Next", "Next"); - btnLast = createButton("Last", "Last", "Last"); + btnDetailRecord = createButton("DetailRecord", "Detail", "Detail"); addSeparator(); btnReport = createButton("Report", "Report", "Report"); btnArchive = createButton("Archive", "Archive", "Archive"); @@ -259,11 +255,7 @@ public class CWindowToolbar extends FToolbar implements EventListener keyMap.put(KeyEvent.F12, btnPrint); altKeyMap.put(KeyEvent.LEFT, btnParentRecord); - altKeyMap.put(KeyEvent.RIGHT, btnDetailRecord); - altKeyMap.put(KeyEvent.UP, btnPrevious); - altKeyMap.put(KeyEvent.DOWN, btnNext); - altKeyMap.put(KeyEvent.PAGE_UP, btnFirst); - altKeyMap.put(KeyEvent.PAGE_DOWN, btnLast); + altKeyMap.put(KeyEvent.RIGHT, btnDetailRecord); altKeyMap.put(VK_P, btnReport); altKeyMap.put(VK_Z, btnIgnore); @@ -363,15 +355,7 @@ public class CWindowToolbar extends FToolbar implements EventListener } this.event = null; } - - public void enableNavigation(boolean enabled) - { - this.btnFirst.setDisabled(!enabled); - this.btnPrevious.setDisabled(!enabled); - this.btnNext.setDisabled(!enabled); - this.btnLast.setDisabled(!enabled); - } - + public void enableTabNavigation(boolean enabled) { enableTabNavigation(enabled, enabled); @@ -383,18 +367,6 @@ public class CWindowToolbar extends FToolbar implements EventListener this.btnDetailRecord.setDisabled(!enableDetail); } - public void enableFirstNavigation(boolean enabled) - { - this.btnFirst.setDisabled(!enabled); - this.btnPrevious.setDisabled(!enabled); - } - - public void enableLastNavigation(boolean enabled) - { - this.btnLast.setDisabled(!enabled); - this.btnNext.setDisabled(!enabled); - } - public void enableRefresh(boolean enabled) { this.btnRefresh.setDisabled(!enabled); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/AbstractADTab.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADTabbox.java similarity index 95% rename from org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/AbstractADTab.java rename to org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADTabbox.java index cb7a22bce6..1ca071106b 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/AbstractADTab.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADTabbox.java @@ -15,16 +15,13 @@ * or via info@posterita.org or http://www.posterita.org/ * *****************************************************************************/ -package org.adempiere.webui.component; +package org.adempiere.webui.adwindow; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import org.adempiere.webui.panel.ADTabpanel; -import org.adempiere.webui.panel.AbstractADWindowPanel; import org.adempiere.webui.panel.CustomizeGridViewPanel; -import org.adempiere.webui.panel.IADTabpanel; import org.adempiere.webui.part.AbstractUIPart; import org.compiere.model.DataStatusEvent; import org.compiere.model.GridField; @@ -41,18 +38,18 @@ import org.compiere.util.Evaluator; * @date Feb 25, 2007 * @version $Revision: 0.10 $ */ -public abstract class AbstractADTab extends AbstractUIPart implements IADTab +public abstract class AbstractADTabbox extends AbstractUIPart implements IADTabbox { /** Logger */ - private static CLogger log = CLogger.getCLogger (AbstractADTab.class); + private static CLogger log = CLogger.getCLogger (AbstractADTabbox.class); /** List of dependent Variables */ private ArrayList m_dependents = new ArrayList(); /** Tabs associated to this tab box */ protected List tabPanelList = new ArrayList(); - protected AbstractADWindowPanel adWindowPanel; + protected AbstractADWindowContent adWindowPanel; - public AbstractADTab() + public AbstractADTabbox() { } @@ -336,7 +333,7 @@ public abstract class AbstractADTab extends AbstractUIPart implements IADTab updateSelectedIndex(oldIndex, newIndex); } - public void setADWindowPanel(AbstractADWindowPanel abstractADWindowPanel) { + public void setADWindowPanel(AbstractADWindowContent abstractADWindowPanel) { this.adWindowPanel = abstractADWindowPanel; } } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/AbstractADWindowPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADWindowContent.java similarity index 69% rename from org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/AbstractADWindowPanel.java rename to org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADWindowContent.java index 8d81abd1bf..931fd81560 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/AbstractADWindowPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADWindowContent.java @@ -15,7 +15,7 @@ * or via info@posterita.org or http://www.posterita.org/ * *****************************************************************************/ -package org.adempiere.webui.panel; +package org.adempiere.webui.adwindow; import static org.compiere.model.SystemIDs.PROCESS_AD_CHANGELOG_REDO; import static org.compiere.model.SystemIDs.PROCESS_AD_CHANGELOG_UNDO; @@ -44,10 +44,8 @@ import org.adempiere.webui.apps.ProcessModalDialog; import org.adempiere.webui.apps.form.WCreateFromFactory; import org.adempiere.webui.apps.form.WCreateFromWindow; import org.adempiere.webui.apps.form.WPayment; -import org.adempiere.webui.component.CWindowToolbar; -import org.adempiere.webui.component.IADTab; -import org.adempiere.webui.component.IADTabList; import org.adempiere.webui.component.Listbox; +import org.adempiere.webui.component.ToolBarButton; import org.adempiere.webui.component.Window; import org.adempiere.webui.editor.WButtonEditor; import org.adempiere.webui.event.ActionEvent; @@ -55,6 +53,10 @@ import org.adempiere.webui.event.ActionListener; import org.adempiere.webui.event.DialogEvents; import org.adempiere.webui.event.ToolbarListener; import org.adempiere.webui.exception.ApplicationException; +import org.adempiere.webui.panel.ADForm; +import org.adempiere.webui.panel.InfoPanel; +import org.adempiere.webui.panel.WAttachment; +import org.adempiere.webui.panel.WDocActionPanel; import org.adempiere.webui.panel.action.ExportAction; import org.adempiere.webui.panel.action.ReportAction; import org.adempiere.webui.part.AbstractUIPart; @@ -126,35 +128,31 @@ import org.zkoss.zul.Menupopup; *
  • BF [ 2985892 ] Opening a window using a new record query is not working * https://sourceforge.net/tracker/?func=detail&aid=2985892&group_id=176962&atid=955896 */ -public abstract class AbstractADWindowPanel extends AbstractUIPart implements ToolbarListener, +public abstract class AbstractADWindowContent extends AbstractUIPart implements ToolbarListener, EventListener, DataStatusListener, ActionListener { private static final CLogger logger; static { - logger = CLogger.getCLogger(AbstractADWindowPanel.class); + logger = CLogger.getCLogger(AbstractADWindowContent.class); } private Properties ctx; private GridWindow gridWindow; - protected StatusBarPanel statusBar; + protected StatusBar statusBar; - protected IADTab adTab; + protected IADTabbox adTabbox; private int curWindowNo; - private GridTab curTab; +// private GridTab curTab; private boolean m_onlyCurrentRows = true; - private IADTabpanel curTabpanel; - - protected CWindowToolbar toolbar; - - private int curTabIndex; + protected ADWindowToolbar toolbar; protected String title; @@ -172,12 +170,14 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To private boolean m_queryInitiating; + protected BreadCrumb breadCrumb; + /** * Constructor * @param ctx * @param windowNo */ - public AbstractADWindowPanel(Properties ctx, int windowNo) + public AbstractADWindowContent(Properties ctx, int windowNo) { this.ctx = ctx; this.curWindowNo = windowNo; @@ -194,17 +194,22 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To if (parent instanceof Component) this.parent = (Component) parent; - adTab = createADTab(); - adTab.addSelectionEventListener(this); - adTab.setADWindowPanel(this); + adTabbox = createADTab(); + adTabbox.setSelectionEventListener(this); + adTabbox.setADWindowPanel(this); return super.createPart(parent); } + public BreadCrumb getBreadCrumb() + { + return breadCrumb; + } + /** * @return StatusBarPanel */ - public StatusBarPanel getStatusBar() + public StatusBar getStatusBar() { return statusBar; } @@ -212,24 +217,28 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To private void initComponents() { /** Initalise toolbar */ - toolbar = new CWindowToolbar(getWindowNo()); + toolbar = new ADWindowToolbar(getWindowNo()); toolbar.addListener(this); - statusBar = new StatusBarPanel(); + statusBar = new StatusBar(); } /** * @return IADTab */ - protected abstract IADTab createADTab(); + protected abstract IADTabbox createADTab(); private void focusToActivePanel() { - IADTabpanel adTabPanel = adTab.getSelectedTabpanel(); + IADTabpanel adTabPanel = adTabbox.getSelectedTabpanel(); + focusToTabpanel(adTabPanel); + } + + private void focusToTabpanel(IADTabpanel adTabPanel ) { if (adTabPanel != null && adTabPanel instanceof HtmlBasedComponent) { ((HtmlBasedComponent)adTabPanel).focus(); } } - + /** * @param adWindowId * @param query @@ -301,25 +310,24 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To int tabSize = gridWindow.getTabCount(); + GridTab gridTab = null; for (int tab = 0; tab < tabSize; tab++) { - initTab(query, tab); - if (tab == 0 && curTab == null && m_findCancelled) + gridTab = initTab(query, tab); + if (tab == 0 && gridTab == null && m_findCancelled) return false; } Env.setContext(ctx, curWindowNo, "WindowName", gridWindow.getName()); - if (curTab != null) - curTab.getTableModel().setChanged(false); + if (gridTab != null) + gridTab.getTableModel().setChanged(false); - curTabIndex = 0; - - adTab.setSelectedIndex(0); + adTabbox.setSelectedIndex(0); // all fields context for window is clear at AbstractADTab.prepareContext, set again IsSOTrx for window Env.setContext(ctx, curWindowNo, "IsSOTrx", gridWindow.isSOTrx()); - toolbar.enableTabNavigation(adTab.getTabCount() > 1); + toolbar.enableTabNavigation(adTabbox.getTabCount() > 1); toolbar.enableFind(true); - adTab.evaluate(null); + adTabbox.evaluate(null); if (detailQuery != null && zoomToDetailTab(detailQuery)) { @@ -410,7 +418,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To MQuery pquery = new MQuery(pTab.getAD_Table_ID()); pquery.addRestriction((String)value[0], "=", value[1]); pTab.setQuery(pquery); - IADTabpanel tp = adTab.findADTabpanel(pTab); + IADTabpanel tp = adTabbox.findADTabpanel(pTab); tp.createUI(); tp.query(); } @@ -419,7 +427,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To targetQuery.addRestriction(gTab.getLinkColumnName(), "=", parentId); gTab.setQuery(targetQuery); IADTabpanel gc = null; - gc = adTab.findADTabpanel(gTab); + gc = adTabbox.findADTabpanel(gTab); gc.createUI(); gc.query(false, 0, 0); @@ -442,6 +450,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To } private void initQueryOnNew(MQuery result) { + GridTab curTab = adTabbox.getSelectedGridTab(); if (curTab.isHighVolume() && m_findCreateNew) onNew(); else if (result == null && curTab.getRowCount() == 0 && Env.isAutoNew(ctx, curWindowNo)) @@ -454,7 +463,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To * @param query * @param tabIndex */ - protected void initTab(MQuery query, int tabIndex) { + protected GridTab initTab(MQuery query, int tabIndex) { gridWindow.initTab(tabIndex); final GridTab gTab = gridWindow.getTab(tabIndex); @@ -485,7 +494,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To gTab.setQuery(result); } - if (curTabpanel != null) + if (adTabbox.getSelectedTabpanel() != null) { initFirstTabpanel(); @@ -495,18 +504,16 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To }); - curTab = gTab; - curTabIndex = tabIndex; +// curTab = gTab; } if (gTab.isSortTab()) { ADSortTab sortTab = new ADSortTab(curWindowNo, gTab); - adTab.addTab(gTab, sortTab); + adTabbox.addTab(gTab, sortTab); sortTab.registerAPanel(this); if (tabIndex == 0) { - curTabpanel = sortTab; - curTabpanel.createUI(); + sortTab.createUI(); if (!m_queryInitiating) { initFirstTabpanel(); @@ -519,10 +526,9 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To ADTabpanel fTabPanel = new ADTabpanel(); gTab.addDataStatusListener(this); fTabPanel.init(this, curWindowNo, gTab, gridWindow); - adTab.addTab(gTab, fTabPanel); + adTabbox.addTab(gTab, fTabPanel); if (tabIndex == 0) { fTabPanel.createUI(); - curTabpanel = fTabPanel; if (!m_queryInitiating) { initFirstTabpanel(); @@ -534,11 +540,13 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To initQueryOnNew(query); } } + + return gTab; } private void initFirstTabpanel() { - curTabpanel.query(m_onlyCurrentRows, m_onlyCurrentDays, MRole.getDefault().getMaxQueryRecords()); - curTabpanel.activate(true); + adTabbox.getSelectedTabpanel().query(m_onlyCurrentRows, m_onlyCurrentDays, MRole.getDefault().getMaxQueryRecords()); + adTabbox.getSelectedTabpanel().activate(true); } /** @@ -650,6 +658,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To */ public void onDetailRecord() { + /* int maxInd = adTab.getTabCount() - 1; int curInd = adTab.getSelectedIndex(); if (curInd < maxInd) @@ -661,7 +670,8 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To focusToActivePanel(); } }); - } + }*/ + adTabbox.onDetailRecord(); } /** @@ -669,16 +679,17 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To */ public void onParentRecord() { - int curInd = adTab.getSelectedIndex(); - if (curInd > 0) - { - setActiveTab(curInd - 1, new Callback() { - @Override - public void onCallback(Boolean result) { - focusToActivePanel(); - } - }); - } +// int curInd = adTab.getSelectedIndex(); +// if (curInd > 0) +// { +// setActiveTab(curInd - 1, new Callback() { +// @Override +// public void onCallback(Boolean result) { +// focusToActivePanel(); +// } +// }); +// } + adTabbox.onParentRecord(); } /** @@ -690,7 +701,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To @Override public void onCallback(Boolean result) { if (result) { - curTab.navigate(0); + adTabbox.getSelectedGridTab().navigate(0); focusToActivePanel(); } } @@ -707,7 +718,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To @Override public void onCallback(Boolean result) { if (result) { - curTab.navigate(curTab.getRowCount() - 1); + adTabbox.getSelectedGridTab().navigate(adTabbox.getSelectedGridTab().getRowCount() - 1); focusToActivePanel(); } } @@ -724,7 +735,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To @Override public void onCallback(Boolean result) { if (result) { - curTab.navigateRelative(+1); + adTabbox.getSelectedGridTab().navigateRelative(+1); focusToActivePanel(); } } @@ -741,7 +752,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To @Override public void onCallback(Boolean result) { if (result) { - curTab.navigateRelative(-1); + adTabbox.getSelectedGridTab().navigateRelative(-1); focusToActivePanel(); } } @@ -763,7 +774,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To { if (!toolbar.isPersonalLock) return; - if (curTab.getRecord_ID() == -1) // No Key + if (adTabbox.getSelectedGridTab().getRecord_ID() == -1) // No Key return; if(m_popup == null) @@ -776,10 +787,10 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To { public void onEvent(Event event) throws Exception { - curTab.lock(Env.getCtx(), curTab.getRecord_ID(), !toolbar.getButton("Lock").isPressed()); - curTab.loadAttachments(); // reload + adTabbox.getSelectedGridTab().lock(Env.getCtx(), adTabbox.getSelectedGridTab().getRecord_ID(), !toolbar.getButton("Lock").isPressed()); + adTabbox.getSelectedGridTab().loadAttachments(); // reload - toolbar.lock(curTab.isLocked()); + toolbar.lock(adTabbox.getSelectedGridTab().isLocked()); } }); @@ -789,12 +800,12 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To { public void onEvent(Event event) throws Exception { - WRecordAccessDialog recordAccessDialog = new WRecordAccessDialog(null, curTab.getAD_Table_ID(), curTab.getRecord_ID()); + WRecordAccessDialog recordAccessDialog = new WRecordAccessDialog(null, adTabbox.getSelectedGridTab().getAD_Table_ID(), adTabbox.getSelectedGridTab().getRecord_ID()); recordAccessDialog.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener() { @Override public void onEvent(Event event) throws Exception { - toolbar.lock(curTab.isLocked()); + toolbar.lock(adTabbox.getSelectedGridTab().isLocked()); } }); @@ -814,7 +825,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To */ public void onAttachment() { - int record_ID = curTab.getRecord_ID(); + int record_ID = adTabbox.getSelectedGridTab().getRecord_ID(); logger.info("Record_ID=" + record_ID); if (record_ID == -1) // No Key @@ -827,19 +838,19 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To @Override public void onEvent(Event event) throws Exception { - curTab.loadAttachments(); // reload - toolbar.getButton("Attachment").setPressed(curTab.hasAttachment()); + adTabbox.getSelectedGridTab().loadAttachments(); // reload + toolbar.getButton("Attachment").setPressed(adTabbox.getSelectedGridTab().hasAttachment()); focusToActivePanel(); } }; // Attachment va = - new WAttachment ( curWindowNo, curTab.getAD_AttachmentID(), - curTab.getAD_Table_ID(), record_ID, null, listener); + new WAttachment ( curWindowNo, adTabbox.getSelectedGridTab().getAD_AttachmentID(), + adTabbox.getSelectedGridTab().getAD_Table_ID(), record_ID, null, listener); } public void onChat() { - int recordId = curTab.getRecord_ID(); + int recordId = adTabbox.getSelectedGridTab().getRecord_ID(); logger.info("Record_ID=" + recordId); if (recordId== -1) // No Key @@ -850,9 +861,9 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To // Find display String infoName = null; String infoDisplay = null; - for (int i = 0; i < curTab.getFieldCount(); i++) + for (int i = 0; i < adTabbox.getSelectedGridTab().getFieldCount(); i++) { - GridField field = curTab.getField(i); + GridField field = adTabbox.getSelectedGridTab().getField(i); if (field.isKey()) infoName = field.getHeader(); if ((field.getColumnName().equals("Name") || field.getColumnName().equals("DocumentNo") ) @@ -863,12 +874,12 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To } String description = infoName + ": " + infoDisplay; - WChat chat = new WChat(curWindowNo, curTab.getCM_ChatID(), curTab.getAD_Table_ID(), recordId, description, null); + WChat chat = new WChat(curWindowNo, adTabbox.getSelectedGridTab().getCM_ChatID(), adTabbox.getSelectedGridTab().getAD_Table_ID(), recordId, description, null); chat.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener() { @Override public void onEvent(Event event) throws Exception { - curTab.loadChats(); - toolbar.getButton("Chat").setPressed(curTab.hasChat()); + adTabbox.getSelectedGridTab().loadChats(); + toolbar.getButton("Chat").setPressed(adTabbox.getSelectedGridTab().hasChat()); focusToActivePanel(); } }); @@ -880,10 +891,10 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To */ public void onToggle() { - curTabpanel.switchRowPresentation(); + adTabbox.getSelectedTabpanel().switchRowPresentation(); //Deepak-Enabling customize button IDEMPIERE-364 - if(!(curTabpanel instanceof ADSortTab)) - toolbar.enableCustomize(((ADTabpanel)curTabpanel).isGridView()); + if(!(adTabbox.getSelectedTabpanel() instanceof ADSortTab)) + toolbar.enableCustomize(((ADTabpanel)adTabbox.getSelectedTabpanel()).isGridView()); focusToActivePanel(); } @@ -908,47 +919,29 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To */ public void onEvent(Event event) { - if (Events.ON_SELECT.equals(event.getName())) + if (CompositeADTabbox.ON_SELECTION_CHANGED_EVENT.equals(event.getName())) { - IADTabList tabList = null; - Component target = event.getTarget(); - if (target instanceof IADTabList) - { - tabList = (IADTabList) target; - } - else - { - target = target.getParent(); - while(target != null) - { - if (target instanceof IADTabList) - { - tabList = (IADTabList) target; - break; - } - target = target.getParent(); - } - } + Object eventData = event.getData(); - if (tabList != null) + if (eventData != null && eventData instanceof Object[] && ((Object[])eventData).length == 2) { - int newTabIndex = tabList.getSelectedIndex(); + Object[] indexes = (Object[]) eventData; + int newTabIndex = (Integer)indexes[1]; - final IADTabList tabListRef = tabList; - final int originalTabIndex = curTabIndex; + final int originalTabIndex = adTabbox.getSelectedIndex(); + final int originalTabRow = adTabbox.getSelectedGridTab().getCurrentRow(); setActiveTab(newTabIndex, new Callback() { @Override public void onCallback(Boolean result) { if (result) { - //force sync model - tabListRef.refresh(); + adTabbox.setDetailpaneSelection(originalTabIndex, originalTabRow); } else { //reset to original - tabListRef.setSelectedIndex(originalTabIndex); + adTabbox.setSelectedIndex(originalTabIndex); } } @@ -965,7 +958,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To private void setActiveTab(final int newTabIndex, final Callback callback) { - final int oldTabIndex = curTabIndex; + final int oldTabIndex = adTabbox.getSelectedIndex(); if (oldTabIndex == newTabIndex) { @@ -990,23 +983,23 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To } - protected void saveAndNavigate(final Callback callback) { - if (curTab != null) + public void saveAndNavigate(final Callback callback) { + if (adTabbox != null) { - if (curTab.isSortTab()) + if (adTabbox.isSortTab()) { onSave(false, true, callback); } - else if (curTab.needSave(true, false)) + else if (adTabbox.needSave(true, false)) { - if (curTab.needSave(true, true)) + if (adTabbox.needSave(true, true)) { onSave(false, true, callback); } else { // new record, but nothing changed - curTab.dataIgnore(); + adTabbox.dataIgnore(); callback.onCallback(true); } } // there is a change @@ -1020,7 +1013,9 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To private void setActiveTab0(int oldTabIndex, int newTabIndex, final Callback callback) { boolean back = false; - if (!adTab.updateSelectedIndex(oldTabIndex, newTabIndex)) + IADTabpanel oldTabpanel = adTabbox.getSelectedTabpanel(); + + if (!adTabbox.updateSelectedIndex(oldTabIndex, newTabIndex)) { FDialog.warn(curWindowNo, "TabSwitchJumpGo", title); if (callback != null) @@ -1028,13 +1023,14 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To return; } - IADTabpanel oldTabpanel = curTabpanel; - IADTabpanel newTabpanel = adTab.getSelectedTabpanel(); - curTab = newTabpanel.getGridTab(); + + IADTabpanel newTabpanel = adTabbox.getSelectedTabpanel(); + boolean activated = newTabpanel.isActive(); if (oldTabpanel != null) oldTabpanel.activate(false); - newTabpanel.activate(true); + if (activated) + newTabpanel.activate(true); back = (newTabIndex < oldTabIndex); if (back && newTabpanel.getTabLevel() > 0) @@ -1045,7 +1041,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To { for (int i = oldTabIndex - 1; i > newTabIndex; i--) { - IADTabpanel next = adTab.getADTabpanel(i); + IADTabpanel next = adTabbox.getADTabpanel(i); if (next != null && next.getTabLevel() <= newTabpanel.getTabLevel()) { back = false; @@ -1055,31 +1051,33 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To } } - if (!back) +// if (!activated) +// { + if (!back) + { + newTabpanel.query(); + } + else + { + newTabpanel.refresh(); + } +// } + + if (adTabbox.getSelectedTabpanel() instanceof ADSortTab) { - newTabpanel.query(); + ((ADSortTab)adTabbox.getSelectedTabpanel()).registerAPanel(this); } else { - newTabpanel.refresh(); - } - - curTabIndex = newTabIndex; - curTabpanel = newTabpanel; - - if (curTabpanel instanceof ADSortTab) - { - ((ADSortTab)curTabpanel).registerAPanel(this); - } - else - { - if (curTab.getRowCount() == 0 && Env.isAutoNew(ctx, getWindowNo())) + if (adTabbox.getSelectedGridTab().getRowCount() == 0 && Env.isAutoNew(ctx, getWindowNo())) { onNew(); } } updateToolbar(); + + breadCrumb.setNavigationToolbarVisibility(!adTabbox.getSelectedGridTab().isSortTab()); if (callback != null) callback.onCallback(true); @@ -1087,23 +1085,24 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To private void updateToolbar() { - toolbar.enableTabNavigation(curTabIndex > 0, - curTabIndex < (adTab.getTabCount() - 1)); +// toolbar.enableTabNavigation(adTab.getSelectedGridTab()Index > 0, +// adTab.getSelectedGridTab()Index < (adTab.getTabCount() - 1)); + toolbar.enableTabNavigation(adTabbox.getTabCount() > 1, adTabbox.getTabCount() > 1); - toolbar.getButton("Attachment").setPressed(curTab.hasAttachment()); - toolbar.getButton("Chat").setPressed(curTab.hasChat()); - toolbar.getButton("Find").setPressed(curTab.isQueryActive()); + toolbar.getButton("Attachment").setPressed(adTabbox.getSelectedGridTab().hasAttachment()); + toolbar.getButton("Chat").setPressed(adTabbox.getSelectedGridTab().hasChat()); + toolbar.getButton("Find").setPressed(adTabbox.getSelectedGridTab().isQueryActive()); if (toolbar.isPersonalLock) { - toolbar.lock(curTab.isLocked()); + toolbar.lock(adTabbox.getSelectedGridTab().isLocked()); } - toolbar.enablePrint(curTab.isPrinted()); + toolbar.enablePrint(adTabbox.getSelectedGridTab().isPrinted()); //Deepak-Enabling customize button IDEMPIERE-364 - if(!(curTabpanel instanceof ADSortTab)) - toolbar.enableCustomize(((ADTabpanel)curTabpanel).isGridView()); + if(!(adTabbox.getSelectedTabpanel() instanceof ADSortTab)) + toolbar.enableCustomize(((ADTabpanel)adTabbox.getSelectedTabpanel()).isGridView()); else toolbar.enableCustomize(false); } @@ -1114,56 +1113,87 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To */ public void dataStatusChanged(DataStatusEvent e) { - //ignore non-ui thread event for now. + //ignore non-ui thread event. if (Executions.getCurrent() == null) return; + + boolean detailTab = false; + if (e.getSource() instanceof GridTable) + { + GridTable gridTable = (GridTable) e.getSource(); + if (adTabbox.getSelectedGridTab() != null && adTabbox.getSelectedGridTab().getTableModel() != gridTable) { + detailTab = true; + } + } else if (e.getSource() instanceof GridTab) + { + GridTab gridTab = (GridTab)e.getSource(); + if (adTabbox.getSelectedGridTab() != gridTab) detailTab = true; + } - logger.info(e.getMessage()); - String dbInfo = e.getMessage(); - if (curTab != null && curTab.isQueryActive()) - dbInfo = "[ " + dbInfo + " ]"; - statusBar.setStatusDB(dbInfo, e); + if (!detailTab) + { + logger.info(e.getMessage()); + String dbInfo = e.getMessage(); + if (adTabbox.getSelectedGridTab() != null && adTabbox.getSelectedGridTab().isQueryActive()) + dbInfo = "[ " + dbInfo + " ]"; + breadCrumb.setStatusDB(dbInfo, e); + } // Set Message / Info if (e.getAD_Message() != null || e.getInfo() != null) { - StringBuffer sb = new StringBuffer(); - String msg = e.getMessage(); - if (msg != null && msg.length() > 0) - { - sb.append(Msg.getMsg(Env.getCtx(), e.getAD_Message())); - } - String info = e.getInfo(); - if (info != null && info.length() > 0) - { - if (sb.length() > 0 && !sb.toString().trim().endsWith(":")) - sb.append(": "); - sb.append(info); - } - if (sb.length() > 0) - { - int pos = sb.indexOf("\n"); - if (pos != -1 && pos+1 < sb.length()) // replace CR/NL - { - sb.replace(pos, pos+1, " - "); - } - boolean showPopup = e.isError() - || (!GridTab.DEFAULT_STATUS_MESSAGE.equals(e.getAD_Message()) && !GridTable.DATA_REFRESH_MESSAGE.equals(e.getAD_Message())); - statusBar.setStatusLine (sb.toString (), e.isError (), showPopup); - } + if (GridTab.DEFAULT_STATUS_MESSAGE.equals(e.getAD_Message())) + { + if (detailTab) { + adTabbox.setDetailPaneStatusMessage("", false); + } else { + breadCrumb.setStatusLine ("", false); + } + } + else + { + StringBuffer sb = new StringBuffer(); + String msg = e.getMessage(); + if (msg != null && msg.length() > 0) + { + sb.append(Msg.getMsg(Env.getCtx(), e.getAD_Message())); + } + String info = e.getInfo(); + if (info != null && info.length() > 0) + { + if (sb.length() > 0 && !sb.toString().trim().endsWith(":")) + sb.append(": "); + sb.append(info); + } + if (sb.length() > 0) + { + int pos = sb.indexOf("\n"); + if (pos != -1 && pos+1 < sb.length()) // replace CR/NL + { + sb.replace(pos, pos+1, " - "); + } + if (detailTab) { + adTabbox.setDetailPaneStatusMessage(sb.toString (), e.isError ()); + } else { + breadCrumb.setStatusLine (sb.toString (), e.isError ()); + } + } + } } + IADTabpanel tabPanel = detailTab ? adTabbox.getSelectedDetailADTabpanel() + : getADTab().getSelectedTabpanel(); + // Confirm Error - if (e.isError() && !e.isConfirmed()) + if (e.isError() && !e.isConfirmed() && tabPanel instanceof ADTabpanel) { - //focus to error field - ADTabpanel tabPanel = (ADTabpanel) getADTab().getSelectedTabpanel(); - GridField[] fields = curTab.getFields(); + //focus to error field + GridField[] fields = tabPanel.getGridTab().getFields(); for (GridField field : fields) { if (field.isError()) { - tabPanel.setFocusToField(field.getColumnName()); + ((ADTabpanel)tabPanel).setFocusToField(field.getColumnName()); break; } } @@ -1176,39 +1206,40 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To e.setConfirmed(true); // show just once - if MTable.setCurrentRow is involved the status event is re-issued } - // update Navigation - boolean firstRow = e.isFirstRow(); - boolean lastRow = e.isLastRow(); - toolbar.enableFirstNavigation(!firstRow && !curTab.isSortTab()); - toolbar.enableLastNavigation(!lastRow && !curTab.isSortTab()); - - // update Change boolean changed = e.isChanged() || e.isInserting(); - boolChanges = changed; - boolean readOnly = curTab.isReadOnly(); + boolean readOnly = tabPanel.getGridTab().isReadOnly(); boolean insertRecord = !readOnly; - - if (insertRecord) + if (!detailTab) { - insertRecord = curTab.isInsertRecord(); + // update Change + boolChanges = changed; + + if (insertRecord) + { + insertRecord = tabPanel.getGridTab().isInsertRecord(); + } + toolbar.enableNew(!changed && insertRecord && !tabPanel.getGridTab().isSortTab()); + toolbar.enableRefresh(!changed); + toolbar.enableDelete(!changed && !readOnly && !tabPanel.getGridTab().isSortTab()); + // + if (readOnly && adTabbox.getSelectedGridTab().isAlwaysUpdateField()) + { + readOnly = false; + } } - toolbar.enableNew(!changed && insertRecord && !curTab.isSortTab()); - toolbar.enableRefresh(!changed); - toolbar.enableDelete(!changed && !readOnly && !curTab.isSortTab()); - // - if (readOnly && curTab.isAlwaysUpdateField()) + else { - readOnly = false; + adTabbox.updateDetailPaneToolbar(changed, readOnly); } - toolbar.enableIgnore(changed && !readOnly); + toolbar.enableIgnore(adTabbox.needSave(true, false)); if (changed && !readOnly && !toolbar.isSaveEnable() ) { - if (curTab.getRecord_ID() > 0) { - if (curTabIndex == 0) { - MRecentItem.addModifiedField(ctx, curTab.getAD_Table_ID(), - curTab.getRecord_ID(), Env.getAD_User_ID(ctx), - Env.getAD_Role_ID(ctx), curTab.getAD_Window_ID(), - curTab.getAD_Tab_ID()); + if (tabPanel.getGridTab().getRecord_ID() > 0) { + if (adTabbox.getSelectedIndex() == 0 && !detailTab) { + MRecentItem.addModifiedField(ctx, adTabbox.getSelectedGridTab().getAD_Table_ID(), + adTabbox.getSelectedGridTab().getRecord_ID(), Env.getAD_User_ID(ctx), + Env.getAD_Role_ID(ctx), adTabbox.getSelectedGridTab().getAD_Window_ID(), + adTabbox.getSelectedGridTab().getAD_Tab_ID()); } else { /* when a detail record is modified add header to recent items */ GridTab mainTab = gridWindow.getTab(0); @@ -1222,38 +1253,46 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To } } - toolbar.enableSave(changed && !readOnly); + toolbar.enableSave(adTabbox.needSave(true, false)); + if (detailTab) { + ToolBarButton btn = toolbar.getButton("SaveCreate"); + if (btn != null && !btn.isDisabled()) + btn.setDisabled(true); + } // // No Rows - if (e.getTotalRows() == 0 && insertRecord) + if (e.getTotalRows() == 0 && insertRecord && !detailTab) { toolbar.enableNew(true); toolbar.enableDelete(false); } // Transaction info - String trxInfo = curTab.getTrxInfo(); - if (trxInfo != null) + if (!detailTab) { - statusBar.setInfo(trxInfo); + String trxInfo = adTabbox.getSelectedGridTab().getTrxInfo(); + if (trxInfo != null) + { + statusBar.setInfo(trxInfo); + } } - // Check Attachment - boolean canHaveAttachment = curTab.canHaveAttachment(); // not single _ID column + // Check Attachment + boolean canHaveAttachment = adTabbox.getSelectedGridTab().canHaveAttachment(); // not single _ID column // if (canHaveAttachment && e.isLoading() && - curTab.getCurrentRow() > e.getLoadedRows()) + adTabbox.getSelectedGridTab().getCurrentRow() > e.getLoadedRows()) { canHaveAttachment = false; } - if (canHaveAttachment && curTab.getRecord_ID() == -1) // No Key + if (canHaveAttachment && adTabbox.getSelectedGridTab().getRecord_ID() == -1) // No Key { canHaveAttachment = false; } if (canHaveAttachment) { toolbar.enableAttachment(true); - toolbar.getButton("Attachment").setPressed(curTab.hasAttachment()); + toolbar.getButton("Attachment").setPressed(adTabbox.getSelectedGridTab().hasAttachment()); } else { @@ -1263,43 +1302,43 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To // Check Chat boolean canHaveChat = true; if (e.isLoading() && - curTab.getCurrentRow() > e.getLoadedRows()) + adTabbox.getSelectedGridTab().getCurrentRow() > e.getLoadedRows()) { canHaveChat = false; } - if (canHaveChat && curTab.getRecord_ID() == -1) // No Key + if (canHaveChat && adTabbox.getSelectedGridTab().getRecord_ID() == -1) // No Key { canHaveChat = false; } if (canHaveChat) { toolbar.enableChat(true); - toolbar.getButton("Chat").setPressed(curTab.hasChat()); + toolbar.getButton("Chat").setPressed(adTabbox.getSelectedGridTab().hasChat()); } else { toolbar.enableChat(false); } - toolbar.getButton("Find").setPressed(curTab.isQueryActive()); + toolbar.getButton("Find").setPressed(adTabbox.getSelectedGridTab().isQueryActive()); // Elaine 2008/12/05 // Lock Indicator if (toolbar.isPersonalLock) { - toolbar.lock(curTab.isLocked()); + toolbar.lock(adTabbox.getSelectedGridTab().isLocked()); } // - adTab.evaluate(e); + adTabbox.evaluate(e); - toolbar.enablePrint(curTab.isPrinted()); + toolbar.enablePrint(adTabbox.getSelectedGridTab().isPrinted()); toolbar.enableReport(true); - toolbar.enableExport(!curTab.isSortTab()); + toolbar.enableExport(!adTabbox.getSelectedGridTab().isSortTab()); //Deepak-Enabling customize button IDEMPIERE-364 - if(!(curTabpanel instanceof ADSortTab)) - toolbar.enableCustomize(((ADTabpanel)curTabpanel).isGridView()); + if(!(adTabbox.getSelectedTabpanel() instanceof ADSortTab)) + toolbar.enableCustomize(((ADTabpanel)adTabbox.getSelectedTabpanel()).isGridView()); toolbar.updateToolBarAndMenuWithRestriction(gridWindow.getAD_Window_ID()); } @@ -1308,7 +1347,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To */ public boolean isFirstTab() { - int selTabIndex = adTab.getSelectedIndex(); + int selTabIndex = adTabbox.getSelectedIndex(); return (selTabIndex == 0); } @@ -1334,16 +1373,16 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To @Override public void onCallback(Boolean result) { - curTab.dataRefreshAll(fireEvent, true); - curTabpanel.dynamicDisplay(0); + adTabbox.getSelectedGridTab().dataRefreshAll(fireEvent, true); + adTabbox.getSelectedTabpanel().dynamicDisplay(0); focusToActivePanel(); } }); } else { - curTab.dataRefreshAll(fireEvent, true); - curTabpanel.dynamicDisplay(0); + adTabbox.getSelectedGridTab().dataRefreshAll(fireEvent, true); + adTabbox.getSelectedTabpanel().dynamicDisplay(0); focusToActivePanel(); } } @@ -1370,7 +1409,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To */ public void onNew() { - if (!curTab.isInsertRecord()) + if (!adTabbox.getSelectedGridTab().isInsertRecord()) { logger.warning("Insert Record disabled for Tab"); return; @@ -1381,16 +1420,16 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To public void onCallback(Boolean result) { if (result) { - newRecord = curTab.dataNew(false); + newRecord = adTabbox.getSelectedGridTab().dataNew(false); if (newRecord) { - curTabpanel.dynamicDisplay(0); + adTabbox.getSelectedTabpanel().dynamicDisplay(0); toolbar.enableNew(false); toolbar.enableDelete(false); - toolbar.enableNavigation(false); + breadCrumb.enableNavigation(false); toolbar.enableTabNavigation(false); toolbar.enableIgnore(true); - toolbar.enablePrint(curTab.isPrinted()); + toolbar.enablePrint(adTabbox.getSelectedGridTab().isPrinted()); toolbar.enableReport(true); } else @@ -1409,22 +1448,22 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To */ public void onCopy() { - if (!curTab.isInsertRecord()) + if (!adTabbox.getSelectedGridTab().isInsertRecord()) { logger.warning("Insert Record disabled for Tab"); return; } - newRecord = curTab.dataNew(true); + newRecord = adTabbox.getSelectedGridTab().dataNew(true); if (newRecord) { - curTabpanel.dynamicDisplay(0); + adTabbox.getSelectedTabpanel().dynamicDisplay(0); toolbar.enableNew(false); toolbar.enableDelete(false); - toolbar.enableNavigation(false); + breadCrumb.enableNavigation(false); toolbar.enableTabNavigation(false); toolbar.enableIgnore(true); - toolbar.enablePrint(curTab.isPrinted()); + toolbar.enablePrint(adTabbox.getSelectedGridTab().isPrinted()); toolbar.enableReport(true); } else @@ -1440,7 +1479,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To */ public void onFind() { - if (curTab == null) + if (adTabbox.getSelectedGridTab() == null) return; onSave(false, false, new Callback() { @@ -1456,13 +1495,13 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To private void doOnFind() { // Gets Fields from AD_Field_v - GridField[] findFields = curTab.getFields(); - if (findWindow == null || !findWindow.validate(curTab.getWindowNo(), curTab.getName(), - curTab.getAD_Table_ID(), curTab.getTableName(), - curTab.getWhereExtended(), findFields, 1, curTab.getAD_Tab_ID())) { - findWindow = new FindWindow (curTab.getWindowNo(), curTab.getName(), - curTab.getAD_Table_ID(), curTab.getTableName(), - curTab.getWhereExtended(), findFields, 1, curTab.getAD_Tab_ID()); + GridField[] findFields = adTabbox.getSelectedGridTab().getFields(); + if (findWindow == null || !findWindow.validate(adTabbox.getSelectedGridTab().getWindowNo(), adTabbox.getSelectedGridTab().getName(), + adTabbox.getSelectedGridTab().getAD_Table_ID(), adTabbox.getSelectedGridTab().getTableName(), + adTabbox.getSelectedGridTab().getWhereExtended(), findFields, 1, adTabbox.getSelectedGridTab().getAD_Tab_ID())) { + findWindow = new FindWindow (adTabbox.getSelectedGridTab().getWindowNo(), adTabbox.getSelectedGridTab().getName(), + adTabbox.getSelectedGridTab().getAD_Table_ID(), adTabbox.getSelectedGridTab().getTableName(), + adTabbox.getSelectedGridTab().getWhereExtended(), findFields, 1, adTabbox.getSelectedGridTab().getAD_Tab_ID()); if (!findWindow.initialize()) { if (findWindow.getTotalRecords() == 0) { @@ -1484,18 +1523,18 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To if (query != null) { m_onlyCurrentRows = false; // search history too - curTab.setQuery(query); - curTabpanel.query(m_onlyCurrentRows, m_onlyCurrentDays, MRole.getDefault().getMaxQueryRecords()); // autoSize + adTabbox.getSelectedGridTab().setQuery(query); + adTabbox.getSelectedTabpanel().query(m_onlyCurrentRows, m_onlyCurrentDays, MRole.getDefault().getMaxQueryRecords()); // autoSize } if (findWindow.isCreateNew()) onNew(); else - curTab.dataRefresh(false); // Elaine 2008/07/25 + adTabbox.getSelectedGridTab().dataRefresh(false); // Elaine 2008/07/25 } else { - toolbar.getButton("Find").setPressed(curTab.isQueryActive()); + toolbar.getButton("Find").setPressed(adTabbox.getSelectedGridTab().isQueryActive()); } focusToActivePanel(); } @@ -1510,19 +1549,27 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To */ public void onIgnore() { - if (curTab.isSortTab()) + IADTabpanel dirtyTabpanel = adTabbox.getDirtyADTabpanel(); + boolean newrecod = adTabbox.getSelectedGridTab().isNew(); + if (dirtyTabpanel != null && dirtyTabpanel.getGridTab().isSortTab()) { - curTabpanel.refresh(); + dirtyTabpanel.refresh(); toolbar.enableIgnore(false); } else { - curTab.dataIgnore(); - curTab.dataRefresh(true); // update statusbar & toolbar - curTabpanel.dynamicDisplay(0); + adTabbox.dataIgnore(); toolbar.enableIgnore(false); + if (newrecod) { + onRefresh(true); + } else if (dirtyTabpanel != null) { + dirtyTabpanel.getGridTab().dataRefresh(true); // update statusbar & toolbar + dirtyTabpanel.dynamicDisplay(0); + } + } - focusToActivePanel(); + if (dirtyTabpanel != null) + focusToTabpanel(dirtyTabpanel); } /** @@ -1530,17 +1577,24 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To */ public void onSave() { + final IADTabpanel dirtyTabpanel = adTabbox.getDirtyADTabpanel(); onSave(true, false, new Callback() { @Override public void onCallback(Boolean result) { if (result) { - String statusLine = statusBar.getStatusLine(); - curTab.dataRefreshAll(true, true); - statusBar.setStatusLine(statusLine); + String statusLine = breadCrumb.getStatusLine(); + adTabbox.getSelectedGridTab().dataRefreshAll(true, true); + breadCrumb.setStatusLine(statusLine); } - focusToActivePanel(); + if (dirtyTabpanel != null) { + if (dirtyTabpanel == adTabbox.getSelectedDetailADTabpanel()) + onDetailRecord(); + focusToTabpanel(dirtyTabpanel); + } else { + focusToActivePanel(); + } } }); } @@ -1549,29 +1603,40 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To * @param onSaveEvent */ private void onSave(final boolean onSaveEvent, final boolean onNavigationEvent, final Callback callback) - { - final boolean newRecord = (curTab.getRecord_ID() <= 0); + { final boolean wasChanged = toolbar.isSaveEnable(); - if (curTab.isSortTab()) + IADTabpanel dirtyTabpanel = adTabbox.getDirtyADTabpanel(); + final boolean newRecord = dirtyTabpanel != null ? (dirtyTabpanel.getGridTab().getRecord_ID() <= 0) + : false; + if (dirtyTabpanel != null && dirtyTabpanel instanceof ADSortTab) { + ADSortTab sortTab = (ADSortTab) dirtyTabpanel; if (onNavigationEvent) - ((ADSortTab)curTabpanel).unregisterPanel(); + sortTab.unregisterPanel(); else - ((ADSortTab)curTabpanel).saveData(); + sortTab.saveData(); if (!onNavigationEvent) { - toolbar.enableSave(false); // set explicitly - toolbar.enableIgnore(false); + toolbar.enableSave(sortTab.isChanged()); // set explicitly + toolbar.enableIgnore(sortTab.isChanged()); + } + if (!sortTab.isChanged()) { + if (sortTab == adTabbox.getSelectedTabpanel()) { + breadCrumb.setStatusLine(Msg.getMsg(Env.getCtx(), "Saved")); + } else { + adTabbox.setDetailPaneStatusMessage(Msg.getMsg(Env.getCtx(), "Saved"), false); + } } if (callback != null) callback.onCallback(true); } else - { - if ((curTab.getCommitWarning() != null && curTab.getCommitWarning().trim().length() > 0) || + { + if ((dirtyTabpanel != null && dirtyTabpanel.getGridTab().getCommitWarning() != null + && dirtyTabpanel.getGridTab().getCommitWarning().trim().length() > 0) || (!Env.isAutoCommit(ctx, curWindowNo) && onNavigationEvent)) { - FDialog.ask(curWindowNo, this.getComponent(), "SaveChanges?", curTab.getCommitWarning(), new Callback() { + FDialog.ask(curWindowNo, this.getComponent(), "SaveChanges?", dirtyTabpanel.getGridTab().getCommitWarning(), new Callback() { @Override public void onCallback(Boolean result) @@ -1597,7 +1662,8 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To private void onSave0(boolean onSaveEvent, boolean navigationEvent, boolean newRecord, boolean wasChanged, Callback callback) { - boolean retValue = curTab.dataSave(onSaveEvent); + IADTabpanel dirtyTabpanel = adTabbox.getDirtyADTabpanel(); + boolean retValue = adTabbox.dataSave(onSaveEvent); if (!retValue) { @@ -1605,24 +1671,30 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To if (callback != null) callback.onCallback(false); return; - } else if (!onSaveEvent) //need manual refresh + } else if (!onSaveEvent && dirtyTabpanel != null) //need manual refresh { - curTab.setCurrentRow(curTab.getCurrentRow()); + dirtyTabpanel.getGridTab().setCurrentRow(dirtyTabpanel.getGridTab().getCurrentRow()); } - if (!navigationEvent) { - curTabpanel.dynamicDisplay(0); - curTabpanel.afterSave(onSaveEvent); + if (!navigationEvent && dirtyTabpanel != null) { + dirtyTabpanel.dynamicDisplay(0); + dirtyTabpanel.afterSave(onSaveEvent); + } + + IADTabpanel dirtyTabpanel2 = adTabbox.getDirtyADTabpanel(); + if (dirtyTabpanel2 != null && dirtyTabpanel2 != dirtyTabpanel) { + onSave(onSaveEvent, navigationEvent, callback); + return; } if (wasChanged) { if (newRecord) { - if (curTab.getRecord_ID() > 0) { - if (curTabIndex == 0) { - MRecentItem.addModifiedField(ctx, curTab.getAD_Table_ID(), - curTab.getRecord_ID(), Env.getAD_User_ID(ctx), - Env.getAD_Role_ID(ctx), curTab.getAD_Window_ID(), - curTab.getAD_Tab_ID()); + if (adTabbox.getSelectedGridTab().getRecord_ID() > 0) { + if (adTabbox.getSelectedIndex() == 0) { + MRecentItem.addModifiedField(ctx, adTabbox.getSelectedGridTab().getAD_Table_ID(), + adTabbox.getSelectedGridTab().getRecord_ID(), Env.getAD_User_ID(ctx), + Env.getAD_Role_ID(ctx), adTabbox.getSelectedGridTab().getAD_Window_ID(), + adTabbox.getSelectedGridTab().getAD_Tab_ID()); } else { /* when a detail record is modified add header to recent items */ GridTab mainTab = gridWindow.getTab(0); @@ -1635,9 +1707,9 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To } } } else { - if (curTabIndex == 0) { - MRecentItem.touchUpdatedRecord(ctx, curTab.getAD_Table_ID(), - curTab.getRecord_ID(), Env.getAD_User_ID(ctx)); + if (adTabbox.getSelectedIndex() == 0) { + MRecentItem.touchUpdatedRecord(ctx, adTabbox.getSelectedGridTab().getAD_Table_ID(), + adTabbox.getSelectedGridTab().getRecord_ID(), Env.getAD_User_ID(ctx)); } else { GridTab mainTab = gridWindow.getTab(0); if (mainTab != null) { @@ -1656,7 +1728,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To String msg = CLogger.retrieveErrorString(null); if (msg != null) { - statusBar.setStatusLine(Msg.getMsg(Env.getCtx(), msg), true, true); + breadCrumb.setStatusLine(Msg.getMsg(Env.getCtx(), msg), true); } //other error will be catch in the dataStatusChanged event } @@ -1673,7 +1745,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To { if(result) { - curTab.dataRefreshAll(true, true); + adTabbox.getSelectedGridTab().dataRefreshAll(true, true); onNew(); } } @@ -1685,7 +1757,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To */ public void onDelete() { - if (curTab.isReadOnly()) + if (adTabbox.getSelectedGridTab().isReadOnly()) { return; } @@ -1698,9 +1770,9 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To if (result) { //error will be catch in the dataStatusChanged event - curTab.dataDelete(); + adTabbox.getSelectedGridTab().dataDelete(); - curTabpanel.dynamicDisplay(0); + adTabbox.getSelectedTabpanel().dynamicDisplay(0); focusToActivePanel(); } } @@ -1713,7 +1785,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To */ public void onDeleteSelection() { - if (curTab.isReadOnly()) + if (adTabbox.getSelectedGridTab().isReadOnly()) { return; } @@ -1731,18 +1803,18 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To // Display the first 5 fields data exclude Organization, Client and YesNo field data Vector columnNames = new Vector(); - GridField[] fields = curTab.getFields(); - if(curTab.getField("DocumentNo")!=null){ - columnNames.add(curTab.getField("DocumentNo").getColumnName()); + GridField[] fields = adTabbox.getSelectedGridTab().getFields(); + if(adTabbox.getSelectedGridTab().getField("DocumentNo")!=null){ + columnNames.add(adTabbox.getSelectedGridTab().getField("DocumentNo").getColumnName()); } - if(curTab.getField("Line")!=null){ - columnNames.add(curTab.getField("Line").getColumnName()); + if(adTabbox.getSelectedGridTab().getField("Line")!=null){ + columnNames.add(adTabbox.getSelectedGridTab().getField("Line").getColumnName()); } - if(curTab.getField("Value")!=null){ - columnNames.add(curTab.getField("Value").getColumnName()); + if(adTabbox.getSelectedGridTab().getField("Value")!=null){ + columnNames.add(adTabbox.getSelectedGridTab().getField("Value").getColumnName()); } - if(curTab.getField("Name")!=null){ - columnNames.add(curTab.getField("Name").getColumnName()); + if(adTabbox.getSelectedGridTab().getField("Name")!=null){ + columnNames.add(adTabbox.getSelectedGridTab().getField("Name").getColumnName()); } for(int i = 0; i < fields.length; i++) { @@ -1758,40 +1830,40 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To } Vector data = new Vector(); - int noOfRows = curTab.getRowCount(); + int noOfRows = adTabbox.getSelectedGridTab().getRowCount(); for(int i=0; i parentColumnNames = curTab.getParentColumnNames(); + ArrayList parentColumnNames = adTabbox.getSelectedGridTab().getParentColumnNames(); for (Iterator iter = parentColumnNames.iterator(); iter.hasNext();) { String columnName = iter.next(); - GridField field = curTab.getField(columnName); + GridField field = adTabbox.getSelectedGridTab().getField(columnName); if(field.isLookup()){ Lookup lookup = field.getLookup(); if (lookup != null){ - displayValue = displayValue.append(lookup.getDisplay(curTab.getValue(i,columnName))).append(" | "); + displayValue = displayValue.append(lookup.getDisplay(adTabbox.getSelectedGridTab().getValue(i,columnName))).append(" | "); } else { - displayValue = displayValue.append(curTab.getValue(i,columnName)).append(" | "); + displayValue = displayValue.append(adTabbox.getSelectedGridTab().getValue(i,columnName)).append(" | "); } } else { - displayValue = displayValue.append(curTab.getValue(i,columnName)).append(" | "); + displayValue = displayValue.append(adTabbox.getSelectedGridTab().getValue(i,columnName)).append(" | "); } } } else { - displayValue = displayValue.append(curTab.getValue(i,curTab.getKeyColumnName())); + displayValue = displayValue.append(adTabbox.getSelectedGridTab().getValue(i,adTabbox.getSelectedGridTab().getKeyColumnName())); } int count = 0; for(int j=0; j < columnNames.size() && count < 5; j++) { - Object value = curTab.getValue(i, columnNames.get(j)); + Object value = adTabbox.getSelectedGridTab().getValue(i, columnNames.get(j)); if(value == null) continue; // skip when value is null String text = value.toString().trim(); if(text.length() == 0) continue; // skip when value is empty - GridField field = curTab.getField(columnNames.get(j)); + GridField field = adTabbox.getSelectedGridTab().getField(columnNames.get(j)); if(field != null) { if (field.isLookup()) @@ -1861,13 +1933,13 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To int offset = 0; for (int i = 0; i < indices.length; i++) { - curTab.navigate(indices[i]-offset); - if (curTab.dataDelete()) + adTabbox.getSelectedGridTab().navigate(indices[i]-offset); + if (adTabbox.getSelectedGridTab().dataDelete()) { offset++; } } - curTabpanel.dynamicDisplay(0); + adTabbox.getSelectedTabpanel().dynamicDisplay(0); messagePanel.dispose(); } else { @@ -1910,7 +1982,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To */ public void onPrint() { //Get process defined for this tab - final int AD_Process_ID = curTab.getAD_Process_ID(); + final int AD_Process_ID = adTabbox.getSelectedGridTab().getAD_Process_ID(); //log.info("ID=" + AD_Process_ID); // No report defined @@ -1925,13 +1997,13 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To @Override public void onCallback(Boolean result) { if (result) { - int table_ID = curTab.getAD_Table_ID(); - int record_ID = curTab.getRecord_ID(); + int table_ID = adTabbox.getSelectedGridTab().getAD_Table_ID(); + int record_ID = adTabbox.getSelectedGridTab().getRecord_ID(); - ProcessModalDialog dialog = new ProcessModalDialog(AbstractADWindowPanel.this, getWindowNo(), AD_Process_ID,table_ID, record_ID, true); + ProcessModalDialog dialog = new ProcessModalDialog(AbstractADWindowContent.this, getWindowNo(), AD_Process_ID,table_ID, record_ID, true); if (dialog.isValid()) { dialog.setPosition("center"); - dialog.setPage(AbstractADWindowPanel.this.getComponent().getPage()); + dialog.setPage(AbstractADWindowContent.this.getComponent().getPage()); dialog.doHighlighted(); } } @@ -1944,7 +2016,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To * @see ToolbarListener#onReport() */ public void onReport() { - if (!MRole.getDefault().isCanReport(curTab.getAD_Table_ID())) + if (!MRole.getDefault().isCanReport(adTabbox.getSelectedGridTab().getAD_Table_ID())) { FDialog.error(curWindowNo, parent, "AccessCannotReport"); return; @@ -1973,17 +2045,17 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To public void onZoomAcross() { if (toolbar.getEvent() != null) { - int record_ID = curTab.getRecord_ID(); + int record_ID = adTabbox.getSelectedGridTab().getRecord_ID(); if (record_ID <= 0) return; // Query MQuery query = new MQuery(); // Current row - String link = curTab.getKeyColumnName(); + String link = adTabbox.getSelectedGridTab().getKeyColumnName(); // Link for detail records if (link.length() == 0) - link = curTab.getLinkColumnName(); + link = adTabbox.getSelectedGridTab().getLinkColumnName(); if (link.length() != 0) { if (link.endsWith("_ID")) @@ -1993,8 +2065,8 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To query.addRestriction(link, MQuery.EQUAL, Env.getContext(ctx, curWindowNo, link)); } - new WZoomAcross(toolbar.getEvent().getTarget(), curTab - .getTableName(), curTab.getAD_Window_ID(), query); + new WZoomAcross(toolbar.getEvent().getTarget(), adTabbox.getSelectedGridTab() + .getTableName(), adTabbox.getSelectedGridTab().getAD_Window_ID(), query); } } @@ -2005,10 +2077,10 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To public void onActiveWorkflows() { if (toolbar.getEvent() != null) { - if (curTab.getRecord_ID() <= 0) + if (adTabbox.getSelectedGridTab().getRecord_ID() <= 0) return; else - AEnv.startWorkflowProcess(curTab.getAD_Table_ID(), curTab.getRecord_ID()); + AEnv.startWorkflowProcess(adTabbox.getSelectedGridTab().getAD_Table_ID(), adTabbox.getSelectedGridTab().getRecord_ID()); } } // @@ -2021,15 +2093,15 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To { if (toolbar.getEvent() != null) { - if (curTab.getRecord_ID() <= 0) + if (adTabbox.getSelectedGridTab().getRecord_ID() <= 0) return; int C_BPartner_ID = 0; - Object bpartner = curTab.getValue("C_BPartner_ID"); + Object bpartner = adTabbox.getSelectedGridTab().getValue("C_BPartner_ID"); if(bpartner != null) C_BPartner_ID = Integer.valueOf(bpartner.toString()); - new WRequest(toolbar.getEvent().getTarget(), curTab.getAD_Table_ID(), curTab.getRecord_ID(), C_BPartner_ID); + new WRequest(toolbar.getEvent().getTarget(), adTabbox.getSelectedGridTab().getAD_Table_ID(), adTabbox.getSelectedGridTab().getRecord_ID(), C_BPartner_ID); } } // @@ -2053,10 +2125,10 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To { if (toolbar.getEvent() != null) { - if (curTab.getRecord_ID() <= 0) + if (adTabbox.getSelectedGridTab().getRecord_ID() <= 0) return; - new WArchive(toolbar.getEvent().getTarget(), curTab.getAD_Table_ID(), curTab.getRecord_ID()); + new WArchive(toolbar.getEvent().getTarget(), adTabbox.getSelectedGridTab().getAD_Table_ID(), adTabbox.getSelectedGridTab().getRecord_ID()); } } @@ -2074,7 +2146,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To */ private void actionButton (final WButtonEditor wButton) { - if (curTab.hasChangedCurrentTabAndParents()) { + if (adTabbox.getSelectedGridTab().hasChangedCurrentTabAndParents()) { String msg = CLogger.retrieveErrorString("Please ReQuery Window"); FDialog.error(curWindowNo, parent, null, msg); return; @@ -2096,7 +2168,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To // save first --------------- - if (curTab.needSave(true, false)) + if (adTabbox.needSave(true, false)) { onSave(false, false, new Callback() { @Override @@ -2120,16 +2192,17 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To */ private void actionButton0 (String col, final WButtonEditor wButton) { + final IADTabpanel adtabPanel = findADTabpanel(wButton); boolean startWOasking = false; - final int table_ID = curTab.getAD_Table_ID(); + final int table_ID = adtabPanel.getGridTab().getAD_Table_ID(); // Record_ID - int record_ID = curTab.getRecord_ID(); + int record_ID = adtabPanel.getGridTab().getRecord_ID(); // Record_ID - Language Handling - if (record_ID == -1 && curTab.getKeyColumnName().equals("AD_Language")) + if (record_ID == -1 && adtabPanel.getGridTab().getKeyColumnName().equals("AD_Language")) record_ID = Env.getContextAsInt (ctx, curWindowNo, "AD_Language_ID"); // Record_ID - Change Log ID @@ -2137,13 +2210,13 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To if (record_ID == -1 && (wButton.getProcess_ID() == PROCESS_AD_CHANGELOG_UNDO || wButton.getProcess_ID() == PROCESS_AD_CHANGELOG_REDO)) { - Integer id = (Integer)curTab.getValue("AD_ChangeLog_ID"); + Integer id = (Integer)adtabPanel.getGridTab().getValue("AD_ChangeLog_ID"); record_ID = id.intValue(); } // Ensure it's saved - if (record_ID == -1 && curTab.getKeyColumnName().endsWith("_ID")) + if (record_ID == -1 && adtabPanel.getGridTab().getKeyColumnName().endsWith("_ID")) { FDialog.error(curWindowNo, parent, "SaveErrorRowNotFound"); return; @@ -2154,7 +2227,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To // Pop up Payment Rules if (col.equals("PaymentRule")) { - final WPayment vp = new WPayment(curWindowNo, curTab, wButton); + final WPayment vp = new WPayment(curWindowNo, adtabPanel.getGridTab(), wButton); if (vp.isInitOK()) // may not be allowed { vp.setAttribute(Window.MODE_KEY, Window.MODE_HIGHLIGHTED); @@ -2183,7 +2256,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To else if (col.equals("DocAction")) { - final WDocActionPanel win = new WDocActionPanel(curTab); + final WDocActionPanel win = new WDocActionPanel(adtabPanel.getGridTab()); if (win.getNumberOfOptions() == 0) { logger.info("DocAction - No Options"); @@ -2213,7 +2286,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To else if (col.equals("CreateFrom")) { - ICreateFrom cf = WCreateFromFactory.create(curTab); + ICreateFrom cf = WCreateFromFactory.create(adtabPanel.getGridTab()); if(cf != null) { @@ -2225,7 +2298,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To @Override public void onEvent(Event event) throws Exception { if (!window.isCancel()) { - curTab.dataRefresh(); + adtabPanel.getGridTab().dataRefresh(); } } }); @@ -2266,12 +2339,12 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To int recordId = Env.getContextAsInt(ctx, curWindowNo, "Record_ID", true); if ( tableId == 0 || recordId == 0 ) { - tableId = curTab.getAD_Table_ID(); - recordId = curTab.getRecord_ID(); + tableId = adtabPanel.getGridTab().getAD_Table_ID(); + recordId = adtabPanel.getGridTab().getRecord_ID(); } // Check Post Status - final Object ps = curTab.getValue("Posted"); + final Object ps = adtabPanel.getGridTab().getValue("Posted"); if (ps != null && ps.equals("Y")) { @@ -2295,7 +2368,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To tableIdRef, recordIdRef, force); if (error != null) - statusBar.setStatusLine(error, true, true); + breadCrumb.setStatusLine(error, true); onRefresh(false, false); } @@ -2329,7 +2402,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To // Save item changed - if (curTab.needSave(true, false)) + if (adTabbox.needSave(true, false)) { onSave(false, false, new Callback() { @@ -2397,7 +2470,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To String error = processButtonCallout((WButtonEditor)event.getSource()); if (error != null && error.trim().length() > 0) { - statusBar.setStatusLine(error, true); + breadCrumb.setStatusLine(error, true); return; } actionButton((WButtonEditor)event.getSource()); @@ -2422,16 +2495,34 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To */ private String processButtonCallout (WButtonEditor button) { - GridField field = curTab.getField(button.getColumnName()); - return curTab.processCallout(field); + IADTabpanel adtab = findADTabpanel(button); + if (adtab != null) { + GridField field = adtab.getGridTab().getField(button.getColumnName()); + return adtab.getGridTab().processCallout(field); + } else { + return ""; + } } // processButtonCallout + public IADTabpanel findADTabpanel(WButtonEditor button) { + IADTabpanel adtab = null; + Component c = button.getComponent(); + while (c != null) { + if (c instanceof IADTabpanel) { + adtab = (IADTabpanel) c; + break; + } + c = c.getParent(); + } + return adtab; + } + /** * * @return IADTab */ - public IADTab getADTab() { - return adTab; + public IADTabbox getADTab() { + return adTabbox; } /** @@ -2445,7 +2536,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To */ private void onModalClose(ProcessInfo pi) { boolean notPrint = pi != null - && pi.getAD_Process_ID() != curTab.getAD_Process_ID() + && pi.getAD_Process_ID() != adTabbox.getSelectedGridTab().getAD_Process_ID() && pi.isReportingProcess() == false; // // Process Result @@ -2487,7 +2578,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To String summary = pi.getSummary(); if (summary != null && summary.indexOf('@') != -1) pi.setSummary(Msg.parseTranslation(Env.getCtx(), summary)); - statusBar.setStatusLine(pi.getSummary(), pi.isError(), true); + breadCrumb.setStatusLine(pi.getSummary(), pi.isError()); // Get Log Info ProcessInfoUtil.setLogFromDB(pi); String logInfo = pi.getLogInfo(); @@ -2500,7 +2591,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To * * @return toolbar instance */ - public CWindowToolbar getToolbar() { + public ADWindowToolbar getToolbar() { return toolbar; } @@ -2508,7 +2599,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To * @return active grid tab */ public GridTab getActiveGridTab() { - return curTab; + return adTabbox.getSelectedGridTab(); } /** @@ -2535,8 +2626,6 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To gridFieldIds.add(fields[i].getAD_Field_ID()); } - - CustomizeGridViewDialog.showCustomize(0, curTab.getAD_Tab_ID(), columnsWidth,gridFieldIds,tabPanel.getGridView()); - + CustomizeGridViewDialog.showCustomize(0, adTabbox.getSelectedGridTab().getAD_Tab_ID(), columnsWidth,gridFieldIds,tabPanel.getGridView()); } } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/BreadCrumb.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/BreadCrumb.java new file mode 100644 index 0000000000..017f07cd69 --- /dev/null +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/BreadCrumb.java @@ -0,0 +1,434 @@ +/****************************************************************************** + * Copyright (C) 2012 Heng Sin Low * + * Copyright (C) 2012 Trek Global * + * This program is free software; you can redistribute it and/or modify it * + * under the terms version 2 of the GNU General Public License as published * + * by the Free Software Foundation. This program is distributed in the hope * + * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * + * See the GNU General Public License for more details. * + * You should have received a copy of the GNU General Public License along * + * with this program; if not, write to the Free Software Foundation, Inc., * + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * + *****************************************************************************/ +package org.adempiere.webui.adwindow; + +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; + +import org.adempiere.webui.AdempiereIdGenerator; +import org.adempiere.webui.LayoutUtils; +import org.adempiere.webui.component.Label; +import org.adempiere.webui.component.Menupopup; +import org.adempiere.webui.component.ToolBar; +import org.adempiere.webui.component.ToolBarButton; +import org.adempiere.webui.component.Window; +import org.adempiere.webui.event.ToolbarListener; +import org.adempiere.webui.session.SessionManager; +import org.adempiere.webui.window.WRecordInfo; +import org.compiere.model.DataStatusEvent; +import org.compiere.model.MRole; +import org.compiere.util.Env; +import org.compiere.util.Msg; +import org.zkoss.zhtml.Text; +import org.zkoss.zk.ui.Execution; +import org.zkoss.zk.ui.Executions; +import org.zkoss.zk.ui.Page; +import org.zkoss.zk.ui.event.Event; +import org.zkoss.zk.ui.event.EventListener; +import org.zkoss.zk.ui.event.Events; +import org.zkoss.zk.ui.event.KeyEvent; +import org.zkoss.zk.ui.event.MouseEvent; +import org.zkoss.zk.ui.util.Clients; +import org.zkoss.zul.Caption; +import org.zkoss.zul.Div; +import org.zkoss.zul.Hbox; +import org.zkoss.zul.Hlayout; +import org.zkoss.zul.Image; +import org.zkoss.zul.Menuitem; +import org.zkoss.zul.Space; + +/** + * @author hengsin + * + */ +public class BreadCrumb extends Div implements EventListener{ + + private static final String INFO_INDICATOR_IMAGE = "/images/InfoIndicator16.png"; + + private static final String ERROR_INDICATOR_IMAGE = "/images/ErrorIndicator16.png"; + + /** + * generated serial id + */ + private static final long serialVersionUID = 929253935475618911L; + + private static final String BTNPREFIX = "Btn"; + + private Hbox layout; + + private ToolBarButton btnFirst, btnPrevious, btnNext, btnLast, btnRecordInfo; + + private LinkedHashMap links; + + private int windowNo; + + private HashMap buttons = new HashMap(); + private Map altKeyMap = new HashMap(); + + private DataStatusEvent m_dse; + + private String m_text; + + private boolean m_statusError; + + private String m_statusText; + + private Window msgPopup; + + private Div msgPopupCnt; + + private ToolbarListener toolbarListener; + + private Hlayout toolbarContainer; + + private Hbox messageContainer; + + private Caption msgPopupCaption; + + /** + * + */ + public BreadCrumb(int windowNo) { + this.windowNo = windowNo; + layout = new Hbox(); + layout.setPack("start"); + layout.setAlign("center"); + this.appendChild(layout); + layout.setHeight("100%"); + layout.setStyle("float: left"); + + this.setVisible(false); + this.setSclass("adwindow-breadcrumb"); + + toolbarContainer = new Hlayout(); + layout.appendChild(toolbarContainer); + + ToolBar toolbar = new ToolBar(); + toolbarContainer.appendChild(toolbar); + btnFirst = createButton("First", "First", "First"); + toolbar.appendChild(btnFirst); + btnPrevious = createButton("Previous", "Previous", "Previous"); + toolbar.appendChild(btnPrevious); + btnRecordInfo = new ToolBarButton(); + btnRecordInfo.setLabel(""); + btnRecordInfo.setStyle("font-size: 12px"); + btnRecordInfo.setTooltiptext("Record Info"); + btnRecordInfo.addEventListener(Events.ON_CLICK, this); + toolbar.appendChild(btnRecordInfo); + btnNext = createButton("Next", "Next", "Next"); + toolbar.appendChild(btnNext); + btnLast = createButton("Last", "Last", "Last"); + toolbar.appendChild(btnLast); + + messageContainer = new Hbox(); + messageContainer.setStyle("float: right; height: 30px;"); + messageContainer.setAlign("center"); + appendChild(messageContainer); + + altKeyMap.put(KeyEvent.UP, btnPrevious); + altKeyMap.put(KeyEvent.DOWN, btnNext); + altKeyMap.put(KeyEvent.PAGE_UP, btnFirst); + altKeyMap.put(KeyEvent.PAGE_DOWN, btnLast); + + createPopup(); + + toolbar.setStyle("background-image: none; background-color: transparent; border: none;"); + } + + public void setToolbarListener(ToolbarListener listener) { + this.toolbarListener = listener; + } + + public void addPath(String label, String id, boolean clickable) { + if (clickable) { + BreadCrumbLink a = new BreadCrumbLink(); + a.setLabel(label); + a.setPathId(id); + a.addEventListener(Events.ON_CLICK, this); + if (layout.getChildren().size() > 1) { + Label symbol = new Label(); + symbol.setValue(" > "); + layout.insertBefore(symbol, toolbarContainer); + } + layout.insertBefore(a, toolbarContainer); + } else { + Label pathLabel = new Label(); + pathLabel.setValue(label); + if (layout.getChildren().size() > 1) { + Label symbol = new Label(); + symbol.setValue(" > "); + layout.insertBefore(symbol, toolbarContainer); + } + pathLabel.setStyle("font-weight: bold"); + layout.insertBefore(pathLabel, toolbarContainer); + } + } + + public void addLinks(LinkedHashMap links) { + this.links = links; + final Label pathLabel = (Label) layout.getChildren().get(layout.getChildren().size()-2); + pathLabel.setStyle("cursor: pointer; font-weight: bold"); + pathLabel.addEventListener(Events.ON_CLICK, new EventListener() { + @Override + public void onEvent(Event event) throws Exception { + Menupopup popup = new Menupopup(); + for(Map.Entryentry : BreadCrumb.this.links.entrySet()) { + final Menuitem item = new Menuitem(); + item.setLabel(entry.getValue()); + item.setValue(entry.getKey()); + item.addEventListener(Events.ON_CLICK, BreadCrumb.this); + popup.appendChild(item); + } + popup.setPage(pathLabel.getPage()); + popup.open(pathLabel); + } + }); + } + + @Override + public void onEvent(Event event) throws Exception { + if (event.getTarget() == btnRecordInfo) { + if (m_dse == null + || m_dse.CreatedBy == null + || !MRole.getDefault().isShowPreference()) + return; + + String title = Msg.getMsg(Env.getCtx(), "Who") + m_text; + new WRecordInfo (title, m_dse); + } else if (event.getTarget().getParent() == messageContainer) { + showPopup(); + } else if (event.getTarget() == btnFirst) { + if (toolbarListener != null) + toolbarListener.onFirst(); + } else if (event.getTarget() == btnPrevious) { + if (toolbarListener != null) + toolbarListener.onPrevious(); + } else if (event.getTarget() == btnNext) { + if (toolbarListener != null) + toolbarListener.onNext(); + } else if (event.getTarget() == btnLast) { + if (toolbarListener != null) + toolbarListener.onLast(); + } else { + MouseEvent me = (MouseEvent) event; + Events.sendEvent(this, me); + } + } + + public void reset() { + layout.getChildren().clear(); + layout.appendChild(toolbarContainer); + this.links = null; + } + + private void enableFirstNavigation(boolean enabled) + { + this.btnFirst.setDisabled(!enabled); + this.btnPrevious.setDisabled(!enabled); + } + + private void enableLastNavigation(boolean enabled) + { + this.btnLast.setDisabled(!enabled); + this.btnNext.setDisabled(!enabled); + } + + public void enableNavigation(boolean enabled) + { + this.btnFirst.setDisabled(!enabled); + this.btnPrevious.setDisabled(!enabled); + this.btnNext.setDisabled(!enabled); + this.btnLast.setDisabled(!enabled); + } + + private ToolBarButton createButton(String name, String image, String tooltip) + { + ToolBarButton btn = new ToolBarButton(""); + btn.setName(BTNPREFIX+name); + if (windowNo > 0) + btn.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, "unq" + btn.getName() + "_" + windowNo); + else + btn.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, btn.getName()); + btn.setImage("/images/"+image + "24.png"); + btn.setTooltiptext(Msg.getMsg(Env.getCtx(),tooltip)); + btn.setSclass("toolbar-button"); + + buttons.put(name, btn); + this.appendChild(btn); + //make toolbar button last to receive focus + btn.setTabindex(0); + btn.addEventListener(Events.ON_CLICK, this); + btn.setDisabled(true); + + return btn; + } + + /** + * @param text + */ + public void setStatusDB (String text) + { + setStatusDB(text, null); + } + + /** + * @param text + * @param dse + */ + public void setStatusDB (String text, DataStatusEvent dse) + { + if (text == null || text.length() == 0) + { + btnRecordInfo.setLabel(""); + } + else + { + btnRecordInfo.setLabel(text); + } + + m_text = text; + m_dse = dse; + if (m_dse != null) { + enableFirstNavigation(m_dse.getCurrentRow() > 0); + enableLastNavigation(m_dse.getTotalRows() > m_dse.getCurrentRow()+1); + } + } + + /** + * @param text + */ + public void setStatusLine (String text) + { + setStatusLine(text, false); + } + + /** + * @param text + * @param error + */ + public void setStatusLine (String text, boolean error) + { + Execution execution = Executions.getCurrent(); + if (execution != null) { + String key = this.getClass().getName()+"."+getUuid(); + Object o = execution.getAttribute(key); + if (o != null) { + if (text == null || text.trim().length() == 0) + return; + } else { + execution.setAttribute(key, Boolean.TRUE); + } + } + + m_statusText = text; + m_statusError = error; + + messageContainer.getChildren().clear(); + + if (text == null || text.trim().length() == 0 ) + return; + + Image image = null; + if (error) + image = new Image(ERROR_INDICATOR_IMAGE); + else + image = new Image(INFO_INDICATOR_IMAGE); + + image.setAttribute("org.zkoss.zul.image.preload", Boolean.TRUE); + messageContainer.appendChild(image); + String labelText = buildLabelText(m_statusText); + if (error) { + Clients.showNotification(labelText, "error", image, "overlap_start", 3500, true); + } + Label label = new Label(labelText); + messageContainer.appendChild(label); + if (labelText.length() != m_statusText.length()) { + image.addEventListener(Events.ON_CLICK, this); + image.setStyle("cursor: pointer"); + label.addEventListener(Events.ON_CLICK, this); + label.setStyle("cursor: pointer"); + + label = new Label(" ..."); + label.setStyle("cursor: pointer"); + messageContainer.appendChild(label); + label.addEventListener(Events.ON_CLICK, this); + } + messageContainer.appendChild(new Space()); + + createPopupContent(); + } + + private String buildLabelText(String statusText) { + if (statusText == null) + return ""; + if (statusText.length() <= 80) + return statusText; + + int index = statusText.indexOf(" - java.lang.Exception"); + if (index > 0) + return statusText.substring(0, index); + return statusText.substring(0, 80); + } + + protected void createPopupContent() { + Text t = new Text(m_statusText); + msgPopupCnt.getChildren().clear(); + msgPopupCnt.appendChild(t); + } + + /** + * + * @return current status line text + */ + public String getStatusLine() { + return m_statusText; + } + + private void createPopup() { + msgPopupCnt = new Div(); + msgPopupCnt.setVflex("1"); + + + msgPopup = new Window(); + msgPopup.setBorder(true); + msgPopup.setClosable(true); + msgPopup.setSizable(true); + msgPopup.setContentStyle("overflow: auto"); + msgPopup.setWidth("500px"); + msgPopup.appendChild(msgPopupCnt); + msgPopup.setPage(SessionManager.getAppDesktop().getComponent().getPage()); + msgPopup.setShadow(true); + msgPopupCaption = new Caption(); + msgPopup.appendChild(msgPopupCaption); + } + + private void showPopup() { + msgPopupCaption.setImage(m_statusError ? ERROR_INDICATOR_IMAGE : INFO_INDICATOR_IMAGE); + LayoutUtils.openOverlappedWindow(messageContainer, msgPopup, "overlap_end"); + } + + @Override + public void onPageDetached(Page page) { + super.onPageDetached(page); + if (msgPopup != null) + msgPopup.detach(); + } + + public void setNavigationToolbarVisibility(boolean visible) { + toolbarContainer.setVisible(visible); + } + + +} diff --git a/org.zkoss.zk.library/src/org/zkoss/util/resource/IResourceLocator.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/BreadCrumbLink.java similarity index 76% rename from org.zkoss.zk.library/src/org/zkoss/util/resource/IResourceLocator.java rename to org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/BreadCrumbLink.java index 6ec65055f9..e1ce423868 100644 --- a/org.zkoss.zk.library/src/org/zkoss/util/resource/IResourceLocator.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/BreadCrumbLink.java @@ -11,21 +11,29 @@ * with this program; if not, write to the Free Software Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * *****************************************************************************/ -package org.zkoss.util.resource; +package org.adempiere.webui.adwindow; -import java.net.URL; +import org.zkoss.zul.A; /** - * * @author hengsin * */ -public interface IResourceLocator { - - /** - * @param name - * @return resource url - */ - public URL getResource(String name); +public class BreadCrumbLink extends A { + /** + * generated serial id + */ + private static final long serialVersionUID = 170361731431877695L; + + private String pathId; + + public String getPathId() { + return pathId; + } + + public void setPathId(String pathId) { + this.pathId = pathId; + } + } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/CompositeADTabbox.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/CompositeADTabbox.java new file mode 100644 index 0000000000..a6d6d25003 --- /dev/null +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/CompositeADTabbox.java @@ -0,0 +1,663 @@ +/****************************************************************************** + * Product: Posterita Ajax UI * + * Copyright (C) 2007 Posterita Ltd. All Rights Reserved. * + * This program is free software; you can redistribute it and/or modify it * + * under the terms version 2 of the GNU General Public License as published * + * by the Free Software Foundation. This program is distributed in the hope * + * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * + * See the GNU General Public License for more details. * + * You should have received a copy of the GNU General Public License along * + * with this program; if not, write to the Free Software Foundation, Inc., * + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * + * For the text or an alternative of this public license, you may reach us * + * Posterita Ltd., 3, Draper Avenue, Quatre Bornes, Mauritius * + * or via info@posterita.org or http://www.posterita.org/ * + *****************************************************************************/ + +package org.adempiere.webui.adwindow; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; + +import org.adempiere.util.Callback; +import org.adempiere.webui.component.ADTabListModel; +import org.adempiere.webui.component.ADTabListModel.ADTabLabel; +import org.adempiere.webui.window.FDialog; +import org.compiere.model.DataStatusEvent; +import org.compiere.model.DataStatusListener; +import org.compiere.model.GridField; +import org.compiere.model.GridTab; +import org.compiere.util.CLogger; +import org.compiere.util.Env; +import org.compiere.util.Msg; +import org.zkoss.zk.ui.Component; +import org.zkoss.zk.ui.Execution; +import org.zkoss.zk.ui.Executions; +import org.zkoss.zk.ui.HtmlBasedComponent; +import org.zkoss.zk.ui.event.Event; +import org.zkoss.zk.ui.event.EventListener; +import org.zkoss.zk.ui.event.Events; +import org.zkoss.zk.ui.util.Clients; +import org.zkoss.zul.Menuitem; +import org.zkoss.zul.Vlayout; + +/** + * + * @author Ashley G Ramdass + * @author Low Heng Sin + * @date Feb 25, 2007 + * @version $Revision: 0.10 $ + */ +public class CompositeADTabbox extends AbstractADTabbox +{ + private static final String ON_SWITCH_VIEW_EVENT = "onSwitchView"; + + private static final String ON_ACTIVATE_EVENT = "onActivate"; + + public static final String ON_SELECTION_CHANGED_EVENT = "onSelectionChanged"; + + public static final String ADTAB_INDEX_ATTRIBUTE = "adtab.index"; + + /** Logger */ + @SuppressWarnings("unused") + private static CLogger log = CLogger.getCLogger (CompositeADTabbox.class); + + private List tabLabelList = new ArrayList(); + + private List tabPanelList = new ArrayList(); + + private Vlayout layout; + + protected DetailPane detailPane; + + private EventListener selectionListener; + + private IADTabpanel headerTab; + + private int selectedIndex = 0; + + public CompositeADTabbox() + { + detailPane = new DetailPane(); + detailPane.setEventListener(new EventListener() { + + @Override + public void onEvent(Event event) throws Exception { + if (DetailPane.ON_EDIT_EVENT.equals(event.getName())) { + final int row = detailPane.getSelectedADTabpanel() != null + ? detailPane.getSelectedADTabpanel().getGridTab().getCurrentRow() + : 0; + adWindowPanel.saveAndNavigate(new Callback() { + @Override + public void onCallback(Boolean result) { + if (result) + onEditDetail(row); + } + }); + } + else if (DetailPane.ON_NEW_EVENT.equals(event.getName())) { + final int row = detailPane.getSelectedADTabpanel() != null + ? detailPane.getSelectedADTabpanel().getGridTab().getCurrentRow() + : 0; + adWindowPanel.saveAndNavigate(new Callback() { + @Override + public void onCallback(Boolean result) { + if (result) { + onEditDetail(row); + adWindowPanel.onNew(); + } + } + }); + } + else if (DetailPane.ON_DELETE_EVENT.equals(event.getName())) { + final IADTabpanel tabPanel = detailPane.getSelectedADTabpanel(); + if (tabPanel != null && tabPanel.getGridTab().getRowCount() > 0 + && tabPanel.getGridTab().getCurrentRow() >= 0) { + FDialog.ask(tabPanel.getGridTab().getWindowNo(), null, "DeleteRecord?", new Callback() { + + @Override + public void onCallback(Boolean result) { + if (!result) return; + if (!tabPanel.getGridTab().dataDelete()) { + showLastError(); + } else { + adWindowPanel.onRefresh(false); + } + } + }); + } + } + } + }); + } + + protected void onEditDetail(int row) { + int oldIndex = selectedIndex; + IADTabpanel selectedPanel = detailPane.getSelectedADTabpanel(); + int newIndex = (Integer)selectedPanel.getAttribute(ADTAB_INDEX_ATTRIBUTE); + + Event selectionChanged = new Event(ON_SELECTION_CHANGED_EVENT, layout, new Object[]{oldIndex, newIndex}); + try { + selectionListener.onEvent(selectionChanged); + } catch (Exception e) { + throw new RuntimeException(e); + } + + headerTab.setDetailPaneMode(false, true); + if (headerTab.isGridView()) { + headerTab.switchRowPresentation(); + } + headerTab.getGridTab().setCurrentRow(row, true); + } + + protected Component doCreatePart(Component parent) + { + layout = new Vlayout(); + layout.setHeight("100%"); + layout.setWidth("100%"); + layout.setStyle("position: relative"); + if (parent != null) { + layout.setParent(parent); + } else { + layout.setPage(page); + } + + BreadCrumb breadCrumb = getBreadCrumb(); + breadCrumb.addEventListener(Events.ON_CLICK, new EventListener() { + @Override + public void onEvent(Event event) throws Exception { + int oldIndex = selectedIndex; + if (event.getTarget() instanceof BreadCrumbLink) { + BreadCrumbLink link = (BreadCrumbLink) event.getTarget(); + int newIndex = Integer.parseInt(link.getPathId()); + + Event selectionChanged = new Event(ON_SELECTION_CHANGED_EVENT, layout, new Object[]{oldIndex, newIndex}); + selectionListener.onEvent(selectionChanged); + } else if (event.getTarget() instanceof Menuitem) { + Menuitem item = (Menuitem) event.getTarget(); + int newIndex = Integer.parseInt(item.getValue()); + + Event selectionChanged = new Event(ON_SELECTION_CHANGED_EVENT, layout, new Object[]{oldIndex, newIndex}); + selectionListener.onEvent(selectionChanged); + } + } + }); + + return layout; + } + + @Override + protected void doAddTab(GridTab gTab, IADTabpanel tabPanel) { + ADTabListModel.ADTabLabel tabLabel = new ADTabListModel.ADTabLabel(gTab.getName(), gTab.getTabLevel(),gTab.getDescription(), + gTab.getWindowNo(),gTab.getAD_Tab_ID()); + tabLabelList.add(tabLabel); + tabPanelList.add(tabPanel); + + tabPanel.setAttribute(ADTAB_INDEX_ATTRIBUTE, tabPanelList.size()-1); + + tabPanel.addEventListener(ON_ACTIVATE_EVENT, new EventListener() { + @Override + public void onEvent(Event event) throws Exception { + Boolean b = (Boolean) event.getData(); + if (b != null && !b.booleanValue()) + return; + + IADTabpanel tabPanel = (IADTabpanel) event.getTarget(); + if (tabPanel == headerTab) { + if (b != null && b.booleanValue()) { + activateDetailADTabpanel(); + } + if (selectedIndex > 0 && tabPanel.isGridView()) { + tabPanel.switchRowPresentation(); + } + } else { + onActivateDetail(tabPanel); + } + } + }); + + tabPanel.addEventListener(DetailPane.ON_ACTIVATE_DETAIL_EVENT, new EventListener() { + @Override + public void onEvent(Event event) throws Exception { + final IADTabpanel tabPanel = (IADTabpanel) event.getTarget(); + int oldIndex = (Integer) event.getData(); + if (oldIndex != detailPane.getSelectedIndex()) { + IADTabpanel prevTabPanel = detailPane.getADTabpanel(oldIndex); + if (prevTabPanel != null && prevTabPanel.getGridTab().needSave(true, true)) { + final int newIndex = detailPane.getSelectedIndex(); + detailPane.setSelectedIndex(oldIndex); + adWindowPanel.saveAndNavigate(new Callback() { + @Override + public void onCallback(Boolean result) { + if (result) { + detailPane.setSelectedIndex(newIndex); + onActivateDetail(tabPanel); + } + } + }); + } else { + onActivateDetail(tabPanel); + } + } else { + onActivateDetail(tabPanel); + } + } + }); + + tabPanel.addEventListener(ON_SWITCH_VIEW_EVENT, new EventListener() { + + @Override + public void onEvent(Event event) throws Exception { + IADTabpanel tabPanel = (IADTabpanel) event.getTarget(); + if (tabPanel == headerTab) { + IADTabpanel detailPanel = getSelectedDetailADTabpanel(); + if (detailPanel != null) { + detailPanel.setDetailPaneMode(true, headerTab.isGridView()); + } + detailPane.setVflex(Boolean.toString(headerTab.isGridView())); + layout.invalidate(); + } + } + }); + + tabPanel.addEventListener(ADTabpanel.ON_TOGGLE_EVENT, new EventListener() { + + @Override + public void onEvent(Event event) throws Exception { + IADTabpanel tabPanel = (IADTabpanel) event.getTarget(); + if (tabPanel == headerTab) { + adWindowPanel.onToggle(); + } else { + detailPane.onEdit(); + } + + } + }); + + if (layout.getChildren().isEmpty()) { + layout.appendChild(tabPanel); + headerTab = tabPanel; + updateBreadCrumb(); + } else if (tabLabel.tabLevel <= 1) { + boolean activate = false; + if (detailPane.getParent() == null) { + ADTabpanel adtabpanel = (ADTabpanel) headerTab; + adtabpanel.addDetails(detailPane); + activate = true; + } else + tabPanel.setVisible(false); + detailPane.setHflex("1"); + detailPane.setStyle("min-height: 200px; overflow-y: visible;"); + detailPane.addADTabpanel(tabPanel, tabLabel); + tabPanel.setDetailPaneMode(true, headerTab.isGridView()); + detailPane.setVflex(Boolean.toString(headerTab.isGridView())); + if (activate) + activateDetailADTabpanel(); + } else { + detailPane.addADTabpanel(tabPanel, tabLabel, false); + tabPanel.setDetailPaneMode(true, headerTab.isGridView()); + detailPane.setVflex(Boolean.toString(headerTab.isGridView())); + } + HtmlBasedComponent htmlComponent = (HtmlBasedComponent) tabPanel; + htmlComponent.setVflex("1"); + htmlComponent.setWidth("100%"); + + tabPanel.getGridTab().addDataStatusListener(new SyncDataStatusListener(tabPanel)); + } + + protected void activateDetailADTabpanel() { + if (detailPane != null && detailPane.getParent() != null) { + IADTabpanel tabPanel = detailPane.getSelectedADTabpanel(); + tabPanel.activate(true); + if (!tabPanel.isGridView()) { + tabPanel.switchRowPresentation(); + } + } + } + + /** + * Evaluate Tab Logic + * @param e event + */ + public void evaluate (DataStatusEvent e) + { + super.evaluate(e); + + } // evaluate + + @Override + protected void updateTabState() { + detailPane.refresh(); + } + + /** + * Return the selected Tab Panel + */ + public IADTabpanel getSelectedTabpanel() + { + return tabPanelList.isEmpty() ? null : tabPanelList.get(selectedIndex); + } + + public int getSelectedIndex() { + return selectedIndex; + } + + public void setSelectionEventListener(EventListener listener) { + selectionListener = listener; + } + + @Override + protected void doTabSelectionChanged(int oldIndex, int newIndex) { + selectedIndex = newIndex; + IADTabpanel oldTabpanel = oldIndex >= 0 ? tabPanelList.get(oldIndex) : null; + IADTabpanel newTabpanel = tabPanelList.get(newIndex); + if (oldTabpanel != null) { + oldTabpanel.setVisible(false); + } + newTabpanel.createUI(); + newTabpanel.setVisible(true); + + headerTab = newTabpanel; + layout.getChildren().clear(); + layout.appendChild(headerTab); + + detailPane.detach(); + detailPane.reset(); + + int currentLevel = headerTab.getTabLevel(); + for (int i = selectedIndex + 1; i< tabPanelList.size(); i++) { + IADTabpanel tabPanel = tabPanelList.get(i); + int tabLevel = tabPanel.getTabLevel(); + ADTabListModel.ADTabLabel tabLabel = tabLabelList.get(i); + if ((tabLevel - currentLevel) == 1 || (tabLevel == 0 && currentLevel == 0)) { + if (tabPanel.isActive() && !tabPanel.isGridView()) { + tabPanel.switchRowPresentation(); + } + if (tabPanel.getParent() != null) tabPanel.detach(); + detailPane.addADTabpanel(tabPanel, tabLabel); + tabPanel.setDetailPaneMode(true, headerTab.isGridView()); + } else if (tabLevel > currentLevel ){ + detailPane.addADTabpanel(tabPanel, tabLabel, false); + tabPanel.setDetailPaneMode(true, headerTab.isGridView()); + } + } + + if (detailPane.getTabcount() > 0 && !headerTab.getGridTab().isSortTab()) { + ADTabpanel adtabpanel = (ADTabpanel) headerTab; + adtabpanel.addDetails(detailPane); + detailPane.setVflex(Boolean.toString(headerTab.isGridView())); + detailPane.setSelectedIndex(0); + } + + updateBreadCrumb(); + } + + private void updateBreadCrumb() { + BreadCrumb breadCrumb = getBreadCrumb(); + breadCrumb.reset(); + + if (selectedIndex > 0) { + List parents = new ArrayList(); + List parentIndex = new ArrayList(); + int currentLevel = headerTab.getTabLevel(); + for(int i = selectedIndex - 1; i >= 0; i--) { + ADTabLabel tabLabel = tabLabelList.get(i); + if (tabLabel.tabLevel == currentLevel-1) { + parents.add(tabLabel); + parentIndex.add(i); + currentLevel = tabLabel.tabLevel; + } + } + Collections.reverse(parents); + Collections.reverse(parentIndex); + for(ADTabLabel tabLabel : parents) { + int index = parentIndex.remove(0); + breadCrumb.addPath(tabLabel.label, Integer.toString(index), true); + } + } + ADTabLabel tabLabel = tabLabelList.get(selectedIndex); + breadCrumb.addPath(tabLabel.label, Integer.toString(selectedIndex), false); + breadCrumb.setVisible(true); + + LinkedHashMap links = new LinkedHashMap(); + int parentIndex = 0; + if (headerTab.getTabLevel() > 1) { + for(int i = selectedIndex - 1; i > 0; i--) { + tabLabel = tabLabelList.get(i); + if (tabLabel.tabLevel == (headerTab.getTabLevel()-1)) { + parentIndex = i; + break; + } + } + } + for(int i = parentIndex+1; i < tabLabelList.size(); i++) { + if (i == selectedIndex) continue; + + tabLabel = tabLabelList.get(i); + if (tabLabel.tabLevel == headerTab.getTabLevel()) { + links.put(Integer.toString(i), tabLabel.label); + } else if (tabLabel.tabLevel < headerTab.getTabLevel()) { + break; + } + } + + if (!links.isEmpty()) { + breadCrumb.addLinks(links); + } + } + + protected BreadCrumb getBreadCrumb() { + ADWindowContent window = (ADWindowContent) adWindowPanel; + BreadCrumb breadCrumb = window.getBreadCrumb(); + return breadCrumb; + } + + public Component getComponent() { + return layout; + } + + @Override + public IADTabpanel findADTabpanel(GridTab gTab) { + for (IADTabpanel tabpanel : tabPanelList) { + if (tabpanel.getGridTab() == gTab) { + return tabpanel; + } + } + return null; + } + +// public void refresh() { +// } + + class SyncDataStatusListener implements DataStatusListener { + + private IADTabpanel tabPanel; + + SyncDataStatusListener(IADTabpanel tabpanel) { + this.tabPanel = tabpanel; + } + + @Override + public void dataStatusChanged(DataStatusEvent e) { + Execution execution = Executions.getCurrent(); + if (execution == null) return; + + if (tabPanel == headerTab && detailPane.getPage() != null && e.getChangedColumn() == -1) { + ArrayList parentColumnNames = new ArrayList(); + GridField[] parentFields = headerTab.getGridTab().getFields(); + for (GridField parentField : parentFields) { + parentColumnNames.add(parentField.getColumnName()); + } + + IADTabpanel detailTab = detailPane.getSelectedADTabpanel(); + + //check data action + String uuid = (String) execution.getAttribute(CompositeADTabbox.class.getName()+".dataAction"); + if (uuid != null && uuid.equals(detailTab.getUuid())) { + //refresh current row + detailTab.getGridTab().dataRefresh(false); + //keep focus + onDetailRecord(); + + return; + } + + GridTab tab = detailTab.getGridTab(); + GridField[] fields = tab.getFields(); + for (GridField field : fields) + { + if (!parentColumnNames.contains(field.getColumnName())) + Env.setContext(Env.getCtx(), field.getWindowNo(), field.getColumnName(), ""); + } + detailTab.query(false, 0, 0); + detailTab.activate(true); + detailTab.setDetailPaneMode(true, headerTab.isGridView()); + detailPane.setVflex(Boolean.toString(headerTab.isGridView())); + } + } + + } + + @Override + public void onDetailRecord() { + if (detailPane != null && detailPane.getParent() != null) { + Clients.scrollIntoView(detailPane); + detailPane.focus(); + } + } + + @Override + public void onParentRecord() { + Clients.scrollIntoView(headerTab); + ((HtmlBasedComponent)headerTab).focus(); + } + + @Override + public boolean isSortTab() { + return headerTab != null ? headerTab.getGridTab().isSortTab() : false; + } + + @Override + public IADTabpanel getSelectedDetailADTabpanel() { + if (detailPane != null && detailPane.getParent() != null) { + return detailPane.getSelectedADTabpanel(); + } + return null; + } + + @Override + public boolean needSave(boolean rowChange, boolean onlyRealChange) { + boolean b = headerTab.getGridTab().needSave(rowChange, onlyRealChange); + if (b) + return b; + + IADTabpanel detailPanel = getSelectedDetailADTabpanel(); + if (detailPanel != null) { + b = detailPanel.getGridTab().needSave(rowChange, onlyRealChange); + } + + return b; + } + + @Override + public void dataIgnore() { + IADTabpanel detailPanel = getSelectedDetailADTabpanel(); + if (detailPanel != null) { + detailPanel.getGridTab().dataIgnore(); + } + headerTab.getGridTab().dataIgnore(); + } + + @Override + public GridTab getSelectedGridTab() { + IADTabpanel tabpanel = getSelectedTabpanel(); + return tabpanel == null ? null : tabpanel.getGridTab(); + } + + @Override + public boolean dataSave(boolean onSaveEvent) { + IADTabpanel detail = getSelectedDetailADTabpanel(); + if (detail != null && detail.getGridTab().needSave(true, true)) { + Execution execution = Executions.getCurrent(); + if (execution != null) { + execution.setAttribute(getClass().getName()+".dataAction", detail.getUuid()); + } + return detail.getGridTab().dataSave(onSaveEvent); + } + return headerTab.getGridTab().dataSave(onSaveEvent); + } + + @Override + public void setDetailPaneStatusMessage(String status, boolean error) { + detailPane.setStatusMessage(status, error); + } + + @Override + public IADTabpanel getDirtyADTabpanel() { + IADTabpanel detail = getSelectedDetailADTabpanel(); + if (detail != null && detail.getGridTab().needSave(true, true)) { + return detail; + } else if (detail != null && detail instanceof ADSortTab && ((ADSortTab)detail).isChanged()) { + return detail; + } else if (headerTab.getGridTab().needSave(true, true)) { + return headerTab; + } else if (headerTab instanceof ADSortTab && ((ADSortTab)headerTab).isChanged()) { + return headerTab; + } + + return null; + } + + protected void onActivateDetail(IADTabpanel tabPanel) { + tabPanel.createUI(); + tabPanel.query(false, 0, 0); + if (!tabPanel.isVisible()) + tabPanel.setVisible(true); + if (!tabPanel.isGridView()) { + tabPanel.switchRowPresentation(); + } + tabPanel.setDetailPaneMode(true, headerTab.isGridView()); + detailPane.setVflex(Boolean.toString(headerTab.isGridView())); + if (tabPanel instanceof ADSortTab) { + detailPane.invalidate(); + detailPane.updateToolbar(false, true); + onDetailRecord(); + } + } + + private void showLastError() { + String msg = CLogger.retrieveErrorString(null); + if (msg != null) + { + detailPane.setStatusMessage(Msg.getMsg(Env.getCtx(), msg), true); + } + //other error will be catch in the dataStatusChanged event + } + + @Override + public void updateDetailPaneToolbar(boolean changed, boolean readOnly) { + detailPane.updateToolbar(changed, readOnly); + } + + @Override + public void setDetailpaneSelection(int tabIndex, int currentRow) { + if (detailPane.getTabcount() > 0) { + for(int i = 0; i < detailPane.getTabcount(); i++) { + IADTabpanel adtab = detailPane.getADTabpanel(i); + int index = (Integer) adtab.getAttribute(ADTAB_INDEX_ATTRIBUTE); + if (index == tabIndex) { + if (i != detailPane.getSelectedIndex()) { + detailPane.setSelectedIndex(i); + detailPane.fireActivateDetailEvent(); + } + if (adtab.getGridTab().getCurrentRow() != currentRow) + adtab.getGridTab().setCurrentRow(currentRow, true); + break; + } + } + } + } +} diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/DetailPane.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/DetailPane.java new file mode 100644 index 0000000000..78f75a49ff --- /dev/null +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/DetailPane.java @@ -0,0 +1,418 @@ +/** + * + */ +package org.adempiere.webui.adwindow; + +import java.util.HashMap; +import java.util.Map; + +import org.adempiere.webui.LayoutUtils; +import org.adempiere.webui.component.Label; +import org.adempiere.webui.component.Panel; +import org.adempiere.webui.component.Tab; +import org.adempiere.webui.component.Tabbox; +import org.adempiere.webui.component.Tabpanel; +import org.adempiere.webui.component.ToolBar; +import org.adempiere.webui.component.ToolBarButton; +import org.adempiere.webui.component.Window; +import org.adempiere.webui.component.ADTabListModel.ADTabLabel; +import org.adempiere.webui.session.SessionManager; +import org.compiere.util.Env; +import org.compiere.util.Msg; +import org.compiere.util.Util; +import org.zkoss.zhtml.Text; +import org.zkoss.zk.ui.Component; +import org.zkoss.zk.ui.Execution; +import org.zkoss.zk.ui.Executions; +import org.zkoss.zk.ui.Page; +import org.zkoss.zk.ui.event.Event; +import org.zkoss.zk.ui.event.EventListener; +import org.zkoss.zk.ui.event.Events; +import org.zkoss.zk.ui.util.Clients; +import org.zkoss.zul.Caption; +import org.zkoss.zul.Div; +import org.zkoss.zul.Hbox; +import org.zkoss.zul.Image; +import org.zkoss.zul.Space; +import org.zkoss.zul.Tabpanels; +import org.zkoss.zul.Tabs; +import org.zkoss.zul.Toolbar; + +/** + * @author hengsin + * + */ +public class DetailPane extends Panel implements EventListener { + + private static final String STATUS_TEXT_ATTRIBUTE = "status.text"; + + private static final String STATUS_ERROR_ATTRIBUTE = "status.error"; + + private static final String TABBOX_STYLE = "min-height: 200px; overflow-y: visible; width: 99%; margin: auto;"; + private static final String DELETE_IMAGE = "/images/Delete16.png"; + private static final String EDIT_IMAGE = "/images/EditRecord16.png"; + private static final String NEW_IMAGE = "/images/New16.png"; + private static final String STYLE = "min-height: 200px; width: 100%; overflow-y: visible;"; + + /** + * generated serial id + */ + private static final long serialVersionUID = -7914602940626352282L; + + private static final String INFO_INDICATOR_IMAGE = "/images/InfoIndicator16.png"; + + private static final String ERROR_INDICATOR_IMAGE = "/images/ErrorIndicator16.png"; + + private Tabbox tabbox; + + private EventListener eventListener; + + private Map messageContainers = new HashMap(); + + private Div msgPopupCnt; + + private Window msgPopup; + + private Caption msgPopupCaption; + + private int prevSelectedIndex = 0; + + public static final String ON_ACTIVATE_DETAIL_EVENT = "onActivateDetail"; + + public static final String ON_DELETE_EVENT = "onDelete"; + + public static final String ON_NEW_EVENT = "onNew"; + + public static final String ON_EDIT_EVENT = "onEdit"; + + public DetailPane() { + tabbox = new Tabbox(); + tabbox.setParent(this); + tabbox.addEventListener(Events.ON_SELECT, new EventListener() { + @Override + public void onEvent(Event event) throws Exception { + fireActivateDetailEvent(); + } + }); + tabbox.setStyle(TABBOX_STYLE); + + createPopup(); + + this.setStyle(STYLE); + + //TODO: this probably not needed + this.setHflex("true"); + } + + public int getSelectedIndex() { + return tabbox.getSelectedIndex(); + } + + public void setSelectedIndex(int curTabIndex) { + tabbox.setSelectedIndex(curTabIndex); + prevSelectedIndex = curTabIndex; + } + + public int getTabcount() { + int count = 0; + Tabs tabs = tabbox.getTabs(); + if (tabs != null) + count = tabs.getChildren().size(); + return count; + } + + public void undoLastTabSelection() { + tabbox.setSelectedIndex(prevSelectedIndex); + } + + public void refresh() { + tabbox.invalidate(); + } + + public void addADTabpanel(IADTabpanel tabPanel, ADTabLabel tabLabel) { + addADTabpanel(tabPanel, tabLabel, true); + } + + public void addADTabpanel(IADTabpanel tabPanel, ADTabLabel tabLabel, boolean enabled) { + Tabs tabs = tabbox.getTabs(); + if (tabs == null) { + tabs = new Tabs(); + tabbox.appendChild(tabs); + } + Tab tab = new Tab(); + tabs.appendChild(tab); + tab.setLabel(tabLabel.label); + if (!enabled) { + tab.setDisabled(true); + } + + Tabpanels tabpanels = tabbox.getTabpanels(); + if (tabpanels == null) { + tabpanels = new Tabpanels(); + //TODO: is this style needed ? + tabpanels.setStyle("min-height: 200px; overflow-y: visible;"); + tabpanels.setWidth("100%"); + tabbox.appendChild(tabpanels); + } + Tabpanel tp = new Tabpanel(); + //TODO: is this style needed + tp.setStyle("min-height: 180px; overflow-y: visible; width: 99%; margin: auto;"); + tabpanels.appendChild(tp); + tp.setStyle("background-color: #fff"); + ToolBar toolbar = new ToolBar(); + tp.appendChild(toolbar); + ToolBarButton button = new ToolBarButton(); + + button = new ToolBarButton(); + button.setImage(NEW_IMAGE); + toolbar.appendChild(button); + button.addEventListener(Events.ON_CLICK, new EventListener() { + @Override + public void onEvent(Event event) throws Exception { + Event openEvent = new Event(ON_NEW_EVENT, DetailPane.this); + eventListener.onEvent(openEvent); + } + }); + button.setTooltiptext(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "New"))); + + button = new ToolBarButton(); + button.setImage(EDIT_IMAGE); + toolbar.appendChild(button); + button.addEventListener(Events.ON_CLICK, new EventListener() { + @Override + public void onEvent(Event event) throws Exception { + onEdit(); + } + }); + button.setTooltiptext(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "EditRecord"))); + + button = new ToolBarButton(); + button.setImage(DELETE_IMAGE); + toolbar.appendChild(button); + button.addEventListener(Events.ON_CLICK, new EventListener() { + @Override + public void onEvent(Event event) throws Exception { + Event openEvent = new Event(ON_DELETE_EVENT, DetailPane.this); + eventListener.onEvent(openEvent); + } + }); + button.setTooltiptext(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "Delete"))); + + Hbox messageContainer = new Hbox(); + messageContainer.setPack("end"); + messageContainer.setHflex("1"); + messageContainer.setStyle("float: right"); + + toolbar.appendChild(messageContainer); + toolbar.setSclass("adtab-detail-toolbar"); + toolbar.setVflex("0"); + messageContainers.put(tabLabel.AD_Tab_ID, messageContainer); + tabPanel.setAttribute("AD_Tab_ID", tabLabel.AD_Tab_ID); + + tp.appendChild(tabPanel); + } + + public void setEventListener(EventListener listener) { + eventListener = listener; + } + + public void reset() { + if (tabbox.getTabs() != null) { + tabbox.getTabs().getChildren().clear(); + } + if (tabbox.getTabpanels() != null) { + tabbox.getTabpanels().getChildren().clear(); + } + + } + + public IADTabpanel getADTabpanel(int index) { + if (index < 0 || index >= tabbox.getTabpanels().getChildren().size()) + return null; + + org.zkoss.zul.Tabpanel tabPanel = tabbox.getTabpanel(index); + for(Component c : tabPanel.getChildren()) { + if (c instanceof IADTabpanel) + return (IADTabpanel)c; + } + return null; + } + + public IADTabpanel getSelectedADTabpanel() { + org.zkoss.zul.Tabpanel selectedPanel = tabbox.getSelectedPanel(); + if (selectedPanel != null) { + for(Component c : selectedPanel.getChildren()) { + if (c instanceof IADTabpanel) + return (IADTabpanel)c; + } + } + return null; + } + + public void setStatusMessage(String status, boolean error) { + IADTabpanel tabPanel = getSelectedADTabpanel(); + Hbox messageContainer = messageContainers.get(tabPanel.getAttribute("AD_Tab_ID")); + + Execution execution = Executions.getCurrent(); + if (execution != null) { + String key = this.getClass().getName()+"."+messageContainer.getUuid(); + Object o = execution.getAttribute(key); + if (o != null) { + if (status == null || status.trim().length() == 0) + return; + } else { + execution.setAttribute(key, Boolean.TRUE); + } + } + + messageContainer.getChildren().clear(); + messageContainer.setAttribute(STATUS_ERROR_ATTRIBUTE, error); + messageContainer.setAttribute(STATUS_TEXT_ATTRIBUTE, status); + + if (status == null || status.trim().length() == 0) + return; + + Image image = null; + if (error) + image = new Image(ERROR_INDICATOR_IMAGE); + else + image = new Image(INFO_INDICATOR_IMAGE); + + image.setAttribute("org.zkoss.zul.image.preload", Boolean.TRUE); + messageContainer.appendChild(image); + String labelText = buildLabelText(status); + if (error) { + Clients.showNotification(labelText, "error", image, "overlap_start", 3500, true); + } + Label label = new Label(labelText); + messageContainer.appendChild(label); + if (labelText.length() != status.length()) { + image.addEventListener(Events.ON_CLICK, this); + image.setStyle("cursor: pointer"); + label.addEventListener(Events.ON_CLICK, this); + label.setStyle("cursor: pointer"); + + label = new Label(" ..."); + label.setStyle("cursor: pointer"); + messageContainer.appendChild(label); + label.addEventListener(Events.ON_CLICK, this); + } + + messageContainer.appendChild(new Space()); + } + + private String buildLabelText(String statusText) { + if (statusText == null) + return ""; + if (statusText.length() <= 80) + return statusText; + + int index = statusText.indexOf(" - java.lang.Exception"); + if (index > 0) + return statusText.substring(0, index); + return statusText.substring(0, 80); + } + + @Override + public void onEvent(Event event) throws Exception { + Component messageContainer = event.getTarget().getParent(); + Boolean error = (Boolean) messageContainer.getAttribute(STATUS_ERROR_ATTRIBUTE); + String status = (String) messageContainer.getAttribute(STATUS_TEXT_ATTRIBUTE); + + createPopupContent(status); + showPopup(error, messageContainer); + } + + protected void createPopupContent(String status) { + Text t = new Text(status); + msgPopupCnt.getChildren().clear(); + msgPopupCnt.appendChild(t); + } + + private void showPopup(boolean error, Component messageContainer) { + msgPopupCaption.setImage(error ? ERROR_INDICATOR_IMAGE : INFO_INDICATOR_IMAGE); + LayoutUtils.openOverlappedWindow(messageContainer, msgPopup, "overlap_end"); + } + + private void createPopup() { + msgPopupCnt = new Div(); + msgPopupCnt.setVflex("1"); + + + msgPopup = new Window(); + msgPopup.setBorder(true); + msgPopup.setClosable(true); + msgPopup.setSizable(true); + msgPopup.setContentStyle("overflow: auto"); + msgPopup.setWidth("500px"); + msgPopup.appendChild(msgPopupCnt); + msgPopup.setPage(SessionManager.getAppDesktop().getComponent().getPage()); + msgPopup.setShadow(true); + msgPopupCaption = new Caption(); + msgPopup.appendChild(msgPopupCaption); + } + + @Override + public void onPageDetached(Page page) { + super.onPageDetached(page); + if (msgPopup != null) + msgPopup.detach(); + } + + /* (non-Javadoc) + * @see org.zkoss.zk.ui.HtmlBasedComponent#setVflex(java.lang.String) + */ + @Override + public void setVflex(String flex) { + super.setVflex(flex); + tabbox.setVflex(flex); + } + + public void updateToolbar(boolean changed, boolean readOnly) { + int index = getSelectedIndex(); + if (index < 0 || index >= getTabcount()) return; + + Tabpanel tabpanel = tabbox.getTabpanel(index); + Toolbar toolbar = (Toolbar) tabpanel.getFirstChild(); + + IADTabpanel adtab = getADTabpanel(index); + if (adtab.getGridTab().isSortTab()) + readOnly = true; + + boolean insertRecord = !readOnly; + if (insertRecord) + { + insertRecord = adtab.getGridTab().isInsertRecord(); + } + boolean enableNew = !changed && insertRecord && !adtab.getGridTab().isSortTab(); + boolean enableDelete = !changed && !readOnly && !adtab.getGridTab().isSortTab(); + int newBtn = 0; + int deleteBtn = 0; + for(Component c : toolbar.getChildren()) { + if (c instanceof ToolBarButton) { + ToolBarButton btn = (ToolBarButton) c; + if (NEW_IMAGE.equals(btn.getImage())) { + btn.setDisabled(!enableNew); + newBtn++; + } else if (DELETE_IMAGE.equals(btn.getImage())) { + btn.setDisabled(!enableDelete); + deleteBtn++; + } + if (newBtn > 0 && deleteBtn > 0) + break; + } + } + } + + public void onEdit() throws Exception { + Event openEvent = new Event(ON_EDIT_EVENT, DetailPane.this); + eventListener.onEvent(openEvent); + } + + public void fireActivateDetailEvent() { + int index = tabbox.getSelectedIndex(); + IADTabpanel tabPanel = (IADTabpanel) tabbox.getTabpanel(index).getChildren().get(1); + Event activateEvent = new Event(ON_ACTIVATE_DETAIL_EVENT, tabPanel, prevSelectedIndex); + Events.sendEvent(activateEvent); + } +} diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/GridTabRowRenderer.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/GridTabRowRenderer.java similarity index 97% rename from org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/GridTabRowRenderer.java rename to org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/GridTabRowRenderer.java index b41caae61b..1b0975ca52 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/GridTabRowRenderer.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/GridTabRowRenderer.java @@ -10,7 +10,7 @@ * with this program; if not, write to the Free Software Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * *****************************************************************************/ -package org.adempiere.webui.component; +package org.adempiere.webui.adwindow; import java.sql.Timestamp; import java.text.SimpleDateFormat; @@ -23,6 +23,9 @@ import java.util.Map.Entry; import org.adempiere.util.GridRowCtx; import org.adempiere.webui.apps.AEnv; +import org.adempiere.webui.component.Checkbox; +import org.adempiere.webui.component.EditorBox; +import org.adempiere.webui.component.NumberBox; import org.adempiere.webui.editor.WButtonEditor; import org.adempiere.webui.editor.WEditor; import org.adempiere.webui.editor.WEditorPopupMenu; @@ -30,16 +33,13 @@ import org.adempiere.webui.editor.WebEditorFactory; import org.adempiere.webui.event.ActionEvent; import org.adempiere.webui.event.ActionListener; import org.adempiere.webui.event.ContextMenuListener; -import org.adempiere.webui.panel.AbstractADWindowPanel; import org.adempiere.webui.session.SessionManager; import org.adempiere.webui.util.GridTabDataBinder; -import org.adempiere.webui.window.ADWindow; import org.compiere.model.GridField; import org.compiere.model.GridTab; import org.compiere.util.DisplayType; import org.compiere.util.Env; import org.compiere.util.NamePair; -import org.zkoss.xml.XMLs; import org.zkoss.zk.au.out.AuFocus; import org.zkoss.zk.ui.Component; import org.zkoss.zk.ui.HtmlBasedComponent; @@ -80,12 +80,12 @@ public class GridTabRowRenderer implements RowRenderer, RowRendererExt private RowListener rowListener; private Grid grid = null; - private GridPanel gridPanel = null; + private GridView gridPanel = null; private Row currentRow; private Object[] currentValues; private boolean editing = false; private int currentRowIndex = -1; - private AbstractADWindowPanel m_windowPanel; + private AbstractADWindowContent m_windowPanel; /** * @@ -122,7 +122,7 @@ public class GridTabRowRenderer implements RowRenderer, RowRendererExt Object window = SessionManager.getAppDesktop().findWindow(windowNo); if (window != null && window instanceof ADWindow) { - AbstractADWindowPanel windowPanel = ((ADWindow)window).getADWindowPanel(); + AbstractADWindowContent windowPanel = ((ADWindow)window).getADWindowContent(); ((WButtonEditor)editor).addActionListener(windowPanel); } } @@ -625,7 +625,7 @@ public class GridTabRowRenderer implements RowRenderer, RowRendererExt * * @param gridPanel */ - public void setGridPanel(GridPanel gridPanel) { + public void setGridPanel(GridView gridPanel) { this.gridPanel = gridPanel; } @@ -664,7 +664,7 @@ public class GridTabRowRenderer implements RowRenderer, RowRendererExt /** * @param windowPanel */ - public void setADWindowPanel(AbstractADWindowPanel windowPanel) { + public void setADWindowPanel(AbstractADWindowContent windowPanel) { this.m_windowPanel = windowPanel; } } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/GridTableListModel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/GridTableListModel.java similarity index 95% rename from org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/GridTableListModel.java rename to org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/GridTableListModel.java index c9dcc14cb4..0aba293355 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/GridTableListModel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/GridTableListModel.java @@ -10,7 +10,7 @@ * with this program; if not, write to the Free Software Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * *****************************************************************************/ -package org.adempiere.webui.component; +package org.adempiere.webui.adwindow; import java.util.Comparator; diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/GridPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/GridView.java similarity index 84% rename from org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/GridPanel.java rename to org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/GridView.java index 3185093d0f..f390e76f0b 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/GridPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/GridView.java @@ -10,7 +10,7 @@ * with this program; if not, write to the Free Software Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * *****************************************************************************/ -package org.adempiere.webui.component; +package org.adempiere.webui.adwindow; import java.util.ArrayList; import java.util.Collections; @@ -22,11 +22,14 @@ import java.util.Map; import javax.swing.table.AbstractTableModel; import org.adempiere.model.MTabCustomization; -import org.adempiere.webui.LayoutUtils; import org.adempiere.webui.apps.AEnv; +import org.adempiere.webui.component.Borderlayout; +import org.adempiere.webui.component.Columns; +import org.adempiere.webui.component.EditorBox; +import org.adempiere.webui.component.Grid; +import org.adempiere.webui.component.NumberBox; import org.adempiere.webui.editor.WEditor; import org.adempiere.webui.event.TouchEventHelper; -import org.adempiere.webui.panel.AbstractADWindowPanel; import org.adempiere.webui.util.SortComparator; import org.compiere.model.GridField; import org.compiere.model.GridTab; @@ -34,6 +37,8 @@ import org.compiere.model.GridTable; import org.compiere.model.MSysConfig; import org.compiere.util.DisplayType; import org.compiere.util.Env; +import org.compiere.util.Msg; +import org.compiere.util.Util; import org.zkoss.zk.au.out.AuFocus; import org.zkoss.zk.au.out.AuScript; import org.zkoss.zk.ui.AbstractComponent; @@ -42,14 +47,14 @@ import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.EventListener; import org.zkoss.zk.ui.event.Events; import org.zkoss.zk.ui.util.Clients; -import org.zkoss.zul.Borderlayout; import org.zkoss.zul.Center; import org.zkoss.zul.Frozen; -import org.zkoss.zul.South; import org.zkoss.zul.Column; import org.zkoss.zul.Div; +import org.zkoss.zul.North; import org.zkoss.zul.Paging; import org.zkoss.zul.Row; +import org.zkoss.zul.Vbox; import org.zkoss.zul.event.ZulEvents; /** @@ -57,8 +62,12 @@ import org.zkoss.zul.event.ZulEvents; * @author Low Heng Sin * */ -public class GridPanel extends Borderlayout implements EventListener +public class GridView extends Vbox implements EventListener { + private static final int DEFAULT_DETAIL_PAGE_SIZE = 10; + + private static final int DEFAULT_PAGE_SIZE = 50; + /** * generated serial version ID */ @@ -74,7 +83,7 @@ public class GridPanel extends Borderlayout implements EventListener private Grid listbox = null; - private int pageSize = 100; + private int pageSize = DEFAULT_PAGE_SIZE; private GridField[] gridField; private AbstractTableModel tableModel; @@ -93,19 +102,23 @@ public class GridPanel extends Borderlayout implements EventListener private GridTabRowRenderer renderer; - private South south; + private Div gridFooter; private boolean modeless = true; private String columnOnClick; - private AbstractADWindowPanel windowPanel; + private AbstractADWindowContent windowPanel; private boolean refreshing; private Map columnWidthMap; - public GridPanel() + private Component detail; + + private Borderlayout borderLayout; + + public GridView() { this(0); } @@ -113,14 +126,29 @@ public class GridPanel extends Borderlayout implements EventListener /** * @param windowNo */ - public GridPanel(int windowNo) + public GridView(int windowNo) { this.windowNo = windowNo; - listbox = new Grid(); - listbox.addEventListener(ZulEvents.ON_AFTER_RENDER, this); - south = new South(); - this.appendChild(south); + createListbox(); + this.setHflex("1"); + + gridFooter = new Div(); + gridFooter.setHflex("1"); + gridFooter.setVflex("0"); + + borderLayout = new Borderlayout(); + borderLayout.setStyle("position: absolute; height: 100%; width: 100%;"); + appendChild(borderLayout); + Center center = new Center(); + borderLayout.appendChild(center); + North north = new North(); + north.setVflex("min"); + borderLayout.appendChild(north); + + borderLayout.appendCenter(listbox); + borderLayout.appendNorth(gridFooter); + //default paging size if (AEnv.isTablet()) { @@ -129,7 +157,7 @@ public class GridPanel extends Borderlayout implements EventListener } else { - pageSize = MSysConfig.getIntValue(MSysConfig.ZK_PAGING_SIZE, 100); + pageSize = MSysConfig.getIntValue(MSysConfig.ZK_PAGING_SIZE, 50); } //default true for better UI experience @@ -137,6 +165,51 @@ public class GridPanel extends Borderlayout implements EventListener } + protected void createListbox() { + listbox = new Grid(); + listbox.setEmptyMessage(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "FindZeroRecords"))); + listbox.addEventListener(ZulEvents.ON_AFTER_RENDER, this); + listbox.setSizedByContent(true); + listbox.setVflex("1"); + listbox.setHflex("1"); + } + + public void setDetailPaneMode(boolean detailPaneMode, boolean vflex) { + if (detailPaneMode) { + pageSize = DEFAULT_DETAIL_PAGE_SIZE; + updatePaging(); + if (borderLayout.getParent() != null) { + listbox.detach(); + gridFooter.detach(); + borderLayout.detach(); + appendChild(listbox); + appendChild(gridFooter); + } + //false work for header form, true work for header grid + listbox.setVflex(vflex); + this.setVflex(Boolean.toString(vflex)); + } else { + pageSize = MSysConfig.getIntValue(MSysConfig.ZK_PAGING_SIZE, 50); + updatePaging(); + if (borderLayout.getParent() == null) { + listbox.detach(); + gridFooter.detach(); + appendChild(borderLayout); + borderLayout.appendCenter(listbox); + borderLayout.appendNorth(gridFooter); + } + listbox.setVflex("true"); + this.setVflex("true"); + } + } + + private void updatePaging() { + if (paging != null && paging.getPageSize() != pageSize) { + paging.setPageSize(pageSize); + updateModel(); + } + } + /** * * @param gridTab @@ -260,6 +333,10 @@ public class GridPanel extends Borderlayout implements EventListener if (pageSize > 0) { if (paging.getTotalSize() != gridTab.getRowCount()) paging.setTotalSize(gridTab.getRowCount()); + if (paging.getPageCount() > 1 && !gridFooter.isVisible()) { + gridFooter.setVisible(true); + borderLayout.invalidate(); + } int pgIndex = rowIndex >= 0 ? rowIndex % pageSize : 0; int pgNo = rowIndex >= 0 ? (rowIndex - pgIndex) / pageSize : 0; if (listModel.getPage() != pgNo) { @@ -282,6 +359,11 @@ public class GridPanel extends Borderlayout implements EventListener if (paging.getActivePage() != pgNo) { paging.setActivePage(pgNo); } + if (paging.getPageCount() == 1) { + gridFooter.setVisible(false); + } else { + gridFooter.setVisible(true); + } if (rowIndex >= 0 && pgIndex >= 0) { Events.echoEvent("onPostSelectedRowChanged", this, null); } @@ -389,36 +471,29 @@ public class GridPanel extends Borderlayout implements EventListener private void render() { - LayoutUtils.addSclass("adtab-grid-panel", this); - - listbox.setVflex(true); - //true might looks better, false for better performance - listbox.setSizedByContent(false); listbox.addEventListener(Events.ON_CLICK, this); updateModel(); - Center center = new Center(); - center.appendChild(listbox); - if (AEnv.isTablet()) { - LayoutUtils.addSclass("tablet-scrolling", center); - } - this.appendChild(center); - if (pageSize > 0) { paging = new Paging(); paging.setPageSize(pageSize); paging.setTotalSize(tableModel.getRowCount()); paging.setDetailed(true); - south.appendChild(paging); - south.setSclass("adtab-grid-south"); + gridFooter.appendChild(paging); + gridFooter.setSclass("adtab-grid-south"); paging.addEventListener(ZulEvents.ON_PAGING, this); renderer.setPaging(paging); + if (paging.getPageCount() == 1) { + gridFooter.setVisible(false); + } else { + gridFooter.setVisible(true); + } } else { - south.setVisible(false); + gridFooter.setVisible(false); } if (AEnv.isTablet()) { @@ -531,8 +606,6 @@ public class GridPanel extends Borderlayout implements EventListener if (!isRowRendered(row, pgIndex)) { listbox.renderRow(row); } else { -// Row old = renderer.getCurrentRow(); -// int oldIndex = renderer.getCurrentRowIndex(); renderer.setCurrentRow(row); //remark: following 3 line cause the previously selected row being render twice // if (old != null && old != row && oldIndex >= 0 && oldIndex != gridTab.getCurrentRow()) @@ -556,8 +629,6 @@ public class GridPanel extends Borderlayout implements EventListener if (!isRowRendered(row, rowIndex)) { listbox.renderRow(row); } else { -// Row old = renderer.getCurrentRow(); -// int oldIndex = renderer.getCurrentRowIndex(); renderer.setCurrentRow(row); //remark: following 3 line cause the previously selected row being render twice // if (old != null && old != row && oldIndex >= 0 && oldIndex != gridTab.getCurrentRow()) @@ -758,7 +829,7 @@ public class GridPanel extends Borderlayout implements EventListener /** * @param winPanel */ - public void setADWindowPanel(AbstractADWindowPanel winPanel) { + public void setADWindowPanel(AbstractADWindowContent winPanel) { windowPanel = winPanel; if (renderer != null) renderer.setADWindowPanel(windowPanel); @@ -782,4 +853,25 @@ public class GridPanel extends Borderlayout implements EventListener public GridField[] getFields() { return gridField; } + + public void addDetails(Component component) { + detail = component; + borderLayout.appendSouth(detail); + borderLayout.getSouth().setCollapsible(true); + borderLayout.getSouth().setTitle(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "Detail"))); + borderLayout.getSouth().setOpen(false); + borderLayout.getSouth().setHeight("250px"); + } + + public Component removeDetails() { + Component details = null; + if (detail != null) { + if (detail.getParent() != null) { + detail.detach(); + details = detail; + } + detail = null; + } + return details; + } } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/IADTab.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/IADTabbox.java similarity index 71% rename from org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/IADTab.java rename to org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/IADTabbox.java index c40255e03d..524bec5609 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/IADTab.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/IADTabbox.java @@ -10,14 +10,12 @@ * with this program; if not, write to the Free Software Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * *****************************************************************************/ -package org.adempiere.webui.component; +package org.adempiere.webui.adwindow; -import org.adempiere.webui.panel.AbstractADWindowPanel; -import org.adempiere.webui.panel.IADTabpanel; import org.adempiere.webui.part.UIPart; import org.compiere.model.DataStatusEvent; import org.compiere.model.GridTab; -import org.zkoss.zk.ui.Component; +import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.EventListener; /** @@ -25,7 +23,7 @@ import org.zkoss.zk.ui.event.EventListener; * @author Low Heng Sin * */ -public interface IADTab extends UIPart { +public interface IADTabbox extends UIPart { /** * @@ -91,17 +89,7 @@ public interface IADTab extends UIPart { * * @param listener */ - public void addSelectionEventListener(EventListener listener); - - /** - * @return tab selection component - */ - public Component getTabSelectionComponent(); - - /** - * @return boolean - */ - public boolean isUseExternalSelection(); + public void setSelectionEventListener(EventListener listener); /** * @param index @@ -109,18 +97,6 @@ public interface IADTab extends UIPart { */ public IADTabpanel getADTabpanel(int index); - /** - * constant for tab placement - */ - public final int LEFT = 0; - public final int RIGHT = 1; - - /** - * Set tab placement ( left or right ) - * @param tabPlacement - */ - public void setTabplacement(int tabPlacement); - /** * @param gTab * @return IADTabpanel or null if not found @@ -131,5 +107,29 @@ public interface IADTab extends UIPart { * * @param abstractADWindowPanel */ - public void setADWindowPanel(AbstractADWindowPanel abstractADWindowPanel); + public void setADWindowPanel(AbstractADWindowContent abstractADWindowPanel); + + public void onDetailRecord(); + + public void onParentRecord(); + + public boolean isSortTab(); + + public boolean needSave(boolean rowChange, boolean onlyRealChange); + + public void dataIgnore(); + + public GridTab getSelectedGridTab(); + + public boolean dataSave(boolean onSaveEvent); + + public void setDetailPaneStatusMessage(String status, boolean error); + + IADTabpanel getSelectedDetailADTabpanel(); + + IADTabpanel getDirtyADTabpanel(); + + public void updateDetailPaneToolbar(boolean changed, boolean readOnly); + + public void setDetailpaneSelection(int tabIndex, int currentRow); } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/IADTabpanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/IADTabpanel.java similarity index 88% rename from org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/IADTabpanel.java rename to org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/IADTabpanel.java index 93ae8da7b1..295d691f63 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/IADTabpanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/IADTabpanel.java @@ -10,7 +10,7 @@ * with this program; if not, write to the Free Software Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * *****************************************************************************/ -package org.adempiere.webui.panel; +package org.adempiere.webui.adwindow; import org.compiere.model.GridTab; import org.compiere.util.Evaluatee; @@ -111,4 +111,13 @@ public interface IADTabpanel extends Component, Evaluatee { * @return true if the event is process */ public boolean onEnterKey(); + + /** + * @return boolean + */ + public boolean isGridView(); + + public boolean isActive(); + + public void setDetailPaneMode(boolean detailMode, boolean vflex); } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/StatusBar.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/StatusBar.java new file mode 100644 index 0000000000..1829958c3c --- /dev/null +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/StatusBar.java @@ -0,0 +1,90 @@ +/****************************************************************************** +. * Product: Posterita Ajax UI * + * Copyright (C) 2007 Posterita Ltd. All Rights Reserved. * + * This program is free software; you can redistribute it and/or modify it * + * under the terms version 2 of the GNU General Public License as published * + * by the Free Software Foundation. This program is distributed in the hope * + * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * + * See the GNU General Public License for more details. * + * You should have received a copy of the GNU General Public License along * + * with this program; if not, write to the Free Software Foundation, Inc., * + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * + * For the text or an alternative of this public license, you may reach us * + * Posterita Ltd., 3, Draper Avenue, Quatre Bornes, Mauritius * + * or via info@posterita.org or http://www.posterita.org/ * + *****************************************************************************/ + +package org.adempiere.webui.adwindow; + +import org.adempiere.webui.LayoutUtils; +import org.adempiere.webui.component.Label; +import org.adempiere.webui.component.Panel; +import org.zkoss.zul.Cell; +import org.zkoss.zul.Div; +import org.zkoss.zul.Hbox; +import org.zkoss.zul.Vbox; + +/** + * This class is based on org.compiere.apps.StatusBar written by Jorg Janke. + * @author Jorg Janke + * + * @author Ashley G Ramdass + * @date Mar 12, 2007 + * @version $Revision: 0.10 $ + */ +public class StatusBar extends Panel +{ + /** + * + */ + private static final long serialVersionUID = -3262889055635240201L; + + private Label infoLine; + + private Div west; + + public StatusBar() + { + super(); + init(); + } + + private void init() + { + Hbox hbox = new Hbox(); + hbox.setWidth("100%"); + hbox.setHeight("100%"); + hbox.setHflex("1"); + hbox.setPack("center"); + Cell leftCell = new Cell(); + hbox.appendChild(leftCell); + leftCell.setWidth("100%"); + + infoLine = new Label(); + + west = new Div(); + west.setStyle("text-align: left; "); + west.appendChild(infoLine); + Vbox vbox = new Vbox(); + vbox.setPack("center"); + LayoutUtils.addSclass("status", vbox); + vbox.appendChild(west); + leftCell.appendChild(vbox); + + this.appendChild(hbox); + + } + + /** + * Set Info Line + * @param text text + */ + public void setInfo (String text) + { + infoLine.setValue(text != null ? text : ""); + infoLine.setTooltiptext(text); + infoLine.setStyle("font-weight: bold;"); + } // setInfo + +} diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/ProcessDialog.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/ProcessDialog.java index ebcf6cedd4..96cf91f251 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/ProcessDialog.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/ProcessDialog.java @@ -159,7 +159,8 @@ public class ProcessDialog extends Window implements EventListener, IProc center = new Center(); layout.appendChild(center); center.appendChild(centerPanel); - center.setFlex(true); + centerPanel.setHflex("1"); + centerPanel.setVflex("1"); center.setAutoscroll(true); center.setStyle("border: none"); @@ -459,6 +460,8 @@ public class ProcessDialog extends Window implements EventListener, IProc messageDiv.setStyle(""); north.setVisible(false); center.appendChild(messageDiv); + messageDiv.setVflex("1"); + messageDiv.setHflex("1"); invalidate(); Clients.response(new AuEcho(this, "onAfterProcess", null)); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WAllocation.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WAllocation.java index 823c1b65a1..ce24f42fc3 100755 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WAllocation.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WAllocation.java @@ -268,9 +268,10 @@ public class WAllocation extends Allocation center.setStyle("border: none"); // center = new Center(); - center.setFlex(true); mainLayout.appendChild(center); center.appendChild(infoPanel); + infoPanel.setHflex("1"); + infoPanel.setVflex("1"); infoPanel.setStyle("border: none"); infoPanel.setWidth("100%"); @@ -284,9 +285,10 @@ public class WAllocation extends Allocation north.setSplittable(true); center = new Center(); center.setStyle("border: none"); - center.setFlex(true); infoPanel.appendChild(center); center.appendChild(invoicePanel); + invoicePanel.setHflex("1"); + invoicePanel.setVflex("1"); } // jbInit /** diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WCharge.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WCharge.java index 1b1c7b46c5..99be87a404 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WCharge.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WCharge.java @@ -261,10 +261,11 @@ public class WCharge extends Charge implements IFormController, EventListener Center center = new Center(); center.setBorder("none"); - center.setFlex(true); center.setAutoscroll(true); borderlayout.appendChild(center); center.appendChild(m_tblData); + m_tblData.setVflex("1"); + m_tblData.setHflex("1"); South south = new South(); south.setBorder("none"); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WFileImport.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WFileImport.java index e428ef961b..f6cc99865d 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WFileImport.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WFileImport.java @@ -143,9 +143,10 @@ public class WFileImport extends ADForm implements EventListener layout.appendChild(north); north.appendChild(northPanel); Center center = new Center(); - center.setFlex(true); layout.appendChild(center); center.appendChild(centerPanel); + centerPanel.setVflex("1"); + centerPanel.setHflex("1"); South south = new South(); layout.appendChild(south); south.appendChild(confirmPanel); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WGenForm.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WGenForm.java index ca0a562d40..b8f5e24117 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WGenForm.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WGenForm.java @@ -125,7 +125,8 @@ public class WGenForm extends ADForm implements EventListener, WTableModelListen center.setStyle("border: none"); contentPane.appendChild(center); center.appendChild(tabbedPane); - center.setFlex(true); + tabbedPane.setVflex("1"); + tabbedPane.setHflex("1"); South south = new South(); south.setStyle("border: none"); contentPane.appendChild(south); @@ -177,7 +178,8 @@ public class WGenForm extends ADForm implements EventListener, WTableModelListen Center center = new Center(); selPanel.appendChild(center); center.appendChild(miniTable); - center.setFlex(true); + miniTable.setVflex("1"); + miniTable.setHflex("1"); miniTable.setHeight("99%"); confirmPanelSel.addActionListener(this); // diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WMatch.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WMatch.java index b09134e29a..37cba7e55e 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WMatch.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WMatch.java @@ -272,7 +272,8 @@ public class WMatch extends Match Center center = new Center(); mainLayout.appendChild(center); center.appendChild(centerPanel); - center.setFlex(true); + centerPanel.setHflex("1"); + centerPanel.setVflex("1"); centerLayout.setWidth("100%"); centerLayout.setHeight("100%"); north = new North(); @@ -298,9 +299,10 @@ public class WMatch extends Match center = new Center(); centerLayout.appendChild(center); center.setStyle("border: none"); - center.setFlex(false); // center.setHeight("6%"); center.appendChild(xPanel); + xPanel.setVflex("1"); + xPanel.setHflex("1"); xPanel.appendChild(sameBPartner); xPanel.appendChild(new Space()); xPanel.appendChild(sameProduct); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WSetupWizard.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WSetupWizard.java index 83f6f79512..d90ab54e47 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WSetupWizard.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WSetupWizard.java @@ -251,7 +251,8 @@ public class WSetupWizard extends SetupWizard implements IFormController, EventL West west = new West(); mainLayout.appendChild(west); west.appendChild(wfnodeTree); - west.setFlex(true); + wfnodeTree.setVflex("1"); + wfnodeTree.setHflex("1"); west.setAutoscroll(true); west.setWidth("30%"); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WTreeBOM.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WTreeBOM.java index dcc7598c3e..50e6fb26c0 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WTreeBOM.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WTreeBOM.java @@ -228,7 +228,8 @@ public class WTreeBOM extends TreeBOM implements IFormController, EventListener mainLayout.appendChild(center); center.appendChild(dataPane); dataPane.appendChild(tableBOM); - center.setFlex(true); + dataPane.setHflex("1"); + dataPane.setVflex("1"); center.setAutoscroll(true); } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WTreeMaintenance.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WTreeMaintenance.java index 685145abc1..aa0909b2e3 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WTreeMaintenance.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WTreeMaintenance.java @@ -169,7 +169,8 @@ public class WTreeMaintenance extends TreeMaintenance implements IFormController Center center = new Center(); mainLayout.appendChild(center); center.appendChild(centerTree); - center.setFlex(true); + centerTree.setVflex("1"); + centerTree.setHflex("1"); center.setAutoscroll(true); East east = new East(); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WTrxMaterial.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WTrxMaterial.java index f11ddb2e30..a59ba329d1 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WTrxMaterial.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WTrxMaterial.java @@ -21,6 +21,7 @@ import java.util.Properties; import java.util.logging.Level; import org.adempiere.webui.LayoutUtils; +import org.adempiere.webui.adwindow.ADTabpanel; import org.adempiere.webui.apps.AEnv; import org.adempiere.webui.component.ConfirmPanel; import org.adempiere.webui.component.Grid; @@ -36,7 +37,6 @@ import org.adempiere.webui.editor.WTableDirEditor; import org.adempiere.webui.event.ValueChangeEvent; import org.adempiere.webui.event.ValueChangeListener; import org.adempiere.webui.panel.ADForm; -import org.adempiere.webui.panel.ADTabpanel; import org.adempiere.webui.panel.CustomForm; import org.adempiere.webui.panel.IFormController; import org.adempiere.webui.panel.StatusBarPanel; @@ -212,8 +212,9 @@ public class WTrxMaterial extends TrxMaterial m_gridController.switchRowPresentation(); Center center = new Center(); mainLayout.appendChild(center); - center.setFlex(true); center.appendChild(m_gridController); + m_gridController.setVflex("1"); + m_gridController.setHflex("1"); } // dynInit diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/wf/WFPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/wf/WFPanel.java index c37c79e093..c5ac1ec68c 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/wf/WFPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/wf/WFPanel.java @@ -108,7 +108,6 @@ public class WFPanel extends Borderlayout implements EventListener center.appendChild(table); contentPanel.setStyle("width: 100%; heigh: 100%;"); center.setAutoscroll(true); - center.setFlex(false); South south = new South(); this.appendChild(south); @@ -120,7 +119,8 @@ public class WFPanel extends Borderlayout implements EventListener south.setSplittable(true); south.setCollapsible(true); south.setAutoscroll(true); - south.setFlex(true); + div.setVflex("1"); + div.setHflex("1"); } // jbInit private void createTable() { diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/wf/WWFActivity.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/wf/WWFActivity.java index 2b72f6b7b1..cba1db924b 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/wf/WWFActivity.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/wf/WWFActivity.java @@ -243,7 +243,8 @@ public class WWFActivity extends ADForm implements EventListener North north = new North(); north.appendChild(listbox); north.setSplittable(true); - north.setFlex(true); + listbox.setVflex("1"); + listbox.setHflex("1"); north.setHeight("50%"); layout.appendChild(north); north.setStyle("background-color: transparent"); @@ -253,7 +254,8 @@ public class WWFActivity extends ADForm implements EventListener center.appendChild(grid); layout.appendChild(center); center.setStyle("background-color: transparent"); - center.setFlex(true); + grid.setVflex("1"); + grid.setHflex("1"); South south = new South(); south.appendChild(statusBar); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/ADButtonTabList.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/ADButtonTabList.java deleted file mode 100644 index 8eee630b9e..0000000000 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/ADButtonTabList.java +++ /dev/null @@ -1,179 +0,0 @@ -/****************************************************************************** - * Copyright (C) 2008 Low Heng Sin * - * Copyright (C) 2009 Idalica Corporation * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.adempiere.webui.component; - -import java.util.ArrayList; -import java.util.List; - -import org.adempiere.webui.AdempiereIdGenerator; -import org.adempiere.webui.component.ADTabListModel.ADTabLabel; -import org.zkoss.zhtml.Button; -import org.zkoss.zhtml.Text; -import org.zkoss.zk.ui.Component; -import org.zkoss.zk.ui.event.Event; -import org.zkoss.zk.ui.event.EventListener; -import org.zkoss.zk.ui.event.Events; - -/** - * - * @author Low Heng Sin - * - */ -public class ADButtonTabList extends Panel implements IADTabList, EventListener { - - /** - * - */ - private static final long serialVersionUID = -9203013067784673646L; - private List listItems = new ArrayList(); - private List listeners = new ArrayList(); - private IADTab tabbox; - private int selectedIndex = 0; - private int tabPlacement = IADTab.LEFT; - - public ADButtonTabList() { - this.setStyle("margin:0;padding:0"); - } - - /** - * Set tab placement ( left or right ) - * @param tabPlacement - */ - public void setTabplacement(int tabPlacement) { - if (tabPlacement != IADTab.LEFT && tabPlacement != IADTab.RIGHT) - return; - else if (tabPlacement == this.tabPlacement) - return; - else { - this.tabPlacement = tabPlacement; - this.invalidate(); - } - } - - public synchronized void refresh() { - List childs = getChildren(); - int childCount = childs.size(); - for (int c = childCount - 1; c >=0; c--) { - removeChild((Component) childs.get(c)); - } - Object[] items = listItems.toArray(); - int tabWidth = 100; - List