Package org.eclipse.sapphire.ui.forms

Examples of org.eclipse.sapphire.ui.forms.MasterDetailsEditorPageState


                final Element element = part.getLocalModelElement();
               
                if( element instanceof Item )
                {
                    final Item item = (Item) element;
                    final MasterDetailsEditorPageState state = page.state();
   
                    return new FunctionResult( this, context )
                    {
                        private Listener listener;
                       
                        @Override
                        protected void init()
                        {
                            this.listener = new FilteredListener<PropertyContentEvent>()
                            {
                                @Override
                                protected void handleTypedEvent( final PropertyContentEvent event )
                                {
                                    refresh();
                                }
                            };
                           
                            state.attach( this.listener, MasterDetailsEditorPageState.PROP_ATTRIBUTES.name() + "/*" );
                            element.property( Item.PROP_MANUFACTURER ).attach( this.listener );
                        }
   
                        @Override
                        protected Object evaluate()
                        {
                            final boolean color = state.getAttribute( ShowManufacturerColorActionHandler.ATTRIBUTE, false );
                           
                            if( color )
                            {
                                final String manufacturer = item.getManufacturer().content();
                                final int hashCode = ( manufacturer == null ? 0 : manufacturer.hashCode() );
                                final int index = abs( hashCode ) % IMAGES.length;
                               
                                return IMAGES[ index ];
                            }
                            else
                            {
                                return IMAGE_GENERIC;
                            }
                        }
   
                        @Override
                        public void dispose()
                        {
                            super.dispose();
                           
                            if( this.listener != null )
                            {
                                state.detach( this.listener, MasterDetailsEditorPageState.PROP_ATTRIBUTES.name() + "/*" );
                               
                                if( ! element.disposed() )
                                {
                                    element.property( Item.PROP_MANUFACTURER ).detach( this.listener );
                                }
View Full Code Here

TOP

Related Classes of org.eclipse.sapphire.ui.forms.MasterDetailsEditorPageState

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.