Package org.eclipse.sapphire.modeling

Examples of org.eclipse.sapphire.modeling.ModelPath$Segment


    @Override
    protected void init()
    {
        final WithDef def = (WithDef) this.definition;
       
        this.path = new ModelPath( substituteParams( def.getPath().text() ) );
        this.element = getModelElement();
       
        for( int i = 0, n = this.path.length(); i < n; i++ )
        {
            final ModelPath.Segment segment = this.path.segment( i );
View Full Code Here


       
        final ISapphireUiDef rootdef = this.definition.nearest( ISapphireUiDef.class );
        final PropertyEditorDef propertyEditorPartDef = (PropertyEditorDef) this.definition;
       
        final String propertyEditorPath = substituteParams( propertyEditorPartDef.getProperty().text() );
        this.property = getModelElement().property( new ModelPath( propertyEditorPath ) );
       
        if( this.property == null )
        {
            throw new RuntimeException( invalidPath.format( propertyEditorPath ) );
        }
       
        // Read the property to ensure that initial events are broadcast and avoid being surprised
        // by them later.
       
        this.property.empty();
       
        // Child properties.       
       
        final ListFactory<ModelPath> childPropertiesListFactory = ListFactory.start();
        final ElementType type = this.property.definition().getType();
       
        if( type != null )
        {
            if( propertyEditorPartDef.getChildProperties().isEmpty() )
            {
                for( PropertyDef childProperty : type.properties() )
                {
                    if( childProperty instanceof ValueProperty )
                    {
                        childPropertiesListFactory.add( new ModelPath( childProperty.name() ) );
                    }
                }
            }
            else
            {
                for( PropertyEditorDef childPropertyEditor : propertyEditorPartDef.getChildProperties() )
                {
                    final ModelPath childPropertyPath = new ModelPath( childPropertyEditor.getProperty().content() );
                    boolean invalid = false;
                   
                    if( childPropertyPath.length() == 0 )
                    {
                        invalid = true;
                    }
                    else
                    {
                        ElementType t = type;
                       
                        for( int i = 0, n = childPropertyPath.length(); i < n && ! invalid; i++ )
                        {
                            final ModelPath.Segment segment = childPropertyPath.segment( i );
                           
                            if( segment instanceof ModelPath.PropertySegment )
                            {
                                final PropertyDef p = t.property( ( (ModelPath.PropertySegment) segment ).getPropertyName() );
                               
                                if( p instanceof ValueProperty )
                                {
                                    if( i + 1 != n )
                                    {
                                        invalid = true;
                                    }
                                }
                                else if( p instanceof ImpliedElementProperty )
                                {
                                    if( i + 1 == n )
                                    {
                                        invalid = true;
                                    }
                                    else
                                    {
                                        t = p.getType();
                                    }
                                }
                                else
                                {
                                    invalid = true;
                                }
                            }
                            else
                            {
                                invalid = true;
                            }
                        }
                    }
                   
                    if( invalid )
                    {
                        final String msg = invalidChildPropertyPath.format( this.property.name(), childPropertyPath.toString() );
                        Sapphire.service( LoggingService.class ).logError( msg );
                    }
                    else
                    {
                        childPropertiesListFactory.add( childPropertyPath );
View Full Code Here

    }
   
    public PropertyEditorPart getChildPropertyEditor( final Element element,
                                                      final PropertyDef property )
    {
        return getChildPropertyEditor( element, new ModelPath( property.name() ) );
    }
View Full Code Here

public final class CustomDependenciesService extends DependenciesService
{
    @Override
    protected DependenciesServiceData compute()
    {
        return new DependenciesServiceData( new ModelPath( "Name" ), new ModelPath( "Id" ) );
    }
View Full Code Here

    public void testCustom1() throws Exception
    {
        final TestModel model = TestModel.TYPE.instantiate();
        final TestModelItem item = model.getItems().insert();
       
        assertEquals( set( new ModelPath( "Name" ), new ModelPath( "Id" ) ), dependencies( item.getCustom1() ) );
    }
View Full Code Here

    public void testCustom2() throws Exception
    {
        final TestModel model = TestModel.TYPE.instantiate();
        final TestModelItem item = model.getItems().insert();
       
        assertEquals( set( new ModelPath( "Name" ), new ModelPath( "Id" ), new ModelPath( "Custom1" ) ), dependencies( item.getCustom2() ) );
    }
View Full Code Here

    @Override
    protected void init()
    {
        final WithDef def = (WithDef) this.definition;
       
        this.path = new ModelPath( substituteParams( def.getPath().text() ) );
        this.property = (ElementHandle<?>) getModelElement().property( this.path );
       
        if( this.property == null )
        {
            throw new IllegalStateException();
View Full Code Here

    @Override
    public boolean setFocus( final ModelPath path )
    {
        if( this.path.isPrefixOf( path ) )
        {
            final ModelPath tail = path.makeRelativeTo( this.path );
           
            if( this.property == null || this.property.enabled() )
            {
                return super.setFocus( tail );
            }
View Full Code Here

        return false;
    }
   
    public final boolean setFocus( final String path )
    {
        return setFocus( new ModelPath( path ) );
    }
View Full Code Here

    public static PropertyEditorDef getChildPropertyEditor( final PropertyEditorDef propertyEditorDef,
                                                            final ModelPath property )
    {
        for( PropertyEditorDef childPropertyEditorDef : propertyEditorDef.getChildProperties() )
        {
            if( property.equals( new ModelPath( childPropertyEditorDef.getProperty().text() ) ) )
            {
                return childPropertyEditorDef;
            }
        }
       
View Full Code Here

TOP

Related Classes of org.eclipse.sapphire.modeling.ModelPath$Segment

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.