From 7.2 onwards, there's a hint on an interface for generating its implementations. But it assumes you want to create a new class; it doesn't let you select an existing class where the interface should be implemented.
Does not sounds like a defect to me.
Well, I think this one is a defect because if you type an existing class into the dialog, a new class is created. I would expect the normal behavior to be that if an existing class is entered, the interface will be added to the interfaces declared in the existing class, not in a new one.
Yes, I agree it should add the interface to the list of implemented interfaces in such a case.
Dusan, I do not remember if there was a reason to instantiate the template before entering the user task, but note that there is GeneratorUtilities.createFromTemplate now. If the template wouldn't be instantiated before the user task, that would make a fix for this much easier, I think. Note that a new file can be created by calling WorkingCopy.rewrite(null, CUT).
Since this is a defect, could it be fixed for 7.2?
Why wouldn't you just type "implements WordProcessor" at the end of the existing class definition and then accept to hint to implement all unimplemented methods?
Because the nice thing about this hint is that you can define your interface and then, from the interface, automatically implement it.
But even if you disagree with this, then it still is an error that the user can enter an existing class and then end up having the hint create a new class. E.g., if I type "MyImpl" and then "MyImpl" already exists, the hint will create "MyImpl1". That's simply wrong.
Fixed in jet-main.
Integrated into 'main-golden', will be available in build *201204130400* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
User: Dusan Balek <email@example.com>
Log: Issue #210804: Implement an interface into an existing class - fixed.