[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.tools] Re: plugin needs to send events to the workbench?

"John Arthorne" <John_Arthorne@xxxxxxxx> wrote in message
news:3E9EC9A8.8030407@xxxxxxxxxxx
> Your code looks fine, although some parts are not necessary.  This
> should be sufficient:
>
> ByteArrayOutputStream ostr = new ByteArrayOutputStream();
> parser.prettify( currentFile.getContents(), ostr );
> InputStream newStream = new ByteArrayInputStream( ostr.toByteArray());
> currentFile.setContents( newStream, false, true, null);
>
> I.e., you don't need to close the newStream, since the contract of
> setContents says it will always be closed.  The refreshLocal is
> definitely not need here, since you're only using the IFile API to
> modify the file.  A couple more questions:

Ok, I was just grasping for straws and trying to find the magic bullet that
would allow Eclipse to know that the file was modified and have the
underlying system release the file handle.

> - You didn't show the exception handling, but I assume get/setContents
> aren't throwing any exceptions?

Correct, there's no exceptions happening.  All that handleException() does
is show an error popup with the message from the thrown exception.

> - What does the deletion exception look like?  If you catch the
> exception in the debugger, can you see any more details?

Unfortunately, I can't run in the workbench debugger.  When I start a
run-time workbench,  the only projects available to me are "Simple", no
"Java", and even so, I cannot create files within a newly created simple
project.  It's strange because my eclipse install on my home machine allows
me to debug plugins and create Java projects for testing in the run-time
workbench.  They are both ver. 2.1.  If you know a way to fix my run-time
workbench please advise...

So when I work on this plugin on my work machine I am reduced to "printf
style debugging" via MessageDialog.showInformation().  :(

Here's what shows up in my .log though:

!ENTRY org.eclipse.jdt.ui 4 0 Apr 17, 2003 09:15:09.655
!MESSAGE See details
!SUBENTRY 1 org.eclipse.core.resources 4 273 Apr 17, 2003 09:15:09.655
!MESSAGE Could not delete:
C:\Dev\Devtools\eclipse\workspace\com.work.util.ide.eclipse\src\com\work\uti
l\ide\eclipse\popup\actions\AM.java.

> - if you replace parser.prettify with a simple method that copies from
> one stream to the other, do you still get the exception?  I wonder if
> there's still a possible code path in prettify that does not close the
> stream.  It might be better to do it like this:

Unfortunately the formatter utility is third-party and I don't have access
to the source.
Again, thanks for the help.

--Eric