Author: scabanovich
Date: 2008-03-31 08:28:27 -0400 (Mon, 31 Mar 2008)
New Revision: 7204
Added:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/FilePathHelper.java
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileAnyImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileObjectComparator.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemPeer.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemsImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FolderImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/JarFolderImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/SelectOverlappedFileSystemHandler.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/OpenedProjectsImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/EclipseResourceUtil.java
Log:
JBIDE-1973
Added:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/FilePathHelper.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/FilePathHelper.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/FilePathHelper.java 2008-03-31
12:28:27 UTC (rev 7204)
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.model.filesystems;
+
+import java.io.File;
+
+import org.eclipse.core.runtime.Platform;
+import org.jboss.tools.common.model.plugin.ModelPlugin;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.osgi.framework.Bundle;
+
+/**
+ * @author Viacheslav Kabanovich
+ */
+public class FilePathHelper {
+ private static Check check = null;
+
+ public static boolean isCaseSensitive() {
+ if(check == null) check = new Check();
+ return check.isCaseSensitive;
+ }
+
+ public static String toPathPath(String name) {
+ return name == null || isCaseSensitive() ? name : name.toLowerCase();
+ }
+
+ private static class Check {
+ boolean isCaseSensitive = false;
+ public Check() {
+ Bundle b = Platform.getBundle(ModelPlugin.PLUGIN_ID);
+ String path = EclipseResourceUtil.getInstallPath(b);
+ if(path == null) return;
+ String file = path + "/images/default.gif";
+ if(!new File(file).isFile()) {
+ ModelPlugin.getPluginLog().logWarning("Cannot find file " + file);
+ return;
+ }
+ String file2 = path + "/images/Default.gif";
+ if(!new File(file2).isFile()) {
+ isCaseSensitive = true;
+ }
+ }
+ }
+
+}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileAnyImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileAnyImpl.java 2008-03-31
11:46:52 UTC (rev 7203)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileAnyImpl.java 2008-03-31
12:28:27 UTC (rev 7204)
@@ -117,7 +117,8 @@
public String getPathPart() {
String n = name();
- return (n == null) ? null : n.toLowerCase();
+ String pp = FilePathHelper.toPathPath(n);
+ return (n == null) ? null : pp;
}
public static String toFileName(XProperty p) {
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileObjectComparator.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileObjectComparator.java 2008-03-31
11:46:52 UTC (rev 7203)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileObjectComparator.java 2008-03-31
12:28:27 UTC (rev 7204)
@@ -12,6 +12,7 @@
import java.util.*;
import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.filesystems.FilePathHelper;
public class FileObjectComparator implements Comparator<XModelObject> {
@@ -21,7 +22,9 @@
int i1 = o1.getFileType();
int i2 = o2.getFileType();
if(i1 != i2) return (i2 - i1);
- return o1.getPathPart().toLowerCase().compareTo(o2.getPathPart().toLowerCase());
+ String p1 = FilePathHelper.toPathPath(o1.getPathPart());
+ String p2 = FilePathHelper.toPathPath(o2.getPathPart());
+ return p1.compareTo(p2);
}
public boolean equals(Object obj) {
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemPeer.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemPeer.java 2008-03-31
11:46:52 UTC (rev 7203)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemPeer.java 2008-03-31
12:28:27 UTC (rev 7204)
@@ -13,6 +13,8 @@
import java.io.*;
import java.util.*;
+import org.jboss.tools.common.model.filesystems.FilePathHelper;
+
public class FileSystemPeer {
private Hashtable<String,Long> p = new Hashtable<String,Long>();
@@ -53,7 +55,8 @@
}
private String toKey(File f, boolean asDir) {
- String s = f.getAbsolutePath().replace('\\', '/').toLowerCase();
+ String s = f.getAbsolutePath().replace('\\', '/');
+ s = FilePathHelper.toPathPath(s);
return (asDir) ? s + "/" : s;
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemsImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemsImpl.java 2008-03-31
11:46:52 UTC (rev 7203)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemsImpl.java 2008-03-31
12:28:27 UTC (rev 7204)
@@ -20,6 +20,7 @@
import org.eclipse.ui.IContributorResourceAdapter;
import org.eclipse.ui.model.IWorkbenchAdapter;
import org.jboss.tools.common.model.*;
+import org.jboss.tools.common.model.filesystems.FilePathHelper;
import org.jboss.tools.common.model.impl.*;
import org.jboss.tools.common.model.plugin.ModelPlugin;
import org.jboss.tools.common.model.util.*;
@@ -121,7 +122,8 @@
String path = XModelObjectUtil.getExpandedValue(cs[i], "location",
null);
try {
File f = new File(path);
- path = f.getCanonicalPath().replace('\\',
'/').toLowerCase();
+ path = f.getCanonicalPath().replace('\\', '/');
+ path = FilePathHelper.toPathPath(path);
if (path.charAt(path.length()-1) != '/') path += '/';
paths[i] = path;
} catch (IOException e) {
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FolderImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FolderImpl.java 2008-03-31
11:46:52 UTC (rev 7203)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FolderImpl.java 2008-03-31
12:28:27 UTC (rev 7204)
@@ -30,12 +30,12 @@
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.filesystems.BodySource;
import org.jboss.tools.common.model.filesystems.FileAuxiliary;
+import org.jboss.tools.common.model.filesystems.FilePathHelper;
import org.jboss.tools.common.model.filesystems.XFileObject;
import org.jboss.tools.common.model.impl.RegularObjectImpl;
import org.jboss.tools.common.model.impl.XModelImpl;
import org.jboss.tools.common.model.loaders.Reloadable;
import org.jboss.tools.common.model.loaders.XObjectLoader;
-import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.common.model.util.Paths;
import org.jboss.tools.common.model.util.XModelObjectLoaderUtil;
import org.jboss.tools.common.util.FileUtil;
@@ -141,8 +141,9 @@
if(!rs[i].isAccessible()) continue;
if(!rs[i].isLinked()) continue;
File f = rs[i].getLocation().toFile();
- linked.put(f.getName().toLowerCase(), f);
- linkedResources.put(f.getName().toLowerCase(), rs[i]);
+ String pp = FilePathHelper.toPathPath(f.getName());
+ linked.put(pp, f);
+ linkedResources.put(pp, rs[i]);
_loadChild(peer, f);
}
fire = true;
@@ -153,8 +154,9 @@
Properties p = new Properties();
p.setProperty("name", f.getName());
XModelObject c = getModel().createModelObject("FileFolder", p);
- if(linked.containsKey(f.getName().toLowerCase())) {
- c.setObject("file", linked.get(f.getName().toLowerCase()));
+ String pp = FilePathHelper.toPathPath(f.getName());
+ if(linked.containsKey(pp)) {
+ c.setObject("file", linked.get(pp));
}
addChild(c);
} else {
@@ -234,7 +236,8 @@
for (int i = 0; i < rs.length; i++) {
if(!rs[i].isSynchronized(IResource.DEPTH_ZERO)) {
if(unsynchronized == null) unsynchronized = new HashSet<String>();
- unsynchronized.add(rs[i].getName().toLowerCase());
+ String pp = FilePathHelper.toPathPath(rs[i].getName());
+ unsynchronized.add(pp);
}
}
if(resource.exists()) {
@@ -258,7 +261,7 @@
for (int i = 0; i < rs.length; i++) {
if(rs[i].isLinked()) {
File f = rs[i].getLocation().toFile();
- String p = f.getName().toLowerCase();
+ String p = FilePathHelper.toPathPath(f.getName());
mf.put(p, f);
linked.put(p, f);
linkedResources.put(p, rs[i]);
@@ -269,16 +272,19 @@
}
File[] fs = getFiles();
- for (int i = 0; i < fs.length; i++) mf.put(fs[i].getName().toLowerCase(),
fs[i]);
+ for (int i = 0; i < fs.length; i++) {
+ String p = FilePathHelper.toPathPath(fs[i].getName());
+ mf.put(p, fs[i]);
+ }
Map<String,XModelObject> mc = children.getObjectsMap();
updateAuxiliary(mc, mf);
Map<String,XModelObject> toRemove = new
HashMap<String,XModelObject>();
- Iterator io = mc.keySet().iterator();
+ Iterator<String> io = mc.keySet().iterator();
while(io.hasNext()) {
- String nm = (String)io.next();
+ String nm = io.next();
if(mf.containsKey(nm)) continue;
XModelObject o = (XModelObject)mc.get(nm);
File of = getChildIOFile(o);
@@ -291,9 +297,9 @@
io.remove();
}
- Iterator it = mf.keySet().iterator();
+ Iterator<String> it = mf.keySet().iterator();
while(it.hasNext()) {
- String nm = (String)it.next();
+ String nm = it.next();
File f = (File)mf.get(nm);
XModelObject o = (XModelObject)mc.get(nm);
if(o != null) {
@@ -334,8 +340,9 @@
protected File getChildIOFile(String filename) {
File f = null;
- if(linked.containsKey(filename.toLowerCase())) {
- f = linked.get(filename.toLowerCase());
+ String p = FilePathHelper.toPathPath(filename);
+ if(linked.containsKey(p)) {
+ f = linked.get(p);
}
if(f == null) {
f = new File(getFile(), filename);
@@ -343,12 +350,12 @@
return f;
}
- private void updateAuxiliary(Map mc, Map mf) {
- Iterator it = mf.keySet().iterator();
+ private void updateAuxiliary(Map<String,XModelObject> mc,
Map<String,File> mf) {
+ Iterator<String> it = mf.keySet().iterator();
while(it.hasNext()) {
String nm = (String)it.next();
- File f = (File)mf.get(nm);
- XModelObject o = (XModelObject)mc.get(nm);
+ File f = mf.get(nm);
+ XModelObject o = mc.get(nm);
if(o == null ||
!o.getModelEntity().getName().equals(FileAuxiliary.AUX_FILE_ENTITY)) continue;
it.remove();
FileAnyAuxiliaryImpl aux = (FileAnyAuxiliaryImpl)o;
@@ -457,7 +464,8 @@
}
return;
}
- int i = (!o.isModified() || unsynchronized == null ||
!unsynchronized.contains(f.getName().toLowerCase())) ? 0 : question(f);
+ String p = FilePathHelper.toPathPath(f.getName());
+ int i = (!o.isModified() || unsynchronized == null ||
!unsynchronized.contains(p)) ? 0 : question(f);
if(i == 0) {
reload(o, f);
} else if(i == -100) {
@@ -530,7 +538,7 @@
}
}
- protected boolean updateNew(String pathpart, File f, Map toRemove) {
+ protected boolean updateNew(String pathpart, File f, Map<String,XModelObject>
toRemove) {
FileSystemPeer peer = getFileSystem().getPeer();
if(peer.contains(f) && !peer.isUpdated(f)) return false;
XModelObject c = null;
@@ -538,8 +546,9 @@
Properties p = new Properties();
p.setProperty("name", f.getName());
c = getModel().createModelObject("FileFolder", p);
- if(linked.containsKey(f.getName().toLowerCase())) {
- c.setObject("file", linked.get(f.getName().toLowerCase()));
+ String pp = FilePathHelper.toPathPath(f.getName());
+ if(linked.containsKey(pp)) {
+ c.setObject("file", linked.get(pp));
}
} else {
Properties ep = getEntityProperties(f);
@@ -562,9 +571,9 @@
return (c != null && addChild(c));
}
- private XModelObject findOldObject(String entity, Map toRemove) {
+ private XModelObject findOldObject(String entity, Map<String,XModelObject>
toRemove) {
if(entity == null || toRemove.size() == 0) return null;
- Iterator it = toRemove.keySet().iterator();
+ Iterator<String> it = toRemove.keySet().iterator();
while(it.hasNext()) {
String nm = it.next().toString();
XModelObject o = (XModelObject)toRemove.get(nm);
@@ -678,7 +687,10 @@
}
File[] fs = getFiles();
Map<String,File> t = new HashMap<String,File>();
- for (int i = 0; i < fs.length; i++) t.put(fs[i].getName().toLowerCase(),
fs[i]);
+ for (int i = 0; i < fs.length; i++) {
+ String p = FilePathHelper.toPathPath(fs[i].getName());
+ t.put(p, fs[i]);
+ }
FileSystemPeer peer = getFileSystem().getPeer();
peer.register(f);
XModelObject[] cs = getChildren();
@@ -706,9 +718,9 @@
t.remove(cs[i].getPathPart());
}
- Iterator it = t.values().iterator();
+ Iterator<File> it = t.values().iterator();
while(it.hasNext()) {
- File df = (File)it.next();
+ File df = it.next();
boolean d = df.isDirectory();
boolean r = (d && peer.containsDir(df)) || ((!d) &&
peer.contains(df));
if(!r) continue;
@@ -837,11 +849,12 @@
public String getPathPart() {
String s = get("NAME");
- return (s == null) ? null : s.toLowerCase();
+ return FilePathHelper.toPathPath(s);
}
public XModelObject getChildByPathPart(String pathpart) {
- return super.getChildByPathPart(pathpart.toLowerCase());
+ pathpart = FilePathHelper.toPathPath(pathpart);
+ return super.getChildByPathPart(pathpart);
}
static boolean isLateloadFile(XModelObject o) {
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/JarFolderImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/JarFolderImpl.java 2008-03-31
11:46:52 UTC (rev 7203)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/JarFolderImpl.java 2008-03-31
12:28:27 UTC (rev 7204)
@@ -123,11 +123,12 @@
public String getPathPart() {
String s = super.getPathPart();
- return (s == null) ? null : s.toLowerCase();
+ return FilePathHelper.toPathPath(s);
}
public XModelObject getChildByPathPart(String pathpart) {
- return super.getChildByPathPart(pathpart.toLowerCase());
+ pathpart = FilePathHelper.toPathPath(pathpart);
+ return super.getChildByPathPart(pathpart);
}
public boolean update() {
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/SelectOverlappedFileSystemHandler.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/SelectOverlappedFileSystemHandler.java 2008-03-31
11:46:52 UTC (rev 7203)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/SelectOverlappedFileSystemHandler.java 2008-03-31
12:28:27 UTC (rev 7204)
@@ -16,9 +16,9 @@
import org.jboss.tools.common.meta.action.XActionInvoker;
import org.jboss.tools.common.meta.action.impl.*;
import org.jboss.tools.common.model.*;
+import org.jboss.tools.common.model.filesystems.FilePathHelper;
import org.jboss.tools.common.model.impl.*;
import org.jboss.tools.common.model.util.*;
-import org.jboss.tools.common.model.util.FindObjectHelper;
public class SelectOverlappedFileSystemHandler extends AbstractHandler {
@@ -62,7 +62,8 @@
private static String getAbsoluteFileSystemPath(XModelObject fso) {
String path = XModelObjectUtil.getExpandedValue(fso, "location",
null);
try {
- return new File(path).getCanonicalPath().replace('\\',
'/').toLowerCase();
+ path = new File(path).getCanonicalPath().replace('\\', '/');
+ return FilePathHelper.toPathPath(path);
} catch (Exception e) {
//ignore
return null;
@@ -74,7 +75,8 @@
String rpath = XModelObjectLoaderUtil.getResourcePath(f);
if(path == null || rpath == null) return null;
XModelObject fso = f.getModel().getByPath(path.substring(0, path.length() -
rpath.length()));
- return (getAbsoluteFileSystemPath(fso) + rpath).toLowerCase();
+ String pp = getAbsoluteFileSystemPath(fso) + rpath;
+ return FilePathHelper.toPathPath(pp);
}
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/OpenedProjectsImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/OpenedProjectsImpl.java 2008-03-31
11:46:52 UTC (rev 7203)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/OpenedProjectsImpl.java 2008-03-31
12:28:27 UTC (rev 7204)
@@ -13,6 +13,7 @@
import java.util.*;
import org.jboss.tools.common.model.*;
import org.jboss.tools.common.model.event.XModelTreeEvent;
+import org.jboss.tools.common.model.filesystems.FilePathHelper;
import org.jboss.tools.common.model.util.XModelObjectUtil;
public class OpenedProjectsImpl extends OrderedObjectImpl {
@@ -47,10 +48,13 @@
public XModelObject getChildByFile(String name) {
if(name == null) return null;
- name = name.toLowerCase().replace('\\', '/');
+ name = FilePathHelper.toPathPath(name);
+ name = name.replace('\\', '/');
XModelObject[] os = children.getObjects();
for (int i = 0; i < os.length; i++) {
- if(name.equals(XModelObjectUtil.getExpandedValue(os[i], "name",
null).toLowerCase().replace('\\', '/'))) return os[i];
+ String p = XModelObjectUtil.getExpandedValue(os[i], "name", null);
+ p = FilePathHelper.toPathPath(p);
+ if(name.equals(p.replace('\\', '/'))) return os[i];
}
return null;
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/EclipseResourceUtil.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/EclipseResourceUtil.java 2008-03-31
11:46:52 UTC (rev 7203)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/EclipseResourceUtil.java 2008-03-31
12:28:27 UTC (rev 7204)
@@ -28,6 +28,7 @@
import org.jboss.tools.common.meta.action.XActionInvoker;
import org.jboss.tools.common.model.*;
+import org.jboss.tools.common.model.filesystems.FilePathHelper;
import org.jboss.tools.common.model.filesystems.FileSystemsHelper;
import org.jboss.tools.common.model.filesystems.XFileObject;
import org.jboss.tools.common.model.filesystems.impl.*;
@@ -404,7 +405,8 @@
properties.setProperty("name", f.getParentFile().getName());
FileSystemImpl s =
(FileSystemImpl)model.createModelObject("FileSystemFolder", properties);
fs.addChild(s);
- return model.getByPath("/" + f.getName().toLowerCase());
+ String pp = FilePathHelper.toPathPath(f.getName());
+ return model.getByPath("/" + pp);
}
public static String[] getJavaProjectSrcLocations(IProject project) {