|
|
Re: Refactoring: extract nested class [message #658111 is a reply to message #658108] |
Sun, 06 March 2011 16:18 |
Mauro Condarelli Messages: 428 Registered: September 2009 |
Senior Member |
|
|
Il 06/03/2011 15:57, David Wegener ha scritto:
> On Sun, 2011-03-06 at 13:02 +0100, Mauro Condarelli wrote:
>> Is there a way to extract an inner class (a class fully declared inside
>> another, not an anonymous one) to make it an external, public one (in
>> it's own .java file)?
>> I would have thought it an obvious thing, but I couldn't find a way to
>> do it (aside from the usual copy & paste, obviously).
>> I see "Convert anonymous class to nested", but not a "Convert nested to
>> top level".
>> There are several commands sounding promising (e.g.: "Extract Class" or
>> "Move Type to new file"), but they do not do what I need.
>> Where did You hide this command? ;)
>>
>> TiA
>> Mauro
>
> The Move Type to new file refactoring provides this function. You say
> that it doesn't do what you need. Could you provide an example of
> exactly what you are trying to do and why Move Type doesn't match your
> needs?
>
In an Editor generated automatically by EMF ("Generate editor") I have the following:
public class WorldEditor
extends MultiPageEditorPart
implements IEditingDomainProvider, ISelectionProvider, IMenuListener, IViewerProvider {
...
public IContentOutlinePage getContentOutlinePage() {
if (contentOutlinePage == null) {
// The content outline is just a tree.
//
class MyContentOutlinePage extends ContentOutlinePage {
@Override
public void createControl(Composite parent) {
super.createControl(parent);
contentOutlineViewer = getTreeViewer();
contentOutlineViewer.addSelectionChangedListener(this);
....
I want to extract MyContentOutlinePage to its own file.
if I select it (I tried moving cursor on it, selecting the name and selecting the whole class) and then do Refactor->Move Type to New File... I get:
Operation Unavailable
To activate this refactoring, please select the name of a member type or a secondary type.
What am I doing wrong?
TiA
Mauro
|
|
|
Powered by
FUDForum. Page generated in 0.03086 seconds