Community
Participate
Working Groups
Build Identifier: 20110615-0604 When cursor is over an interface Type, add an "Implement this interface" line in the quick fix (ctrl+1) menu. Choosing it should start the new Class wizard with the interface set and a reasonable default class name and package. Reproducible: Always Steps to Reproduce: 1. In a Java Editor, put the cursor on an interface Type 2. Press ctrl+1 3. In menu choose element "Implement this interface" 4. New class wizard starts with prefilled fields in package (current or interface's package), class name (a unique name based on interface name, like FooBarImpl for interface FooBar or FooBar for interface IFooBar) and interface. The cursor should be in the class name field and the name should be selected to allow immediate overwrite. Simply pressing enter should create the class.
Move to JDT/UI
Note that there is already a quick fix if one of your classes declares to implement the interface, e.g. "class MyClass implements Iterator {}". Adding a quick assist on just the type seems overkill. Maybe we could do better in initializing the class wizard when an interface is selected.
IMHO the hassle of creating a new class is too high. My typical usage is: 1. choose package in package explorer 2. right mouse click, choose New, choose Class 3. fill-out all fields and finish Especially the mouse using parts (1. and 2.) are a pain. Note this made curious, and I realized that the new class wizard can be called using a keyboard shortcut, and there the package is already filled correctly. nice!. So I agree with Dani: just pre-filling out the fields of the new class wizard will do. - add the interface if one was selected when the wizard was started - add a default unique class name if an interface was selected - add a super class if a Class was selected when the wizard was started (and the super class is not final)
(In reply to comment #3) > So I agree with Dani: just pre-filling out the fields of the new class wizard > will do. > - add the interface if one was selected when the wizard was started > - add a default unique class name if an interface was selected > - add a super class if a Class was selected when the wizard was started (and > the super class is not final) I think pre-filling interface and/or super class info could quickly get annoying. Current behavior with pre-filling of package field in New Class Wizard - Selection in Java editor - Parent package of the current CU is chosen - Selection in PE - The selected package or the parent package of the selected IJavaElement is chosen - Now if an interface (or a type) is open in Java editor and you open the New Class Wizard - do you *always* want to implement the interface (or extend the type) opened in the editor? - Does the pre-filling happen only when the selection is in Package Explorer? Given that there could be unexpected results for a user, and an alternative efficient workflow exists (quick fox from comment 2). I would close this as WONTFIX. Dani, thoughts?
> Dani, thoughts? We already fill in the interface or super class if such an element is in the structured selection. We should simply do the same with text selections.