Package org.eclipse.sapphire.modeling.xml

Examples of org.eclipse.sapphire.modeling.xml.XmlResourceStore


                           
                            return super.adapt( adapterType );
                        }
                    };
                   
                    final XmlResourceStore xmlResourceStore = new XmlResourceStore( store );
                    final RootXmlResource resource = new RootXmlResource( xmlResourceStore );
                    final SapphireExtensionDef extension = SapphireExtensionDef.TYPE.instantiate( resource );
                    list.add( extension );
                }
                catch( ResourceStoreException e )
View Full Code Here


       
        try
        {
            try
            {
                resource = new RootXmlResource( new XmlResourceStore( new DefinitionLoaderResourceStore( stream, this.context ) ) );
            }
            catch( ResourceStoreException e )
            {
                throw new IllegalArgumentException( e );
            }
View Full Code Here

                           
                            return super.adapt( adapterType );
                        }
                    };
                   
                    final XmlResourceStore xmlResourceStore = new XmlResourceStore( store );
                    final RootXmlResource resource = new RootXmlResource( xmlResourceStore );
                    final ISapphireUiExtensionDef extension = ISapphireUiExtensionDef.TYPE.instantiate( resource );
                    list.add( extension );
                }
                catch( ResourceStoreException e )
View Full Code Here

           
            final ElementType persistedStateElementType = ElementType.read( (Class<?>) persistedStateElementJavaType.artifact() );
           
            try
            {
                final Resource resource = new RootXmlResource( new XmlResourceStore( file ) ) ;
               
                resource.setCorruptedResourceExceptionInterceptor
                (
                    new CorruptedResourceExceptionInterceptor()
                    {
View Full Code Here

            monitor.worked( 1 );
           
            try
            {
                final WorkspaceFileResourceStore fileResourceStore = new WorkspaceFileResourceStore( targetSchemaFile );
                final XmlResourceStore xmlResourceStore = new XmlResourceStore( fileResourceStore );
                final XmlElement root = new XmlElement( xmlResourceStore, xmlResourceStore.getDomDocument().getDocumentElement() );
               
                final String targetNamespace = root.getAttributeText( "targetNamespace" );
                String targetNamespacePrefix = null;
               
                for( XmlAttribute attribute : root.getAttributes() )
                {
                    final String name = attribute.getDomNode().getName();
                    final String value = attribute.getText();
                   
                    if( name.startsWith( "xmlns:" ) && value.equals( targetNamespace ) )
                    {
                        targetNamespacePrefix = name.substring( 6 );
                    }
                }
   
                final Set<String> included = new HashSet<String>();
                included.add( sourceSchemaFile.getLocation().toOSString() );
                while( inlineIncludes( root, sourceSchemaFile.getParent().getLocation().toOSString(), included ) );
               
                removeComments( root );
                removeAnnotations( root );
                removeDefaultMinMaxOccurs( root );
               
                if( operation.getRemoveWildcards().content() )
                {
                    removeWildcards( root );
                }
               
                exclude( root, operation.getExclusions() );
               
                final Map<String,XmlElement> types = new HashMap<String,XmlElement>();
                final Map<String,XmlElement> elements = new HashMap<String,XmlElement>();
                final Map<String,XmlElement> groups = new HashMap<String,XmlElement>();
               
                for( XmlElement element : root.getChildElements() )
                {
                    final String elname = element.getLocalName();
                   
                    if( elname.equals( "simpleType" ) || elname.equals( "complexType" ) )
                    {
                        String tname = element.getAttributeText( "name" );
                       
                        if( tname.length() > 0 )
                        {
                            if( targetNamespacePrefix != null )
                            {
                                tname = targetNamespacePrefix + ":" + tname;
                            }
                           
                            if( types.containsKey( tname ) )
                            {
                                element.remove();
                            }
                            else
                            {
                                types.put( tname, element );
                            }
                        }
                    }
                    else if( elname.equals( "element" ) )
                    {
                        String ename = element.getAttributeText( "name" );
                       
                        if( ename.length() > 0 )
                        {
                            if( targetNamespacePrefix != null )
                            {
                                ename = targetNamespacePrefix + ":" + ename;
                            }
                           
                            if( elements.containsKey( ename ) )
                            {
                                element.remove();
                            }
                            else
                            {
                                elements.put( ename, element );
                            }
                        }
                    }
                    else if( elname.equals( "group" ) )
                    {
                        String gname = element.getAttributeText( "name" );
                       
                        if( gname.length() > 0 )
                        {
                            if( targetNamespacePrefix != null )
                            {
                                gname = targetNamespacePrefix + ":" + gname;
                            }
                           
                            if( groups.containsKey( gname ) )
                            {
                                element.remove();
                            }
                            else
                            {
                                groups.put( gname, element );
                            }
                        }
                    }
                }
               
                changeSchemaNamespacePrefix( root.getDomNode().getOwnerDocument(), "xsd" );
               
                final Map<String,String> typeSubstitutions = new HashMap<String,String>();
               
                for( TypeSubstitution sub : operation.getTypeSubstitutions() )
                {
                    typeSubstitutions.put( sub.getBefore().content(), sub.getAfter().content() );
                }
               
                applyTypeSubstitutions( root, typeSubstitutions );
               
                boolean keepInlining = true;
               
                while( keepInlining )
                {
                    keepInlining =
                        inlineRestriction( root )
                        || inlineExtension( root )
                        || inlineSequenceInSequence( root )
                        || inlineSequenceInChoice( root )
                        || inlineTypes( root, types, SetFactory.<String>empty() )
                        || inlineElements( root, elements, SetFactory.<String>empty() )
                        || inlineGroups( root, groups, SetFactory.<String>empty() )
                        || removeRedundantMinMaxOccursInChoice( root );
                }
               
                for( XmlElement element : root.getChildElements() )
                {
                    final String elname = element.getLocalName();
                   
                    if( elname.equals( "simpleType" ) || elname.equals( "complexType" ) || elname.equals( "group" ) )
                    {
                        element.remove();
                    }
                }
               
                // If root elements are specified, remove all other top-level elements.
               
                if( ! operation.getRootElements().empty() )
                {
                    final SetFactory<String> rootsFactory = SetFactory.start();
                   
                    operation.visit
                    (
                        "RootElements/Name",
                        new PropertyVisitor()
                        {
                            @Override
                            public boolean visit( final Value<?> property )
                            {
                                rootsFactory.add( property.text() );
                                return true;
                            }
                        }
                    );
                   
                    final Set<String> roots = rootsFactory.result();
                           
                    for( XmlElement element : root.getChildElements() )
                    {
                        final String elname = element.getLocalName();
                       
                        if( elname.equals( "element" ) && ! roots.contains( element.getAttributeText( "name" ) ) )
                        {
                            element.remove();
                        }
                    }
                }
               
                sortChoiceContent( root );
                sortElementContent( root );
               
                if( operation.getSortSequenceContent().content() )
                {
                    sortSequenceContent( root );
                }
               
                sort( root );
               
                root.format();
               
                xmlResourceStore.save();
            }
            catch( ResourceStoreException e )
            {
                return Status.createErrorStatus( e );
            }
View Full Code Here

                else
                {
                    includedSchemaResourceStore = new FileResourceStore( new File( includedSchemaLocation ) );
                }
           
                final XmlResourceStore xmlResourceStore = new XmlResourceStore( includedSchemaResourceStore );
                final XmlElement includedSchemaRoot = new XmlElement( xmlResourceStore, xmlResourceStore.getDomDocument().getDocumentElement() );
   
                for( XmlElement includedSchemaElement : includedSchemaRoot.getChildElements() )
                {
                    final Element inlinedDomNode = (Element) document.importNode( includedSchemaElement.getDomNode(), true );
                    rootDomNode.insertBefore( inlinedDomNode, includeElementDomNode );
View Full Code Here

    {
      String fileName = computeLayoutFileName(this.editorInput);
      if (fileName != null)
      {
        File layoutFile = getLayoutPersistenceFile(fileName);
        final XmlResourceStore resourceStore = new XmlResourceStore( new FileResourceStore(layoutFile));
        layoutModel = StandardDiagramLayout.TYPE.instantiate(new RootXmlResource( resourceStore ));     
      }
    }
    catch (Exception e)
    {
View Full Code Here

    try
    {
      String fileName = computeLayoutFileName(this.editorInput);
      if (fileName != null)
      {
        final XmlResourceStore resourceStore;
       
        if (this.editorInput instanceof IFileEditorInput)
        {
          IFileEditorInput fileInput = (IFileEditorInput)this.editorInput;
          IFolder layoutFolder = (IFolder)fileInput.getFile().getParent();
          IFile layoutFile = layoutFolder.getFile(fileName);
          resourceStore = new XmlResourceStore( new WorkspaceFileResourceStore(layoutFile));
        }
          else if (this.editorInput instanceof FileStoreEditorInput)
          {
            FileStoreEditorInput fileStoreInput = (FileStoreEditorInput)this.editorInput;
              IFileStore store = EFS.getStore(fileStoreInput.getURI());
              File localFile = store.toLocalFile(EFS.NONE, null);
            //if no local file is available, obtain a cached file
            if (localFile == null)
              localFile = store.toLocalFile(EFS.CACHE, null);
            if (localFile == null)
              throw new IllegalArgumentException();
            File layoutFile = new File(localFile.getParentFile(), fileName);
            resourceStore = new XmlResourceStore( new FileResourceStore(layoutFile));
          }
          else
          {
              throw new IllegalStateException();
          }
View Full Code Here

      if (fileName != null)
      {
        IFile layoutFile = getLayoutPersistenceFile(fileName);
        if (layoutFile != null)
        {
          final XmlResourceStore resourceStore = new XmlResourceStore( new WorkspaceFileResourceStore(layoutFile));
          layoutModel = StandardDiagramLayout.TYPE.instantiate(new RootXmlResource( resourceStore ));
        }
      }
    }
    catch (Exception e)
View Full Code Here

    @Test
   
    public void testValueProperties1() throws Exception
    {
        final ByteArrayResourceStore resourceStore = new ByteArrayResourceStore();
        final XmlResourceStore xmlResourceStore = new XmlResourceStore( resourceStore );
        final XmlBindingTestModel model = XmlBindingTestModel.TYPE.instantiate( new RootXmlResource( xmlResourceStore ) );
       
        testValueProperties( resourceStore, model, loadResource( XmlBindingTests.class.getSimpleName() + ".testValueProperties1.txt" ) );
    }
View Full Code Here

TOP

Related Classes of org.eclipse.sapphire.modeling.xml.XmlResourceStore

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.