Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 354898

Summary: Provide an option to create class, in addition to browse
Product: z_Archived Reporter: Ling Hao <ling.hao>
Component: SapphireAssignee: Konstantin Komissarchik <konstantin>
Status: CLOSED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: ram.venkataswamy
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Ling Hao CLA 2011-08-16 19:38:23 EDT
Sapphire-gallery.xml -> Java Type Names -> Required class 2

Notice Sapphire provides a browse button, but it might be useful to provide an option to provide a create class button as well.
Comment 1 Konstantin Komissarchik CLA 2011-08-25 01:23:35 EDT
Enhancement implemented. Documented in the enhancement doc along with the new "Working with Java Types" document. Please verify.
Comment 2 Ram Venkataswamy CLA 2011-08-29 21:26:53 EDT
verified
Comment 3 Konstantin Komissarchik CLA 2011-08-29 21:31:44 EDT
Closing.
Comment 4 Ling Hao CLA 2011-08-30 17:05:14 EDT
It would be nice to add implement methods from the interface. At least, we should provide an option?
Comment 5 Ling Hao CLA 2011-08-30 18:01:17 EDT
Also inner interfaces is not generated correctly. Example:

    @JavaTypeConstraint( kind = JavaTypeKind.CLASS, type = "com.tangosol.net.cache.ConfigurableCacheMap$UnitCalculator" )

Generated:
public class MyUnitCalculator implements ConfigurableCacheMap$UnitCalculator {
}

Note the missing import statement and the "$" 

Ram's bug Bug 310501
Comment 6 Ling Hao CLA 2011-08-30 18:04:59 EDT
Oops Ram's bug for inner class is Bug 12929122
Comment 7 Ling Hao CLA 2011-08-30 18:12:14 EDT
For the following java constraints - the create class button is not available:

    @JavaTypeConstraint( kind = JavaTypeKind.CLASS, 
      type = { 
    	"com.tangosol.net.cache.OverflowMap",
    	"com.tangosol.net.cache.SimpleOverflowMap" 
    	},
      behavior = JavaTypeConstraintBehavior.AT_LEAST_ONE		
    )

Ram's bug Bug 12929129
Comment 8 Konstantin Komissarchik CLA 2011-08-30 18:26:33 EDT
> For the following java constraints - the create class button is not available:
>
>    @JavaTypeConstraint( kind = JavaTypeKind.CLASS, 
>      type = { 
>        "com.tangosol.net.cache.OverflowMap",
>        "com.tangosol.net.cache.SimpleOverflowMap" 
>        },
>      behavior = JavaTypeConstraintBehavior.AT_LEAST_ONE        
>    )
>
> Ram's bug Bug 12929129

That's expected. The create action is not defined for AT_LEAST_ONE as there isn't a single way to create that class. Does SimpleOverflowMap extend from OverflowMap? If so you can simplify that definition and get the creation action to work.
Comment 9 Ling Hao CLA 2011-08-30 18:58:29 EDT
(In reply to comment #8)
> > For the following java constraints - the create class button is not available:
> >
> >    @JavaTypeConstraint( kind = JavaTypeKind.CLASS, 
> >      type = { 
> >        "com.tangosol.net.cache.OverflowMap",
> >        "com.tangosol.net.cache.SimpleOverflowMap" 
> >        },
> >      behavior = JavaTypeConstraintBehavior.AT_LEAST_ONE        
> >    )
> >
> > Ram's bug Bug 12929129
> 
> That's expected. The create action is not defined for AT_LEAST_ONE as there
> isn't a single way to create that class. Does SimpleOverflowMap extend from
> OverflowMap? If so you can simplify that definition and get the creation action
> to work.

No, SimpleOverflowMap does not extend from OverflowMap. I think we should still create it, using the first interface listed?
Comment 10 Ling Hao CLA 2011-08-31 16:59:49 EDT
Also, create class should validate, for example "abc". It should warn that java type usually start with an upper case. 
Ram's bug 12932359
Comment 11 Ling Hao CLA 2011-08-31 17:03:13 EDT
Create class should be available for java types that does not have any @JavaTypeConstraint. Ram suggested that we should create a simple class that doesn’t implement/extend another type. 
Ram's bug 12931834 (I had closed the bug as work as expected earlier, but reopened to get your thoughts)
Comment 12 Konstantin Komissarchik CLA 2011-09-02 20:30:51 EDT
> It would be nice to add implement methods from the interface. At least, we
> should provide an option?

Done.

> Also inner interfaces is not generated correctly. Example:
> 
> @JavaTypeConstraint( kind = JavaTypeKind.CLASS, type =
> "com.tangosol.net.cache.ConfigurableCacheMap$UnitCalculator" )

Fixed.

> No, SimpleOverflowMap does not extend from OverflowMap. I think we should still
> create it, using the first interface listed?

Ok. Implemented "use the first one" semantics.

> Also, create class should validate, for example "abc". It should warn that java
> type usually start with an upper case. 

Added validation for missing package and lowercase start of type name. The validation is presented as a confirmation dialog upon invoking the action.

> Create class should be available for java types that does not have any
> @JavaTypeConstraint. Ram suggested that we should create a simple class that
> doesn’t implement/extend another type. 

I now interpret missing @JavaTypeConstraint as equivalent to @JavaTypeConstraint.kind() listing all possibilities. The effect is that create action has four options for different kinds of java types.

Please verify.
Comment 13 Ling Hao CLA 2011-09-13 14:20:41 EDT
> Inner interfaces is not generated correctly. Example:
> 
> @JavaTypeConstraint( kind = JavaTypeKind.CLASS, type =
> "com.tangosol.net.cache.ConfigurableCacheMap$UnitCalculator" )

The generated code doesn't import the type and implement required methods.
Comment 14 Ling Hao CLA 2011-09-13 14:23:16 EDT
The newly created class should create constructors from superclass. 

Ram's reopened bug 12929122.
Comment 15 Konstantin Komissarchik CLA 2011-09-15 23:27:16 EDT
Both issues fixed.
Comment 16 Ram Venkataswamy CLA 2011-09-19 13:58:28 EDT
verified all fixes.
Comment 17 Konstantin Komissarchik CLA 2011-09-19 15:02:12 EDT
Closing. Thanks.
Comment 18 Ling Hao CLA 2011-09-23 17:53:40 EDT
@ In the latest build, create class generate incorrect code..
@ .
@ ex: Try creating a new listener class...
@ .
@ public c
@ .
@ public MyList1() {
@ super();
@ // TODO Auto-generated constructor stub
@ }lass MyList1 implements MapListener
@ {

@ generating HTTP Acceptor class puts the constructor outside the class
@ .
@ public MyHTTPAcc() {
@ super();
@ // TODO Auto-generated constructor stub
@ };
@ .
@ public class MyHTTPAcc implements HttpServer
@ {

Ram's reopened bug 12929122.
Comment 19 Konstantin Komissarchik CLA 2011-09-27 13:28:56 EDT
Could not reproduce any issues. Will try to reproduce in adopter product. Its time to close this bug and keep it closed. Any further enhancements or bugs in this area should be separately described/filed.
Comment 20 Konstantin Komissarchik CLA 2011-09-27 14:14:17 EDT
Ok. I was able to reproduce this in adopter product. Don't know what the issue is or why my previous repro didn't show it, but will take another stab at it via this bug for now.
Comment 21 Konstantin Komissarchik CLA 2011-09-27 14:33:37 EDT
The problem described in Comment #18 was due to an attempt to ensure that generated constructors come before generated abstract methods, which is not how the JDT API wants to generate them by default. Removed attempted workaround. The constructors will come last and user can re-arrange them as appropriate.

Please verify again.
Comment 22 Ram Venkataswamy CLA 2011-09-28 14:17:08 EDT
verified
Comment 23 Konstantin Komissarchik CLA 2011-09-28 14:27:14 EDT
Closing.