Package org.eclipse.sapphire.modeling

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


        private final ListenerContext listeners = new ListenerContext();
       
        public NodeFactory( final MasterDetailsContentNodeFactoryDef definition,
                            final Map<String,String> params )
        {
            final ModelPath path = new ModelPath( substituteParams( definition.getProperty().content(), params ) );
           
            Element element = getLocalModelElement();
            Property p = null;
           
            for( int i = 0, n = path.length(); i < n; i++ )
            {
                if( p != null )
                {
                    throw new RuntimeException( path.toString() );
                }
               
                final ModelPath.Segment segment = path.segment( i );
               
                if( segment instanceof ModelPath.ModelRootSegment )
                {
                    element = element.root();
                }
                else if( segment instanceof ModelPath.ParentElementSegment )
                {
                    element = element.parent().element();
                }
                else if( segment instanceof ModelPath.PropertySegment )
                {
                    final Property property = element.property( ( (ModelPath.PropertySegment) segment ).getPropertyName() );
                   
                    if( property != null && property.definition() instanceof ImpliedElementProperty )
                    {
                        element = ( (ElementHandle<?>) property ).content();
                    }
                    else if( property instanceof ElementList || property instanceof ElementHandle )
                    {
                        p = property;
                    }
                    else
                    {
                        throw new RuntimeException( path.toString() );
                    }
                }
                else
                {
                    throw new RuntimeException( path.toString() );
                }
            }
           
            if( p == null )
            {
                throw new RuntimeException( path.toString() );
            }
           
            this.property = p;
           
            this.propertyListener = new Listener()
View Full Code Here


    {
        super.init();

        final String pathString = ( (DetailSectionDef) this.definition ).getProperty().content();
        final String pathStringSubstituted = substituteParams( pathString, this.params );
        final ModelPath path = new ModelPath( pathStringSubstituted );
       
        this.element = getLocalModelElement();

        for( int i = 0, n = path.length(); i < n; i++ )
        {
            final ModelPath.Segment segment = path.segment( i );

            if( segment instanceof ModelPath.ModelRootSegment )
            {
                this.element = this.element.root();
            }
View Full Code Here

    @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

TOP

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

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.