|Trying to figure out how I was supposed to figure this out [message #334941]
||Tue, 10 March 2009 23:13
Originally posted by: marc.esher.comcast.net|
I'm really trying to understand "The Eclipse Way". At times, it's quite
easy. At other times, it's maddening. I believe this is because I'm still
learning how to get my head around such a massive API, and also because I
simply don't know yet the patterns/idioms that Eclipse expects me to know
to work easily with it.
Here's something I finally got working after I found a powerpoint
presentation that showed the 3 lines of code I needed. If I hadn't found it,
I'm not sure I would've ever got it working. The two books on Eclipse
programming that I own didn't cover this topic (at least, I couldn't find
it), so they weren't much help. My thing is: I want to know how to do this
stuff myself without relying on Google. I want to learn deep.
I wanted a simple Compare Dialog that showed a diff of two strings. I
created an Input class that extended CompareEditorInput. Within
prepareInput, I created a new DiffNode taking in a left and right instance
of a class that implemented ITypedElement (We'll call this class
"CompareItem"). I created an Action that calls CompareUI.openCompareDialog()
taking in my Input class. This successfully popped up the dialog, but there
was no content in either window.
I actually expected this b/c I couldn't figure out how the content I was
passing into my CompareItem ITypedElement objects was ever getting pulled
back out. So I searched all the javadocs of the seemingly relevant classes,
but I didn't see anything. I spent quite some time on this. Now, understand
that I've never done any Editor programming, just View programming. So
possibly the answer should've been obvious.
Eventually, as I said, I found the answer in a powerpoint given to a
Polish eclipse user group. I needed to have my CompareItem also implement
IStreamContentAccessor and then implement getContents(), returning a
ByteArrayInputStream of the string I was passing into the Item.
My question is this: How can I learn how to find this stuff on my own? I
really want to learn to think like an Eclipse programmer. I want to be able
to sit down and crank out stuff rather than spend hours on a few lines of
thanks for any guidance!
|Re: Trying to figure out how I was supposed to figure this out [message #334956 is a reply to message #334941]
||Wed, 11 March 2009 19:14
| Walter Harley
Registered: July 2009
"Marc E" <email@example.com> wrote in message |
> Greetings all,
> I'm really trying to understand "The Eclipse Way". At times, it's quite
> easy. At other times, it's maddening.
Amen to that. I don't think you'll find much argument there.
>My thing is: I want to know how to do this stuff myself without relying on
>Google. I want to learn deep.
False dichotomy, I think. I'd suggest relying on Google to *find* answers,
and then on study of code to *understand* the answers. (And to verify the
frequently-incorrect advice from Google.)
> My question is this: How can I learn how to find this stuff on my own? I
> really want to learn to think like an Eclipse programmer. I want to be
> able to sit down and crank out stuff rather than spend hours on a few
> lines of code.
Personally I have found it most useful to think "where else in the product
does something like this happen", and then look at the source code for that
plug-in to see how they did it there. This is not always easy. Knowing the
basic extension points makes it somewhat easier to find the implementation
but it is still always a challenge.
I have rarely found that the javadoc alone is enough to tell me how to use
an API, or even which API method to use. I usually end up having to look at
the callers and at the implementation. Fortunately Eclipse makes this not
too hard (e.g., go to PDE perspective, Plug-ins tab, and import a plug-in
project as binary; voila, navigable source code).
It's still pretty hard, though. As you say, it's a huge and constantly
evolving API. Eclipse's principle of avoiding API breakage means that there
are often many ways to do something and some of them are obsolete or less
functional; finding the most-modern way is a challenge.
Feel free to use the newsgroups and IRC liberally, that's what they're there
for (providing that questions are asked in a useful way, as yours was).
Powered by FUDForum
. Page generated in 0.02222 seconds