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


Java UniFileLoader类代码示例

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


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

示例1: testUnmodifiedDocumentSaveAs

import org.openide.loaders.UniFileLoader; //导入依赖的package包/类
public void testUnmodifiedDocumentSaveAs() throws IOException {
    FileUtil.createData(FileUtil.getConfigRoot(), "someFolder/someFile.obj");
    
    DataObject obj = DataObject.find(FileUtil.getConfigFile("someFolder/someFile.obj"));
    assertEquals( MyDataObject.class, obj.getClass());
    assertTrue( "we need UniFileLoader", obj.getLoader() instanceof UniFileLoader );
    
    MyEnv env = new MyEnv( obj );
    MyDataEditorSupport des = new MyDataEditorSupport( obj, env );
    
    FileObject newFolder = FileUtil.createFolder(FileUtil.getConfigRoot(), "otherFolder");
    
    des.saveAs( newFolder, "newFile.newExt" );
    
    DataObject newObj = DataObject.find(FileUtil.getConfigFile("otherFolder/newFile.newExt"));
    assertEquals( MyDataObject.class, newObj.getClass());
    MyDataObject myObj = (MyDataObject)newObj;
    
    assertEquals("the original document was closed", 1, des.closeCounter );
    assertEquals("we don't ask before closing the original document", 0, des.canCloseCounter );
    assertEquals("new document was opened", 1, myObj.openCookieCalls);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:DataEditorSupportSaveAsTest.java

示例2: testModifiedDocumentSaveAs

import org.openide.loaders.UniFileLoader; //导入依赖的package包/类
public void testModifiedDocumentSaveAs() throws IOException {
    FileUtil.createData(FileUtil.getConfigRoot(), "someFolder/someFile.obj");
    
    DataObject obj = DataObject.find(FileUtil.getConfigFile("someFolder/someFile.obj"));
    assertEquals( MyDataObject.class, obj.getClass());
    assertTrue( "we need UniFileLoader", obj.getLoader() instanceof UniFileLoader );
    
    obj.setModified( true );
    
    MyEnv env = new MyEnv( obj );
    MyDataEditorSupport des = new MyDataEditorSupport( obj, env );
    
    FileObject newFolder = FileUtil.createFolder(FileUtil.getConfigRoot(), "otherFolder");
    
    des.saveAs( newFolder, "newFile.newExt" );
    
    DataObject newObj = DataObject.find(FileUtil.getConfigFile("otherFolder/newFile.newExt"));
    assertEquals( MyDataObject.class, newObj.getClass());
    MyDataObject myObj = (MyDataObject)newObj;
    
    assertEquals("the original StyledDocument was rendered (no file copy)", 1, des.renderCounter);
    assertFalse("the original document is no longer modified", obj.isModified() );
    assertEquals("the original document was closed", 1, des.closeCounter );
    assertEquals("we don't ask before closing the original document", 0, des.canCloseCounter );
    assertTrue("new document was opened", myObj.openCookieCalls > 0);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:DataEditorSupportSaveAsTest.java

示例3: testRename

import org.openide.loaders.UniFileLoader; //导入依赖的package包/类
/** Test updating document property Document.TitleProperty when dataobject is renamed */
public void testRename () throws IOException {
    FileUtil.createData(FileUtil.getConfigRoot(), "someFolder/someFile.obj");
    
    DataObject obj = DataObject.find(FileUtil.getConfigFile("someFolder/someFile.obj"));
    assertEquals( MyDataObject.class, obj.getClass());
    assertTrue( "we need UniFileLoader", obj.getLoader() instanceof UniFileLoader );

    EditorCookie ec = obj.getCookie(EditorCookie.class);
    
    StyledDocument doc = ec.openDocument();

    String val = (String) doc.getProperty(Document.TitleProperty);
    assertTrue("Test property value", val.startsWith("someFolder/someFile.obj"));

    obj.rename("newFile");

    val = (String) doc.getProperty(Document.TitleProperty);
    assertTrue("Test property value", val.startsWith("someFolder/newFile.obj"));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:DocumentTitlePropertyTest.java

示例4: testDocumentId

import org.openide.loaders.UniFileLoader; //导入依赖的package包/类
public void testDocumentId () throws IOException {
    FileUtil.createData(FileUtil.getConfigRoot(), "someFolder/someFile.obj");
    FileUtil.createData(FileUtil.getConfigRoot(), "someFolder/someFile.txt");
    
    DataObject obj = DataObject.find(FileUtil.getConfigFile("someFolder/someFile.obj"));
    DataObject txt = DataObject.find(FileUtil.getConfigFile("someFolder/someFile.txt"));
    assertEquals( MyDataObject.class, obj.getClass());
    assertTrue( "we need UniFileLoader", obj.getLoader() instanceof UniFileLoader );

    CloneableEditorSupport ecobj = (CloneableEditorSupport) obj.getCookie(EditorCookie.class);
    CloneableEditorSupport ectxt = (CloneableEditorSupport) txt.getCookie(EditorCookie.class);
    
    if (ecobj.documentID().equals(ectxt.documentID())) {
        fail("The same ID: " + ectxt.documentID());
    }
    assertEquals("Should be full name of the fileObj", obj.getPrimaryFile().getNameExt(), ecobj.documentID());
    assertEquals("Should be full name of the txtObj", txt.getPrimaryFile().getNameExt(), ectxt.documentID());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:DocumentTitlePropertyTest.java

示例5: testMove

import org.openide.loaders.UniFileLoader; //导入依赖的package包/类
/** Test updating document property Document.TitleProperty when dataobject is moved */
public void testMove () throws IOException {
    FileUtil.createData(FileUtil.getConfigRoot(), "someFolder/someFile.obj");
    FileUtil.createFolder(FileUtil.getConfigRoot(), "newFolder");

    DataObject obj = DataObject.find(FileUtil.getConfigFile("someFolder/someFile.obj"));
    DataFolder dFolder = (DataFolder) DataObject.find(FileUtil.getConfigFile("newFolder"));

    assertEquals( MyDataObject.class, obj.getClass());
    assertTrue( "we need UniFileLoader", obj.getLoader() instanceof UniFileLoader );

    EditorCookie ec = obj.getCookie(EditorCookie.class);

    StyledDocument doc = ec.openDocument();

    String val = (String) doc.getProperty(Document.TitleProperty);
    assertTrue("Test property value", val.startsWith("someFolder/someFile.obj"));

    obj.move(dFolder);

    val = (String) doc.getProperty(Document.TitleProperty);
    assertTrue("Test property value", val.startsWith("newFolder/someFile.obj"));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:DocumentTitlePropertyTest.java

示例6: HtmlDataObject

import org.openide.loaders.UniFileLoader; //导入依赖的package包/类
/** New instance.
 * @param pf primary file object for this data object
 * @param loader the data loader creating it
 * @exception DataObjectExistsException if there was already a data object for it
 */
public HtmlDataObject(FileObject pf, UniFileLoader loader) throws DataObjectExistsException {
    super(pf, loader);
    CookieSet set = getCookieSet();
    set.add(HtmlEditorSupport.class, this);
    set.add(ViewSupport.class, this);
    set.assign(SaveAsCapable.class, new SaveAsCapable() {
        public void saveAs( FileObject folder, String fileName ) throws IOException {
            HtmlEditorSupport es = getCookie( HtmlEditorSupport.class );
            try {
                es.updateEncoding();
                es.saveAs( folder, fileName );
            } catch (UserCancelException e) {
                //ignore, just not save anything
            }
        }
    });

    set.assign(FileEncodingQueryImplementation.class, new FileEncodingQueryImpl());
            
    //add check/validate xml cookies
    InputSource in = DataObjectAdapters.inputSource(this);
    set.add(new ValidateXMLSupport(in));
    set.add(new CheckXMLSupport(in));
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:HtmlDataObject.java

示例7: getAdditionalBeanInfo

import org.openide.loaders.UniFileLoader; //导入依赖的package包/类
public BeanInfo[] getAdditionalBeanInfo() {
    try {
        return new BeanInfo[] {Introspector.getBeanInfo(UniFileLoader.class)};
    } catch (IntrospectionException ie) {
        throw new AssertionError(ie);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:JarDataLoaderBeanInfo.java

示例8: getAdditionalBeanInfo

import org.openide.loaders.UniFileLoader; //导入依赖的package包/类
@Override
public BeanInfo[] getAdditionalBeanInfo() {
    try {
        return new BeanInfo[]{Introspector.getBeanInfo(UniFileLoader.class)};
    } catch (IntrospectionException e) {
        throw new AssertionError(e);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:SpringXMLConfigDataLoaderBeanInfo.java

示例9: getAdditionalBeanInfo

import org.openide.loaders.UniFileLoader; //导入依赖的package包/类
public BeanInfo[] getAdditionalBeanInfo() {
    try {
        return new BeanInfo[] {Introspector.getBeanInfo(UniFileLoader.class)};
    } catch (IntrospectionException e) {
        throw new AssertionError(e);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:WhereUsedDataLoaderBeanInfo.java

示例10: testRename

import org.openide.loaders.UniFileLoader; //导入依赖的package包/类
/**
 * Test that fileChange event from FileObject.refresh in DES.Env.getTime is ignored
 * ie. no property change event from DES.Env is fired.
 */
public void testRename () throws IOException {
    counter = 0;
    FileObject folder = FileUtil.toFileObject(getWorkDir());
    FileObject fo = FileUtil.createData(folder,"someFile.obj");
    
    DataObject obj = DataObject.find(fo);
    assertEquals( MyDataObject.class, obj.getClass());
    assertTrue( "we need UniFileLoader", obj.getLoader() instanceof UniFileLoader );

    EditorCookie ec = obj.getCookie(EditorCookie.class);

    DataEditorSupport des = (DataEditorSupport) ec;
    DataEditorSupport.Env env = (DataEditorSupport.Env) des.desEnv();

    File file = FileUtil.toFile(fo);
    //Set lastModified time to future so openDocument -> getTime -> FileObject.refresh
    //will generate fileChange event. fileChange event must be ignored in DES.Env to avoid
    //firing propertyChange event.
    file.setLastModified(file.lastModified() + 1000000L);
    
    env.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            counter++;
        }
    });
    
    StyledDocument doc = ec.openDocument();

    assertEquals("Counter must be zero", 0, counter);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:35,代码来源:PropertyChangeTest.java

示例11: getAdditionalBeanInfo

import org.openide.loaders.UniFileLoader; //导入依赖的package包/类
public BeanInfo[] getAdditionalBeanInfo () {
    try {
        return new BeanInfo[] { Introspector.getBeanInfo(UniFileLoader.class) };
    } catch (IntrospectionException ie) {
 Exceptions.printStackTrace(ie);
        return null;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:SQLDataLoaderBeanInfo.java

示例12: getAdditionalBeanInfo

import org.openide.loaders.UniFileLoader; //导入依赖的package包/类
public BeanInfo[] getAdditionalBeanInfo () {
    try {
        return new BeanInfo[] { Introspector.getBeanInfo (UniFileLoader.class) };
    } catch (IntrospectionException ie) {
 Exceptions.printStackTrace(ie);
        return null;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:HtmlLoaderBeanInfo.java

示例13: getAdditionalBeanInfo

import org.openide.loaders.UniFileLoader; //导入依赖的package包/类
/** Gets additional beaninfo. */
@Override
public BeanInfo[] getAdditionalBeanInfo () {
    try {
        return new BeanInfo[] { Introspector.getBeanInfo (UniFileLoader.class) };
    } catch (IntrospectionException ie) {
        ErrorManager.getDefault().notify(ie);
        
        return null;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:URLDataLoaderBeanInfo.java

示例14: getAdditionalBeanInfo

import org.openide.loaders.UniFileLoader; //导入依赖的package包/类
/** Gets additional bean infos. */
@Override
public BeanInfo[] getAdditionalBeanInfo() {
    try {
        return new BeanInfo[] { Introspector.getBeanInfo(UniFileLoader.class) };
    } catch (IntrospectionException ie) {
        ErrorManager.getDefault().notify(ie);
        
        return null;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:PDFDataLoaderBeanInfo.java

示例15: getAdditionalBeanInfo

import org.openide.loaders.UniFileLoader; //导入依赖的package包/类
public BeanInfo[] getAdditionalBeanInfo () {
    try {
        return new BeanInfo[] { Introspector.getBeanInfo (UniFileLoader.class) };
    } catch (IntrospectionException ie) {
 ErrorManager.getDefault().notify(ie);
        return null;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:ImageDataLoaderBeanInfo.java


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