Mar 15 2008

Eclipse – a workspace and its resources. Problem with case-insensitive file systems.

Published by at 2:23 pm under Eclipse,IT,Java

All the resources in Eclipse workspace are case-sensitive. Name of the file inside a project in Eclipse workspace is case-sensitive. On Eclipse API level two resources called somefile.TXT and somefile.txt are different resources. The problem starts while such resources are stored in the file system. Method org.eclipse.core.resources.IResource.exists() will return false for somefile.TXT if there is already somefile.txt in the workbench. This cause problem if you are for example implementing wizard for creating new file resource – basing on the Eclipse API you cannot check if such file already exists. My workaround for this was using java.io classes directly for this. Another problem is if in you wizard you want to overwrite existing file with new one e.g. somefile.TXT with somefile.txt. If you try to use org.eclipse.ui.ide.IDE.openEditor(IWorkbenchPage page, IFile input, String editorId, boolean activate) for this overwritten file – it will fail opening it. In Eclipse 3.3 there was introduced method openEditor(IWorkbenchPage page, URI uri, String editorId, boolean activate) – which doesn’t have problem with case-sensitivity. Unfortunately it opens the file in read-only mode while the new resource is out of the workbench! I haven’t found any nice programmatic way to “refresh” workbench in order to reflect the changes that were made on file system behind the scene (as user can do manually by pressing F5). May workaround for this is opening the editor twice – first time using openEditor(IWorkbenchPage page, IFile input, String editorId, boolean activate) and closing it immediately in order to “refresh” workbench and after that using openEditor(IWorkbenchPage page, URI uri, String editorId, boolean activate) – now the new file is already in the workbench and the it’s not opened in read-only mode.

This is one of the problems I encountered while developing Eclipse plugins on Windows platform. I’m missing possibility for configuring all the resources related code for dealing with OS-dependent stuff like mentioned above problem with case-sensitivity.

Eclipse 3.3 API reference can be found here.

No responses yet

Trackback URI | Comments RSS

Leave a Reply

You must be logged in to post a comment.