Builder does not fire when editor save is complete [message #324003] |
Wed, 16 January 2008 02:14  |
Eclipse User |
|
|
|
Originally posted by: zeddicus76.hotmail.com
I have a custom editor using FormEditor and FormPage objects. When the save
completes my builder does not fire. If I edit the same file using a
TextEditor, after the save the builder fires off just fine.
When I use my custom editor, I can see the timestamp and filesize on the
file change so I know it's getting written to.
I don't know where to look to figure out why the builder is not recognizing
the change in the resource.
Thank you,
Gavin
|
|
|
|
Re: Builder does not fire when editor save is complete [message #324053 is a reply to message #324007] |
Thu, 17 January 2008 03:06   |
Eclipse User |
|
|
|
Originally posted by: zeddicus76.hotmail.com
Valere,
Thank you for the quick response.
I tried the refresh but nothing happens in my editor, I would assume that
means I didn't implement a refresh.
This is my first attempt at an Eclipse Editor and Builder so I don't think
I'm going at this the right way. Here is what I am currently doing.
The file format that I am trying to edit using a FormEditor is XML format
that contains one to many sets that are something like this:
<configuration name="myconfig">
<resource>/path/to/resource.txt</resource>
<resource>/path/to/anotherresource.txt</resource>
<options>--verbose</options>
</configuration>
I am trying to create a multiple page editor so that it is easy to add
resources (I am currently using a TreeViewer and it is working great), the
options can be edited by selecting a button that brings up a separate window
and then checking or unchecking the available options.
In the FormEditor object, I create an object that represents the XML file.
In this object I use
if (input instanceof IFileEditorInput) {
file = ((IFileEditorInput)input).getFile();
myFile = new myFile(file);
myFile parses the file using DocumentBuilderFactory and parsing the XML file
into an array of configuration objects. Then the FormEditor creates a new
ConfigPage for each of the configurations found in the XML file.
To save it, I update all of the configuration objects from the data in the
FormPages and then I update the document model and then convert it to the
XML file using:
Source src = new DOMSource(doc);
File outputFile = new File(pdFile.getLocation().toOSString());
Result result = new StreamResult(outputFile);
Transformer xformer = TransformerFactory.newInstance().newTransformer();
xformer.transform(src, result);
I don't see any way to use .setContents to save in the XML format. Am I
completely missing the boat here?
Thank you,
Gavin
"valere fedronic" <valere.fedronic.ext@streamezzo.com> wrote in message
news:fmkhh9$osu$1@build.eclipse.org...
> Hi,
>
> And if you try to refresh the file (F5) doest it fire a resource change
> event?
> If it is the case, the builder is not called because the way you save the
> resource doesn't launch a resource change event.
> How do you save the file ?
> IFile#setContents() works.
>
>
> Val
|
|
|
Re: Builder does not fire when editor save is complete [message #324074 is a reply to message #324053] |
Thu, 17 January 2008 05:50   |
Eclipse User |
|
|
|
Originally posted by: valere.fedronic.ext.streamezzo.com
Try something like this:
Source src = new DOMSource(doc);
FileOutputStream outputStream = new
FileOutputStream(pdFile.getFullPath().toFile());
Result result = new StreamResult(outputStream );
Transformer xformer = TransformerFactory.newInstance().newTransformer();
xformer.transform(src, result);
[... in a finally block ..]
outputStream .close();
[..]
pdFile.refreshLocal(IResource.DEPTH_ZERO, null);
Gavin a écrit :
> Valere,
> Thank you for the quick response.
>
> I tried the refresh but nothing happens in my editor, I would assume that
> means I didn't implement a refresh.
>
> This is my first attempt at an Eclipse Editor and Builder so I don't think
> I'm going at this the right way. Here is what I am currently doing.
>
> The file format that I am trying to edit using a FormEditor is XML format
> that contains one to many sets that are something like this:
> <configuration name="myconfig">
> <resource>/path/to/resource.txt</resource>
> <resource>/path/to/anotherresource.txt</resource>
> <options>--verbose</options>
> </configuration>
>
> I am trying to create a multiple page editor so that it is easy to add
> resources (I am currently using a TreeViewer and it is working great), the
> options can be edited by selecting a button that brings up a separate window
> and then checking or unchecking the available options.
>
> In the FormEditor object, I create an object that represents the XML file.
> In this object I use
> if (input instanceof IFileEditorInput) {
> file = ((IFileEditorInput)input).getFile();
> myFile = new myFile(file);
>
> myFile parses the file using DocumentBuilderFactory and parsing the XML file
> into an array of configuration objects. Then the FormEditor creates a new
> ConfigPage for each of the configurations found in the XML file.
>
> To save it, I update all of the configuration objects from the data in the
> FormPages and then I update the document model and then convert it to the
> XML file using:
>
> Source src = new DOMSource(doc);
> File outputFile = new File(pdFile.getLocation().toOSString());
> Result result = new StreamResult(outputFile);
>
> Transformer xformer = TransformerFactory.newInstance().newTransformer();
> xformer.transform(src, result);
>
> I don't see any way to use .setContents to save in the XML format. Am I
> completely missing the boat here?
> Thank you,
> Gavin
>
>
>
>
>
> "valere fedronic" <valere.fedronic.ext@streamezzo.com> wrote in message
> news:fmkhh9$osu$1@build.eclipse.org...
>> Hi,
>>
>> And if you try to refresh the file (F5) doest it fire a resource change
>> event?
>> If it is the case, the builder is not called because the way you save the
>> resource doesn't launch a resource change event.
>> How do you save the file ?
>> IFile#setContents() works.
>>
>>
>> Valère
>>
>> Gavin a écrit :
>>> I have a custom editor using FormEditor and FormPage objects. When the
>>> save completes my builder does not fire. If I edit the same file using a
>>> TextEditor, after the save the builder fires off just fine.
>>> When I use my custom editor, I can see the timestamp and filesize on the
>>> file change so I know it's getting written to.
>>>
>>> I don't know where to look to figure out why the builder is not
>>> recognizing the change in the resource.
>>>
>>> Thank you,
>>> Gavin
>
>
|
|
|
Re: Builder does not fire when editor save is complete [message #324206 is a reply to message #324074] |
Sat, 19 January 2008 17:38  |
Eclipse User |
|
|
|
Originally posted by: zeddicus76.hotmail.com
Valere,
Thank you very much. That appears to have done the trick. The only thing I
had to change was the FileOutputStream:
new FileOutputStream(pdFile.getLocation().toFile()) so that the system could
find the file correctly.
After that, the builder finally fired after my editor completed the save.
Thank you again,
Gavin
"valere fedronic" <valere.fedronic.ext@streamezzo.com> wrote in message
news:fmnbso$osu$2@build.eclipse.org...
> Try something like this:
>
> Source src = new DOMSource(doc);
>
> FileOutputStream outputStream = new
> FileOutputStream(pdFile.getFullPath().toFile());
> Result result = new StreamResult(outputStream );
>
> Transformer xformer = TransformerFactory.newInstance().newTransformer();
> xformer.transform(src, result);
>
> [... in a finally block ..]
> outputStream .close();
> [..]
>
> pdFile.refreshLocal(IResource.DEPTH_ZERO, null);
>
>
> Gavin a
|
|
|
Powered by
FUDForum. Page generated in 0.03198 seconds