Bug 164955

Summary: [move static members] enhance validation process
Product: [Eclipse Project] JDT Reporter: Bartosz Kowalewski <Bartosz.Kowalewski>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: NEW --- QA Contact:
Severity: enhancement    
Priority: P3    
Version: 3.3   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Additional validation none

Description Bartosz Kowalewski CLA 2006-11-17 07:40:28 EST
There is one simple scenario which could be easily eliminated using plain validation mechanisms directly on the "Move static members" wizard (that is the MoveMembersWizard class). 

Currently it is possible to choose the declaring type as destination of refactoring. The error is produced later - during the refactoring process. Adding a single (two line) if-statement in the validateDestinationType() method will do ;)

I can provide a patch :).
Comment 1 Martin Aeschlimann CLA 2006-11-17 10:48:34 EST
Patches are always welcome!
Comment 2 Bartosz Kowalewski CLA 2006-11-20 06:28:48 EST
Created attachment 54162 [details]
Additional validation
Comment 3 Bartosz Kowalewski CLA 2006-11-20 06:29:14 EST
A simple patch is now attached to this bug. Unfortunately I had to remove static modifier from one of the methods.

Before applying the provided patch, I advise checking the given scenario (I did not have time to check what causes the wizard to behave this way, but this could be a bug):

- open the Move Static Members wizard (alt + shift + v with any of the static members highlighted),
- choose the destination type -> it should be the same as the declaring type !!,
- click ok, an error message will be displayed,
- click the back button -> Move Static Members wizard will be displayed,
- change the input's contents (type in a correct class name),
- the OK button is disabled !!! :/ (nothing seems to be able to make it enabled),  
- ... however, it is possible to accept the action using the preview button - click preview, and OK on the next page.