[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-awt-dev
Subject:    <AWT Dev> Second patch for 6927978 (Directory Selection standard dialog support)
From:       Anthony.Petrov () Sun ! COM (Anthony Petrov)
Date:       2010-05-26 8:50:52
Message-ID: 4BFCE0EC.8090000 () sun ! com
[Download RAW message or body]

Hi Costantino, Damjan,

The webrev for the second version is published at:

http://cr.openjdk.java.net/~anthony/7-45-DirectoryDialog-6927978.1/

On 5/19/2010 1:57 AM Costantino Cerbo wrote:
>> here is my second patch for the new DirectoryDialog.
>> In this new patch I take care of your previous annotations and I've
>> also implemented the XDirectoryDialogPeer as we've discussed.
>> XDirectoryDialogPeer is largely based on the XFileDialogPeer (there is
>> no inheritance because for several reasons, for example the
>> constructor, it wasn't a good option).

Actually even the constructors (not counting other methods) share quite 
a bit of code between the XDir and XFile dialogs. The code might  easily 
be factored out in a separate method (like createGUI() or whatever) 
which is invoked in the constructor.  A common base class of the two 
could only create the components related to choosing a directory. The 
DirDlg would just call the super implementation, and the FileDlg would 
also add its own components (like the filter, the file names listbox, 
etc.) Moreover, all this could be just left out in the constructor w/o 
introducing the createGUI() method.

Reducing code duplication would really simplify further maintenance of 
the classes.


src/share/classes/java/awt/DirectoryDialog.java
>  152         if (peer != null) {
>  153             ((DirectoryDialogPeer) this.peer).setDirectory(this.dir);
>  154         }

We use another idiom across the AWT:

DirectoryDialogPeer peer = (DirectoryDialogPeer)this.peer;
if (peer != null) {
    // blah-blah-blah
}

This way we avoid NPEs should the peer be released and GC'ed just after 
the if () but before the actual actions.


>> We have now the DirectoryDialog for both GTK and X11 but not yet for MS Windows!
>> @Damjan: Are you still going to implement the DirectoryDialog for MS
>> Windows? We didn't hear from you for weeks... it would be great if you
>> could do it!

Damjan: we look forward to reviewing your implementation of the 
DirectoryDialog on MS Windows. Thanks in advance!

--
best regards,
Anthony

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic