You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by ma...@apache.org on 2021/12/27 22:01:19 UTC

[netbeans] branch master updated: [NETBEANS-5901] Handling of FileObjects not backed by j.i.File when sorting by full path is requested.

This is an automated email from the ASF dual-hosted git repository.

matthiasblaesing pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git


The following commit(s) were added to refs/heads/master by this push:
     new 923c632  [NETBEANS-5901] Handling of FileObjects not backed by j.i.File when sorting by full path is requested.
     new dcc34cd  Merge pull request #3134 from jlahoda/NETBEANS-5901
923c632 is described below

commit 923c6327932632ee50959b082eac828c97d679db
Author: Jan Lahoda <jl...@netbeans.org>
AuthorDate: Fri Aug 27 18:06:14 2021 +0200

    [NETBEANS-5901] Handling of FileObjects not backed by j.i.File when sorting by full path is requested.
---
 .../netbeans/core/windows/model/DefaultModeModel.java | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/platform/core.windows/src/org/netbeans/core/windows/model/DefaultModeModel.java b/platform/core.windows/src/org/netbeans/core/windows/model/DefaultModeModel.java
index 9b9bda1..124b876 100644
--- a/platform/core.windows/src/org/netbeans/core/windows/model/DefaultModeModel.java
+++ b/platform/core.windows/src/org/netbeans/core/windows/model/DefaultModeModel.java
@@ -22,6 +22,7 @@ package org.netbeans.core.windows.model;
 
 
 import java.awt.*;
+import java.io.File;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -232,7 +233,23 @@ final class DefaultModeModel implements ModeModel {
     }
 
     private int compareFullFilePath(FileObject f1, FileObject f2) {
-        return FileUtil.toFile(f1).compareTo(FileUtil.toFile(f2));
+        return toFullFilePath(f1).compareToIgnoreCase(toFullFilePath(f2));
+    }
+
+    private String toFullFilePath(FileObject fo) {
+        File f = FileUtil.toFile(fo);
+
+        if (f != null) {
+            return f.getAbsolutePath();
+        }
+
+        FileObject rootFO = FileUtil.getArchiveFile(fo);
+
+        if (rootFO != null) {
+            return toFullFilePath(rootFO) + "/" + fo.getPath();
+        }
+
+        return fo.toURL().getPath();
     }
 
     private int compareFileName(FileObject f1, FileObject f2) {

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists