resource.getContents is empty [message #322607] |
Wed, 21 November 2007 10:02  |
Eclipse User |
|
|
|
Originally posted by: alexjaquet.gmail.com
Hi,
I can't figure out why I'm loosing the content of a resource. In class A
I do
private void saveModel(Model model, IFile file) {
String filePath = file.getFullPath().toString();
URI uri = URI.createPlatformResourceURI(filePath, true);
ResourceSet resourceSet =
ResourceSetHolder.getInstance().getResourceSet();
Resource resource = resourceSet.createResource(uri);
resource.getContents().add(model);
try {
resource.save(null);
} catch (IOException ioe) {
Logger.error("Unable to create the model", ioe);
throw new PageException("Unable to create the model", ioe);
}
}
and in class B I do
protected void setInput(IEditorInput input) {
super.setInput(input);
IFile file = ((IFileEditorInput) input).getFile();
String filePath = file.getFullPath().toString();
URI uri = URI.createPlatformResourceURI(filePath, true);
Resource resource = getResourceSet().getResource(uri, true);
model = (Model) resource.getContents().get(0);
rootWidget = model.getWidget();
// Update the Widgets taking into account changes to the metamodel
// TODO Other places in the designer read the model from file. Should we
// add this code there also?
new WidgetFactory().update(rootWidget);
// Update the Palette
paletteRoot = null;
getEditDomain().setPaletteRoot(getPaletteRoot());
pageListener.setFile(file);
// These are needed otherwise the pages cannot be printed
setPartName(file.getName());
setContentDescription(file.getName());
}
The problem is in the setInput method the following line return null
model = (Model) resource.getContents().get(0);
What can be happened during the execution of my plugin ...
|
|
|
|
Re: resource.getContents is empty [message #322614 is a reply to message #322609] |
Wed, 21 November 2007 11:26  |
Eclipse User |
|
|
|
Originally posted by: merks.ca.ibm.com
This is a multi-part message in MIME format.
--------------090004060207080704050202
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Alexandre,
You should use the EMF newsgroup for EMF specific questions.
news://news.eclipse.org/eclipse.tools.emf
Alexandre Jaquet wrote:
> Hm after debuging a bit I see in my resource set I've two times each
> resource I created one time empty and one time with contents
>
> let's search where I do that ...
--------------090004060207080704050202
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Alexandre,<br>
<br>
You should use the EMF newsgroup for EMF specific questions.<br>
<blockquote><a href="news://news.eclipse.org/eclipse.tools.emf">news://news.eclipse.org/eclipse.tools.emf</a><br>
</blockquote>
<br>
Alexandre Jaquet wrote:
<blockquote cite="mid:fi1hvd$uqa$6@build.eclipse.org" type="cite">Hm
after debuging a bit I see in my resource set I've two times each
resource I created one time empty and one time with contents
<br>
<br>
let's search where I do that ...
<br>
</blockquote>
<br>
</body>
</html>
--------------090004060207080704050202--
|
|
|
Powered by
FUDForum. Page generated in 0.03769 seconds