當前位置: 首頁>>代碼示例>>Java>>正文


Java FileUtil.getConfigFile方法代碼示例

本文整理匯總了Java中org.openide.filesystems.FileUtil.getConfigFile方法的典型用法代碼示例。如果您正苦於以下問題:Java FileUtil.getConfigFile方法的具體用法?Java FileUtil.getConfigFile怎麽用?Java FileUtil.getConfigFile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.openide.filesystems.FileUtil的用法示例。


在下文中一共展示了FileUtil.getConfigFile方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testFactoryActionIsOKInEQ

import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
public void testFactoryActionIsOKInEQ() throws Exception {
    assertTrue("This one needs to run in EQT", EventQueue.isDispatchThread());
    FileObject fo = FileUtil.getConfigFile("Actions/Windows/open-factory-tc.instance");
    assertNotNull("Action generated", fo);
    Action a = (Action)fo.getAttribute("instanceCreate");
    assertNotNull("Action found", a);
    assertEquals("Not created yet", 0, TC.cnt);
    a.actionPerformed(new ActionEvent(this, 0, ""));
    assertEquals("Created", 1, TC.cnt);
    assertEquals("Hello TC!", a.getValue(Action.NAME));
    assertEquals("any/iconbase.png", a.getValue("iconBase"));
    assertEquals("preferredID found", "factory-tc", fo.getAttribute("preferredID"));
    
    FileObject dir = FileUtil.getConfigFile("Kuk/Huk");
    assertNotNull("Kuk/Huk found", dir);
    FileObject ref = dir.getFileObject("open-factory-tc.shadow");
    assertNotNull("Reference found: " + Arrays.toString(dir.getChildren()), ref);
    assertEquals(fo.getPath(), ref.getAttribute("originalFile"));
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:20,代碼來源:TopComponentProcessorTest.java

示例2: testContextAction

import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
public void testContextAction() throws Exception {
    Context.cnt = 0;
    
    FileObject fo = FileUtil.getConfigFile(
        "actions/support/test/testInjectContext.instance"
    );
    assertNotNull("File found", fo);
    Object obj = fo.getAttribute("instanceCreate");
    assertNotNull("Attribute present", obj);
    assertTrue("It is context aware action", obj instanceof ContextAwareAction);
    ContextAwareAction a = (ContextAwareAction)obj;

    InstanceContent ic = new InstanceContent();
    AbstractLookup lkp = new AbstractLookup(ic);
    Action clone = a.createContextAwareInstance(lkp);
    ic.add(10);

    assertEquals("Number lover!", clone.getValue(Action.NAME));
    clone.actionPerformed(new ActionEvent(this, 300, ""));
    assertEquals("Global Action not called", 10, Context.cnt);

    ic.remove(10);
    clone.actionPerformed(new ActionEvent(this, 200, ""));
    assertEquals("Global Action stays same", 10, Context.cnt);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:26,代碼來源:ContextActionInjectTest.java

示例3: testOSGiCanProvideLayer

import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
public void testOSGiCanProvideLayer() throws Exception {
    mgr.mutexPrivileged().enterWriteAccess();
    FileObject fo;
    try {
        String mfBar = "Bundle-SymbolicName: org.bar\n" +
            "Bundle-Version: 1.1.0\n" +
            "Bundle-ManifestVersion: 2\n" +
            "Import-Package: org.foo\n" +
            "OpenIDE-Module-Layer: org/bar/layer.xml\n" +
            "\n\n";

        File j2 = changeManifest(new File(jars, "depends-on-simple-module.jar"), mfBar);
        Module m2 = mgr.create(j2, null, false, false, false);
        mgr.enable(m2);
    } finally {
        mgr.mutexPrivileged().exitWriteAccess();
    }
    fo = FileUtil.getConfigFile("TestFolder");
    assertNotNull("Folder found", fo);

    URL u = mgr.getClassLoader().getResource("org/bar/layer.xml");
    assertNotNull("System ClassLoader can load resources", u);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:24,代碼來源:NetigsoLayerTest.java

示例4: setStartOffset

import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
@Override
public void setStartOffset(int offset) {
    super.setStartOffset (offset);
    FileObject fileObject = FileUtil.getConfigFile ("Spellcheckers/Properties");
    Boolean b = (Boolean) fileObject.getAttribute ("Hidden");
    hidden = Boolean.TRUE.equals (b);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:8,代碼來源:PropertiesTokenList.java

示例5: getTemplate

import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
/**
 * Returns template data object for properties file.
 */
public static DataObject getTemplate() throws IOException {
    FileObject fileObject = FileUtil.getConfigFile("Templates/Other/properties.properties"); // NOI18N

    if(fileObject == null)
        throw new IOException(Util.getString("EXC_TemplateNotFound"));

    try {
        return DataObject.find(fileObject);
    } catch(DataObjectNotFoundException e) {
        throw new IOException(Util.getString("EXC_TemplateNotFound"));
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:16,代碼來源:JavaResourceHolder.java

示例6: testDataObject

import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
public void testDataObject() throws Exception {
    FileObject template = FileUtil.getConfigFile("Templates/Other/SQLTemplate.sql");
    assertNotNull("Template file shall be found", template);

    DataObject obj = DataObject.find(template);
    assertEquals("It is our data object", SQLDataObject.class, obj.getClass());
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:8,代碼來源:SQLDataObjectTest.java

示例7: setUp

import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
protected @Override void setUp() throws Exception {
    super.setUp();
    clearWorkDir();

    EditorTestLookup.setLookup(
        new URL[] {
            getClass().getClassLoader().getResource(
                "org/netbeans/modules/editor/settings/storage/layer.xml"),
            getClass().getClassLoader().getResource(
                "org/netbeans/core/resources/mf-layer.xml"), // for MIMEResolverImpl to work
            getClass().getClassLoader().getResource(
                "org/netbeans/modules/editor/settings/storage/compatibility/p1/SFS-Editors-Folder.zip"), 
        },
        getWorkDir(),
        new Object[] {},
        getClass().getClassLoader()
    );

    // This is here to initialize Nb URL factory (org.netbeans.core.startup),
    // which is needed by Nb EntityCatalog (org.netbeans.core).
    // Also see the test dependencies in project.xml
    Main.initializeURLFactory();

    // Sanity check
    FileObject f = FileUtil.getConfigFile("Editors/text/x-java/NetBeans/Defaults/coloring.xml");
    assertNotNull("Corrupted SystemFileSystem!", f);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:28,代碼來源:Pre90403Phase1CompatibilityTest.java

示例8: testFullFontsColorsMixedLayout

import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
public void testFullFontsColorsMixedLayout() throws Exception {
    String writableUserFile = "Editors/" + getWritableFileName(ColoringStorage.ID, "text/x-whatever", "NetBeans", "xyz", false);
    String [] files = new String [] {
        "Editors/text/x-whatever/NetBeans/Defaults/defaultColoring.xml",
        "Editors/text/x-whatever/NetBeans/Defaults/coloring.xml",
        "Editors/text/x-whatever/NetBeans/Defaults/editorColoring.xml",
        "Editors/text/x-whatever/FontsColors/NetBeans/Defaults/file1.xml",
        "Editors/text/x-whatever/FontsColors/NetBeans/Defaults/file2.xml",
        "Editors/text/x-whatever/FontsColors/NetBeans/Defaults/file3.xml",
        "Editors/text/x-whatever/FontsColors/NetBeans/Defaults/file4.xml",
        "Editors/text/x-whatever/NetBeans/coloring.xml",
        "Editors/text/x-whatever/NetBeans/editorColoring.xml",
        "Editors/text/x-whatever/FontsColors/NetBeans/file1.xml",
        "Editors/text/x-whatever/FontsColors/NetBeans/file2.xml",
        "Editors/text/x-whatever/FontsColors/NetBeans/file3.xml",
        writableUserFile,
    };
    
    createOrderedFiles(files, FC_CONTENTS);
    
    FileObject baseFolder = FileUtil.getConfigFile("Editors");
    Map<String, List<Object []>> results = new HashMap<>();
    scan(ColoringStorage.ID, baseFolder, "text/x-whatever", null, true, true, true, results);
    
    assertNotNull("Scan results should not null", results);
    assertEquals("Wrong number of profiles", 1, results.size());
    
    List<Object []> profileFiles = results.get("NetBeans");
    checkProfileFiles(files, writableUserFile, profileFiles, "NetBeans");
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:31,代碼來源:LocatorTest.java

示例9: testDefineAFileAndCheckType

import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
public void testDefineAFileAndCheckType() throws Exception {
    FileObject type = FileUtil.createData(FileUtil.getConfigRoot(), "Templates/type.inc");
    assertEquals("At first unknown", "content/unknown", type.getMIMEType());
    
    FileObject mimeRoot = FileUtil.getConfigFile("Services/MIMEResolver/");
    assertNotNull("Mime root found", mimeRoot);
    
    
    String txt = "<?xml version='1.0' encoding='UTF-8'?>\n"
        + "<!DOCTYPE MIME-resolver PUBLIC '-//NetBeans//DTD MIME Resolver 1.1//EN' 'http://www.netbeans.org/dtds/mime-resolver-1_1.dtd'>\n"
        + "<MIME-resolver>\n"
        + "  <file>\n"
        + "    <ext name='XXX'/>\n"
        + "    <ext name='inc'/>\n"
        + "    <resolver mime='text/x-h'/>\n"
        + "</file>\n"
        + "</MIME-resolver>\n";
    
    FileObject udmr = FileUtil.createData(mimeRoot, "user-defined-mime-resolver.xml");
    
    assertEquals("Still unknown", "content/unknown", type.getMIMEType());
    
    
    OutputStream os = udmr.getOutputStream();
    os.write(txt.getBytes("UTF-8"));
    os.close();
    udmr.setAttribute("position", 555);
    udmr.setAttribute("user-defined-mime-resolver", Boolean.TRUE);
    
    assertEquals("Recognized well at the end", "text/x-h", type.getMIMEType());
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:32,代碼來源:UserDefinedMIMETest.java

示例10: deleteFileImpl

import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
private static void deleteFileImpl(File workDir, String path) throws IOException{
    FileObject fo = FileUtil.toFileObject(new File(workDir, path));
    if (fo == null) {
        fo = FileUtil.getConfigFile(path); // NOI18N
        if (fo == null){
            return;
        }
    }
    fo.delete();        
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:11,代碼來源:TestUtilities.java

示例11: validate

import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
/**
 * Validate according to all *.xsd found in catalog.
 * @param dom DOM fragment to validate
 * @throws SAXException if schemas were malformed or the document was invalid
 */
public static void validate(Element dom) throws SAXException {
    if (FileUtil.getConfigFile(CATALOG) == null) {
        // Probably running from inside a unit test which overrides the system filesystem.
        // Safest and simplest to just skip validation in this case.
        return;
    }
    XMLUtil.validate(dom, projectXmlCombinedSchema());
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:14,代碼來源:ProjectXMLCatalogReader.java

示例12: isValid

import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
public boolean isValid () {
    if (shortcutsFolder == null)
        shortcutsFolder = FileUtil.getConfigFile ("Shortcuts"); // NOI18N
    return (getPanel().stroke != null) &&
           (shortcutsFolder.getFileObject(Utilities.keyToString(getPanel().stroke), "instance") == null) && // NOI18N
           (shortcutsFolder.getFileObject(Utilities.keyToString(getPanel().stroke), "xml") == null); // NOI18N
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:8,代碼來源:SelectKeyboardShortcutPanel.java

示例13: setUp

import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
@Override
protected void setUp() throws Exception {
    NbBundle.setBranding("big");
    folder = FileUtil.getConfigFile("actions/support/test");
    assertNotNull("testing layer is loaded: ", folder);

    myIconResourceCounter = 0;
    myListenerCalled = 0;
    myListenerCounter = 0;
    MyAction.last = null;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:12,代碼來源:AlwaysEnabledActionTest.java

示例14: setUp

import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
@Override
protected void setUp() throws IOException {
    FileObject fo = FileUtil.getConfigFile("Services");
    if (fo != null) {
        fo.delete();
    }
    clearWorkDir();
    MockLookup.setInstances(TestProject.createProjectType());
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:10,代碼來源:GeneratedSourceRootTest.java

示例15: getRepositoryRoot

import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
@NonNull
private FileObject getRepositoryRoot() {
    FileObject root = FileUtil.getConfigFile("NBProfiler/Config/OQL"); // NOI18N
    if (root == null) {
        throw new IllegalStateException("can not find OQL queries repository"); // NOI18N
    }
    return root;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:9,代碼來源:OQLQueryRepository.java


注:本文中的org.openide.filesystems.FileUtil.getConfigFile方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。