Merge with 551978ddd62bc487b713f6f75e3db9c60c407499

This commit is contained in:
Heng Sin Low 2012-10-22 10:46:26 +08:00
commit 8bddd48175
3 changed files with 49 additions and 17 deletions

View File

@ -141,9 +141,6 @@ public final class Ini implements Serializable
/** Role */ /** Role */
public static final String P_ROLE = "Role"; public static final String P_ROLE = "Role";
private static final String DEFAULT_ROLE = ""; private static final String DEFAULT_ROLE = "";
/**Server Name */
public static final String P_SERVERNAME = "ServerName";
private static final String DEFAULT_SERVERNAME = "";
/** Client Name */ /** Client Name */
public static final String P_CLIENT = "Client"; public static final String P_CLIENT = "Client";
private static final String DEFAULT_CLIENT = ""; private static final String DEFAULT_CLIENT = "";
@ -199,7 +196,7 @@ public final class Ini implements Serializable
P_ADEMPIERESYS, P_LOGMIGRATIONSCRIPT, P_SHOW_ACCT, P_SHOW_TRL, P_ADEMPIERESYS, P_LOGMIGRATIONSCRIPT, P_SHOW_ACCT, P_SHOW_TRL,
P_SHOW_ADVANCED, P_CACHE_WINDOW, P_SHOW_ADVANCED, P_CACHE_WINDOW,
P_CONTEXT, P_TEMP_DIR, P_CONTEXT, P_TEMP_DIR,
P_ROLE, P_SERVERNAME, P_CLIENT, P_ORG, P_PRINTER, P_WAREHOUSE, P_TODAY, P_ROLE, P_CLIENT, P_ORG, P_PRINTER, P_WAREHOUSE, P_TODAY,
P_PRINTPREVIEW, P_PRINTPREVIEW,
P_VALIDATE_CONNECTION_ON_STARTUP, P_VALIDATE_CONNECTION_ON_STARTUP,
P_SINGLE_INSTANCE_PER_WINDOW, P_SINGLE_INSTANCE_PER_WINDOW,
@ -217,7 +214,7 @@ public final class Ini implements Serializable
DEFAULT_ADEMPIERESYS?"Y":"N", DEFAULT_LOGMIGRATIONSCRIPT?"Y":"N", DEFAULT_SHOW_ACCT?"Y":"N", DEFAULT_SHOW_TRL?"Y":"N", DEFAULT_ADEMPIERESYS?"Y":"N", DEFAULT_LOGMIGRATIONSCRIPT?"Y":"N", DEFAULT_SHOW_ACCT?"Y":"N", DEFAULT_SHOW_TRL?"Y":"N",
DEFAULT_SHOW_ADVANCED?"Y":"N", DEFAULT_CACHE_WINDOW?"Y":"N", DEFAULT_SHOW_ADVANCED?"Y":"N", DEFAULT_CACHE_WINDOW?"Y":"N",
DEFAULT_CONTEXT, DEFAULT_TEMP_DIR, DEFAULT_CONTEXT, DEFAULT_TEMP_DIR,
DEFAULT_ROLE, DEFAULT_SERVERNAME, DEFAULT_CLIENT, DEFAULT_ORG, DEFAULT_PRINTER, DEFAULT_WAREHOUSE, DEFAULT_TODAY.toString(), DEFAULT_ROLE, DEFAULT_CLIENT, DEFAULT_ORG, DEFAULT_PRINTER, DEFAULT_WAREHOUSE, DEFAULT_TODAY.toString(),
DEFAULT_PRINTPREVIEW?"Y":"N", DEFAULT_PRINTPREVIEW?"Y":"N",
DEFAULT_VALIDATE_CONNECTION_ON_STARTUP?"Y":"N", DEFAULT_VALIDATE_CONNECTION_ON_STARTUP?"Y":"N",
DEFAULT_SINGLE_INSTANCE_PER_WINDOW?"Y":"N", DEFAULT_SINGLE_INSTANCE_PER_WINDOW?"Y":"N",

View File

@ -25,6 +25,8 @@ import java.io.PrintWriter;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.net.URLDecoder; import java.net.URLDecoder;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.net.UnknownHostException; import java.net.UnknownHostException;
@ -32,6 +34,7 @@ import java.sql.Timestamp;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Enumeration;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Level; import java.util.logging.Level;
@ -1259,24 +1262,56 @@ public final class WebUtil
*/ */
public static String getServerName(){ public static String getServerName(){
StringBuilder strBuilder = new StringBuilder(); StringBuilder strBuilder = new StringBuilder();
String serverName = Ini.getProperties().getProperty("ServerName");
try { try {
strBuilder.append(InetAddress.getLocalHost().getHostName()); strBuilder.append(InetAddress.getLocalHost().getHostName());
} catch (UnknownHostException e) { } catch (UnknownHostException e) {
log.log(Level.WARNING, "Local host or IP not found", e); log.log(Level.WARNING, "Local host or IP not found", e);
} }
strBuilder.append(":"); strBuilder.append(":").append(getHostIP());
try {
strBuilder.append(InetAddress.getLocalHost().getHostAddress());
} catch (UnknownHostException e) {
log.log(Level.WARNING, "Local host or IP not found", e);
}
strBuilder.append(":");
if(serverName!=null)
strBuilder.append(serverName);
return strBuilder.toString(); return strBuilder.toString();
} }
public static String getHostIP() {
String retVal = null;
try {
InetAddress localAddress= InetAddress.getLocalHost();
if (!localAddress.isLinkLocalAddress() && !localAddress.isLoopbackAddress() && localAddress.isSiteLocalAddress())
return localAddress.getHostAddress();
} catch (UnknownHostException e) {
log.log(Level.WARNING,
"UnknownHostException while retrieving host ip");
}
try {
for (Enumeration<NetworkInterface> en = NetworkInterface
.getNetworkInterfaces(); en.hasMoreElements();) {
NetworkInterface intf = en.nextElement();
for (Enumeration<InetAddress> enumIpAddr = intf
.getInetAddresses(); enumIpAddr.hasMoreElements();) {
InetAddress inetAddress = enumIpAddr.nextElement();
if (!inetAddress.isLoopbackAddress()
&& !inetAddress.isLinkLocalAddress()
&& inetAddress.isSiteLocalAddress()) {
retVal = inetAddress.getHostAddress().toString();
break;
}
}
}
} catch (SocketException e) {
log.log(Level.WARNING, "Socket Exeception while retrieving host ip");
}
if (retVal == null) {
try {
retVal = InetAddress.getLocalHost().getHostAddress();
} catch (UnknownHostException e) {
log.log(Level.WARNING,
"UnknownHostException while retrieving host ip");
}
}
return retVal;
}
} // WUtil } // WUtil

View File

@ -282,7 +282,7 @@ public class GridView extends Vbox implements EventListener<Event>
gridField = fieldList.toArray(new GridField[0]); gridField = fieldList.toArray(new GridField[0]);
if (customComponent.length == 2) { if (customComponent.length == 2) {
String[] widths = customComponent[1].split("[,]"); String[] widths = customComponent[1].split("[,]");
for(int i = 0; i< gridField.length; i++) { for(int i = 0; i< gridField.length && i<widths.length; i++) {
columnWidthMap.put(gridField[i].getAD_Field_ID(), widths[i]); columnWidthMap.put(gridField[i].getAD_Field_ID(), widths[i]);
} }
} }