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

Hi Vadim,

I had (maybe) a similar problem. After creating a file in a Wizard the
file did not appear in the workspace. There was no synchronisation with
the filesystem.
I played around hours with this problem, trying a lot of the things you
also tried, until I found a solution which worked for me.

I execute all file-creation-code into a WorkspaceModificationOperation
and execute I workspace refesh after creating the files.
Because I am quite new to Eclipse-development I do not know whether this
is the right way or whether it has some side-effects. Just try it, if
the idea with the WorkSpaceJob does not work.
Maybe this works for you, too.

See an example below.

Regards,

Martin

IRunnableWithProgress op = new WorkspaceModifyOperation(null)
			{

				protected void execute(IProgressMonitor monitor) throws
CoreException, InterruptedException
				{
				
					//....your file creation code

					try
					{
						IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
						root.refreshLocal(IResource.DEPTH_INFINITE, monitor);

					}
					catch (CoreException e)
					{

						e.printStackTrace();
					}
				}
			};

			getContainer().run(false, true, op);


Vadim Chepegin schrieb:
> Zsolt Török wrote:
> 
>> Hi Vadim,
> 
>> Apparently you tried lots of different ways to fix this, but let me
>> recommend you another one: writing a WorkspaceJob implementation.
> (http://help.eclipse.org/ganymede/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/core/resources/WorkspaceJob.html)
> 
>> The javadoc is quite detailed, and it all boils down to putting your
>> workspace modification code into the runInWorkspace method and hooking
>> up a resource change listener.
> 
>> HTH,
>> Zsolt
> Thank you, Zsolt! I will definetely give it a try.
> 
> If anybody has other options as wel, you are welcome :)
>