[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.modeling.gmf] synchronize file system and workspace

Hello everybody,

I need an advice how to synchronize a workspace with a file system programmatically.

I create a new project including directory structure using my wizard. I also create a file with a new default diagram and write it into one of those directories.

Then I open an editor for this file.

The problem is that sometimes (often) I get a popup with an error message:
"Modification could not be completed.
Reason
The following files are out of synchronization with the workspace: <name_of_file>"


I tried several things:

1. Tried to listen changes in file system (may be needed something else?):

IResourceChangeListener rcl = FileChangeManager.getInstance();
ResourcesPlugin.getWorkspace().addResourceChangeListener(rcl);


2. Extract the code that writes a file into a separate thread, start it and join the current thread to it. So writing a file must be finished before opening an editor.

3. Re-opening a new resource and reveal it

  IFile file = folder.getFile(schemaName + ".snf");
  selectAndReveal(file);

4. force refreshing of a workspace
IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
workspaceRoot.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());


5. Check

 file.isSynchronized(depth)

Even if it is true the message can appear.

6. Dummy Thread.wait(<some_seconds>)

Anyway, the problem occurs from time to time!


So, I need an advice how to force this synchronization when needed?