When both doRefreshCurrent && doRefreshParent are defined, we need to refresh both BLD200409151800
authormentlicher@netbeans.org
Wed, 15 Sep 2004 17:14:13 +0000
changeset 5216de37d440409f
parent 5215 c8ab846fba25
child 5217 830f27e8b389
When both doRefreshCurrent && doRefreshParent are defined, we need to refresh both
the current folder and parent folder.
This is a fix of issue #48723
vcscore/src/org/netbeans/modules/vcscore/commands/CommandExecutorSupport.java
     1.1 --- a/vcscore/src/org/netbeans/modules/vcscore/commands/CommandExecutorSupport.java	Wed Sep 15 16:31:28 2004 +0000
     1.2 +++ b/vcscore/src/org/netbeans/modules/vcscore/commands/CommandExecutorSupport.java	Wed Sep 15 17:14:13 2004 +0000
     1.3 @@ -329,14 +329,17 @@
     1.4                  String file = VcsUtilities.getFileNamePart(fullPath);
     1.5                  //System.out.println("  fullPath = "+fullPath+", dir = "+dir+", file = "+file);
     1.6                  Boolean recursively[] = { Boolean.FALSE };
     1.7 -                String folderName = getFolderToRefresh(fileSystem, vce.getExec(),
     1.8 -                                                       cmd, dir, file, foldersOnly,
     1.9 -                                                       doRefreshCurrent, doRefreshParent,
    1.10 -                                                       recursively);
    1.11 -                if (folderName != null) {
    1.12 -                    Boolean rec = (Boolean) foldersToRefresh.get(folderName);
    1.13 -                    if (!Boolean.TRUE.equals(rec)) {
    1.14 -                        foldersToRefresh.put(folderName, recursively[0]);
    1.15 +                String[] folderNames = getFolderToRefresh(fileSystem, vce.getExec(),
    1.16 +                                                          cmd, dir, file, foldersOnly,
    1.17 +                                                          doRefreshCurrent, doRefreshParent,
    1.18 +                                                          recursively);
    1.19 +                if (folderNames != null) {
    1.20 +                    for (int i = 0; i < folderNames.length; i++) {
    1.21 +                        String folderName = folderNames[i];
    1.22 +                        Boolean rec = (Boolean) foldersToRefresh.get(folderName);
    1.23 +                        if (!Boolean.TRUE.equals(rec)) {
    1.24 +                            foldersToRefresh.put(folderName, recursively[0]);
    1.25 +                        }
    1.26                      }
    1.27                  }
    1.28              }
    1.29 @@ -348,10 +351,10 @@
    1.30       * @param recursively [0] is filled by the method
    1.31       * @return dir[+file] converted to FS path or <code>null</code>
    1.32       */
    1.33 -    private static String getFolderToRefresh(VcsFileSystem fileSystem, String exec,
    1.34 -                                             VcsCommand cmd, String dir, String file,
    1.35 -                                             boolean foldersOnly, boolean doRefreshCurrent,
    1.36 -                                             boolean doRefreshParent, Boolean[] recursively) {
    1.37 +    private static String[] getFolderToRefresh(VcsFileSystem fileSystem, String exec,
    1.38 +                                               VcsCommand cmd, String dir, String file,
    1.39 +                                               boolean foldersOnly, boolean doRefreshCurrent,
    1.40 +                                               boolean doRefreshParent, Boolean[] recursively) {
    1.41  
    1.42          FileCacheProvider cache = fileSystem.getCacheProvider();
    1.43          FileStatusProvider statusProvider = fileSystem.getStatusProvider();
    1.44 @@ -362,7 +365,15 @@
    1.45              String refreshPath = dir;//(String) vars.get("DIR");
    1.46              refreshPath.replace(java.io.File.separatorChar, '/');
    1.47              String refreshPathFile = refreshPath + ((refreshPath.length() > 0) ? "/" : "") + file; //(String) vars.get("FILE");
    1.48 -            if (!doRefreshParent && cache != null && cache.isDir(refreshPathFile)) refreshPath = refreshPathFile;
    1.49 +            String[] refreshPaths = null;
    1.50 +            if (cache != null && cache.isDir(refreshPathFile)) {
    1.51 +                if (doRefreshCurrent && doRefreshParent) {
    1.52 +                    refreshPaths = new String[] { refreshPath, refreshPathFile };
    1.53 +                } else if (!doRefreshParent) {
    1.54 +                    refreshPath = refreshPathFile;
    1.55 +                }
    1.56 +            }
    1.57 +            //if (!doRefreshParent && cache != null && cache.isDir(refreshPathFile)) refreshPath = refreshPathFile;
    1.58              String patternMatch = (String) cmd.getProperty(VcsCommand.PROPERTY_REFRESH_RECURSIVELY_PATTERN_MATCHED);
    1.59              String patternUnmatch = (String) cmd.getProperty(VcsCommand.PROPERTY_REFRESH_RECURSIVELY_PATTERN_UNMATCHED);
    1.60              boolean rec = (exec != null
    1.61 @@ -372,9 +383,11 @@
    1.62                      || patternUnmatch != null && patternUnmatch.length() > 0 && exec.indexOf(patternUnmatch) < 0));
    1.63              recursively[0] = (rec) ? Boolean.TRUE : Boolean.FALSE;
    1.64              //System.out.println("  !foldersOnly = "+(!foldersOnly)+", cache.isDir("+refreshPath+") = "+cache.isDir(refreshPath));
    1.65 -            if (!foldersOnly || cache.isDir(refreshPath)) {
    1.66 +            if (refreshPaths != null) {
    1.67 +                return refreshPaths;
    1.68 +            } else if (!foldersOnly || cache.isDir(refreshPath)) {
    1.69                  //System.out.println("  CALLING REFRESH!");
    1.70 -                return refreshPath;
    1.71 +                return new String[] { refreshPath };
    1.72              } else {
    1.73                  return null;
    1.74              }