diff --git a/migration/i1.0a-release/oracle/201212131100_IDEMPIERE-530.sql b/migration/i1.0a-release/oracle/201212131100_IDEMPIERE-530.sql new file mode 100644 index 0000000000..9282fcf507 --- /dev/null +++ b/migration/i1.0a-release/oracle/201212131100_IDEMPIERE-530.sql @@ -0,0 +1,6 @@ +CREATE UNIQUE INDEX cm_chat_record ON cm_chat (ad_table_id, record_id); + + +SELECT register_migration_script('201212131100_IDEMPIERE-530.sql') FROM dual +; + diff --git a/migration/i1.0a-release/postgresql/201212131100_IDEMPIERE-530.sql b/migration/i1.0a-release/postgresql/201212131100_IDEMPIERE-530.sql new file mode 100644 index 0000000000..9282fcf507 --- /dev/null +++ b/migration/i1.0a-release/postgresql/201212131100_IDEMPIERE-530.sql @@ -0,0 +1,6 @@ +CREATE UNIQUE INDEX cm_chat_record ON cm_chat (ad_table_id, record_id); + + +SELECT register_migration_script('201212131100_IDEMPIERE-530.sql') FROM dual +; + diff --git a/org.adempiere.base/src/org/compiere/acct/DocManager.java b/org.adempiere.base/src/org/compiere/acct/DocManager.java index 3b2d00a234..3696376460 100644 --- a/org.adempiere.base/src/org/compiere/acct/DocManager.java +++ b/org.adempiere.base/src/org/compiere/acct/DocManager.java @@ -66,7 +66,7 @@ public class DocManager { return documentsTableName; } - private static void fillDocumentsTableArrays() { + private synchronized static void fillDocumentsTableArrays() { if (documentsTableID == null) { String sql = "SELECT t.AD_Table_ID, t.TableName " + "FROM AD_Table t, AD_Column c " + diff --git a/org.adempiere.base/src/org/compiere/db/CConnection.java b/org.adempiere.base/src/org/compiere/db/CConnection.java index 8a452470c9..58594c7d11 100644 --- a/org.adempiere.base/src/org/compiere/db/CConnection.java +++ b/org.adempiere.base/src/org/compiere/db/CConnection.java @@ -48,7 +48,7 @@ public class CConnection implements Serializable, Cloneable */ private static final long serialVersionUID = -7893119456331485444L; /** Connection */ - private static CConnection s_cc = null; + private volatile static CConnection s_cc = null; /** Logger */ private static CLogger log = CLogger.getCLogger (CConnection.class); @@ -86,7 +86,7 @@ public class CConnection implements Serializable, Cloneable * @param apps_host optional apps host for new connections * @return Connection Descriptor */ - public static CConnection get (String apps_host) + public synchronized static CConnection get (String apps_host) { if (s_cc == null) { @@ -1418,7 +1418,7 @@ public class CConnection implements Serializable, Cloneable * Get Last Exception of Apps Server Connection attempt * @return Exception or null */ - public Exception getAppsServerException () + public synchronized Exception getAppsServerException () { return m_appsException; } // getAppsServerException diff --git a/org.adempiere.base/src/org/compiere/dbPort/Convert.java b/org.adempiere.base/src/org/compiere/dbPort/Convert.java index 494449eb49..f669498599 100644 --- a/org.adempiere.base/src/org/compiere/dbPort/Convert.java +++ b/org.adempiere.base/src/org/compiere/dbPort/Convert.java @@ -432,7 +432,7 @@ public abstract class Convert */ public abstract boolean isOracle(); - public static void logMigrationScript(String oraStatement, String pgStatement) { + public synchronized static void logMigrationScript(String oraStatement, String pgStatement) { // Check AdempiereSys // check property Log migration script boolean logMigrationScript = false; diff --git a/org.adempiere.base/src/org/compiere/model/GridTab.java b/org.adempiere.base/src/org/compiere/model/GridTab.java index d28f965484..c1a33e2449 100644 --- a/org.adempiere.base/src/org/compiere/model/GridTab.java +++ b/org.adempiere.base/src/org/compiere/model/GridTab.java @@ -28,7 +28,6 @@ import java.sql.SQLException; import java.sql.Timestamp; import java.text.MessageFormat; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import java.util.Properties; import java.util.StringTokenizer; @@ -111,7 +110,7 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable /** * */ - private static final long serialVersionUID = 336562925897569888L; + private static final long serialVersionUID = -1638364577972806113L; public static final String DEFAULT_STATUS_MESSAGE = "NavigateOrUpdate"; @@ -163,10 +162,6 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable private String m_parentColumnName = ""; private String m_extendedWhere; - /** Attachments */ - private HashMap m_Attachments = null; - /** Chats */ - private HashMap m_Chats = null; /** Locks */ private ArrayList m_Lock = null; @@ -333,12 +328,6 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable // m_depOnField.clear(); m_depOnField = null; - if (m_Attachments != null) - m_Attachments.clear(); - m_Attachments = null; - if (m_Chats != null) - m_Chats.clear(); - m_Chats = null; // if (m_vo.isInitFields()) m_vo.getFields().clear(); @@ -2034,43 +2023,6 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable } // loadDependentInfo - - /************************************************************************** - * Load Attachments for this table - */ - public void loadAttachments() - { - log.fine("#" + m_vo.TabNo); - if (!canHaveAttachment()) - return; - - String SQL = "SELECT AD_Attachment_ID, Record_ID FROM AD_Attachment " - + "WHERE AD_Table_ID=?"; - try - { - if (m_Attachments == null) - m_Attachments = new HashMap(); - else - m_Attachments.clear(); - PreparedStatement pstmt = DB.prepareStatement(SQL, null); - pstmt.setInt(1, m_vo.AD_Table_ID); - ResultSet rs = pstmt.executeQuery(); - while (rs.next()) - { - Integer key = new Integer(rs.getInt(2)); - Integer value = new Integer(rs.getInt(1)); - m_Attachments.put(key, value); - } - rs.close(); - pstmt.close(); - } - catch (SQLException e) - { - log.log(Level.SEVERE, "loadAttachments", e); - } - log.config("#" + m_Attachments.size()); - } // loadAttachment - /** * Can this tab have Attachments?. *

@@ -2091,13 +2043,7 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable */ public boolean hasAttachment() { - if (m_Attachments == null) - loadAttachments(); - if (m_Attachments == null || m_Attachments.isEmpty()) - return false; - // - Integer key = new Integer(m_mTable.getKeyID (m_currentRow)); - return m_Attachments.containsKey(key); + return getAD_AttachmentID() > 0; } // hasAttachment /** @@ -2106,54 +2052,11 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable */ public int getAD_AttachmentID() { - if (m_Attachments == null) - loadAttachments(); - if (m_Attachments.isEmpty()) - return 0; - // - Integer key = new Integer(m_mTable.getKeyID (m_currentRow)); - Integer value = (Integer)m_Attachments.get(key); - if (value == null) - return 0; - else - return value.intValue(); - } // getAttachmentID - - /************************************************************************** - * Load Chats for this table - */ - public void loadChats() - { - log.fine("#" + m_vo.TabNo); if (!canHaveAttachment()) - return; - - String sql = "SELECT CM_Chat_ID, Record_ID FROM CM_Chat " - + "WHERE AD_Table_ID=?"; - try - { - if (m_Chats == null) - m_Chats = new HashMap(); - else - m_Chats.clear(); - PreparedStatement pstmt = DB.prepareStatement(sql, null); - pstmt.setInt(1, m_vo.AD_Table_ID); - ResultSet rs = pstmt.executeQuery(); - while (rs.next()) - { - Integer key = new Integer(rs.getInt(2)); // Record_ID - Integer value = new Integer(rs.getInt(1)); // CM_Chat_ID - m_Chats.put(key, value); - } - rs.close(); - pstmt.close(); - } - catch (SQLException e) - { - log.log(Level.SEVERE, sql, e); - } - log.config("#" + m_Chats.size()); - } // loadChats + return 0; + int recordID = m_mTable.getKeyID(m_currentRow); + return MAttachment.getID(m_vo.AD_Table_ID, recordID); + } // getAttachmentID /** * Returns true, if current row has a Chat @@ -2161,13 +2064,7 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable */ public boolean hasChat() { - if (m_Chats == null) - loadChats(); - if (m_Chats == null || m_Chats.isEmpty()) - return false; - // - Integer key = new Integer(m_mTable.getKeyID (m_currentRow)); - return m_Chats.containsKey(key); + return getCM_ChatID() > 0; } // hasChat /** @@ -2176,17 +2073,10 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable */ public int getCM_ChatID() { - if (m_Chats == null) - loadChats(); - if (m_Chats.isEmpty()) + if (!canHaveAttachment()) return 0; - // - Integer key = new Integer(m_mTable.getKeyID (m_currentRow)); - Integer value = (Integer)m_Chats.get(key); - if (value == null) - return 0; - else - return value.intValue(); + int recordID = m_mTable.getKeyID(m_currentRow); + return MChat.getID(m_vo.AD_Table_ID, recordID); } // getCM_ChatID diff --git a/org.adempiere.base/src/org/compiere/model/MAttachment.java b/org.adempiere.base/src/org/compiere/model/MAttachment.java index d115d7d47e..ab45213663 100644 --- a/org.adempiere.base/src/org/compiere/model/MAttachment.java +++ b/org.adempiere.base/src/org/compiere/model/MAttachment.java @@ -26,6 +26,7 @@ import java.util.Properties; import java.util.logging.Level; import org.compiere.util.CLogger; +import org.compiere.util.DB; import org.compiere.util.Env; import org.compiere.util.MimeType; @@ -47,7 +48,7 @@ public class MAttachment extends X_AD_Attachment /** * */ - private static final long serialVersionUID = -8013716602070647299L; + private static final long serialVersionUID = -8261865873158774665L; /** * Get Attachment (if there are more than one attachment it gets the first in no specific order) @@ -94,9 +95,7 @@ public class MAttachment extends X_AD_Attachment */ public MAttachment(Properties ctx, int AD_Table_ID, int Record_ID, String trxName) { - this (ctx - , MAttachment.get(ctx, AD_Table_ID, Record_ID) == null ? 0 : MAttachment.get(ctx, AD_Table_ID, Record_ID).get_ID() - , trxName); + this (ctx, MAttachment.getID(AD_Table_ID, Record_ID) > 0 ? MAttachment.getID(AD_Table_ID, Record_ID) : 0, trxName); if (get_ID() == 0) { setAD_Table_ID (AD_Table_ID); setRecord_ID (Record_ID); @@ -598,4 +597,17 @@ public class MAttachment extends X_AD_Attachment return true; } + /** + * IDEMPIERE-530 + * Get the attachment ID based on table_id and record_id + * @param AD_Table_ID + * @param Record_ID + * @return AD_Attachment_ID + */ + public static int getID(int Table_ID, int Record_ID) { + String sql="SELECT AD_Attachment_ID FROM AD_Attachment WHERE AD_Table_ID=? AND Record_ID=?"; + int attachid = DB.getSQLValue(null, sql, Table_ID, Record_ID); + return attachid; + } + } // MAttachment diff --git a/org.adempiere.base/src/org/compiere/model/MChat.java b/org.adempiere.base/src/org/compiere/model/MChat.java index 4598ff4391..b55bc34d65 100644 --- a/org.adempiere.base/src/org/compiere/model/MChat.java +++ b/org.adempiere.base/src/org/compiere/model/MChat.java @@ -44,8 +44,7 @@ public class MChat extends X_CM_Chat /** * */ - private static final long serialVersionUID = -5053130533036069784L; - + private static final long serialVersionUID = 9165439123618441913L; /** * Get Chats Of Table - of client in context @@ -240,7 +239,19 @@ public class MChat extends X_CM_Chat } // entry // return history; - } // getHistory - + } // getHistory + + /** + * IDEMPIERE-530 + * Get the chat ID based on table_id and record_id + * @param AD_Table_ID + * @param Record_ID + * @return CM_Chat_ID + */ + public static int getID(int Table_ID, int Record_ID) { + String sql="SELECT CM_Chat_ID FROM CM_Chat WHERE AD_Table_ID=? AND Record_ID=?"; + int chatID = DB.getSQLValueEx(null, sql, Table_ID, Record_ID); + return chatID; + } } // MChat diff --git a/org.adempiere.base/src/org/compiere/model/MEXPProcessor.java b/org.adempiere.base/src/org/compiere/model/MEXPProcessor.java index b2d69b69c2..c300207d61 100644 --- a/org.adempiere.base/src/org/compiere/model/MEXPProcessor.java +++ b/org.adempiere.base/src/org/compiere/model/MEXPProcessor.java @@ -51,7 +51,7 @@ public class MEXPProcessor extends X_EXP_Processor { /** Static Logger */ private static CLogger s_log = CLogger.getCLogger (MEXPProcessor.class); - private static MEXPProcessor processor= null; + private volatile static MEXPProcessor processor= null; private X_EXP_ProcessorParameter[] parameters = null; public static MEXPProcessor get(Properties ctx, int EXP_Processor_ID, String trxName) diff --git a/org.adempiere.base/src/org/compiere/model/MLocator.java b/org.adempiere.base/src/org/compiere/model/MLocator.java index 67c3d306a3..2ece305a49 100644 --- a/org.adempiere.base/src/org/compiere/model/MLocator.java +++ b/org.adempiere.base/src/org/compiere/model/MLocator.java @@ -186,7 +186,7 @@ public class MLocator extends X_M_Locator } // get /** Cache */ - private static CCache s_cache; + private volatile static CCache s_cache; /** Logger */ private static CLogger s_log = CLogger.getCLogger (MLocator.class); diff --git a/org.adempiere.base/src/org/compiere/model/MRequestType.java b/org.adempiere.base/src/org/compiere/model/MRequestType.java index e447537429..1e8363092e 100644 --- a/org.adempiere.base/src/org/compiere/model/MRequestType.java +++ b/org.adempiere.base/src/org/compiere/model/MRequestType.java @@ -196,7 +196,7 @@ public class MRequestType extends X_R_RequestType * Get Total No of requests of type * @return no */ - public int getTotalNo() + public synchronized int getTotalNo() { updateStatistics(); return m_totalNo; @@ -206,7 +206,7 @@ public class MRequestType extends X_R_RequestType * Get Open No of requests of type * @return no */ - public int getOpenNo() + public synchronized int getOpenNo() { updateStatistics(); return m_openNo; @@ -216,7 +216,7 @@ public class MRequestType extends X_R_RequestType * Get Closed in last 30 days of type * @return no */ - public int getClosed30No() + public synchronized int getClosed30No() { updateStatistics(); return m_closed30No; @@ -226,7 +226,7 @@ public class MRequestType extends X_R_RequestType * Get New in the last 30 days of type * @return no */ - public int getNew30No() + public synchronized int getNew30No() { updateStatistics(); return m_new30No; diff --git a/org.adempiere.base/src/org/compiere/model/MSystem.java b/org.adempiere.base/src/org/compiere/model/MSystem.java index fed85f1340..a983d7d81e 100644 --- a/org.adempiere.base/src/org/compiere/model/MSystem.java +++ b/org.adempiere.base/src/org/compiere/model/MSystem.java @@ -62,7 +62,7 @@ public class MSystem extends X_AD_System * @param ctx context * @return System */ - public static MSystem get (Properties ctx) + public synchronized static MSystem get (Properties ctx) { if (s_system != null) return s_system; diff --git a/org.adempiere.base/src/org/compiere/model/MUserDefWin.java b/org.adempiere.base/src/org/compiere/model/MUserDefWin.java index bd52bbfbb9..511b2eb0cf 100644 --- a/org.adempiere.base/src/org/compiere/model/MUserDefWin.java +++ b/org.adempiere.base/src/org/compiere/model/MUserDefWin.java @@ -35,7 +35,7 @@ public class MUserDefWin extends X_AD_UserDef_Win */ private static final long serialVersionUID = -5775251886672840324L; - private static List m_fullList = null; + private volatile static List m_fullList = null; /** * Standard constructor. diff --git a/org.adempiere.base/src/org/compiere/model/TranslationTable.java b/org.adempiere.base/src/org/compiere/model/TranslationTable.java index f6528a3feb..17ecde661c 100644 --- a/org.adempiere.base/src/org/compiere/model/TranslationTable.java +++ b/org.adempiere.base/src/org/compiere/model/TranslationTable.java @@ -65,7 +65,7 @@ public class TranslationTable * @param requery requery * @return number of active Translations */ - public static int getActiveLanguages (boolean requery) + public synchronized static int getActiveLanguages (boolean requery) { if (s_activeLanguages != null && !requery) return s_activeLanguages.intValue(); diff --git a/org.adempiere.base/src/org/compiere/print/ArchiveEngine.java b/org.adempiere.base/src/org/compiere/print/ArchiveEngine.java index 6594b201f9..db23742186 100644 --- a/org.adempiere.base/src/org/compiere/print/ArchiveEngine.java +++ b/org.adempiere.base/src/org/compiere/print/ArchiveEngine.java @@ -195,7 +195,7 @@ public class ArchiveEngine /** Logger */ private static CLogger log = CLogger.getCLogger(ArchiveEngine.class); /** Singleton */ - private static ArchiveEngine s_engine = null; + private volatile static ArchiveEngine s_engine = null; /************************************************************************** diff --git a/org.adempiere.base/src/org/compiere/print/util/SwapFile.java b/org.adempiere.base/src/org/compiere/print/util/SwapFile.java index 51c0764980..89f8f8438b 100644 --- a/org.adempiere.base/src/org/compiere/print/util/SwapFile.java +++ b/org.adempiere.base/src/org/compiere/print/util/SwapFile.java @@ -171,7 +171,7 @@ public class SwapFile freeBlocks(segment.getOffsets()); } - private void verifyOpen() { + private synchronized void verifyOpen() { if (randomAccessFile == null) { throw new RuntimeException("Swap file not open for read write access"); } diff --git a/org.adempiere.base/src/org/compiere/util/CCachedRowSet.java b/org.adempiere.base/src/org/compiere/util/CCachedRowSet.java index 13aa1a1168..16a889b3a5 100644 --- a/org.adempiere.base/src/org/compiere/util/CCachedRowSet.java +++ b/org.adempiere.base/src/org/compiere/util/CCachedRowSet.java @@ -52,7 +52,7 @@ public class CCachedRowSet extends CachedRowSetImpl implements CachedRowSet * @return Cached Row Set * @throws SQLException */ - public static CCachedRowSet get() throws SQLException + public synchronized static CCachedRowSet get() throws SQLException { CCachedRowSet crs = null; // only first time call diff --git a/org.adempiere.base/src/org/compiere/util/CLogger.java b/org.adempiere.base/src/org/compiere/util/CLogger.java index 072a064293..653746224e 100644 --- a/org.adempiere.base/src/org/compiere/util/CLogger.java +++ b/org.adempiere.base/src/org/compiere/util/CLogger.java @@ -116,7 +116,7 @@ public class CLogger extends Logger implements Serializable } // get /** Default Logger */ - private static CLogger s_logger = null; + private volatile static CLogger s_logger = null; /************************************************************************** diff --git a/org.adempiere.base/src/org/compiere/util/DB.java b/org.adempiere.base/src/org/compiere/util/DB.java index 28e5092a70..69282464a4 100644 --- a/org.adempiere.base/src/org/compiere/util/DB.java +++ b/org.adempiere.base/src/org/compiere/util/DB.java @@ -255,7 +255,7 @@ public final class DB * Set connection * @param cc connection */ - public static void setDBTarget (CConnection cc) + public synchronized static void setDBTarget (CConnection cc) { if (cc == null) throw new IllegalArgumentException("Connection is NULL"); diff --git a/org.adempiere.base/src/org/compiere/util/Ini.java b/org.adempiere.base/src/org/compiere/util/Ini.java index b39307c61e..9f121f7e69 100644 --- a/org.adempiere.base/src/org/compiere/util/Ini.java +++ b/org.adempiere.base/src/org/compiere/util/Ini.java @@ -224,7 +224,7 @@ public final class Ini implements Serializable }; /** Container for Properties */ - private static Properties s_prop = new Properties(); + private volatile static Properties s_prop = new Properties(); private static String s_propertyFileName = null; diff --git a/org.adempiere.base/src/org/compiere/util/SecureEngine.java b/org.adempiere.base/src/org/compiere/util/SecureEngine.java index 796a532060..ef9be7313c 100644 --- a/org.adempiere.base/src/org/compiere/util/SecureEngine.java +++ b/org.adempiere.base/src/org/compiere/util/SecureEngine.java @@ -217,7 +217,7 @@ public class SecureEngine /** Test String */ private static final String TEST = "This is a 0123456789 .,; -= Test!"; /** Secure Engine */ - private static SecureEngine s_engine = null; + private volatile static SecureEngine s_engine = null; /** The real Engine */ private SecureInterface implementation = null; diff --git a/org.adempiere.base/src/org/compiere/util/WebInfo.java b/org.adempiere.base/src/org/compiere/util/WebInfo.java index 07521402e8..d32b3ba5b0 100644 --- a/org.adempiere.base/src/org/compiere/util/WebInfo.java +++ b/org.adempiere.base/src/org/compiere/util/WebInfo.java @@ -64,7 +64,7 @@ public class WebInfo } // getGeneral /** General Info */ - private static WebInfo m_general = null; + private volatile static WebInfo m_general = null; /** * Constructor diff --git a/org.adempiere.base/src/org/compiere/util/WebUser.java b/org.adempiere.base/src/org/compiere/util/WebUser.java index 92db947e16..5f8fea21ca 100644 --- a/org.adempiere.base/src/org/compiere/util/WebUser.java +++ b/org.adempiere.base/src/org/compiere/util/WebUser.java @@ -107,7 +107,7 @@ public class WebUser } // get /** Short term Cache for immediate re-query/post (hit rate 20%) */ - private static WebUser s_cache = null; + private volatile static WebUser s_cache = null; /*************************************************************************/ diff --git a/org.adempiere.base/src/org/compiere/wf/DocWorkflowManager.java b/org.adempiere.base/src/org/compiere/wf/DocWorkflowManager.java index 5c4772a472..c5d91ac441 100644 --- a/org.adempiere.base/src/org/compiere/wf/DocWorkflowManager.java +++ b/org.adempiere.base/src/org/compiere/wf/DocWorkflowManager.java @@ -55,7 +55,7 @@ public class DocWorkflowManager implements DocWorkflowMgr } /** Document Workflow Manager */ - private static DocWorkflowManager s_mgr = null; + private volatile static DocWorkflowManager s_mgr = null; /** Logger */ private static CLogger log = CLogger.getCLogger(DocWorkflowManager.class); diff --git a/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServiceImpl.java b/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServiceImpl.java index 0d99739af1..8589e2986b 100644 --- a/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServiceImpl.java +++ b/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServiceImpl.java @@ -50,7 +50,7 @@ public class HttpServiceImpl implements HttpService, ExtendedHttpService { shutdown = true; } - private void checkShutdown() { + private synchronized void checkShutdown() { if (shutdown) throw new IllegalStateException("Service instance is already shutdown"); //$NON-NLS-1$ } diff --git a/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/ProxyServlet.java b/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/ProxyServlet.java index a9c051c653..f9d1854f9c 100644 --- a/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/ProxyServlet.java +++ b/org.adempiere.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/ProxyServlet.java @@ -42,7 +42,7 @@ public class ProxyServlet extends HttpServlet implements Filter { Activator.addProxyServlet(this); } - public void destroy() { + public synchronized void destroy() { Activator.removeProxyServlet(this); proxyContext.destroy(); proxyContext = null; @@ -56,7 +56,7 @@ public class ProxyServlet extends HttpServlet implements Filter { process(req, resp, null); } - protected void process(HttpServletRequest req, HttpServletResponse resp, FilterChain filterChain) throws ServletException, IOException { + protected synchronized void process(HttpServletRequest req, HttpServletResponse resp, FilterChain filterChain) throws ServletException, IOException { proxyContext.initializeServletPath(req, filterChain); String alias = HttpServletRequestAdaptor.getDispatchPathInfo(req, filterChain); if (alias == null) diff --git a/org.adempiere.eclipse.equinox.servletbridge/src/org/eclipse/equinox/servletbridge/BridgeServlet.java b/org.adempiere.eclipse.equinox.servletbridge/src/org/eclipse/equinox/servletbridge/BridgeServlet.java index 177b467a4c..f66b1dcc74 100644 --- a/org.adempiere.eclipse.equinox.servletbridge/src/org/eclipse/equinox/servletbridge/BridgeServlet.java +++ b/org.adempiere.eclipse.equinox.servletbridge/src/org/eclipse/equinox/servletbridge/BridgeServlet.java @@ -35,7 +35,7 @@ public class BridgeServlet extends HttpServlet { private static HttpServlet servletDelegateInstance; private HttpServlet delegate; // true if current HttpServlet is an HTTP Filter and false otherwise. - private boolean delegateIsFilter; + private static boolean delegateIsFilter; private int delegateReferenceCount; /** @@ -175,7 +175,7 @@ public class BridgeServlet extends HttpServlet { try { // cache the flag if HttpServlet servlet delegate is an HTTP Filter. - instance.delegateIsFilter = (servletDelegate instanceof Filter); + BridgeServlet.delegateIsFilter = (servletDelegate instanceof Filter); // initialize the servlet delegate. servletDelegate.init(instance.getServletConfig()); } catch (ServletException e) { @@ -207,7 +207,7 @@ public class BridgeServlet extends HttpServlet { HttpServlet oldProxy = instance.delegate; instance.delegate = null; - instance.delegateIsFilter = false; + BridgeServlet.delegateIsFilter = false; while (instance.delegateReferenceCount != 0) { try { instance.wait(); diff --git a/org.adempiere.server/src/main/server/org/compiere/server/AdempiereServerGroup.java b/org.adempiere.server/src/main/server/org/compiere/server/AdempiereServerGroup.java index dad61e56e0..17393879c5 100644 --- a/org.adempiere.server/src/main/server/org/compiere/server/AdempiereServerGroup.java +++ b/org.adempiere.server/src/main/server/org/compiere/server/AdempiereServerGroup.java @@ -38,7 +38,7 @@ public class AdempiereServerGroup extends ThreadGroup } // get /** Group */ - private static AdempiereServerGroup s_group = null; + private volatile static AdempiereServerGroup s_group = null; /** * AdempiereServerGroup diff --git a/org.adempiere.server/src/main/servlet/org/compiere/web/AdempiereMonitor.java b/org.adempiere.server/src/main/servlet/org/compiere/web/AdempiereMonitor.java index ed7a7eb72e..36f006d63a 100644 --- a/org.adempiere.server/src/main/servlet/org/compiere/web/AdempiereMonitor.java +++ b/org.adempiere.server/src/main/servlet/org/compiere/web/AdempiereMonitor.java @@ -94,11 +94,11 @@ public class AdempiereMonitor extends HttpServlet /** Logger */ private static CLogger log = CLogger.getCLogger(AdempiereMonitor.class); /** The Server */ - private AdempiereServerMgr m_serverMgr = null; + private static AdempiereServerMgr m_serverMgr = null; /** Message */ - private p m_message = null; + private static p m_message = null; - private ArrayList m_dirAccessList = null; + private volatile static ArrayList m_dirAccessList = null; /** * Get diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/APanel.java b/org.adempiere.ui.swing/src/org/compiere/apps/APanel.java index d536657b1f..aec0feedf7 100644 --- a/org.adempiere.ui.swing/src/org/compiere/apps/APanel.java +++ b/org.adempiere.ui.swing/src/org/compiere/apps/APanel.java @@ -2304,11 +2304,10 @@ public final class APanel extends CPanel return; } - // Attachment va = - new Attachment (AEnv.getFrame(this), m_curWindowNo, + @SuppressWarnings("unused") + Attachment va = new Attachment (AEnv.getFrame(this), m_curWindowNo, m_curTab.getAD_AttachmentID(), m_curTab.getAD_Table_ID(), record_ID, null); // - m_curTab.loadAttachments(); // reload aAttachment.setPressed(m_curTab.hasAttachment()); } // attachment @@ -2345,7 +2344,6 @@ public final class APanel extends CPanel m_curTab.getCM_ChatID(), m_curTab.getAD_Table_ID(), record_ID, description, null); // - m_curTab.loadChats(); // reload aChat.setPressed(m_curTab.hasChat()); } // chat @@ -2368,7 +2366,6 @@ public final class APanel extends CPanel else { m_curTab.lock (Env.getCtx(), record_ID, aLock.getButton().isSelected()); - m_curTab.loadAttachments(); // reload } aLock.setPressed(m_curTab.isLocked()); } // lock diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/Attachment.java b/org.adempiere.ui.swing/src/org/compiere/apps/Attachment.java index 588a575c62..6d83eb01dc 100644 --- a/org.adempiere.ui.swing/src/org/compiere/apps/Attachment.java +++ b/org.adempiere.ui.swing/src/org/compiere/apps/Attachment.java @@ -78,7 +78,7 @@ public final class Attachment extends CDialog int AD_Table_ID, int Record_ID, String trxName) { super (frame, Msg.getMsg(Env.getCtx(), "Attachment"), true); - // needs to be modal otherwise APanel does not recongize change. + // needs to be modal otherwise APanel does not recognize change. log.config("ID=" + AD_Attachment_ID + ", Table=" + AD_Table_ID + ", Record=" + Record_ID); // @@ -93,10 +93,10 @@ public final class Attachment extends CDialog log.log(Level.SEVERE, "", ex); } // Create Model - if (AD_Attachment_ID == 0) - m_attachment = new MAttachment (Env.getCtx(), AD_Table_ID, Record_ID, trxName); - else + if (AD_Attachment_ID > 0) m_attachment = new MAttachment (Env.getCtx(), AD_Attachment_ID, trxName); + else + m_attachment = new MAttachment (Env.getCtx(), AD_Table_ID, Record_ID, trxName); loadAttachments(); // try @@ -112,7 +112,7 @@ public final class Attachment extends CDialog /** Window No */ private int m_WindowNo; /** Attachment */ - private MAttachment m_attachment; + private MAttachment m_attachment = null; /** Change */ private boolean m_change = false; /** Logger */ @@ -380,7 +380,10 @@ public final class Attachment extends CDialog } } else + { m_attachment.delete(true); + m_attachment = null; + } dispose(); } // Cancel @@ -468,8 +471,10 @@ public final class Attachment extends CDialog private void deleteAttachment() { log.info(""); - if (ADialog.ask(m_WindowNo, this, "AttachmentDelete?")) + if (ADialog.ask(m_WindowNo, this, "AttachmentDelete?")) { m_attachment.delete(true); + m_attachment = null; + } } // deleteAttachment /** diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VAccountDialog.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VAccountDialog.java index 6e5d986a3e..199af65e93 100644 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VAccountDialog.java +++ b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VAccountDialog.java @@ -146,7 +146,7 @@ public final class VAccountDialog extends CDialog protected boolean m_changed = false; /** Accounting Schema */ - private static MAcctSchema s_AcctSchema = null; + private volatile static MAcctSchema s_AcctSchema = null; /** MWindow for AccountCombination */ private GridWindow m_mWindow = null; /** MTab for AccountCombination */ diff --git a/org.adempiere.ui.zk/WEB-INF/src/fi/jawsy/jawwa/zk/atmosphere/AtmosphereServerPush.java b/org.adempiere.ui.zk/WEB-INF/src/fi/jawsy/jawwa/zk/atmosphere/AtmosphereServerPush.java index a9c8ef6dda..f45929b215 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/fi/jawsy/jawwa/zk/atmosphere/AtmosphereServerPush.java +++ b/org.adempiere.ui.zk/WEB-INF/src/fi/jawsy/jawwa/zk/atmosphere/AtmosphereServerPush.java @@ -90,7 +90,7 @@ public class AtmosphereServerPush implements ServerPush { synchronized (info) { info.nActive = 1; //granted - info.notify(); + info.notifyAll(); } try { @@ -145,7 +145,7 @@ public class AtmosphereServerPush implements ServerPush { _active = null; synchronized (_mutex) { - _mutex.notify(); + _mutex.notifyAll(); } } } 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 0ae02e5cb9..c3d383bd17 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 @@ -801,7 +801,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements public void onEvent(Event event) throws Exception { adTabbox.getSelectedGridTab().lock(Env.getCtx(), adTabbox.getSelectedGridTab().getRecord_ID(), !toolbar.getButton("Lock").isPressed()); - adTabbox.getSelectedGridTab().loadAttachments(); // reload + adTabbox.getSelectedGridTab().loadLocks(); // reload toolbar.lock(adTabbox.getSelectedGridTab().isLocked()); } @@ -850,8 +850,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements EventListener listener = new EventListener() { @Override - public void onEvent(Event event) throws Exception { - adTabbox.getSelectedGridTab().loadAttachments(); // reload + public void onEvent(Event event) throws Exception { toolbar.getButton("Attachment").setPressed(adTabbox.getSelectedGridTab().hasAttachment()); focusToActivePanel(); } @@ -899,8 +898,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements 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 { - adTabbox.getSelectedGridTab().loadChats(); + public void onEvent(Event event) throws Exception { toolbar.getButton("Chat").setPressed(adTabbox.getSelectedGridTab().hasChat()); focusToActivePanel(); Clients.clearBusy(getComponent()); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WReportCustomization.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WReportCustomization.java index df49932e04..58fe8d7c29 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WReportCustomization.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WReportCustomization.java @@ -16,6 +16,7 @@ package org.adempiere.webui.apps.form; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.StringWriter; +import java.util.ArrayList; import java.util.Properties; import java.util.logging.Level; @@ -82,7 +83,7 @@ public class WReportCustomization implements IFormController,EventListener pfi ; private Auxheader headerPanel=new Auxheader(); private Listbox comboReport = new Listbox(); @@ -140,7 +141,11 @@ public class WReportCustomization implements IFormController,EventListener() ; + for (MPrintFormatItem item : m_reportEngine.getPrintFormat().getAllItems("IsPrinted DESC, NULLIF(SeqNo,0), Name")) { + pfi.add(item); + } + try { m_ctx = m_reportEngine.getCtx(); @@ -229,6 +234,7 @@ public class WReportCustomization implements IFormController,EventListener selObjects) { - int length = selObjects.size(); int iniIndex =0; Arrays.sort(selObjects.toArray()); ListElement endObject = (ListElement)yesModel.getElementAt(endIndex); - - for (int i = 0; i < length; i++) { - iniIndex = yesModel.indexOf(selObjects.get(i)); + for (ListElement selected : selObjects) { + iniIndex = yesModel.indexOf(selected); ListElement selObject = (ListElement)yesModel.getElementAt(iniIndex); yesModel.removeElement(selObject); endIndex = yesModel.indexOf(endObject); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WAttachment.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WAttachment.java index b60fe5a172..61bc845615 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WAttachment.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WAttachment.java @@ -76,7 +76,7 @@ public class WAttachment extends Window implements EventListener private int m_WindowNo; /** Attachment */ - private MAttachment m_attachment; + private MAttachment m_attachment = null; /** Change */ private boolean m_change = false; @@ -168,10 +168,10 @@ public class WAttachment extends Window implements EventListener // Create Model - if (AD_Attachment_ID == 0) - m_attachment = new MAttachment (Env.getCtx(), AD_Table_ID, Record_ID, trxName); - else + if (AD_Attachment_ID > 0) m_attachment = new MAttachment (Env.getCtx(), AD_Attachment_ID, trxName); + else + m_attachment = new MAttachment (Env.getCtx(), AD_Table_ID, Record_ID, trxName); loadAttachments(); @@ -483,7 +483,10 @@ public class WAttachment extends Window implements EventListener } } else + { m_attachment.delete(true); + m_attachment = null; + } dispose(); } @@ -614,6 +617,7 @@ public class WAttachment extends Window implements EventListener if (result) { m_attachment.delete(true); + m_attachment = null; } } }); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WRC1DisplayFieldsPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WRC1DisplayFieldsPanel.java index a62f3bb914..aa77132232 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WRC1DisplayFieldsPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WRC1DisplayFieldsPanel.java @@ -23,6 +23,7 @@ import org.adempiere.webui.component.Rows; import org.adempiere.webui.component.Textbox; import org.adempiere.webui.component.Window; import org.compiere.print.MPrintFormat; +import org.compiere.print.MPrintFormatItem; import org.compiere.util.KeyNamePair; import org.compiere.util.Util; import org.zkoss.zk.ui.event.Event; @@ -59,9 +60,9 @@ public class WRC1DisplayFieldsPanel extends WRCTabPanel implements EventListener public void init() { - m_chkboxes = new Checkbox[m_pfi.length]; - m_textBoxes = new Textbox[m_pfi.length]; - m_oldLabel = new String[m_pfi.length]; + m_chkboxes = new Checkbox[m_pfi.size()]; + m_textBoxes = new Textbox[m_pfi.size()]; + m_oldLabel = new String[m_pfi.size()]; Window wind=new Window(); wind.setWidth("90%"); @@ -99,20 +100,21 @@ public class WRC1DisplayFieldsPanel extends WRCTabPanel implements EventListener int curCol=0; Rows rows = grid.newRows(); org.zkoss.zul.Row row = null; - for(int i=0;i listColumns=new ArrayList(); SimpleListModel sortModel; + private Listbox sortList; public WRC2FieldOrderPanel() { super(); @@ -59,13 +61,9 @@ public class WRC2FieldOrderPanel extends WRCTabPanel implements EventListener(); - if (m_pfi != null && m_pfi.length > 0) { - for (int i = 0; i < m_pfi.length; i++) { - if (m_pfi[i] != null && m_pfi[i].isPrinted()) { - listColumns.add(m_pfi[i]); - } - } - } + for (MPrintFormatItem item : m_pfi) + if(item!=null && item.isPrinted()) + listColumns.add(item); } public void init() @@ -100,37 +98,21 @@ public class WRC2FieldOrderPanel extends WRCTabPanel implements EventListener selObjects = new ArrayList(); int targetIndex = sortList.getIndexOfItem(targetItem); - ListElement targetElement = (ListElement) sortModel.getElementAt(targetIndex); - ListElement draggedElement = (ListElement) sortModel.getElementAt(draggedIndex); - - int firstposition=0, secondposition=0; - MPrintFormatItem targetPFI = null; - MPrintFormatItem draggedPFI = null; - for(int j=0 ;j selObjects) + { + int iniIndex =0; + Arrays.sort(selObjects.toArray()); + ListElement selObject= null; + ListElement endObject = (ListElement)sortModel.getElementAt(endIndex); + int targetPFISeq = 0; + MPrintFormatItem draggedPFI = null; + + for (ListElement selected : selObjects) { + iniIndex = sortModel.indexOf(selected); + selObject = (ListElement)sortModel.getElementAt(iniIndex); + draggedPFI =listColumns.get(iniIndex); + sortModel.removeElement(selObject); + listColumns.remove(draggedPFI); + endIndex = sortModel.indexOf(endObject); + targetPFISeq = listColumns.get(endIndex).getSeqNo(); + listColumns.add(endIndex, draggedPFI); + sortModel.add(endIndex, selObject); + draggedPFI.setSeqNo(targetPFISeq - 5); + } + } + @Override public void onEvent(Event event) throws Exception { @@ -194,26 +202,15 @@ public class WRC2FieldOrderPanel extends WRCTabPanel implements EventListener 0 && listColumns != null) { int seq = 10; sortModel.removeAllElements(); - for (int i=0; i @@ -53,15 +55,13 @@ public class WRC3SortCriteriaPanel extends WRCTabPanel implements EventListener private Button bRemove = new Button(); private Button bUp = new Button(); private Button bDown = new Button(); - - public ArrayList yesItems=new ArrayList(); - public ArrayList noItems=new ArrayList(); - // SimpleListModel noModel = new SimpleListModel(); SimpleListModel yesModel = new SimpleListModel(); Listbox noList = new Listbox(); Listbox yesList = new Listbox(); + ArrayList yesItems =new ArrayList(); + ArrayList noItems =new ArrayList(); public WRC3SortCriteriaPanel() { super(); @@ -110,59 +110,7 @@ public class WRC3SortCriteriaPanel extends WRCTabPanel implements EventListener noList.addOnDropListener(crossListMouseListener); yesList.setItemDraggable(true); noList.setItemDraggable(true); - - EventListener yesListMouseMotionListener = new EventListener() - { - public void onEvent(Event event) throws Exception { - if (event instanceof DropEvent) - { - DropEvent me = (DropEvent) event; - ListItem startItem = (ListItem) me.getDragged(); - ListItem endItem = (ListItem) me.getTarget(); - if (startItem.getListbox() == endItem.getListbox() && startItem.getListbox() == yesList) - { - int startIndex = yesList.getIndexOfItem(startItem); - int endIndex = yesList.getIndexOfItem(endItem); - ListElement endElement = (ListElement) yesModel.getElementAt(endIndex); - ListElement startElement = (ListElement) yesModel.getElementAt(startIndex); - yesModel.removeElement(startElement); - endIndex = yesModel.indexOf(endElement); - yesModel.add(endIndex, startElement); - yesList.setSelectedIndex(endIndex); - - int firstposition=0, secondposition=0; - MPrintFormatItem targetPFI = null; - MPrintFormatItem draggedPFI = null; - for(int j=0 ;j (); noItems =new ArrayList(); - if (m_pfi.length > 0 && m_pfi != null ) { - int seq = 10; - for(int i=0 ; i < m_pfi.length ; i++ ){ - if (m_pfi[i].isPrinted() && m_pfi[i] != null) { - if (m_pfi[i].isOrderBy()) { - m_pfi[i].setSortNo(seq); - seq=seq+10; - yesItems.add(m_pfi[i]); - } else{ - noItems.add(m_pfi[i]); - } - } - } + for(int i=0 ; i< m_pfi.size();i++){ + MPrintFormatItem item = m_pfi.get(i); + if(item!=null && item.isPrinted()){ + if(item.isOrderBy()){ + yesItems.add(item); + }else{ + noItems.add(item); + } + } } - Collections.sort(yesItems, new Comparator() { @Override public int compare(MPrintFormatItem o1, MPrintFormatItem o2) { return o1.getSortNo()-o2.getSortNo(); } }); - + } + + @Override + public void refresh() { + + this.setListsColumns(); yesList.removeAllItems(); noList.removeAllItems(); if (yesItems.size() > 0 && yesItems != null) { yesModel.removeAllElements(); - for (int i=0 ; i < yesItems.size() ; i++) { - MPrintFormatItem pfi = yesItems.get(i); - if (pfi != null) { - int ID= pfi.get_ID(); - String name =pfi.getPrintName(); - if(name == null) - name=pfi.getName(); - KeyNamePair pair =new KeyNamePair(ID, name); - yesList.addItem(pair); - ListElement element =new ListElement(pfi.get_ID(), pfi.getName(), pfi.getSortNo(), true, pfi.getAD_Client_ID(), pfi.getAD_Org_ID()); - yesModel.addElement(element); - } + for (int i=0 ; i < yesItems.size() ; i++) { + int ID= yesItems.get(i).get_ID(); + String name = yesItems.get(i).getPrintName()==null? yesItems.get(i).getName():yesItems.get(i).getPrintName(); + yesList.addItem(new KeyNamePair(ID, name)); + yesModel.addElement(new ListElement(ID, name, yesItems.get(i).getSortNo(), true, yesItems.get(i).getAD_Client_ID(), yesItems.get(i).getAD_Org_ID())); } } - + if (noItems.size() > 0 && noItems != null) { noModel.removeAllElements(); for (int i=0 ; i < noItems.size() ; i++) { - MPrintFormatItem pfi = noItems.get(i); - if (pfi != null) { - int ID= pfi.get_ID(); - pfi.setSortNo(0); - pfi.setIsOrderBy(false); - String name =pfi.getPrintName(); - if(name == null) - name=pfi.getName(); - KeyNamePair pair =new KeyNamePair(ID, name); - noList.addItem(pair); - ListElement element =new ListElement(pfi.get_ID(), pfi.getName(), pfi.getSortNo(), false, pfi.getAD_Client_ID(), pfi.getAD_Org_ID()); - noModel.add(i,element); - } + int ID= noItems.get(i).get_ID(); + String name = noItems.get(i).getPrintName()== null ? noItems.get(i).getName() : noItems.get(i).getPrintName(); + noItems.get(i).setSortNo(0); + noItems.get(i).setIsOrderBy(false); + noList.addItem(new KeyNamePair(ID, name)); + noModel.add(i,new ListElement(ID, name, noItems.get(i).getSortNo(), false, noItems.get(i).getAD_Client_ID(), noItems.get(i).getAD_Org_ID())); } } } @@ -302,45 +235,104 @@ public class WRC3SortCriteriaPanel extends WRCTabPanel implements EventListener } Listbox listFrom = (source == bAdd || source == noList) ? noList : yesList; Listbox listTo = (source == bAdd || source == noList) ? yesList : noList; - SimpleListModel lmFrom = (source == bAdd || source == noList) ? - noModel : yesModel; - SimpleListModel lmTo = (lmFrom == yesModel) ? noModel : yesModel; + + int endIndex = yesList.getIndexOfItem(listTo.getSelectedItem()); + //Listto is empty. + if (endIndex<0 ) + endIndex=0; + + migrateLists (listFrom,listTo,endIndex); + } // migrateValueAcrossLists + + void migrateLists (Listbox listFrom , Listbox listTo , int endIndex) + { + int index = 0; + SimpleListModel lmFrom = (listFrom == yesList) ? yesModel:noModel; + SimpleListModel lmTo = (lmFrom == yesModel) ? noModel:yesModel; Set selectedItems = listFrom.getSelectedItems(); List selObjects = new ArrayList(); for (Object obj : selectedItems) { ListItem listItem = (ListItem) obj; - int index = listFrom.getIndexOfItem(listItem); + index = listFrom.getIndexOfItem(listItem); ListElement selObject = (ListElement)lmFrom.getElementAt(index); selObjects.add(selObject); } + index = 0; + boolean reOrder = false; + Arrays.sort(selObjects.toArray()); for (ListElement selObject : selObjects) { if (selObject == null) continue; lmFrom.removeElement(selObject); - lmTo.addElement(selObject); - - for (int j=0 ; j pp = new ArrayList(); + for(int i=0 ; i() { + @Override + public int compare(ListElement o1, ListElement o2) { + return o1.getSortNo()-o2.getSortNo(); + } + }); + for(ListElement ele : pp) { + int auxIndex = m_pfi.indexOf(getPrintFormatItem(ele.m_key)); + m_pfi.get(auxIndex).setSortNo(sortNo); + sortNo = sortNo + 10; + } + wc.setIsChanged(true); + } refresh(); if ( listTo.getSelectedItem() != null) { AuFocus focus = new AuFocus(listTo.getSelectedItem()); Clients.response(focus); } - - } // migrateValueAcrossLists + } + + /** + * Move within Yes List with Drag Event and Multiple Choice + * @param event event + */ + void migrateValueWithinYesList (int endIndex, List selObjects) + { + int iniIndex =0; + Arrays.sort(selObjects.toArray()); + ListElement selObject= null; + ListElement endObject = (ListElement)yesModel.getElementAt(endIndex); + for (ListElement selected : selObjects) { + iniIndex = yesModel.indexOf(selected); + selObject = (ListElement)yesModel.getElementAt(iniIndex); + yesModel.removeElement(selObject); + endIndex = yesModel.indexOf(endObject); + yesModel.add(endIndex, selObject); + } + int sortNo = 10; + int auxIndex =0; + yesList.removeAllItems(); + for(int i=0 ; i selObjects = new ArrayList(); + endIndex = yesList.getIndexOfItem(endItem); + for (Object obj : yesList.getSelectedItems()) { + ListItem listItem = (ListItem) obj; + int index = yesList.getIndexOfItem(listItem); + ListElement selObject = (ListElement)yesModel.getElementAt(index); + selObjects.add(selObject); } + migrateValueWithinYesList (endIndex, selObjects); } - wc.setIsChanged(true); - } - - refresh(); - // - noList.clearSelection(); - yesList.clearSelection(); - - yesList.setSelectedIndex(endIndex); - - } - } + } + } + } } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WRC4GroupingCriteriaPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WRC4GroupingCriteriaPanel.java index 5025386c66..d9632c197b 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WRC4GroupingCriteriaPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WRC4GroupingCriteriaPanel.java @@ -48,9 +48,9 @@ public class WRC4GroupingCriteriaPanel extends WRCTabPanel implements EventListe @Override public void refresh() { orderfield = new ArrayList(); - for(int i=0 ; i < m_pfi.length ; i++){ - if(m_pfi[i] != null && m_pfi[i].isOrderBy() && m_pfi[i].isPrinted()){ - orderfield.add(m_pfi[i]); + for(int i=0 ; i < m_pfi.size(); i++){ + if(m_pfi.get(i) != null && m_pfi.get(i).isOrderBy() && m_pfi.get(i).isPrinted()){ + orderfield.add(m_pfi.get(i)); } } dynamicInit(); @@ -59,11 +59,8 @@ public class WRC4GroupingCriteriaPanel extends WRCTabPanel implements EventListe @Override public void updatePFI() { for(int i=0 ; i(); - for(int i=0 ; i m_pfi; public MPrintFormat m_pf; public WReportCustomization wc; + public Map mapPFormatItem = new HashMap(); public abstract void refresh(); @@ -35,14 +42,21 @@ public abstract class WRCTabPanel extends Tabpanel { public void setMPrintFormat(MPrintFormat pf) { m_pf=pf; + for (MPrintFormatItem item : m_pf.getAllItems() ){ + mapPFormatItem.put(item.get_ID(), item); + } } - public void setPrintFormatItems(MPrintFormatItem[] pfis) { + public void setPrintFormatItems(ArrayList pfis) { m_pfi = pfis; } public void setWReportCustomization(WReportCustomization parent){ wc=parent; } - + + public MPrintFormatItem getPrintFormatItem(int AD_PrintFormatItem_ID) { + return mapPFormatItem.get(AD_PrintFormatItem_ID); + } + } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WAccountDialog.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WAccountDialog.java index b922167979..b7dcca971a 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WAccountDialog.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WAccountDialog.java @@ -123,7 +123,7 @@ public final class WAccountDialog extends Window protected boolean m_changed = false; /** Accounting Schema */ - private static MAcctSchema s_AcctSchema = null; + private volatile static MAcctSchema s_AcctSchema = null; /** MWindow for AccountCombination */ private GridWindow m_mWindow = null; /** MTab for AccountCombination */ diff --git a/org.adempiere.webstore.servlet/src/org/compiere/wstore/StoreFilter.java b/org.adempiere.webstore.servlet/src/org/compiere/wstore/StoreFilter.java index 33735ecf04..e18696dc1a 100644 --- a/org.adempiere.webstore.servlet/src/org/compiere/wstore/StoreFilter.java +++ b/org.adempiere.webstore.servlet/src/org/compiere/wstore/StoreFilter.java @@ -43,7 +43,7 @@ import org.compiere.util.WebEnv; public class StoreFilter implements javax.servlet.Filter { /** Logging */ - private static CLogger log = null; + private volatile static CLogger log = null; /** * Init diff --git a/org.compiere.db.oracle.provider/src/org/compiere/db/DB_Oracle.java b/org.compiere.db.oracle.provider/src/org/compiere/db/DB_Oracle.java index e65680e6ef..8ae60f5dc3 100644 --- a/org.compiere.db.oracle.provider/src/org/compiere/db/DB_Oracle.java +++ b/org.compiere.db.oracle.provider/src/org/compiere/db/DB_Oracle.java @@ -164,7 +164,7 @@ public class DB_Oracle implements AdempiereDatabase * @return Driver * @throws SQLException */ - public Driver getDriver() throws SQLException + public synchronized Driver getDriver() throws SQLException { if (s_driver == null) { diff --git a/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/AssertRecord.java b/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/AssertRecord.java index d6dce28088..4cf37ea271 100644 --- a/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/AssertRecord.java +++ b/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/AssertRecord.java @@ -45,7 +45,7 @@ import fitnesse.fixtures.TableFixture; * @author Carlos Ruiz - globalqss */ public class AssertRecord extends TableFixture { - private static Instance adempiereInstance = null; + private volatile static Instance adempiereInstance = null; @Override protected void doStaticTable(int rows) { diff --git a/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/AssertVariable.java b/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/AssertVariable.java index 47e739b981..7a20125665 100644 --- a/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/AssertVariable.java +++ b/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/AssertVariable.java @@ -36,7 +36,7 @@ import fitnesse.fixtures.TableFixture; * @author Carlos Ruiz - globalqss */ public class AssertVariable extends TableFixture { - private static Instance adempiereInstance = null; + private volatile static Instance adempiereInstance = null; @Override protected void doStaticTable(int rows) { diff --git a/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/CreateRecord.java b/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/CreateRecord.java index d4f4c470cd..2f6268d58a 100644 --- a/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/CreateRecord.java +++ b/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/CreateRecord.java @@ -44,7 +44,7 @@ import fitnesse.fixtures.TableFixture; * @author Carlos Ruiz - globalqss */ public class CreateRecord extends TableFixture { - private static Instance adempiereInstance = null; + private volatile static Instance adempiereInstance = null; @Override protected void doStaticTable(int rows) { diff --git a/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/Login.java b/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/Login.java index ed39c9d727..0d8561108f 100644 --- a/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/Login.java +++ b/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/Login.java @@ -39,7 +39,7 @@ import fitnesse.fixtures.TableFixture; */ public class Login extends TableFixture { private static final String LANGUAGE_EN_US = "en_US"; - private static Instance adempiereInstance = null; + private volatile static Instance adempiereInstance = null; private String m_user; private String m_password; private String m_language; diff --git a/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/ReadRecord.java b/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/ReadRecord.java index 28f1eac69e..7f5dd615ce 100644 --- a/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/ReadRecord.java +++ b/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/ReadRecord.java @@ -45,7 +45,7 @@ import fitnesse.fixtures.TableFixture; * @author Carlos Ruiz - globalqss */ public class ReadRecord extends TableFixture { - private static Instance adempiereInstance = null; + private volatile static Instance adempiereInstance = null; @Override protected void doStaticTable(int rows) { diff --git a/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/RunProcess.java b/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/RunProcess.java index a4e34fe805..90b582f69a 100644 --- a/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/RunProcess.java +++ b/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/RunProcess.java @@ -58,7 +58,7 @@ import fitnesse.fixtures.TableFixture; * @author Carlos Ruiz - globalqss */ public class RunProcess extends TableFixture { - private static Instance adempiereInstance = null; + private volatile static Instance adempiereInstance = null; private static CLogger log = CLogger.getCLogger(RunProcess.class); diff --git a/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/SetDocAction.java b/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/SetDocAction.java index 117f975ff7..97422214e0 100644 --- a/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/SetDocAction.java +++ b/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/SetDocAction.java @@ -43,7 +43,7 @@ import fitnesse.fixtures.TableFixture; * @author Carlos Ruiz - globalqss */ public class SetDocAction extends TableFixture { - private static Instance adempiereInstance = null; + private volatile static Instance adempiereInstance = null; @Override protected void doStaticTable(int rows) { diff --git a/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/SetVariable.java b/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/SetVariable.java index a1c6a9d532..c5b65dcce6 100644 --- a/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/SetVariable.java +++ b/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/SetVariable.java @@ -38,7 +38,7 @@ import fitnesse.fixtures.TableFixture; * @author Carlos Ruiz - globalqss */ public class SetVariable extends TableFixture { - private static Instance adempiereInstance = null; + private volatile static Instance adempiereInstance = null; @Override protected void doStaticTable(int rows) { diff --git a/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/Static_iDempiereInstance.java b/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/Static_iDempiereInstance.java index 506624e70e..8d10ee3480 100644 --- a/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/Static_iDempiereInstance.java +++ b/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/Static_iDempiereInstance.java @@ -32,7 +32,7 @@ package org.idempiere.fitnesse.fixture; * @author Carlos Ruiz - globalqss */ public class Static_iDempiereInstance { - private static Instance adempiereInstance; + private volatile static Instance adempiereInstance; public static Instance getInstance() { if (adempiereInstance == null) { diff --git a/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/Activator.java b/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/Activator.java index 9a57f5a743..853fd80b18 100644 --- a/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/Activator.java +++ b/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/Activator.java @@ -39,7 +39,7 @@ public class Activator implements BundleActivator { return context; } - private static HazelcastInstance hazelcastInstance; + private volatile static HazelcastInstance hazelcastInstance; private static AtomicReference> futureRef = new AtomicReference>(); /*