Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [sapphire-dev] java type action customizations

The issue is how you lookup the service. Here is the line in the create action handler:

 

JavaTypeConstraintService javaTypeConstraintService = property.service( JavaTypeConstraintService.class );

 

This looks up the service in property meta model context. That is, you have access to ModelProperty, but not IModelElement. To get access to ModelProperty and IModelElement, you need to look up the service in property instance context. Try this:

 

JavaTypeConstraintService javaTypeConstraintService = element.service( property, JavaTypeConstraintService.class );

 

- Konstantin

 

 

From: sapphire-dev-bounces@xxxxxxxxxxx [mailto:sapphire-dev-bounces@xxxxxxxxxxx] On Behalf Of Greg Amerson
Sent: Thursday, November 10, 2011 8:23 PM
To: Sapphire project
Subject: Re: [sapphire-dev] java type action customizations

 

Thanks Konstantin for targeting 0.4  I want this feature in my adopter product so I'm motivated to get it in this week.  

 

A quick question, in my local copy with my first patch attempt I have my own JavaTypeContraintService added to the particular model property where I want the dynamic behavior.  I'm seeing this my subclass of the service get called by the createClass action handler.  The problem is that in my service I need to be able to see the values of one of the sibling properties in the parent model element.  However, from a modelProperty, I'm not sure how to get adjacent model properties of the same parent element.  

 

In my service subclass I have:


@Override

public String[] type()  
{

            IModelElement element = context(IModelElement.class);

            // element is null

}

On Fri, Nov 11, 2011 at 12:02 PM, Greg Amerson <gregory.amerson@xxxxxxxxxxx> wrote:

I see and I could list for model property changes if I want to toggle enablement.

 

So on to the last point which is create and have a dynamic type.  Here is the enhancement request:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=363551

 

I'll do my best to contribute the patch.  I've attached a rough draft but it only handles the dynamic type(), the kind() and behavior() are not handled by the service.  I just wanted to see if this is in the right direction before continuing.  

 

On Fri, Nov 11, 2011 at 9:45 AM, Konstantin Komissarchik <konstantin.komissarchik@xxxxxxxxxx> wrote:

The applicability conditions associated with action handlers is only checked when the part is initialized, but applicability condition isn’t enablement. To change enablement of your action handler, you can call setEnabled() method. See ShowContactDetailsActionHandler in samples.

 

- Konstantin

 

 

From: sapphire-dev-bounces@xxxxxxxxxxx [mailto:sapphire-dev-bounces@xxxxxxxxxxx] On Behalf Of Greg Amerson
Sent: Thursday, November 10, 2011 2:52 PM
To: Sapphire project
Subject: Re: [sapphire-dev] java type action customizations

 

Hey Konstantin,

 

For Browse, 

 

I got the filter hooked up, no problem and am now contributing my own browse actions instead.  However, one thing I haven't figured out is how to disable one of my "browse" action on a particular property based on the state of the model, i.e. if another property has a value or not.  Can you do this with a Condition class?  I tried at first but I don't see the condition class get recalcuated based on a change in the model.  I am also using the @DependsOn annotation at the model level if that makes a difference.

 

 

 

 

On Wed, Nov 9, 2011 at 11:09 PM, Konstantin Komissarchik <konstantin.komissarchik@xxxxxxxxxx> wrote:

For Browse, 

 

I was wondering if it is possible to modify the filtering capabilities of the dialog.  In one case I need to filter from a list of classnames based on a regex pattern.  In another case I would like to filter classes shown based on the value of another property in the sapphire model.  So is there currently a method for plugging in arbitrary filtering logic for the browse action?   Or maybe overriding the default browse action and be able to extend it?

 

[kosta] There isn’t a built-in system to do what you are after, but you can use a filter to remove the system-provided action handler and attach your own implementation.

 

For Create,

 

I was wondering if there is a way to modify the "create" action to dynamically provide the value of the superclass to use for the new java type?   

 

I know that I add my own custom actions for "browse" and "create" but I wanted to see if we should add this type of capabilities to the framework instead before I wrote my own.  Thanks so much!

 

[kosta] Currently, @JavaTypeConstraint is read directly, so there isn’t a way to substitute dynamic behavior. I can see adding JavaTypeConstraintService like we’ve done in other similar situations. Please open an enhancement request.

 

 

 

From: sapphire-dev-bounces@xxxxxxxxxxx [mailto:sapphire-dev-bounces@xxxxxxxxxxx] On Behalf Of Greg Amerson
Sent: Wednesday, November 09, 2011 1:47 AM
To: Sapphire project
Subject: [sapphire-dev] java type action customizations

 

Hello again,

 

In case you haven't figured this out from all of my recent questions, I am in the process of migrating one of our big wizards that has lots of custom dialogs that needs enhancements and instead of fixing my current stuff, I want to move it all to a new sapphire based editor instead.  :)  I already asked one question about being able to toggle the enablement or disablement of java type actions in another post, so I wont add that in here.

 

This latest question has to do with customizing the default java type browse/create actions. Here is what I would like to do:

 

For Browse, 

 

I was wondering if it is possible to modify the filtering capabilities of the dialog.  In one case I need to filter from a list of classnames based on a regex pattern.  In another case I would like to filter classes shown based on the value of another property in the sapphire model.  So is there currently a method for plugging in arbitrary filtering logic for the browse action?   Or maybe overriding the default browse action and be able to extend it?

 

For Create,

 

I was wondering if there is a way to modify the "create" action to dynamically provide the value of the superclass to use for the new java type?   

 

I know that I add my own custom actions for "browse" and "create" but I wanted to see if we should add this type of capabilities to the framework instead before I wrote my own.  Thanks so much!

 

--

Greg Amerson

Liferay, Inc.


_______________________________________________
sapphire-dev mailing list
sapphire-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/sapphire-dev



 

--

Greg Amerson

Liferay, Inc.


_______________________________________________
sapphire-dev mailing list
sapphire-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/sapphire-dev



 

--

Greg Amerson

Liferay, Inc.



 

--

Greg Amerson

Liferay, Inc.


Back to the top