Bug 352854 - [type wizards] Also fill in interface and super class from text selection
Summary: [type wizards] Also fill in interface and super class from text selection
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.7   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-22 08:49 EDT by Philipp CLA
Modified: 2011-11-13 17:03 EST (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Philipp CLA 2011-07-22 08:49:07 EDT
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.
Comment 1 Olivier Thomann CLA 2011-07-22 10:01:23 EDT
Move to JDT/UI
Comment 2 Dani Megert CLA 2011-07-25 03:30:19 EDT
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.
Comment 3 Philipp CLA 2011-07-26 04:01:02 EDT
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)
Comment 4 Deepak Azad CLA 2011-10-19 00:50:36 EDT
(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?
Comment 5 Dani Megert CLA 2011-10-20 08:42:20 EDT
> 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.