Package org.eclipse.sapphire

Examples of org.eclipse.sapphire.Element


        initBindingMetadata();
    }
   
    private void initBindingMetadata()
    {
        final Element element = property().element();
        final PropertyDef property = property().definition();
       
        try
        {
            final XmlElementBinding xmlElementBindingAnnotation = property.getAnnotation( XmlElementBinding.class );
            final XmlNamespaceResolver xmlNamespaceResolver = ( (XmlResource) element.resource() ).getXmlNamespaceResolver();
           
            final SortedSet<ElementType> possible = this.possibleTypesService.types();
            this.modelElementTypes = possible.toArray( new ElementType[ possible.size() ] );

            if( xmlElementBindingAnnotation == null )
            {
                final XmlBinding xmlBindingAnnotation = property.getAnnotation( XmlBinding.class );
               
                if( xmlBindingAnnotation != null && possible.size() == 1 )
                {
                    final String path = xmlBindingAnnotation.path();
                    final int slashIndex = path.lastIndexOf( '/' );
                   
                    if( slashIndex == -1 )
                    {
                        this.xmlElementNames = new QName[] { createQualifiedName( path, xmlNamespaceResolver ) };
                    }
                    else if( slashIndex > 0 && slashIndex < path.length() - 1 )
                    {
                        this.path = new XmlPath( path.substring( 0, slashIndex ), xmlNamespaceResolver );
                        this.xmlElementNames = new QName[] { createQualifiedName( path.substring( slashIndex + 1 ), xmlNamespaceResolver ) };
                    }
                }
               
                if( this.xmlElementNames == null )
                {
                    this.path = new XmlPath( property.name(), ( (XmlResource) element.resource() ).getXmlNamespaceResolver() );
                   
                    this.xmlElementNames = new QName[ this.modelElementTypes.length ];
                   
                    for( int i = 0; i < this.modelElementTypes.length; i++ )
                    {
                        this.xmlElementNames[ i ] = createDefaultElementName( this.modelElementTypes[ i ], xmlNamespaceResolver );
                    }
                }
            }
            else
            {
                if( xmlElementBindingAnnotation.path().length() > 0 )
                {
                    this.path = new XmlPath( xmlElementBindingAnnotation.path(), xmlNamespaceResolver );
                }
               
                final XmlElementBinding.Mapping[] mappings = xmlElementBindingAnnotation.mappings();
                this.xmlElementNames = new QName[ this.modelElementTypes.length ];
               
                for( int i = 0; i < this.modelElementTypes.length; i++ )
                {
                    final ElementType type = this.modelElementTypes[ i ];
                           
                    for( XmlElementBinding.Mapping mapping : mappings )
                    {
                        if( mapping.type() == type.getModelElementClass() )
                        {
                            final String mappingElementName = mapping.element().trim();
                           
                            if( mappingElementName.length() == 0 )
                            {
                                throw new RuntimeException( mustSpecifyElementNameMsg.text() );
                            }

                            this.xmlElementNames[ i ] = createQualifiedName( mappingElementName, xmlNamespaceResolver );
                           
                            break;
                        }
                    }
                   
                    if( this.xmlElementNames[ i ] == null )
                    {
                        this.xmlElementNames[ i ] = createDefaultElementName( type, xmlNamespaceResolver );
                    }
                }
            }
        }
        catch( Exception e )
        {
            final String msg = failure.format( element.type().getSimpleName(), property.name(), e.getMessage() );
            throw new RuntimeException( msg, e );
        }
    }
View Full Code Here


    @Override
    protected void init()
    {
        super.init();

        final Element element = getLocalModelElement();
        final ListFactory<FormComponentPart> childPartsListFactory = ListFactory.start();
       
        final Listener childPartListener = new FilteredListener<PartValidationEvent>()
        {
            @Override
View Full Code Here

        return new Children()
        {
            @Override
            protected void init( final ListFactory<FormComponentPart> childPartsListFactory )
            {
                final Element element = getLocalModelElement();
               
                for( final PartDef childPartDef : definition().getContent() )
                {
                    childPartsListFactory.add( (FormComponentPart) createWithoutInit( FormPart.this, element, childPartDef, FormPart.this.params ) );
                }
View Full Code Here

        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();
                    }
View Full Code Here

            final ListFactory<MasterDetailsContentNodePart> nodes = ListFactory.start();
           
            for( final Iterator<Map.Entry<Element,MasterDetailsContentNodePart>> itr = this.nodesCache.entrySet().iterator(); itr.hasNext(); )
            {
                final Map.Entry<Element,MasterDetailsContentNodePart> entry = itr.next();
                final Element element = entry.getKey();
                final MasterDetailsContentNodePart node = entry.getValue();
               
                if( element.disposed() )
                {
                    node.dispose();
                }
            }
           
            for( Element element : elements() )
            {
                MasterDetailsContentNodePart node = this.nodesCache.get( element );
               
                if( node == null )
                {
                    MasterDetailsContentNodeDef relevantCaseDef = null;
                   
                    for( MasterDetailsContentNodeFactoryCaseDef entry : this.definition.getCases() )
                    {
                        final JavaType type = entry.getElementType().target();
                       
                        if( type == null )
                        {
                            relevantCaseDef = entry;
                            break;
                        }
                        else
                        {
                            final Class<?> cl = (Class<?>) type.artifact();
       
                            if( cl == null || cl.isAssignableFrom( element.getClass() ) )
                            {
                                relevantCaseDef = entry;
                                break;
                            }
                        }
View Full Code Here

               
                try
                {
                    for( String str : this.input )
                    {
                        final Element element = list.insert();
                        element.property( SlushBucketPropertyEditorPresentation.this.memberProperty ).write( str, true );
                        elements.add( element );
                    }
                }
                finally
                {
View Full Code Here

                    factory.merge( child.validation() );
                }
            }
            else if( this.property instanceof ElementHandle )
            {
                final Element child = ( (ElementHandle<?>) this.property ).content();
               
                if( child != null )
                {
                    factory.merge( child.validation() );
                }
            }
        }
       
        for( SapphirePart relatedContentPart : this.relatedContentParts )
View Full Code Here

    @Override
    protected void init()
    {
        super.init();
       
        final Element element = getModelElement();
        final ListFactory<TabGroupPagePart> pagesListFactory = ListFactory.start();

        final Listener tabPartListener = new FilteredListener<PartValidationEvent>()
        {
            @Override
View Full Code Here

    @Override
    protected void init()
    {
        super.init();

        final Element element = getModelElement();
        final ListFactory<PropertiesViewPagePart> pagesListFactory = ListFactory.start();
       
        final Listener pagePartListener = new FilteredListener<PartValidationEvent>()
        {
            @Override
View Full Code Here

        list.remove( 0 );
        assertEquals( 1, counter.read() );
        counter.reset();
       
        final Element a = list.insert();
        final Element b = list.insert();
        assertEquals( 2, counter.read() );
        counter.reset();
       
        list.moveDown( a );
        assertEquals( 1, counter.read() );
View Full Code Here

TOP

Related Classes of org.eclipse.sapphire.Element

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.