google maps flex API: handle both double and single clicks?

how do you tell a single mouse click from a double click? my single
click listener seems to be trapping all the double clicks as well:

tz locator

it’s a known issue for the flash/flex API but the js workaround doesn’t seem to handle both either: code.google.com

Comments:


Might need a bit of clarification, but make sure you are using the Google Map’s MapMouseEvent, not the Flash API’s click events (please assume this code in inside a Map subclass):

public class GoogleMap extends Map 
{
    import com.google.maps.LatLng;
    import com.google.maps.Map;
    import com.google.maps.MapEvent;
    import com.google.maps.MapMouseEvent;

    public function GoogleMap():void
    {
        super();
        this.key = "YOUR_API_KEY";

        addEventListener(MapEvent.MAP_READY, _onMapReady);
        addEventListener(MapMouseEvent.CLICK, _onMapClick);
        addEventListener(MapMouseEvent.DOUBLE_CLICK, _onMapDoubleClick);
    }

    protected function _onMapClick(event:MapMouseEvent):void 
    {  
        trace("single!");
        var mousePoint:Point = new Point(mouseX, mouseY);
        var mousePointLocal:Point = globalToLocal(mousePoint);
        var mouseLatLng:LatLng = this.fromViewportToLatLng(mousePointLocal); 
    }

    protected function _onMapDoubleClick(event:MapMouseEvent):void 
    {
        trace("double!");
    }

    protected function _onMapReady(event:MapEvent):void 
    {
        trace("ready!")
    }
}

Answers:

What is "Enterprise ready"? Can we test for it?

There are a couple of questions on Stackoverflow asking whether x (Ruby / Drupal) technology is ‘enterprise ready’.

I would like to ask how is ‘enterprise ready’ defined.

Has anyone created their own checklist?

Does anyone have a benchmark that they test against?

Comments:


Most of the time the “test”, if it may really be called as such, is that some enterprise (=large business), has deployed a successful and stable product using it. So its more like saying its proven its worth on the battlefield, or something like that. In other words the framework has been used successfully, or not in the real world, you can’t just follow some checklist and load tests and say its enterprise ready.

Answers:

To be short:
“Enterprise ready” means: If it crashes, the enterprises using it will possibly sue you.

Answers:

From my experience, “Enterprise ready” label is an indicator of the fear of managers to adopt an open-source technology, possibly balanced with a desire not to stay follower in that technology.

This may objectively argued with considerations such as support from a third party company or integration in existing development tools.

Answers:

Like Robert Gould says in his answer, it’s “Enterprise-ready” when it’s been proven by some other huge project. I’d put it this way: if somebody out there has made millions of dollars with it and gotten written up by venture capitalist magazines as the year’s (some year, not necessarily this one) hottest new thing, then it’s Enterprise-ready. 🙂

Another way to look at the question is that a tech is Enterprise-ready when a non-tech boss or business owner won’t worry about whether or not they’ve chosen a good platform to run their business on. In this sense Enterprise-ready is a measure of brand recognition rather than technological maturity.

Answers:

I suppose an application could be considered “enterprise ready” when it is stable enough that a large company would use it. It would also imply some level of support, so when it does inevitable break.

Wether or not something is “enterprise ready” is entirely subjective, and undefined, and rather “buzz word’y”.. Basically, you can’t have a test_isEnterpriseReady() – just make your application as reliable and efficient as it can be..

Answers:

“Enterprise Ready” for the most part means can we run it reliably and effectively within a large organisation.

There are several factors involved:

  • Is it reliable?
  • Can our current staff support it, or do we need specialists?
  • Can it fit in with our established security model?
  • Can deployments be done with our automated tools?
  • How easy is it to administer? Can the business users do it or do we need a specialist?
  • If it uses a database, is it our standard DB, or do we need to train up more specialists?

Depending on how important the system is to the business the following question might also apply:

  • Can it be made highly available?
  • Can it be load balanced?
  • Is it secure enough?

Open Source projects often do not pay enough attention to the difficulties of deploying and running software within a large organisation. e.g. Most OS projects default to MySql as the database, which is a good and sensible choice for most small projects, however, if your Enterprise has an ORACLE site license and a team of highly skilled ORACLE DBAs in place the MySql option looks distinctly unattractive.

Answers:

Having built a couple “Enterprise” applications…

Enterprise outside of development means, that if it breaks, someone can fix it. I’ve worked with employers/contractors that stick with quite possibly the worst managing hosting providers, data vendors, or such because they will fix problems when they crop up, even if they crop up a lot it, and have someone to call when they break.

So to restate it another way, Enterprise software is Enterprisey because it has support options available. A simple example: jQuery isn’t enterprisey while ExtJS is, because ExtJS has a corporate support structure to it. (Yes I know these two frameworks is like comparing a toolset to a factory manufactured home kit ).

Answers:

As my day job is all about enterprise architecture, I believe that the word enterprise isn’t nowadays about size nor scale but refers more to how a software product is sold.

For example, Ruby on Rails isn’t enterprise because there is no vendor that will come into your shop and do Powerpoint presentations repeatedly for the developer community. Ruby on Rails doesn’t have a sales executive that takes me out to the golf course or my favorite restaurant for lunch. Ruby on Rails also isn’t deeply covered by industry analyst firms such as Gartner.

Ruby on Rails will never be considered “enterprise” until these things occur…

Answers:

How can I tell if a file has changed through .NET?

I am looking for a way to determine when a particular file has changed, through .NET. (What I ultimately want is functionality that makes a copy of the file as soon as it has changed.) How can this be done?

Comments:


You can use a FileSystemWatcher object. This raises events on changes to files within the specified watched folder.

Answers:

Microsoft Windows, and its ultimate ancestor MS-DOS, has always had an attribute on its files that indicates whether that file was changed since the last time that attribute was cleared, sort of a “dirty flag”. It was used in the past by backup programs to find those files that needed to be backed up incrementally, and then cleared when a copy of that file had been made.

You can use File.GetAttributes to get the attributes on a file, and use File.SetAttributes to clear that “Archive” attribute. The next time that file is opened for writing, that archive flag will be set again.

Be careful about copying files that have been changed, as those files may still be open. You probably want to avoid concurrency problems by opening them for read exclusively when copying, and if that fails you know that file is still open for writing.

Answers:

class Program
    {
        static void Main(string[] args)
        {
            FileSystemWatcher fsw = new FileSystemWatcher(@"c:temp");
            fsw.Changed += new FileSystemEventHandler(fsw_Changed);
            fsw.Deleted += new FileSystemEventHandler(fsw_Deleted);
            fsw.Renamed += new RenamedEventHandler(fsw_Renamed);
            fsw.Created += new FileSystemEventHandler(fsw_Created);
            fsw.EnableRaisingEvents = true;
            Console.ReadLine();
        }

        static void fsw_Created(object sender, FileSystemEventArgs e)
        {
            Console.WriteLine("{0} was created", e.FullPath);
        }

        static void fsw_Renamed(object sender, RenamedEventArgs e)
        {
            Console.WriteLine("{0} was Renamed", e.FullPath);
        }

        static void fsw_Deleted(object sender, FileSystemEventArgs e)
        {
            Console.WriteLine("{0} was Deleted", e.FullPath);
        }

        static void fsw_Changed(object sender, FileSystemEventArgs e)
        {
            Console.WriteLine("{0} was Changed", e.FullPath);
        }
}

Answers:

To all who responded with, use FileSystemWatcher, how do you deal with the time your app isn’t running? For example, the user has rebooted the box, modified the file you are interested in, and then starts up your app?

Be sure to also read the docs on FileSystemWatcher Class carefully specially the section about Events and Buffer Sizes.

Answers:

You’re likely to run into issues with FileSystemWatcher (not getting events, too many events, etc.) This code wraps it up and solves many of them:
http://precisionsoftware.blogspot.com/2009/05/filesystemwatcher-done-right.html

Answers:

You will have to note the modified date of files which you want to check.
After certain period you can check if the file was modified later.
If the file is modified with different date and time, you can make the copy.

Answers:

Producing valid XML with Java and UTF-8 encoding

I am using JAXP to generate and parse an XML document from which some fields are loaded from a database.

Code to serialize the XML:

DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document doc = builder.newDocument();
Element root = doc.createElement("test");
root.setAttribute("version", text);
doc.appendChild(root);

DOMSource domSource = new DOMSource(doc);
TransformerFactory tFactory = TransformerFactory.newInstance();

FileWriter out = new FileWriter("test.xml");
Transformer transformer = tFactory.newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
transformer.transform(domSource, new StreamResult(out)); 

Code to parse the XML:

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse("test.xml");

And I encounter the following exception:

[Fatal Error] test.xml:1:4: Invalid byte 1 of 1-byte UTF-8 sequence.
Exception in thread "main" org.xml.sax.SAXParseException: Invalid byte 1 of 1-byte UTF-8 sequence.
    at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
    at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
    at javax.xml.parsers.DocumentBuilder.parse(Unknown Source)
    at com.test.Test.xml(Test.java:27)
    at com.test.Test.main(Test.java:55)

The String text includes u-umlaut and o-umlaut (character codes 0xFC and 0xF6). These are the characters that are causing the error. When I escape the String myself to use ü and ö then the problem goes away. Other entities are automatically encoded when I write out the XML.

How do I get my output to be written / read properly without substituting these characters myself?

(I’ve read the following questions already:

How to encode characters from Oracle to XML?

Repairing wrong encoding in XML files)

Comments:


Use a FileOutputStream rather than a FileWriter.

The latter applies its own encoding, which is almost certainly not UTF-8 (depending on your platform, it’s probably Windows-1252 or IS-8859-1).

Edit (now that I have some time):

An XML document without a prologue is permitted to be encoded as UTF-8 or UTF-16. With a prologue, it iss allowed to specify its encoding (the prologue can contain only US-ASCII characters, so prologue is always readable).

A Reader deals with characters; it will decode the byte stream of the underlying InputStream. As a result, when you pass a Reader to the parser, you are telling it that you’ve already handled the encoding, so the parser will ignore the prologue. When you pass an InputStream (which reads bytes), it does not make this assumption, and will look to the prologue to define the encoding — or default to UTF-8/UTF-16 if it’s not there.

I’ve never tried reading a file that is encoded in UTF-16. I suspect that the parser will look for a Byte Order Mark (BOM) as the first 2 bytes of the file.

Answers:

Well, for sure 0xFC and 0xF6 are not valid UTF-8 characters. These should have been finnesed to the two byte sequences: 0x3CBC and 0x3CB6.

Most likely the problem is with the original source of the characters being defined as UTF-8 when they are not.

Answers: