Bug 210804 - Implement an interface into an existing class
Implement an interface into an existing class
Status: RESOLVED FIXED
Product: editor
Classification: Unclassified
Component: Hints & Annotations
7.2
PC Linux
: P3 with 1 vote (vote)
: 7.2
Assigned To: Dusan Balek
issues@editor
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-04-06 10:10 UTC by Geertjan Wielenga
Modified: 2012-04-13 09:50 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Geertjan Wielenga 2012-04-06 10:10:31 UTC
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.
Comment 1 Jan Lahoda 2012-04-06 10:27:12 UTC
Does not sounds like a defect to me.
Comment 2 Geertjan Wielenga 2012-04-06 10:33:28 UTC
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.
Comment 3 Jan Lahoda 2012-04-06 10:43:54 UTC
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).
Comment 4 Geertjan Wielenga 2012-04-06 11:26:39 UTC
Since this is a defect, could it be fixed for 7.2?
Comment 5 Jesse Glick 2012-04-06 12:21:57 UTC
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?
Comment 6 Geertjan Wielenga 2012-04-06 13:14:27 UTC
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.
Comment 7 Dusan Balek 2012-04-11 13:31:06 UTC
Fixed in jet-main.

http://hg.netbeans.org/jet-main/rev/4e7f17de507b
Comment 8 Quality Engineering 2012-04-13 09:50:56 UTC
Integrated into 'main-golden', will be available in build *201204130400* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/4e7f17de507b
User: Dusan Balek <dbalek@netbeans.org>
Log: Issue #210804: Implement an interface into an existing class - fixed.


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo