Community
Participate
Working Groups
Build Identifier: 20110916-0149 I would like to be able to click on the Source menu and have a menu item say "Generate Decorator Class". This will popup a dialog box in which I enter the name of my new class and the source class name. The dialog box will have other controls similar to that of creating a new class dialog box (where applicable). When the user clicks okay in the dialog box it will create the new class. The new class will implement all of the same interfaces and methods as the source class. The new class constructor will accept a reference to the source class. All of the methods in the new class will simply forward the call to the source class. This functionality makes it easy to use the Decorator Pattern. See http://en.wikipedia.org/wiki/Decorator_pattern for more information. Reproducible: Always
You can do most of the heavy lifting already. - Start with ------------------------------------------------ interface MyInterface { void foo(); void bar(); } class Decorator { private MyInterface obj; } ------------------------------------------------ - Select 'obj' - Source > Generate delegate methods - Select 'obj' again - Source > Generate Constructor using fields - Final result is ------------------------------------------------ interface MyInterface { void foo(); void bar(); } class Decorator { private MyInterface obj; public Decorator(MyInterface obj) { super(); this.obj = obj; } public void foo() { obj.foo(); } public void bar() { obj.bar(); } } ------------------------------------------------ Closing as WONTFIX.