Show only folders. Try to give them localized names action-reference-189558
authorJaroslav Tulach <jtulach@netbeans.org>
Wed, 25 Aug 2010 10:52:52 +0200
branchaction-reference-189558
changeset 1763860de2180a7987
parent 176385 1b7d947c69c8
child 176387 d1d13a81525d
Show only folders. Try to give them localized names
apisupport.project/src/org/netbeans/modules/apisupport/project/layers/PathCompletions.java
     1.1 --- a/apisupport.project/src/org/netbeans/modules/apisupport/project/layers/PathCompletions.java	Wed Aug 25 10:52:23 2010 +0200
     1.2 +++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/layers/PathCompletions.java	Wed Aug 25 10:52:52 2010 +0200
     1.3 @@ -63,7 +63,9 @@
     1.4  import org.netbeans.api.project.FileOwnerQuery;
     1.5  import org.netbeans.api.project.Project;
     1.6  import org.openide.filesystems.FileObject;
     1.7 +import org.openide.filesystems.FileStateInvalidException;
     1.8  import org.openide.filesystems.FileSystem;
     1.9 +import org.openide.filesystems.FileSystem.Status;
    1.10  
    1.11  /** Provides code completion items for any annotation that needs to understand
    1.12   * the content of a layer.
    1.13 @@ -76,6 +78,7 @@
    1.14      
    1.15      public static void register() {
    1.16          System.setProperty("org.openide.awt.ActionReference.completion", PathCompletions.class.getName());
    1.17 +        LOG.finest("Registering property"); // NOI18N
    1.18      }
    1.19      
    1.20      @Override
    1.21 @@ -137,9 +140,24 @@
    1.22                  return arr;
    1.23              }
    1.24              for (FileObject fo : from.getChildren()) {
    1.25 -                if (fo.getPath().startsWith(userText)) {
    1.26 -                    LOG.log(Level.FINE, "Accepting: {0}", fo);
    1.27 -                    arr.add(Completions.of(fo.getPath()));
    1.28 +                if (fo.isFolder() && fo.getPath().startsWith(userText)) {
    1.29 +                    String localizedName = null;
    1.30 +                    final String name = fo.getNameExt();
    1.31 +                    try {
    1.32 +                        final Status status = fo.getFileSystem().getStatus();
    1.33 +                        String n = status.annotateName(name, Collections.singleton(fo));
    1.34 +                        if (!n.equals(name)) {
    1.35 +                            localizedName = n;
    1.36 +                        }
    1.37 +                    } catch (FileStateInvalidException ex) {
    1.38 +                        // ok
    1.39 +                    }
    1.40 +                    LOG.log(Level.FINE, "Accepting: {0} as {1}", new Object[] { fo, localizedName });
    1.41 +                    if (localizedName == null) {
    1.42 +                        arr.add(Completions.of("\"" + fo.getPath() + "/"));
    1.43 +                    } else {
    1.44 +                        arr.add(Completions.of("\"" + fo.getPath() + "/", localizedName));
    1.45 +                    }
    1.46                  } else {
    1.47                      LOG.log(Level.FINE, "Ignoring: {0}", fo);
    1.48                  }