Package org.eclipse.sapphire

Examples of org.eclipse.sapphire.PropertyDef


    }
   
    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


public final class JavaTypeJumpActionHandlerCondition extends PropertyEditorCondition
{
    @Override
    protected boolean evaluate( final PropertyEditorPart part )
    {
        final PropertyDef property = part.property().definition();
       
        if( property instanceof ValueProperty && property.isOfType( JavaTypeName.class ) )
        {
            final Reference referenceAnnotation = property.getAnnotation( Reference.class );
           
            if( referenceAnnotation != null && referenceAnnotation.target() == JavaType.class )
            {
                return true;
            }
View Full Code Here

       
        final SortedSet<PropertyDef> allMemberProperties = this.memberType.properties();
       
        if( allMemberProperties.size() == 1 )
        {
            final PropertyDef prop = allMemberProperties.first();
           
            if( prop instanceof ValueProperty )
            {
                this.memberProperty = (ValueProperty) prop;
            }
View Full Code Here

            {
                final SortedSet<PropertyDef> properties = property.definition().getType().properties();
               
                if( properties.size() == 1 )
                {
                    final PropertyDef memberProperty = properties.first();
                   
                    if( memberProperty instanceof ValueProperty &&
                        memberProperty.hasAnnotation( Unique.class ) &&
                        Enum.class.isAssignableFrom( memberProperty.getTypeClass() ) )
                    {
                        return new CheckBoxListPropertyEditorPresentation( part, parent, composite );
                    }
                }
            }
View Full Code Here

                        {
                            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;
View Full Code Here

        if( propertyName != null )
        {
            propertyName = substituteParams( propertyName.trim(), params );
           
            final ElementType type = modelElement.type();
            final PropertyDef property = type.property( propertyName );
           
            if( property == null )
            {
                throw new RuntimeException( "Could not find property " + propertyName + " in " + type.getQualifiedName() );
            }
View Full Code Here

        final Listener listener = new FilteredListener<PropertyEvent>()
        {
            @Override
            protected void handleTypedEvent( final PropertyEvent event )
            {
                final PropertyDef property = event.property().definition();
                final IEventAttachment attachment = (IEventAttachment) element();
               
                if( property == org.eclipse.sapphire.samples.calendar.IEventAttachment.PROP_LOCAL_COPY_LOCATION )
                {
                    attachment.getLocalCopyLocation().refresh();
View Full Code Here

    }
   
    @Override
    protected PropertyBinding createBinding( final Property property )
    {
        final PropertyDef pdef = property.definition();
       
        if( pdef == IEventAttachment.PROP_LOCAL_COPY_LOCATION )
        {
            return new ValuePropertyBinding()
            {
View Full Code Here

    }
   
    public static PropertyDef resolveProperty( final ISapphireUiDef def,
                                                 final String qualifiedPropertyName )
    {
        PropertyDef property = null;
       
        if( qualifiedPropertyName != null )
        {
            final int dot = qualifiedPropertyName.indexOf( '.' );
            final String className = qualifiedPropertyName.substring( 0, dot );
View Full Code Here

        final Listener listener = new FilteredListener<PropertyEvent>()
        {
            @Override
            protected void handleTypedEvent( final PropertyEvent event )
            {
                final PropertyDef property = event.property().definition();
                final IEvent calevent = (IEvent) element();
               
                if( property == org.eclipse.sapphire.samples.calendar.IEvent.PROP_SUBJECT )
                {
                    calevent.getSubject().refresh();
View Full Code Here

TOP

Related Classes of org.eclipse.sapphire.PropertyDef

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.