Package org.eclipse.sapphire

Examples of org.eclipse.sapphire.MasterVersionCompatibilityService


    private static void assertVersionCompatibility( final Element element,
                                                    final PropertyDef property,
                                                    final boolean expectedVersionCompatibility )
    {
        final MasterVersionCompatibilityService service = element.property( property ).service( MasterVersionCompatibilityService.class );
       
        assertNotNull( service );
        assertEquals( expectedVersionCompatibility, service.compatible() );
    }
View Full Code Here


   
    protected static final Function createVersionCompatibleFunction( final Property property )
    {
        if( property != null )
        {
            final MasterVersionCompatibilityService service = property.service( MasterVersionCompatibilityService.class );
           
            final Function function = new Function()
            {
                @Override
                public String name()
                {
                    return "VersionCompatible";
                }

                @Override
                public FunctionResult evaluate( final FunctionContext context )
                {
                    return new FunctionResult( this, context )
                    {
                        private Listener serviceListener;
                        private Listener propertyListener;
                       
                        @Override
                        protected void init()
                        {
                            this.serviceListener = new Listener()
                            {
                                @Override
                                public void handle( final Event event )
                                {
                                    refresh();
                                }
                            };
                           
                            service.attach( this.serviceListener );
                           
                            this.propertyListener = new FilteredListener<PropertyContentEvent>()
                            {
                                @Override
                                protected void handleTypedEvent( final PropertyContentEvent event )
                                {
                                    refresh();
                                }
                            };
                           
                            if( property.definition() instanceof ImpliedElementProperty )
                            {
                                property.element().attach( this.propertyListener, property.name() + "/*" );
                            }
                            else
                            {
                                property.element().attach( this.propertyListener, property.name() );
                            }
                        }

                        @Override
                        protected Object evaluate()
                        {
                            return service.compatible() || ! property.empty();
                        }
                       
                        @Override
                        public void dispose()
                        {
                            super.dispose();
                           
                            service.detach( this.serviceListener );

                            if( property.definition() instanceof ImpliedElementProperty )
                            {
                                property.element().detach( this.propertyListener, property.name() + "/*" );
                            }
View Full Code Here

TOP

Related Classes of org.eclipse.sapphire.MasterVersionCompatibilityService

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.