当前位置: 首页>>代码示例>>Java>>正文


Java ModelSource类代码示例

本文整理汇总了Java中org.netbeans.modules.xml.xam.ModelSource的典型用法代码示例。如果您正苦于以下问题:Java ModelSource类的具体用法?Java ModelSource怎么用?Java ModelSource使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ModelSource类属于org.netbeans.modules.xml.xam包,在下文中一共展示了ModelSource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createMetaSchemaModel

import org.netbeans.modules.xml.xam.ModelSource; //导入依赖的package包/类
private SchemaModel createMetaSchemaModel() {
    try {
        InputStream in = getClass().getResourceAsStream("XMLSchema.xsd"); //NOI18N
        try {
            javax.swing.text.Document d = AbstractDocumentModel.
                    getAccessProvider().loadSwingDocument(in);
            ModelSource ms = new ModelSource(Lookups.singleton(d), false);
            SchemaModel m = SchemaModelFactory.getDefault().createFreshModel(ms);
            m.sync();
            return m;
        } finally {
            in.close();
        }
    } catch (Exception ex) {
        //just catch
    } 
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:MetaSchemaModelProvider.java

示例2: createModelSource

import org.netbeans.modules.xml.xam.ModelSource; //导入依赖的package包/类
/**
 * This method could be overridden by the Unit testcase to return a special
 * ModelSource object for a FileObject with custom impl of classes added to the lookup.
 * This is optional if both getDocument(FO) and createCatalogModel(FO) are overridden.
 */
protected ModelSource createModelSource(final FileObject thisFileObj, boolean editable) throws CatalogModelException{
    assert thisFileObj != null : "Null file object.";
    final CatalogModel catalogModel = createCatalogModel(thisFileObj);
    final DataObject dobj;
    try {
        dobj = DataObject.find(thisFileObj);
    } catch (DataObjectNotFoundException ex) {
        throw new CatalogModelException(ex);
    }
    Lookup proxyLookup = Lookups.proxy(
            new Lookup.Provider() {
        public Lookup getLookup() {
            return Lookups.fixed(new Object[] {
                FileUtil.toFile(thisFileObj),
                thisFileObj,
                getDocument(dobj.getPrimaryFile()),
                dobj,
                catalogModel
            });
        }
    }
    );
    return new ModelSource(proxyLookup, editable);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:TestCatalogModel.java

示例3: createTestModelSource

import org.netbeans.modules.xml.xam.ModelSource; //导入依赖的package包/类
public ModelSource createTestModelSource(FileObject fo, boolean editable) throws CatalogModelException{
    final DataObject dobj;
    final CatalogModel catalogModel = createCatalogModel(fo);
    try {
        dobj = DataObject.find(fo);
    } catch (DataObjectNotFoundException ex) {
        throw new CatalogModelException(ex);
    }
    Lookup lookup = Lookups.proxy(new Lookup.Provider() {
        public Lookup getLookup() {
                    return Lookups.fixed(new Object[] {
                        dobj.getPrimaryFile(),
                        getDocument(dobj.getPrimaryFile()),
                        dobj,
                        catalogModel
                    });
        }
    } );
    return new ModelSource(lookup, editable);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:TestCatalogModel.java

示例4: runTaskWithinContext

import org.netbeans.modules.xml.xam.ModelSource; //导入依赖的package包/类
@Override
public void runTaskWithinContext(Lookup context, Task task) {
    JTextComponent component = context.lookup(JTextComponent.class);
    if (component != null) {
        DataObject dobj = NbEditorUtilities.getDataObject(component.getDocument());
        if (dobj != null) {
            FileObject fo = dobj.getPrimaryFile();
            ModelSource ms = Utilities.createModelSource(fo);
            SettingsModel model = SettingsModelFactory.getDefault().getModel(ms);
            if (model != null) {
                Lookup newContext = new ProxyLookup(context, Lookups.fixed(model));
                task.run(newContext);
                return;
            }
        }
    }
    task.run(context);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:SettingsContextProvider.java

示例5: runTaskWithinContext

import org.netbeans.modules.xml.xam.ModelSource; //导入依赖的package包/类
@Override
public void runTaskWithinContext(Lookup context, Task task) {
    JTextComponent component = context.lookup(JTextComponent.class);
    if (component != null) {
        DataObject dobj = NbEditorUtilities.getDataObject(component.getDocument());
        if (dobj != null) {
            FileObject fo = dobj.getPrimaryFile();
            ModelSource ms = Utilities.createModelSource(fo);
            if (ms.isEditable()) {
                POMModel model = POMModelFactory.getDefault().getModel(ms);
                if (model != null) {
                    Lookup newContext = new ProxyLookup(context, Lookups.fixed(model));
                    task.run(newContext);
                    return;
                }
            }
        }
    }
    task.run(context);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:ContextProvider.java

示例6: getModelSourceFromSystemWideCatalog

import org.netbeans.modules.xml.xam.ModelSource; //导入依赖的package包/类
private ModelSource getModelSourceFromSystemWideCatalog(URI locationURI,
        ModelSource modelSourceOfSourceDocument) {
    if( locationURI == null)
        return null;
    
    try {
        Lookup.Template templ = new Lookup.Template(CatalogModel.class);
        Lookup.Result res = Lookup.getDefault().lookup(templ);
        Collection impls = res.allInstances();
        for(Object obj : impls){
            CatalogModel cm = (CatalogModel) obj;
            return cm.getModelSource(locationURI,
                    modelSourceOfSourceDocument);
        }
    } catch (CatalogModelException ex) {
        //return null
    }
    
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:CatalogModelImpl.java

示例7: createModelSource

import org.netbeans.modules.xml.xam.ModelSource; //导入依赖的package包/类
public static ModelSource createModelSource(final FileObject thisFileObj, boolean editable) throws CatalogModelException{
    assert thisFileObj != null : "Null file object.";
    final DataObject dobj;
    try {
        dobj = DataObject.find(thisFileObj);
    } catch (DataObjectNotFoundException ex) {
        throw new CatalogModelException(ex);
    }
    final Document document = getDocument(thisFileObj);
    Lookup proxyLookup = Lookups.proxy(
            new Lookup.Provider() {
        public Lookup getLookup() {
            return Lookups.fixed(new Object[] {
                FileUtil.toFile(thisFileObj),
                thisFileObj,
                document,
                dobj
            });
        }
    }
    );
    return new ModelSource(proxyLookup, editable);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:TestUtil.java

示例8: resolveImportedModel

import org.netbeans.modules.xml.xam.ModelSource; //导入依赖的package包/类
public DocumentModel resolveImportedModel() throws CatalogModelException {
    ModelSource ms = resolveModel(getLocation());
    
    String location = getLocation().toLowerCase(Locale.US);
    if (location.endsWith(".wsdl")) { //NOI18N
        return loadAsWSDL(ms);
    } else if (location.endsWith(".xsd")) { //NOI18N
        return loadAsSchema(ms);
    } else {
        DocumentModel m = loadAsWSDL(ms);
        if (m == null) {
            m = loadAsSchema(ms);
        }
        return m;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:ImportImpl.java

示例9: validate

import org.netbeans.modules.xml.xam.ModelSource; //导入依赖的package包/类
private void validate(URI uri, int expectedErrorCount)
   throws Exception {
   Validation v = new Validation();
   
   ModelSource ms = TestCatalogModel.getDefault().getModelSource(uri);
   MyModelSource source = new MyModelSource(ms.getLookup(), ms.isEditable(), uri);
   
   WSDLModel model = WSDLModelFactory.getDefault().getModel(source);
   
   WSDLSchemaValidator instance = new WSDLSchemaValidator();
   ValidationResult vr = instance.validate(model, v, Validation.ValidationType.COMPLETE);
   assertNotNull(vr.getValidationResult());
   
   ValidationHelper.dumpErrors(vr);
   assertTrue("expect error " + expectedErrorCount,  vr.getValidationResult().size() == expectedErrorCount);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:WSDLInlineSchemaValidatorTest.java

示例10: createTestModelSource

import org.netbeans.modules.xml.xam.ModelSource; //导入依赖的package包/类
public ModelSource createTestModelSource(FileObject fo, boolean editable) throws CatalogModelException{
    final DataObject dobj;
    final CatalogModel catalogModel = createCatalogModel(fo);
    try {
        dobj = DataObject.find(fo);
    } catch (DataObjectNotFoundException ex) {
        throw new CatalogModelException(ex);
    }
    Lookup lookup = Lookups.proxy(new Lookup.Provider() {
        public Lookup getLookup() {
                    return Lookups.fixed(new Object[] {
                        dobj.getPrimaryFile(),
                        getDocument(dobj.getPrimaryFile()),
                        dobj,
                        catalogModel
                    });

        }
    } );
    return new ModelSource(lookup, editable);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:TestCatalogModel.java

示例11: generateXML

import org.netbeans.modules.xml.xam.ModelSource; //导入依赖的package包/类
public void generateXML(String rootElement) {        
    //TO DO better exception handling
    if(rootElement == null || schemaFileName == null || schemaFileName.equals("") || rootElement.equals(""))
            return;
    File f = new File(schemaFileName);
    f = FileUtil.normalizeFile(f);
    FileObject fObj =FileUtil.toFileObject(f);
    //temp fix to handle http based xsd files
    if(fObj == null)
        return;
    ModelSource ms = null;
    try {
        ms = Utilities.createModelSource(fObj, true);
    } catch (Exception e){
        //dont do anything
        return;
    }
    if(ms == null)
        return;
    SchemaModel model = SchemaModelFactory.getDefault().getModel(ms);
    if (model.getSchema() == null) {
        return;
    }
    generateXML(rootElement, model);
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:XMLGeneratorVisitor.java

示例12: testSettings

import org.netbeans.modules.xml.xam.ModelSource; //导入依赖的package包/类
public void testSettings() throws Exception {
    ModelSource source = createModelSource("settings.xml");
    try {
        assertTrue(source.isEditable());
        SettingsModel model = SettingsModelFactory.getDefault().getModel(source);
        assertNotNull(model.getRootComponent());
        Settings prj = model.getSettings();
        assertNotNull(prj);

        List<org.netbeans.modules.maven.model.settings.Profile> profiles = prj.getProfiles();
        assertNotNull(profiles);
        assertNotNull(prj.findProfileById("mkleint"));

        List<String> actives = prj.getActiveProfiles();
        assertNotNull(actives);
        assertEquals("mkleint", actives.get(0));
    } finally {
        File file = source.getLookup().lookup(File.class);
        file.deleteOnExit();
    }

}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:ModelTest.java

示例13: getModelSource

import org.netbeans.modules.xml.xam.ModelSource; //导入依赖的package包/类
public ModelSource getModelSource(URI locationURI,
        ModelSource modelSourceOfSourceDocument) throws CatalogModelException {
    //
    FileObject sourceFo = modelSourceOfSourceDocument.getLookup().lookup(FileObject.class);
    assert sourceFo != null : "Source file object has to be specified in the lookup";
    //
    FileObject fo = sourceFo.getParent().getFileObject(locationURI.toString());
    // assert fo != null : "Unknown file: " + locationURI.toString();
    if (fo == null) {
        return null;
    }
    //
    Document doc = getDocument(fo);
    assert doc != null : "Can't load the document: " + locationURI.toString();
    //
    Lookup lookup = Lookups.fixed(fo, doc, this, FileObjectModelAccessProvider.getDefault());
    ModelSource ms = new ModelSource(lookup, modelSourceOfSourceDocument.isEditable());
    //
    return ms;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:TestCatalogModel2.java

示例14: testReadUsingXDM

import org.netbeans.modules.xml.xam.ModelSource; //导入依赖的package包/类
public void testReadUsingXDM() throws Exception {
    long start = System.currentTimeMillis();
    javax.swing.text.Document sd = new BaseDocument(true, "text/xml"); //NOI18N
    XDMModel model = null;

    InputStreamReader reader = new InputStreamReader(getClass().getResourceAsStream(SCHEMA_FILE),"UTF-8");
    insertStringInDocument(reader, sd);

    start = System.currentTimeMillis();
    Lookup lookup = Lookups.singleton(sd);
    ModelSource ms = new ModelSource(lookup, true);
    model = new XDMModel(ms);
    model.sync();
    this.assertNotNull("XDM model didn't get created!!!", model);
    long end = System.currentTimeMillis();
    System.out.println("Time taken to parse using XDM: " + (end-start) + "ms.\n");
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:XDMPerfNumberTest.java

示例15: getModelSource

import org.netbeans.modules.xml.xam.ModelSource; //导入依赖的package包/类
public ModelSource getModelSource(URI locationURI,
        ModelSource modelSourceOfSourceDocument) throws CatalogModelException {
    InputStream inputStream = null;
    try {
        UserCatalog cat = UserCatalog.getDefault();
        // mainly for unit tests
        if (cat == null) {
            return null;
        }
        EntityResolver resolver = cat.getEntityResolver();
        InputSource src = resolver.resolveEntity(null, locationURI.toString());
        if(src != null) {
            inputStream = new URL(src.getSystemId()).openStream();
        } else {
            javax.xml.transform.Source isrc = ((javax.xml.transform.URIResolver)resolver).
                    resolve(locationURI.toString(), null);
            if(isrc != null)
                inputStream = new URL(isrc.getSystemId()).openStream();
        }
        if(inputStream != null)
            return createModelSource(inputStream);
    } catch (Exception ex) {
        throw new CatalogModelException(ex);
    }
    
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:RuntimeCatalogModel.java


注:本文中的org.netbeans.modules.xml.xam.ModelSource类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。