Merge e190cdb84c61
This commit is contained in:
commit
96614113b0
|
@ -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
|
||||
;
|
||||
|
|
@ -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
|
||||
;
|
||||
|
|
@ -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 " +
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<Integer,Integer> m_Attachments = null;
|
||||
/** Chats */
|
||||
private HashMap<Integer,Integer> m_Chats = null;
|
||||
/** Locks */
|
||||
private ArrayList<Integer> 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<Integer,Integer>();
|
||||
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?.
|
||||
* <p>
|
||||
|
@ -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<Integer,Integer>();
|
||||
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
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -186,7 +186,7 @@ public class MLocator extends X_M_Locator
|
|||
} // get
|
||||
|
||||
/** Cache */
|
||||
private static CCache<Integer,MLocator> s_cache;
|
||||
private volatile static CCache<Integer,MLocator> s_cache;
|
||||
|
||||
/** Logger */
|
||||
private static CLogger s_log = CLogger.getCLogger (MLocator.class);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -35,7 +35,7 @@ public class MUserDefWin extends X_AD_UserDef_Win
|
|||
*/
|
||||
private static final long serialVersionUID = -5775251886672840324L;
|
||||
|
||||
private static List<MUserDefWin> m_fullList = null;
|
||||
private volatile static List<MUserDefWin> m_fullList = null;
|
||||
|
||||
/**
|
||||
* Standard constructor.
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -64,7 +64,7 @@ public class WebInfo
|
|||
} // getGeneral
|
||||
|
||||
/** General Info */
|
||||
private static WebInfo m_general = null;
|
||||
private volatile static WebInfo m_general = null;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
|
|
@ -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;
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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$
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<File> m_dirAccessList = null;
|
||||
private volatile static ArrayList<File> m_dirAccessList = null;
|
||||
|
||||
/**
|
||||
* Get
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
/**
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<Event> listener = new EventListener<Event>() {
|
||||
|
||||
@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<Event>() {
|
||||
@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());
|
||||
|
|
|
@ -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<Even
|
|||
private boolean m_isCanExport;
|
||||
|
||||
private ReportEngine m_reportEngine=null;
|
||||
public MPrintFormatItem[] pfi ;
|
||||
public ArrayList<MPrintFormatItem> pfi ;
|
||||
|
||||
private Auxheader headerPanel=new Auxheader();
|
||||
private Listbox comboReport = new Listbox();
|
||||
|
@ -140,7 +141,11 @@ public class WReportCustomization implements IFormController,EventListener<Even
|
|||
|
||||
m_reportEngine = re;
|
||||
m_isCanExport=MRole.getDefault().isCanExport();
|
||||
pfi= m_reportEngine.getPrintFormat().getAllItems("IsPrinted DESC, NULLIF(SeqNo,0), Name");
|
||||
pfi = new ArrayList<MPrintFormatItem>() ;
|
||||
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<Even
|
|||
|
||||
tpsc3.setMPrintFormat(fm);
|
||||
tpsc3.setPrintFormatItems(pfi);
|
||||
tpsc3.setListsColumns();
|
||||
tpsc3.init();
|
||||
tpsc3.refresh();
|
||||
tpsc3.setWReportCustomization(this);
|
||||
|
@ -359,10 +365,12 @@ public class WReportCustomization implements IFormController,EventListener<Even
|
|||
}
|
||||
|
||||
private void onSave() {
|
||||
for (int i=0; i < pfi.length ;i++){
|
||||
pfi[i].saveEx();
|
||||
}
|
||||
setIsChanged(false);
|
||||
|
||||
for (MPrintFormatItem item : pfi)
|
||||
if (item.is_Changed())
|
||||
item.saveEx();
|
||||
|
||||
setIsChanged(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -519,8 +527,10 @@ public class WReportCustomization implements IFormController,EventListener<Even
|
|||
|
||||
public void copyFormat(){
|
||||
MPrintFormat newpf=MPrintFormat.copyToClient(m_ctx, m_reportEngine.getPrintFormat().get_ID() ,Env.getAD_Client_ID(m_ctx));
|
||||
pfi = newpf.getAllItems("IsPrinted DESC, NULLIF(SeqNo,0), Name");
|
||||
|
||||
|
||||
for (MPrintFormatItem item : newpf.getAllItems("IsPrinted DESC, NULLIF(SeqNo,0), Name"))
|
||||
pfi.add(item);
|
||||
|
||||
tpdf1.setMPrintFormat(newpf);
|
||||
tpdf1.setPrintFormatItems(pfi);
|
||||
tpdf1.refresh();
|
||||
|
@ -532,6 +542,7 @@ public class WReportCustomization implements IFormController,EventListener<Even
|
|||
|
||||
tpsc3.setMPrintFormat(newpf);
|
||||
tpsc3.setPrintFormatItems(pfi);
|
||||
tpfo2.setListColumns();
|
||||
tpsc3.refresh();
|
||||
|
||||
tpgc4.setMPrintFormat(newpf);
|
||||
|
|
|
@ -408,13 +408,11 @@ public class CustomizeGridViewPanel extends Panel
|
|||
*/
|
||||
void migrateValueWithinYesList (int endIndex, List<ListElement> 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);
|
||||
|
|
|
@ -76,7 +76,7 @@ public class WAttachment extends Window implements EventListener<Event>
|
|||
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<Event>
|
|||
|
||||
// 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<Event>
|
|||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_attachment.delete(true);
|
||||
m_attachment = null;
|
||||
}
|
||||
|
||||
dispose();
|
||||
}
|
||||
|
@ -614,6 +617,7 @@ public class WAttachment extends Window implements EventListener<Event>
|
|||
if (result)
|
||||
{
|
||||
m_attachment.delete(true);
|
||||
m_attachment = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -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<m_pfi.length;i++){
|
||||
int i=0;
|
||||
for (MPrintFormatItem printItem : m_pfi){
|
||||
if(curCol==0){
|
||||
row = new Row();
|
||||
rows.appendChild(row);
|
||||
}
|
||||
m_chkboxes[i] = new Checkbox();
|
||||
m_chkboxes[i].setChecked(m_pfi[i].isPrinted());
|
||||
m_chkboxes[i].setChecked(printItem.isPrinted());
|
||||
m_chkboxes[i].addEventListener(Events.ON_CHECK,this);
|
||||
row.appendChild(m_chkboxes[i]);
|
||||
|
||||
m_textBoxes[i] = new Textbox();
|
||||
String strValue = m_pfi[i].getPrintName();
|
||||
String strValue = printItem.getPrintName();
|
||||
if(strValue ==null || strValue.length()==0){
|
||||
strValue = m_pfi[i].getName();
|
||||
strValue = printItem.getName();
|
||||
}
|
||||
m_oldLabel[i] = strValue;
|
||||
m_textBoxes[i].setText(strValue);
|
||||
|
@ -120,26 +122,26 @@ public class WRC1DisplayFieldsPanel extends WRCTabPanel implements EventListener
|
|||
row.appendChild(m_textBoxes[i]);
|
||||
|
||||
curCol++;
|
||||
i++;
|
||||
curCol = curCol%RENDER_IN_COLUMNS;
|
||||
}
|
||||
}
|
||||
|
||||
public void save(){
|
||||
for(int i=0;i<m_pfi.length;i++){
|
||||
m_pfi[i].setIsActive(m_chkboxes[i].isChecked());
|
||||
m_pfi[i].setPrintName(m_textBoxes[i].getText());
|
||||
m_pfi[i].saveEx();
|
||||
}
|
||||
int i=0;
|
||||
for (MPrintFormatItem item : m_pfi){
|
||||
item.setIsActive(m_chkboxes[i].isChecked());
|
||||
item.setPrintName(m_textBoxes[i].getText());
|
||||
item.saveEx();
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
public KeyNamePair[] getChecked(){
|
||||
KeyNamePair [] listcheck=new KeyNamePair[m_pfi.length];
|
||||
KeyNamePair [] listcheck=new KeyNamePair[m_pfi.size()];
|
||||
for(int i=0;i<m_chkboxes.length;i++){
|
||||
if(m_chkboxes[i].isChecked()){
|
||||
int ID=m_pfi[i].get_ID();
|
||||
String name=m_pfi[i].getName();
|
||||
KeyNamePair pair=new KeyNamePair(ID, name);
|
||||
listcheck[i]=pair;
|
||||
listcheck[i]= new KeyNamePair(m_pfi.get(i).get_ID(),m_pfi.get(i).getName());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -148,8 +150,8 @@ public class WRC1DisplayFieldsPanel extends WRCTabPanel implements EventListener
|
|||
|
||||
@Override
|
||||
public void refresh() {
|
||||
for (int i=0 ; i< m_pfi.length ; i++){
|
||||
m_chkboxes[i].setChecked(m_pfi[i].isPrinted());
|
||||
for (int i=0 ; i< m_pfi.size(); i++){
|
||||
m_chkboxes[i].setChecked(m_pfi.get(i).isPrinted());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -157,21 +159,21 @@ public class WRC1DisplayFieldsPanel extends WRCTabPanel implements EventListener
|
|||
public void updatePFI() {
|
||||
for (int i=0 ;i < m_chkboxes.length ;i++){
|
||||
if(m_chkboxes[i].isChecked()){
|
||||
m_pfi[i].setIsPrinted(true);
|
||||
m_pfi.get(i).setIsPrinted(true);
|
||||
}
|
||||
else{
|
||||
m_pfi[i].setIsPrinted(false);
|
||||
m_pfi.get(i).setIsPrinted(false);
|
||||
}
|
||||
String printname = m_textBoxes[i].getValue();
|
||||
if (!Util.isEmpty(printname))
|
||||
if (! printname.equals(m_pfi[i].getPrintName()))
|
||||
m_pfi[i].setPrintName(m_textBoxes[i].getValue());
|
||||
if (! printname.equals(m_pfi.get(i).getPrintName()))
|
||||
m_pfi.get(i).setPrintName(m_textBoxes[i].getValue());
|
||||
}
|
||||
}
|
||||
|
||||
public void updatePrinted(boolean value){
|
||||
for(int j=0 ; j< m_pfi.length ; j++){
|
||||
m_pfi[j].setIsPrinted(value);
|
||||
for(int j=0 ; j< m_pfi.size() ; j++){
|
||||
m_pfi.get(j).setIsPrinted(value);
|
||||
m_chkboxes[j].setChecked(value);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,8 +15,10 @@
|
|||
package org.adempiere.webui.panel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import org.adempiere.webui.component.Button;
|
||||
import org.adempiere.webui.component.ListHead;
|
||||
|
@ -46,12 +48,12 @@ public class WRC2FieldOrderPanel extends WRCTabPanel implements EventListener<Ev
|
|||
/**
|
||||
*
|
||||
*/
|
||||
private Listbox sortList;
|
||||
private Button bUp = new Button();
|
||||
private Button bDown = new Button();
|
||||
|
||||
private ArrayList<MPrintFormatItem> listColumns=new ArrayList<MPrintFormatItem>();
|
||||
SimpleListModel sortModel;
|
||||
private Listbox sortList;
|
||||
|
||||
public WRC2FieldOrderPanel() {
|
||||
super();
|
||||
|
@ -59,13 +61,9 @@ public class WRC2FieldOrderPanel extends WRCTabPanel implements EventListener<Ev
|
|||
|
||||
public void setListColumns() {
|
||||
listColumns = new ArrayList<MPrintFormatItem>();
|
||||
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<Ev
|
|||
ListItem targetItem = (ListItem) me.getTarget();
|
||||
if (draggedItem.getListbox() == targetItem.getListbox() && draggedItem.getListbox() == sortList)
|
||||
{
|
||||
int draggedIndex = sortList.getIndexOfItem(draggedItem);
|
||||
List<ListElement> selObjects = new ArrayList<ListElement>();
|
||||
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 <m_pfi.length ;j++){
|
||||
if(m_pfi[j].get_ID() == targetElement.getKey()){
|
||||
targetPFI = m_pfi[j];
|
||||
firstposition=j;
|
||||
}
|
||||
if(m_pfi[j].get_ID() == draggedElement.getKey()){
|
||||
draggedPFI = m_pfi[j];
|
||||
secondposition=j;
|
||||
}
|
||||
}
|
||||
draggedPFI.setSeqNo(targetPFI.getSeqNo()-5);
|
||||
|
||||
MPrintFormatItem fi=m_pfi[firstposition];
|
||||
m_pfi[firstposition]=m_pfi[secondposition];
|
||||
m_pfi[secondposition]=fi;
|
||||
|
||||
sortModel.removeElement(draggedElement);
|
||||
targetIndex = sortModel.indexOf(targetElement);
|
||||
sortModel.add(targetIndex, draggedElement);
|
||||
|
||||
if (!draggedItem.isSelected())
|
||||
draggedItem.setSelected(true);
|
||||
|
||||
for (Object obj : sortList.getSelectedItems()) {
|
||||
ListItem listItem = (ListItem) obj;
|
||||
int index = sortList.getIndexOfItem(listItem);
|
||||
ListElement selObject = (ListElement)sortModel.getElementAt(index);
|
||||
selObjects.add(selObject);
|
||||
}
|
||||
migrateValueWithinYesList (targetIndex, selObjects);
|
||||
wc.setIsChanged(true);
|
||||
refresh();
|
||||
sortList.setSelectedIndex(targetIndex);
|
||||
if ( sortList.getSelectedItem() != null)
|
||||
{
|
||||
AuFocus focus = new AuFocus(sortList.getSelectedItem());
|
||||
|
@ -168,12 +150,38 @@ public class WRC2FieldOrderPanel extends WRCTabPanel implements EventListener<Ev
|
|||
vbox.appendChild(bDown);
|
||||
vbox.setWidth("50px");
|
||||
vbox.setHflex("60");
|
||||
//vbox.setParent(wind);
|
||||
hlayout.appendChild(vbox);
|
||||
this.appendChild(hlayout);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Move within Yes List with Drag Event and Multiple Choice
|
||||
* @param event event
|
||||
*/
|
||||
void migrateValueWithinYesList (int endIndex, List<ListElement> 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<Ev
|
|||
if (listColumns.size() > 0 && listColumns != null) {
|
||||
int seq = 10;
|
||||
sortModel.removeAllElements();
|
||||
for (int i=0; i<listColumns.size(); i++) {
|
||||
MPrintFormatItem pfi = listColumns.get(i);
|
||||
if (pfi != null) {
|
||||
pfi.setSeqNo(seq);
|
||||
for(int j=0 ;j<m_pfi.length;j++){
|
||||
if(m_pfi[j].get_ID()== pfi.get_ID()){
|
||||
m_pfi[j].setSeqNo(seq);
|
||||
}
|
||||
}
|
||||
seq = seq + 10;
|
||||
int ID = pfi.get_ID();
|
||||
String name=pfi.getPrintName();
|
||||
if(name == null)
|
||||
name=pfi.getName();
|
||||
ListElement element =new ListElement(ID, name, pfi.getSeqNo(), pfi.getAD_Client_ID(), pfi.getAD_Org_ID());
|
||||
sortModel.addElement(element);
|
||||
KeyNamePair pair=new KeyNamePair(ID, name);
|
||||
sortList.addItem(pair);
|
||||
}
|
||||
}
|
||||
for (MPrintFormatItem pfi : listColumns){
|
||||
pfi.setSeqNo(seq);
|
||||
m_pfi.get(m_pfi.indexOf(pfi)).setSeqNo(seq);
|
||||
String name= pfi.getPrintName()== null ? pfi.getName(): pfi.getPrintName() ;
|
||||
ListElement element =new ListElement(pfi.get_ID(), name, pfi.getSeqNo(), pfi.getAD_Client_ID(), pfi.getAD_Org_ID());
|
||||
sortModel.addElement(element);
|
||||
sortList.addItem(new KeyNamePair(m_pfi.get(m_pfi.indexOf(pfi)).get_ID(), name));
|
||||
seq = seq + 10;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -236,9 +233,8 @@ public class WRC2FieldOrderPanel extends WRCTabPanel implements EventListener<Ev
|
|||
return;
|
||||
//
|
||||
int[] indices = sortList.getSelectedIndices();
|
||||
int firstposition=0, secondposition=0;
|
||||
boolean change = false;
|
||||
//
|
||||
MPrintFormatItem orig = null;
|
||||
Object source = event.getTarget();
|
||||
if (source == bUp)
|
||||
{
|
||||
|
@ -246,26 +242,19 @@ public class WRC2FieldOrderPanel extends WRCTabPanel implements EventListener<Ev
|
|||
int index = indices[i];
|
||||
if (index == 0)
|
||||
break;
|
||||
|
||||
ListElement selObject = (ListElement) sortModel.getElementAt(index);
|
||||
ListElement newObject = (ListElement)sortModel.getElementAt(index - 1);
|
||||
|
||||
sortModel.setElementAt(newObject, index);
|
||||
sortModel.setElementAt(selObject, index - 1);
|
||||
for(int j=0 ;j <m_pfi.length ;j++){
|
||||
if(m_pfi[j].get_ID() == selObject.getKey()){
|
||||
m_pfi[j].setSeqNo(m_pfi[j].getSeqNo()-10);
|
||||
firstposition=j;
|
||||
}
|
||||
if(m_pfi[j].get_ID() == newObject.getKey()){
|
||||
m_pfi[j].setSeqNo(m_pfi[j].getSeqNo()+10);
|
||||
secondposition=j;
|
||||
}
|
||||
}
|
||||
|
||||
listColumns.get(index).setSeqNo(listColumns.get(index).getSeqNo()-10);
|
||||
orig = listColumns.get(index);
|
||||
listColumns.get(index - 1).setSeqNo(listColumns.get(index - 1).getSeqNo()+10);
|
||||
listColumns.set(index, listColumns.get(index-1));
|
||||
listColumns.set(index-1 , orig);
|
||||
indices[i] = index - 1;
|
||||
change = true;
|
||||
MPrintFormatItem fi=m_pfi[firstposition];
|
||||
m_pfi[firstposition]=m_pfi[secondposition];
|
||||
m_pfi[secondposition]=fi;
|
||||
}
|
||||
} // up
|
||||
|
||||
|
@ -277,36 +266,24 @@ public class WRC2FieldOrderPanel extends WRCTabPanel implements EventListener<Ev
|
|||
break;
|
||||
ListElement selObject = (ListElement) sortModel.getElementAt(index);
|
||||
ListElement newObject = (ListElement)sortModel.getElementAt(index + 1);
|
||||
/*if (!selObject.isUpdateable() || !newObject.isUpdateable())
|
||||
break;*/
|
||||
|
||||
sortModel.setElementAt(newObject, index);
|
||||
sortModel.setElementAt(selObject, index + 1);
|
||||
sortList.setSelectedIndex(index + 1);
|
||||
for(int j=0 ;j <m_pfi.length ;j++){
|
||||
if(m_pfi[j].get_ID() == selObject.getKey()){
|
||||
m_pfi[j].setSeqNo(m_pfi[j].getSeqNo()+10);
|
||||
firstposition=j;
|
||||
}
|
||||
if(m_pfi[j].get_ID() == newObject.getKey()){
|
||||
m_pfi[j].setSeqNo(m_pfi[j].getSeqNo()-10);
|
||||
secondposition=j;
|
||||
}
|
||||
}
|
||||
//
|
||||
listColumns.get(index).setSeqNo(listColumns.get(index).getSeqNo()+10);
|
||||
orig = m_pfi.get(index);
|
||||
listColumns.get(index + 1).setSeqNo(listColumns.get(index + 1).getSeqNo()-10);
|
||||
listColumns.set(index, listColumns.get(index+1));
|
||||
listColumns.set(index+1,orig);
|
||||
indices[i] = index + 1;
|
||||
change = true;
|
||||
MPrintFormatItem fi=m_pfi[firstposition];
|
||||
m_pfi[firstposition]=m_pfi[secondposition];
|
||||
m_pfi[secondposition]=fi;
|
||||
}
|
||||
} // down
|
||||
|
||||
//
|
||||
if (change) {
|
||||
sortList.setSelectedIndices(indices);
|
||||
int idx = sortList.getSelectedIndex();
|
||||
refresh();
|
||||
wc.setIsChanged(true);
|
||||
sortList.setSelectedIndex(idx);
|
||||
if ( sortList.getSelectedItem() != null)
|
||||
{
|
||||
AuFocus focus = new AuFocus(sortList.getSelectedItem());
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
package org.adempiere.webui.panel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
@ -37,6 +38,7 @@ 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.Hlayout;
|
||||
|
||||
import org.zkoss.zul.Vbox;
|
||||
|
||||
public class WRC3SortCriteriaPanel extends WRCTabPanel implements EventListener<Event>
|
||||
|
@ -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<MPrintFormatItem> yesItems=new ArrayList<MPrintFormatItem>();
|
||||
public ArrayList<MPrintFormatItem> noItems=new ArrayList<MPrintFormatItem>();
|
||||
|
||||
//
|
||||
SimpleListModel noModel = new SimpleListModel();
|
||||
SimpleListModel yesModel = new SimpleListModel();
|
||||
Listbox noList = new Listbox();
|
||||
Listbox yesList = new Listbox();
|
||||
ArrayList<MPrintFormatItem> yesItems =new ArrayList<MPrintFormatItem>();
|
||||
ArrayList<MPrintFormatItem> noItems =new ArrayList<MPrintFormatItem>();
|
||||
|
||||
public WRC3SortCriteriaPanel() {
|
||||
super();
|
||||
|
@ -110,59 +110,7 @@ public class WRC3SortCriteriaPanel extends WRCTabPanel implements EventListener
|
|||
noList.addOnDropListener(crossListMouseListener);
|
||||
yesList.setItemDraggable(true);
|
||||
noList.setItemDraggable(true);
|
||||
|
||||
EventListener<Event> yesListMouseMotionListener = new EventListener<Event>()
|
||||
{
|
||||
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 <m_pfi.length ;j++){
|
||||
if(m_pfi[j].get_ID() == endElement.getKey()){
|
||||
targetPFI = m_pfi[j];
|
||||
firstposition=j;
|
||||
}
|
||||
if(m_pfi[j].get_ID() == startElement.getKey()){
|
||||
draggedPFI = m_pfi[j];
|
||||
secondposition=j;
|
||||
}
|
||||
}
|
||||
draggedPFI.setSeqNo(targetPFI.getSeqNo()-5);
|
||||
|
||||
wc.setIsChanged(true);
|
||||
updateYesList();
|
||||
MPrintFormatItem fi=m_pfi[firstposition];
|
||||
m_pfi[firstposition]=m_pfi[secondposition];
|
||||
m_pfi[secondposition]=fi;
|
||||
|
||||
if ( yesList.getSelectedItem() != null)
|
||||
{
|
||||
AuFocus focus = new AuFocus(yesList.getSelectedItem());
|
||||
Clients.response(focus);
|
||||
}
|
||||
//setIsChanged(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
yesList.addOnDropListener(yesListMouseMotionListener);
|
||||
|
||||
|
||||
ListHead listHead = new ListHead();
|
||||
listHead.setParent(yesList);
|
||||
ListHeader listHeader = new ListHeader();
|
||||
|
@ -219,69 +167,54 @@ public class WRC3SortCriteriaPanel extends WRCTabPanel implements EventListener
|
|||
public void onEvent(Event event) throws Exception {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refresh() {
|
||||
|
||||
public void setListsColumns() {
|
||||
yesItems =new ArrayList<MPrintFormatItem>();
|
||||
noItems =new ArrayList<MPrintFormatItem>();
|
||||
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<MPrintFormatItem>() {
|
||||
@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<ListElement> selObjects = new ArrayList<ListElement>();
|
||||
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<m_pfi.length ; j++) {
|
||||
if (m_pfi[j].get_ID() == selObject.m_key) {
|
||||
if (listFrom.equals(noList)) {
|
||||
m_pfi[j].setIsOrderBy(true);
|
||||
} else {
|
||||
m_pfi[j].setIsOrderBy(false);
|
||||
}
|
||||
}
|
||||
lmTo.add(endIndex, selObject);
|
||||
index = m_pfi.indexOf(getPrintFormatItem(selObject.m_key));
|
||||
if(listFrom.equals(noList)) {
|
||||
m_pfi.get(index).setIsOrderBy(true);
|
||||
reOrder =true;
|
||||
}else{
|
||||
m_pfi.get(index).setIsOrderBy(false);
|
||||
}
|
||||
wc.setIsChanged(true);
|
||||
}
|
||||
|
||||
if(reOrder){
|
||||
int sortNo =10;
|
||||
ArrayList<ListElement> pp = new ArrayList<ListElement>();
|
||||
for(int i=0 ; i<lmTo.getSize(); i++) {
|
||||
ListElement aux = (ListElement)lmTo.getElementAt(i);
|
||||
aux.setSortNo(sortNo);
|
||||
sortNo =+10;
|
||||
pp.add(aux);
|
||||
}
|
||||
Collections.sort(pp, new Comparator<ListElement>() {
|
||||
@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<ListElement> 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<yesModel.getSize(); i++) {
|
||||
ListElement pp = (ListElement)yesModel.getElementAt(i);
|
||||
auxIndex = m_pfi.indexOf(getPrintFormatItem(pp.m_key));
|
||||
m_pfi.get(auxIndex).setSortNo(sortNo);
|
||||
yesList.addItem(new KeyNamePair(pp.m_key, pp.getName()));
|
||||
sortNo = sortNo + 10;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Move within Yes List
|
||||
|
@ -358,7 +350,8 @@ public class WRC3SortCriteriaPanel extends WRCTabPanel implements EventListener
|
|||
int[] indices = yesList.getSelectedIndices();
|
||||
//
|
||||
boolean change = false;
|
||||
//
|
||||
int selectedPI = 0 , targetPI = 0;
|
||||
MPrintFormatItem orig = null;
|
||||
Object source = event.getTarget();
|
||||
if (source == bUp)
|
||||
{
|
||||
|
@ -371,6 +364,18 @@ public class WRC3SortCriteriaPanel extends WRCTabPanel implements EventListener
|
|||
|
||||
yesModel.setElementAt(newObject, index);
|
||||
yesModel.setElementAt(selObject, index - 1);
|
||||
yesList.setSelectedIndex(index - 1);
|
||||
|
||||
selectedPI = m_pfi.indexOf(getPrintFormatItem(selObject.m_key));
|
||||
targetPI = m_pfi.indexOf(getPrintFormatItem(newObject.m_key));
|
||||
updateSortNo (selectedPI,targetPI);
|
||||
|
||||
yesItems.get(index).setSortNo(yesItems.get(index).getSortNo()-10);
|
||||
orig = yesItems.get(index);
|
||||
yesItems.get(index - 1).setSeqNo(yesItems.get(index - 1).getSeqNo()+10);
|
||||
yesItems.set(index, yesItems.get(index-1));
|
||||
yesItems.set(index-1 , orig);
|
||||
|
||||
indices[i] = index - 1;
|
||||
change = true;
|
||||
}
|
||||
|
@ -388,15 +393,30 @@ public class WRC3SortCriteriaPanel extends WRCTabPanel implements EventListener
|
|||
yesModel.setElementAt(newObject, index);
|
||||
yesModel.setElementAt(selObject, index + 1);
|
||||
yesList.setSelectedIndex(index + 1);
|
||||
|
||||
selectedPI = m_pfi.indexOf(getPrintFormatItem(selObject.m_key));
|
||||
targetPI = m_pfi.indexOf(getPrintFormatItem(newObject.m_key));
|
||||
updateSortNo (selectedPI,targetPI);
|
||||
|
||||
yesItems.get(index).setSeqNo(yesItems.get(index).getSeqNo()+10);
|
||||
orig = m_pfi.get(index);
|
||||
yesItems.get(index + 1).setSeqNo(yesItems.get(index + 1).getSeqNo()-10);
|
||||
yesItems.set(index, yesItems.get(index+1));
|
||||
yesItems.set(index+1,orig);
|
||||
|
||||
indices[i] = index + 1;
|
||||
change = true;
|
||||
}
|
||||
} // down
|
||||
|
||||
//
|
||||
if (change) {
|
||||
yesList.setSelectedIndices(indices);
|
||||
updateYesList();
|
||||
if (change) {
|
||||
yesList.removeAllItems();
|
||||
for(int i=0 ; i<yesModel.getSize(); i++) {
|
||||
ListElement pp = (ListElement)yesModel.getElementAt(i);
|
||||
yesList.addItem(new KeyNamePair(pp.m_key, pp.getName()));
|
||||
}
|
||||
wc.setIsChanged(true);
|
||||
if ( yesList.getSelectedItem() != null)
|
||||
{
|
||||
AuFocus focus = new AuFocus(yesList.getSelectedItem());
|
||||
|
@ -405,23 +425,15 @@ public class WRC3SortCriteriaPanel extends WRCTabPanel implements EventListener
|
|||
}
|
||||
} // migrateValueWithinYesList
|
||||
|
||||
public void updateYesList(){
|
||||
yesList.removeAllItems();
|
||||
wc.setIsChanged(true);
|
||||
int sortNo=10;
|
||||
for(int i=0;i<yesModel.getSize();i++){
|
||||
ListElement obj=(ListElement) yesModel.getElementAt(i);
|
||||
for(int j=0;j<m_pfi.length;j++){
|
||||
if(m_pfi[j].get_ID() == obj.getKey()){
|
||||
String name=obj.getName();
|
||||
int ID=obj.getKey();
|
||||
KeyNamePair pair=new KeyNamePair(ID, name);
|
||||
yesList.addItem(pair);
|
||||
m_pfi[j].setSortNo(sortNo);
|
||||
sortNo=sortNo+10;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int selIndexPI,int targetIndexPI
|
||||
*/
|
||||
private void updateSortNo(int selIndexPI,int targetIndexPI)
|
||||
{
|
||||
int selSortNo = m_pfi.get(selIndexPI).getSortNo();
|
||||
m_pfi.get(selIndexPI).setSortNo(m_pfi.get(targetIndexPI).getSortNo());
|
||||
m_pfi.get(targetIndexPI).setSortNo(selSortNo);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -520,45 +532,36 @@ public class WRC3SortCriteriaPanel extends WRCTabPanel implements EventListener
|
|||
}
|
||||
|
||||
public void onEvent(Event event) throws Exception {
|
||||
int endIndex=0;
|
||||
if (event instanceof DropEvent)
|
||||
{
|
||||
int endIndex = 0;
|
||||
DropEvent me = (DropEvent) event;
|
||||
|
||||
ListItem endItem = (ListItem) me.getTarget();
|
||||
if (!(endItem.getListbox() == yesList))
|
||||
{
|
||||
return; // move within noList
|
||||
}
|
||||
|
||||
ListItem startItem = (ListItem) me.getDragged();
|
||||
if (startItem.getListbox() == endItem.getListbox())
|
||||
|
||||
if (!startItem.isSelected())
|
||||
startItem.setSelected(true);
|
||||
|
||||
if (!(startItem.getListbox() == endItem.getListbox()))
|
||||
{
|
||||
return; //move within same list
|
||||
}
|
||||
int startIndex = noList.getIndexOfItem(startItem);
|
||||
ListElement element = (ListElement) noModel.getElementAt(startIndex);
|
||||
noModel.removeElement(element);
|
||||
endIndex = yesList.getIndexOfItem(endItem);
|
||||
yesModel.add(endIndex, element);
|
||||
|
||||
for (int j=0 ; j<m_pfi.length ; j++) {
|
||||
if (m_pfi[j].get_ID() == element.m_key) {
|
||||
m_pfi[j].setIsOrderBy(true);
|
||||
m_pfi[j].setSortNo(endIndex*10);
|
||||
Listbox listFrom = (Listbox)startItem.getListbox();
|
||||
Listbox listTo = (Listbox)endItem.getListbox();
|
||||
endIndex = yesList.getIndexOfItem(endItem);
|
||||
migrateLists (listFrom,listTo,endIndex);
|
||||
}else if (startItem.getListbox() == endItem.getListbox() && startItem.getListbox() == yesList)
|
||||
{
|
||||
List<ListElement> selObjects = new ArrayList<ListElement>();
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -48,9 +48,9 @@ public class WRC4GroupingCriteriaPanel extends WRCTabPanel implements EventListe
|
|||
@Override
|
||||
public void refresh() {
|
||||
orderfield = new ArrayList<MPrintFormatItem>();
|
||||
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<orderfield.size() ; i++){
|
||||
for(int j=0 ;j<m_pfi.length ; j++){
|
||||
if(orderfield.get(i).get_ID() == m_pfi[j].get_ID()){
|
||||
m_pfi[j].setIsGroupBy(m_chkboxes[i].isChecked());
|
||||
}
|
||||
}
|
||||
int j = m_pfi.indexOf(getPrintFormatItem(orderfield.get(i).get_ID()));
|
||||
m_pfi.get(j).setIsGroupBy(m_chkboxes[i].isChecked());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -102,7 +99,6 @@ public class WRC4GroupingCriteriaPanel extends WRCTabPanel implements EventListe
|
|||
columns.appendChild(cols[i+1]);
|
||||
}
|
||||
grid.appendChild(columns);
|
||||
|
||||
this.appendChild(wind);
|
||||
wind.appendChild(grid);
|
||||
}
|
||||
|
|
|
@ -84,9 +84,9 @@ public class WRC5SummaryFieldsPanel extends WRCTabPanel implements EventListener
|
|||
@Override
|
||||
public void refresh() {
|
||||
DisplayItems = new ArrayList<MPrintFormatItem>();
|
||||
for(int i=0 ; i<m_pfi.length ; i ++){
|
||||
if(m_pfi[i] != null && m_pfi[i].isPrinted()){
|
||||
DisplayItems.add(m_pfi[i]);
|
||||
for(int i=0 ; i<m_pfi.size() ; i ++){
|
||||
if(m_pfi.get(i) != null && m_pfi.get(i).isPrinted()){
|
||||
DisplayItems.add(m_pfi.get(i));
|
||||
}
|
||||
}
|
||||
dynamicInit();
|
||||
|
@ -95,17 +95,14 @@ public class WRC5SummaryFieldsPanel extends WRCTabPanel implements EventListener
|
|||
@Override
|
||||
public void updatePFI() {
|
||||
for(int i=0 ;i<DisplayItems.size() ; i++){
|
||||
for(int j=0 ; j<m_pfi.length ; j++){
|
||||
if(DisplayItems.get(i).get_ID() == m_pfi[j].get_ID()){
|
||||
m_pfi[j].setIsSummarized(m_chkSum[i].isChecked());
|
||||
m_pfi[j].setIsCounted(m_chkCount[i].isChecked());
|
||||
m_pfi[j].setIsMinCalc(m_chkMin[i].isChecked());
|
||||
m_pfi[j].setIsMaxCalc(m_chkMax[i].isChecked());
|
||||
m_pfi[j].setIsAveraged(m_chkMean[i].isChecked());
|
||||
m_pfi[j].setIsVarianceCalc(m_chkVariance[i].isChecked());
|
||||
m_pfi[j].setIsDeviationCalc(m_chkDesviation[i].isChecked());
|
||||
}
|
||||
}
|
||||
int j = m_pfi.indexOf(getPrintFormatItem(DisplayItems.get(i).get_ID()));
|
||||
m_pfi.get(j).setIsSummarized(m_chkSum[i].isChecked());
|
||||
m_pfi.get(j).setIsCounted(m_chkCount[i].isChecked());
|
||||
m_pfi.get(j).setIsMinCalc(m_chkMin[i].isChecked());
|
||||
m_pfi.get(j).setIsMaxCalc(m_chkMax[i].isChecked());
|
||||
m_pfi.get(j).setIsAveraged(m_chkMean[i].isChecked());
|
||||
m_pfi.get(j).setIsVarianceCalc(m_chkVariance[i].isChecked());
|
||||
m_pfi.get(j).setIsDeviationCalc(m_chkDesviation[i].isChecked());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,8 +14,14 @@
|
|||
|
||||
package org.adempiere.webui.panel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.adempiere.webui.apps.form.WReportCustomization;
|
||||
import org.adempiere.webui.component.Tabpanel;
|
||||
import org.compiere.model.GridField;
|
||||
import org.compiere.model.MField;
|
||||
import org.compiere.print.MPrintFormat;
|
||||
import org.compiere.print.MPrintFormatItem;
|
||||
|
||||
|
@ -25,9 +31,10 @@ public abstract class WRCTabPanel extends Tabpanel {
|
|||
*/
|
||||
private static final long serialVersionUID = -6858669581232541371L;
|
||||
|
||||
public MPrintFormatItem[] m_pfi;
|
||||
public ArrayList<MPrintFormatItem> m_pfi;
|
||||
public MPrintFormat m_pf;
|
||||
public WReportCustomization wc;
|
||||
public Map<Integer, MPrintFormatItem> mapPFormatItem = new HashMap<Integer, MPrintFormatItem>();
|
||||
|
||||
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<MPrintFormatItem> pfis) {
|
||||
m_pfi = pfis;
|
||||
}
|
||||
|
||||
public void setWReportCustomization(WReportCustomization parent){
|
||||
wc=parent;
|
||||
}
|
||||
|
||||
|
||||
public MPrintFormatItem getPrintFormatItem(int AD_PrintFormatItem_ID) {
|
||||
return mapPFormatItem.get(AD_PrintFormatItem_ID);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -39,7 +39,7 @@ public class Activator implements BundleActivator {
|
|||
return context;
|
||||
}
|
||||
|
||||
private static HazelcastInstance hazelcastInstance;
|
||||
private volatile static HazelcastInstance hazelcastInstance;
|
||||
private static AtomicReference<Future<?>> futureRef = new AtomicReference<Future<?>>();
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue