Programming
Disable Netbeans Document Close Buttons
by alowe on Feb.04, 2011, under Programming, Tech
To disable netbeans document close tabs on MacOSX (because I keep hitting them when selecting a tab):
edit /Applications/NetBeans/NetBeans\ 6.9.app/Contents/Resources/NetBeans/etc/netbeans.conf (where 6.9 is the version number)
and add (append) to netbeans_default_options the following:
-J-Dnb.tabs.suppressCloseButton=true
Restart netbeans, and your document close buttons on the tabs are gone.
Using SOAP with PHP 5.2 Object References and .Net
by alowe on Nov.02, 2009, under Programming
PHP 5 introduces object references, where objects are assigned by reference (when you do $b=$a) they both point to the same object. This causes problems when using references with the SOAP server functions.
With earlier version of the SOAP library (5.1, etc) the soap server translated these into the full object (very pseudo code):
As of PHP 5.2, the SOAP code, translates this to use references:
This causes problems with .Net clients and servers, which don’t respect the href options.
The solution, use clone: $b=clone $a.
For more detail where Thijs Feryn has a great article on the topic …
http://blog.feryn.eu/2009/01/warning-object-references-affect-xml-serialization/
Soap Client Max Message Size
by alowe on Oct.28, 2009, under Programming
Just found a solution to the max message size exceeded exception that is generated on large soap messages:
http://craigrandall.net/archives/2009/04/maxreceivedmessagesize/
Quick summary: update the values in the binding in the app.config file.
Force UNC Path
by alowe on Oct.08, 2009, under Programming
Some applications I have written have data files that are required to be opened by multiple users on different computers.  These data files are, of course, stored on a common file server.
Usually the user doing the data-entry will have the path mapped as a network drive such as “u:\”. The people who need to look at the data files may not have the drive mapped, or may have it mapped as a different drive letter. The solution is to store the path as a Uniform Naming Convention (UNC) path, such as: “\\myserver\datafiles\”
The quick solution, is when they type the path, just check the string starts with “\\\\” (we check that there are two backslash characters: “\”, however because this is a special character we need to escape it with a backslash).  This way we know it will be a network path.
Usually a user will want to browse to the directory or file, and you would use the standard .Net widgets for these tasks.  The data-entry user will usually have the path mapped as a network drive and try to browse to that, and you checks will detect that the string stored does not start with “\\\\”, but rather “u:\” and display an error to the user.  This is not very productive to the user, who will have to work out how to fix the problem, if they even understand the problem.
What we need is a method to re-map the mapped network drive to the full UNC path, and this is provided bellow:
public string getUNCPath(string sFilePath)
{
if (sFilePath == string.Empty || sFilePath.StartsWith("\\\\"))
return sFilePath;
System.Management.ManagementObjectSearcher searcher = new System.Management.ManagementObjectSearcher("SELECT RemoteName FROM win32_NetworkConnection WHERE LocalName = '" + sFilePath.Substring(0, 2) + "'");
foreach (System.Management.ManagementObject managementObject in searcher.Get())
{
string sRemoteName = managementObject["RemoteName"] as string;
sRemoteName += sFilePath.Substring(2);
return sRemoteName;
}
return sFilePath;
}
After this, a simple check to make sure the string starts with “\\\\” is sufficient to verify that you are storing a UNC path.
DataGridView binding to array of objects
by alowe on Aug.17, 2009, under Programming
When biding an array (or list) of objects of a defined class to a datagridview, you must define get and set methods, otherwise the datagridview cannot discover the members of the class via refection.
class myObject
{
public String string1 {get; set;}
public String string2 {get; set;}
}
Reference: http://snipplr.com/view/15786/datagridview-databind-an-array-of-arbitrary-objects/