This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 206422 - [71cat] cannot move inner class to file
Summary: [71cat] cannot move inner class to file
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Refactoring (show other bugs)
Version: 7.1
Hardware: PC Windows XP
: P2 normal with 2 votes (vote)
Assignee: Ralph Ruijs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-15 08:44 UTC by muellermi
Modified: 2016-04-21 23:14 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description muellermi 2011-12-15 08:44:04 UTC
Product Version = NetBeans IDE 7.1 (Build 201112051121)
Operating System = Windows XP version 5.1 running on x86
Java; VM; Vendor = 1.7.0_01
Runtime = Java HotSpot(TM) Client VM 21.1-b02

given a public class containing some inner classes:

public class MyClass {
[...]
    class CsvFilter extends javax.swing.filechooser.FileFilter {

        @Override
        public boolean accept(File file) {
            String filename = file.getName();
            return file.isDirectory() || filename.toLowerCase().endsWith(".csv");
        }

        @Override
        public String getDescription() {
            return "*.csv";
        }
    }

    class TxtFilter extends javax.swing.filechooser.FileFilter {

        @Override
        public boolean accept(File file) {
            String filename = file.getName();
            return file.isDirectory() || filename.toLowerCase().endsWith(".txt");
        }

        @Override
        public String getDescription() {
            return "*.txt";
        }
    }
[...]
}

For some reason the inner classes should be moved to it's own files and become public (eg. a class had been developed for local usage only, but can be used in general)

- Highlight (select) a whole inner class, eg. class CsvFilter
- Press Alt-Shift-m (move)

--> NB tries to move the whole file, ignoring the selection only
Moving the whole file might be simplier done by just dragging the file to a different package/folder within the project tree.
The selection should indicate to move this part only.

Is the current behavior buggy or is my sugesstion nothing but a new feature requested?
Comment 1 Jan Becicka 2012-04-23 16:07:49 UTC
Maybe Move Inner To Outer should be also merged with "Move" refactoring
Comment 2 Zom-B 2015-11-17 09:37:07 UTC
I have the same problem, and solution doesn't apply to my situation.

I want to move an inner class (member) to another class (as a member).


- When I select the inner class name or the inner class entirely, 'Move' assumes I want to move members inside the inner class.
- When I go to the outer class, 'Move' shows me a list with movable members in the class (my fields, constants and methods) but not inner classes.

My inner class is static and already public. I just want to move it to another class like any other member can be moved, including updating references.
Comment 3 lytles 2016-04-21 23:14:30 UTC
the only workaround i can find is to "move inner to outer level", and then "move" the new class (click "To Type") to an existing class. it's far from perfect - the code gets reformatted and the end result is pretty buggy, eg superclass methods get prepended with the class name and don't resolve

so i'm then copying and pasting the old code into the new class