diff --git a/migration/i2.0z/oracle/201401122152_IDEMPIERE-1684_QuickInfoWidget.sql b/migration/i2.0z/oracle/201401122152_IDEMPIERE-1684_QuickInfoWidget.sql new file mode 100644 index 0000000000..c459a59e94 --- /dev/null +++ b/migration/i2.0z/oracle/201401122152_IDEMPIERE-1684_QuickInfoWidget.sql @@ -0,0 +1,19 @@ +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- Jan 12, 2014 9:51:40 PM COT +-- IDEMPIERE-1150 Status Line window +INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,Created,AD_Client_ID,AD_Org_ID) VALUES ('I','Quick Info',200251,'D','4aa59d81-e275-407b-9bdf-d8017d03c791','QuickInfo','Y',TO_DATE('2014-01-12 21:51:39','YYYY-MM-DD HH24:MI:SS'),100,100,TO_DATE('2014-01-12 21:51:39','YYYY-MM-DD HH24:MI:SS'),0,0) +; + +-- Jan 13, 2014 8:31:22 AM COT +UPDATE AD_Column SET DefaultValue='U',Updated=TO_DATE('2014-01-13 08:31:22','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=210904 +; + +-- Jan 13, 2014 8:31:24 AM COT +ALTER TABLE AD_StatusLine MODIFY EntityType VARCHAR2(40) DEFAULT 'U' +; + +SELECT register_migration_script('201401122152_IDEMPIERE-1684_QuickInfoWidget.sql') FROM dual +; + diff --git a/migration/i2.0z/postgresql/201401122152_IDEMPIERE-1684_QuickInfoWidget.sql b/migration/i2.0z/postgresql/201401122152_IDEMPIERE-1684_QuickInfoWidget.sql new file mode 100644 index 0000000000..698d9fb52c --- /dev/null +++ b/migration/i2.0z/postgresql/201401122152_IDEMPIERE-1684_QuickInfoWidget.sql @@ -0,0 +1,16 @@ +-- Jan 12, 2014 9:51:40 PM COT +-- IDEMPIERE-1150 Status Line window +INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,Created,AD_Client_ID,AD_Org_ID) VALUES ('I','Quick Info',200251,'D','4aa59d81-e275-407b-9bdf-d8017d03c791','QuickInfo','Y',TO_TIMESTAMP('2014-01-12 21:51:39','YYYY-MM-DD HH24:MI:SS'),100,100,TO_TIMESTAMP('2014-01-12 21:51:39','YYYY-MM-DD HH24:MI:SS'),0,0) +; + +-- Jan 13, 2014 8:31:22 AM COT +UPDATE AD_Column SET DefaultValue='U',Updated=TO_TIMESTAMP('2014-01-13 08:31:22','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=210904 +; + +-- Jan 13, 2014 8:31:24 AM COT +INSERT INTO t_alter_column values('ad_statusline','EntityType','VARCHAR(40)',null,'U') +; + +SELECT register_migration_script('201401122152_IDEMPIERE-1684_QuickInfoWidget.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 d1609e967f..cc5dcb601c 100644 --- a/org.adempiere.base/src/org/compiere/model/GridTab.java +++ b/org.adempiere.base/src/org/compiere/model/GridTab.java @@ -26,11 +26,7 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Timestamp; -import java.text.ChoiceFormat; -import java.text.DecimalFormat; -import java.text.Format; import java.text.MessageFormat; -import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.List; import java.util.Properties; @@ -116,7 +112,7 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable /** * */ - private static final long serialVersionUID = -2502318175715266604L; + private static final long serialVersionUID = 3747471319239796736L; public static final String DEFAULT_STATUS_MESSAGE = "NavigateOrUpdate"; @@ -2048,72 +2044,35 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable MStatusLine sl = MStatusLine.getSL(getAD_Window_ID(), getAD_Tab_ID(), getAD_Table_ID()); if (sl != null) { - String sql = sl.getSQLStatement(); - - if (sql.indexOf("@") >= 0) { - sql = Env.parseContext(Env.getCtx(), getWindowNo(), sql, false, false); - if (sql.length() == 0) { - return null; - } - } - - if (log.isLoggable(Level.FINE)) log.fine(m_vo.TableName); - MessageFormat mf = null; - String msgValue = sl.getAD_Message().getValue(); - try - { - mf = new MessageFormat(Msg.getMsg(Env.getAD_Language(m_vo.ctx), msgValue), Env.getLanguage(m_vo.ctx).getLocale()); - } - catch (Exception e) - { - log.log(Level.SEVERE, msgValue + "=" + Msg.getMsg(Env.getAD_Language(m_vo.ctx), msgValue), e); - } - if (mf == null) - return null; - - Format[] fmts = mf.getFormatsByArgumentIndex(); - Object[] arguments = new Object[fmts.length]; - boolean filled = false; - - PreparedStatement stmt = null; - ResultSet rs = null; - try - { - stmt = DB.prepareStatement(sql, null); - rs = stmt.executeQuery(); - if (rs.next()) - { - for (int idx = 0; idx < fmts.length; idx++) { - Format fmt = fmts[idx]; - Object obj; - if (fmt instanceof DecimalFormat || fmt instanceof ChoiceFormat) { - obj = rs.getDouble(idx+1); - } else if (fmt instanceof SimpleDateFormat) { - obj = rs.getTimestamp(idx+1); - } else { - obj = rs.getString(idx+1); - } - arguments[idx] = obj; - } - filled = true; - } - } - catch (SQLException e) - { - log.log(Level.WARNING, sql, e); - } - finally - { - DB.close(rs, stmt); - rs = null; stmt = null; - } - if (filled) - return mf.format(arguments); + String line = sl.parseLine(getWindowNo()); + return line; } return null; } // getStatusLine + /************************************************************************** + * Widget support + * Depending on Window/Tab returns widget lines info + * @return info + */ + public String getStatusLinesWidget() { + MStatusLine[] wls = MStatusLine.getStatusLinesWidget(getAD_Window_ID(), getAD_Tab_ID(), getAD_Table_ID()); + if (wls != null && wls.length > 0) + { + StringBuilder lines = new StringBuilder(); + for (MStatusLine wl : wls) { + String line = wl.parseLine(getWindowNo()); + if (line != null) { + lines.append(line).append("
"); + } + } + if (lines.length() > 0) + return lines.toString(); + } + return null; + } // getWidgetLines + /** * Load Dependent Information */ @@ -3366,4 +3325,5 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable { selection.clear(); } + } // GridTab diff --git a/org.adempiere.base/src/org/compiere/model/MStatusLine.java b/org.adempiere.base/src/org/compiere/model/MStatusLine.java index 1f95b9d4c7..09d5743e87 100644 --- a/org.adempiere.base/src/org/compiere/model/MStatusLine.java +++ b/org.adempiere.base/src/org/compiere/model/MStatusLine.java @@ -16,7 +16,15 @@ *****************************************************************************/ package org.compiere.model; +import java.sql.PreparedStatement; import java.sql.ResultSet; +import java.sql.SQLException; +import java.text.ChoiceFormat; +import java.text.DecimalFormat; +import java.text.Format; +import java.text.MessageFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; import java.util.Properties; import java.util.logging.Level; @@ -24,6 +32,7 @@ import org.compiere.util.CCache; import org.compiere.util.CLogger; import org.compiere.util.DB; import org.compiere.util.Env; +import org.compiere.util.Msg; /** * Status Line Model @@ -36,12 +45,13 @@ public class MStatusLine extends X_AD_StatusLine /** * */ - private static final long serialVersionUID = 9135428468215857507L; + private static final long serialVersionUID = 2473407023692665378L; /** Logging */ private static CLogger s_log = CLogger.getCLogger(MStatusLine.class); /** Status Line Cache */ private static CCache s_cache = new CCache(Table_Name, 10); + private static CCache s_cachew = new CCache(Table_Name, 10); /** * Standard Constructor @@ -66,6 +76,7 @@ public class MStatusLine extends X_AD_StatusLine } // MStatusLine /** + * Get the status line defined for the window|tab|table * @param window_ID * @param tab_ID * @param table_ID @@ -116,4 +127,111 @@ public class MStatusLine extends X_AD_StatusLine return retValue; } + /** + * Get the widget lines defined for the window&tab&table + * @param window_ID + * @param tab_ID + * @param table_ID + * @return array of widget lines discovered for table or specific tab or general window + */ + public static MStatusLine[] getStatusLinesWidget(int window_ID, int tab_ID, int table_ID) { + StringBuilder key = new StringBuilder().append(window_ID).append("|").append(tab_ID).append("|").append(table_ID); + MStatusLine[] retValue = null; + if (s_cachew.containsKey(key.toString())) + { + retValue = s_cachew.get(key.toString()); + if (s_log.isLoggable(Level.FINEST)) s_log.finest("Cache: " + retValue); + return retValue; + } + + final String sql = "" + + "SELECT DISTINCT AD_StatusLine_ID, SeqNo " + + "FROM AD_StatusLineUsedIn " + + "WHERE IsActive = 'Y' " + + " AND IsStatusLine = 'N' " + + " AND (AD_Table_ID = ? OR (AD_Window_ID=? AND AD_Tab_ID=?) OR (AD_Window_ID=? AND AD_Tab_ID IS NULL)) " + + "ORDER BY SeqNo"; + int[] wlids = DB.getIDsEx(null, sql, table_ID, window_ID, tab_ID, window_ID); + if (wlids.length > 0) { + ArrayList list = new ArrayList(); + for (int wlid : wlids) { + MStatusLine wl = new MStatusLine(Env.getCtx(), wlid, null); + list.add(wl); + } + // Convert to array + retValue = new MStatusLine[list.size()]; + for (int i = 0; i < retValue.length; i++) + { + retValue[i] = list.get(i); + } + } + s_cachew.put(key.toString(), retValue); + + return retValue; + } + + public String parseLine(int windowNo) { + String sql = getSQLStatement(); + + if (sql.indexOf("@") >= 0) { + sql = Env.parseContext(Env.getCtx(), windowNo, sql, false, false); + if (sql.length() == 0) { + return null; + } + } + + MessageFormat mf = null; + String msgValue = getAD_Message().getValue(); + try + { + mf = new MessageFormat(Msg.getMsg(Env.getAD_Language(getCtx()), msgValue), Env.getLanguage(getCtx()).getLocale()); + } + catch (Exception e) + { + log.log(Level.SEVERE, msgValue + "=" + Msg.getMsg(Env.getAD_Language(getCtx()), msgValue), e); + } + if (mf == null) + return null; + + Format[] fmts = mf.getFormatsByArgumentIndex(); + Object[] arguments = new Object[fmts.length]; + boolean filled = false; + + PreparedStatement stmt = null; + ResultSet rs = null; + try + { + stmt = DB.prepareStatement(sql, null); + rs = stmt.executeQuery(); + if (rs.next()) + { + for (int idx = 0; idx < fmts.length; idx++) { + Format fmt = fmts[idx]; + Object obj; + if (fmt instanceof DecimalFormat || fmt instanceof ChoiceFormat) { + obj = rs.getDouble(idx+1); + } else if (fmt instanceof SimpleDateFormat) { + obj = rs.getTimestamp(idx+1); + } else { + obj = rs.getString(idx+1); + } + arguments[idx] = obj; + } + filled = true; + } + } + catch (SQLException e) + { + log.log(Level.WARNING, sql, e); + } + finally + { + DB.close(rs, stmt); + rs = null; stmt = null; + } + if (filled) + return mf.format(arguments); + return null; + } + } // MStatusLine diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADWindowContent.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADWindowContent.java index aea647fa73..8de6112b59 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADWindowContent.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADWindowContent.java @@ -1532,11 +1532,13 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements // Transaction info if (!detailTab) { - String trxInfo = adTabbox.getSelectedGridTab().getStatusLine(); + GridTab gt = adTabbox.getSelectedGridTab(); + String trxInfo = gt.getStatusLine(); if (trxInfo != null) { statusBar.setInfo(trxInfo); } + SessionManager.getAppDesktop().updateHelpQuickInfo(gt); } // Check Attachment diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/DefaultDesktop.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/DefaultDesktop.java index 7dcc696803..41c3a16618 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/DefaultDesktop.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/DefaultDesktop.java @@ -54,6 +54,7 @@ import org.adempiere.webui.util.UserPreference; import org.adempiere.webui.window.FDialog; import org.compiere.Adempiere; import org.compiere.model.GridField; +import org.compiere.model.GridTab; import org.compiere.model.MQuery; import org.compiere.model.MRole; import org.compiere.model.MTable; @@ -99,17 +100,17 @@ import org.zkoss.zul.West; */ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Serializable, EventListener, EventHandler, DesktopCleanup { + /** + * + */ + private static final long serialVersionUID = -7495898481342426458L; + private static final String IMAGES_UPARROW_PNG = "images/collapse-header.png"; private static final String IMAGES_DOWNARROW_PNG = "images/expand-header.png"; private static final String IMAGES_CONTEXT_HELP_PNG = "images/Help16.png"; - /** - * generated serial version ID - */ - private static final long serialVersionUID = -8203958978173990301L; - @SuppressWarnings("unused") private static final CLogger logger = CLogger.getCLogger(DefaultDesktop.class); @@ -595,6 +596,11 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria helpController.renderToolTip(gridField); } + @Override + public void updateHelpQuickInfo(GridTab gridTab) { + helpController.renderQuickInfo(gridTab); + } + @Override public ProcessDialog openProcessDialog(int processId, boolean soTrx) { ProcessDialog pd = super.openProcessDialog(processId, soTrx); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/IDesktop.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/IDesktop.java index 16b0516755..287360407d 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/IDesktop.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/IDesktop.java @@ -21,6 +21,7 @@ import org.adempiere.webui.component.Window; import org.adempiere.webui.panel.ADForm; import org.adempiere.webui.part.UIPart; import org.compiere.model.GridField; +import org.compiere.model.GridTab; import org.compiere.model.MQuery; import org.zkoss.zk.ui.Component; import org.zkoss.zk.ui.Page; @@ -205,6 +206,8 @@ public interface IDesktop extends UIPart { public void updateHelpTooltip(GridField gridField); + public void updateHelpQuickInfo(GridTab gridTab); + public boolean isPendingWindow(); public void setTabTitle(String title); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/HelpController.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/HelpController.java index 3c2f912b7c..cb9cb43fec 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/HelpController.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/HelpController.java @@ -21,6 +21,7 @@ import java.util.Properties; import org.adempiere.exceptions.AdempiereException; import org.adempiere.webui.desktop.IDesktop; import org.compiere.model.GridField; +import org.compiere.model.GridTab; import org.compiere.model.MForm; import org.compiere.model.MInfoWindow; import org.compiere.model.MProcess; @@ -59,8 +60,8 @@ import org.zkoss.zul.Vlayout; public class HelpController { private Anchorlayout dashboardLayout; - private Panel pnlToolTip, pnlContextHelp; - private Html htmlToolTip, htmlContextHelp; + private Panel pnlToolTip, pnlContextHelp, pnlQuickInfo; + private Html htmlToolTip, htmlContextHelp, htmlQuickInfo; public HelpController() { @@ -86,6 +87,20 @@ public class HelpController dashboardColumn.appendChild(dashboardColumnLayout); dashboardLayout.appendChild(dashboardColumn); + Panelchildren content = new Panelchildren(); + + pnlQuickInfo = new Panel(); + pnlQuickInfo.setSclass("dashboard-widget"); + pnlQuickInfo.setTitle(Msg.getMsg(Env.getCtx(), "QuickInfo")); + pnlQuickInfo.setMaximizable(false); + pnlQuickInfo.setCollapsible(true); + pnlQuickInfo.setOpen(true); + pnlQuickInfo.setBorder("normal"); + dashboardColumnLayout.appendChild(pnlQuickInfo); + content = new Panelchildren(); + pnlQuickInfo.appendChild(content); + content.appendChild(htmlQuickInfo = new Html()); + pnlToolTip = new Panel(); pnlToolTip.setSclass("dashboard-widget"); pnlToolTip.setTitle(Msg.getMsg(Env.getCtx(), "ToolTip")); @@ -94,7 +109,7 @@ public class HelpController pnlToolTip.setOpen(true); pnlToolTip.setBorder("normal"); dashboardColumnLayout.appendChild(pnlToolTip); - Panelchildren content = new Panelchildren(); + content = new Panelchildren(); pnlToolTip.appendChild(content); content.appendChild(htmlToolTip = new Html()); htmlToolTip.setWidgetOverride("defaultMessage", "'"+Msg.getMsg(Env.getCtx(), "PlaceCursorIntoField")+"'"); @@ -121,6 +136,7 @@ public class HelpController renderToolTip(null); renderCtxHelp(X_AD_CtxHelp.CTXTYPE_Home, 0); + renderQuickInfo(null); } public void renderToolTip(GridField field) @@ -405,6 +421,24 @@ public class HelpController htmlContextHelp.setContent(sb.toString()); } + public void renderQuickInfo(GridTab gridTab) { + if (gridTab == null) { + pnlQuickInfo.setVisible(false); + } else { + String widget = gridTab.getStatusLinesWidget(); + if (widget == null) { + pnlQuickInfo.setVisible(false); + } else { + pnlQuickInfo.setVisible(true); + StringBuilder sb = new StringBuilder(); + sb.append("\n\n
\n"); + sb.append(widget); + sb.append("
\n\n"); + htmlQuickInfo.setContent(sb.toString()); + } + } + } + private String stripHtml(String htmlString, boolean all) { htmlString = htmlString