Package org.eclipse.sapphire

Examples of org.eclipse.sapphire.ElementType


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


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

       
        this.pageDefs = new LinkedHashMap<ElementType,FormDef>();
       
        for( final PageBookCaseDef cs : def.getCases() )
        {
            final ElementType type = ElementType.read( (Class<?>) cs.getElementType().target().artifact() );
            this.pageDefs.put( type, cs );
        }
       
        if( systemDefaultPageDef == null )
        {
View Full Code Here

    @Override
    public void init( final Element modelElement )
    {
        super.init( modelElement );

        final ElementType modelElementType = modelElement.type();
       
        final CustomXmlRootBinding customXmlRootBindingAnnotation = modelElementType.getAnnotation( CustomXmlRootBinding.class );
       
        if( customXmlRootBindingAnnotation != null )
        {
            try
            {
                this.rootElementController = customXmlRootBindingAnnotation.value().newInstance();
            }
            catch( Exception e )
            {
                Sapphire.service( LoggingService.class ).log( e );
            }
        }
       
        if( this.rootElementController == null )
        {
            final XmlBinding xmlBindingAnnotation = modelElementType.getAnnotation( XmlBinding.class );
   
            if( xmlBindingAnnotation != null && xmlBindingAnnotation.path().length() != 0 )
            {
                final XmlPath path = new XmlPath( xmlBindingAnnotation.path(), getXmlNamespaceResolver() );
                final QName qualifiedName = path.getSegment( 0 ).getQualifiedName();
                final String localName = qualifiedName.getLocalPart();
                final String prefix = qualifiedName.getPrefix();
                final String namespace = qualifiedName.getNamespaceURI();
               
                final XmlDocumentType xmlDocumentTypeAnnotation = modelElementType.getAnnotation( XmlDocumentType.class );
              
                if( xmlDocumentTypeAnnotation != null && xmlDocumentTypeAnnotation.systemId().length() != 0 )
                {
                    this.rootElementController = new DocumentTypeRootElementController( localName );
                }
                else
                {
                    final Map<String,String> schemas = new HashMap<String,String>();
                    final XmlSchemas xmlSchemasAnnotation = modelElementType.getAnnotation( XmlSchemas.class );
                   
                    if( xmlSchemasAnnotation != null )
                    {
                        for( XmlSchema xmlSchemaAnnotation : xmlSchemasAnnotation.value() )
                        {
                            final String xmlSchemaNamespace = xmlSchemaAnnotation.namespace().trim();
                            final String xmlSchemaLocation = xmlSchemaAnnotation.location().trim();
                           
                            if( xmlSchemaNamespace.length() != 0 && xmlSchemaLocation.length() != 0 )
                            {
                                schemas.put( xmlSchemaNamespace, xmlSchemaLocation );
                            }
                        }
                    }
                   
                    final XmlSchema xmlSchemaAnnotation = modelElementType.getAnnotation( XmlSchema.class );
                   
                    if( xmlSchemaAnnotation != null )
                    {
                        final String xmlSchemaNamespace = xmlSchemaAnnotation.namespace().trim();
                        final String xmlSchemaLocation = xmlSchemaAnnotation.location().trim();
View Full Code Here

        return this.sourcePage;
    }
   
    protected Element createModel()
    {
        ElementType type = this.type;
       
        if( type == null )
        {
            final EditorPageDef def = getDefinition( this.pageDefinitionId ).resolve();
           
            if( def == null )
            {
                throw new IllegalStateException();
            }
           
            final JavaType elementJavaType = def.getElementType().target();
            type = ElementType.read( (Class<?>) elementJavaType.artifact(), true );
        }
       
        final XmlEditorResourceStore store = createResourceStore( this.sourcePage );
        return type.instantiate( new RootXmlResource( store ) );
    }
View Full Code Here

            if( file != null && file.getName().toLowerCase().endsWith( ".xml" ) )
            {
                return true;
            }
           
            final ElementType type = context( ElementType.class );
           
            if( type != null && ( type.hasAnnotation( XmlBinding.class ) || type.hasAnnotation( CustomXmlRootBinding.class ) ) )
            {
                return 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() );
            }
       
            return property;
        }
       
View Full Code Here

           
            final WorkspaceFileType fileTypeAnnotation = operation.type().getAnnotation( WorkspaceFileType.class );
           
            if( fileTypeAnnotation != null )
            {
                final ElementType type = ElementType.read( fileTypeAnnotation.value() );
                final Resource resource = type.service( MasterConversionService.class ).convert( newFileHandle, Resource.class );
               
                if( resource != null )
                {
                    try
                    {
                        final Element element = type.instantiate( resource );
                       
                        try
                        {
                            element.initialize();
                            resource.save();
View Full Code Here

            if( persistedStateElementJavaType == null )
            {
                throw new IllegalStateException();
            }
           
            final ElementType persistedStateElementType = ElementType.read( (Class<?>) persistedStateElementJavaType.artifact() );
           
            try
            {
                final Resource resource = new RootXmlResource( new XmlResourceStore( file ) ) ;
               
                resource.setCorruptedResourceExceptionInterceptor
                (
                    new CorruptedResourceExceptionInterceptor()
                    {
                        @Override
                        public boolean shouldAttemptRepair()
                        {
                            return true;
                        }
                    }
                );
               
                this.state = persistedStateElementType.instantiate( resource );
            }
            catch( ResourceStoreException e )
            {
                this.state = persistedStateElementType.instantiate();
            }
        }
       
        return this.state;
    }
View Full Code Here

   
    @Override
    public ElementType type( final Resource resource )
    {
        final String text = ( (XmlResource) resource ).getXmlElement().getText();
        final ElementType type;
       
        if( text != null && text.toLowerCase().startsWith( AFTER_PREFIX ) )
        {
            type = ActionLocationHintAfter.TYPE;
        }
View Full Code Here

TOP

Related Classes of org.eclipse.sapphire.ElementType

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.