本文整理匯總了Java中org.openide.filesystems.FileUtil.getConfigRoot方法的典型用法代碼示例。如果您正苦於以下問題:Java FileUtil.getConfigRoot方法的具體用法?Java FileUtil.getConfigRoot怎麽用?Java FileUtil.getConfigRoot使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.openide.filesystems.FileUtil
的用法示例。
在下文中一共展示了FileUtil.getConfigRoot方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testWhoCreatesConstructor
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
public void testWhoCreatesConstructor() throws Exception {
FileObject root = FileUtil.getConfigRoot();
FileObject fo = FileUtil.createFolder (root, "ToolbarsWhoCreates");
final DataFolder df = DataFolder.findFolder(fo);
ToolbarPool pool = new ToolbarPool(df);
assertEquals("No children now", 0, pool.getToolbars().length);
class Atom implements FileSystem.AtomicAction {
FileObject m1, m2;
public void run() throws IOException {
m1 = FileUtil.createFolder(df.getPrimaryFile(), "m1");
DataFolder f1 = DataFolder.findFolder(m1);
InstanceDataObject.create(f1, "X", MyAction.class);
}
}
Atom atom = new Atom();
df.getPrimaryFile().getFileSystem().runAtomicAction(atom);
pool.waitFinished();
assertEquals("One toolbar is there", 1, pool.getToolbars().length);
Toolbar tb = pool.getToolbars()[0];
assertEquals("Pool name", "m1", tb.getName());
assertEquals("Has one subcomponent", 1, tb.getComponents().length);
Object o1 = tb.getComponent(0);
if (!(o1 instanceof JButton)) {
fail("Need JPanel " + o1);
}
assertEquals("And now the action is created", 1, MyAction.counter);
}
示例2: getFolder
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
private FileObject getFolder() {
try {
return fo.getFileSystem().getRoot();
}
catch (FileStateInvalidException ex) {
// ok
}
return FileUtil.getConfigRoot();
}
示例3: setUp
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
@Override
protected void setUp() throws Exception {
if (System.getProperty("netbeans.user") == null) {
System.setProperty("netbeans.user", new File(getWorkDir(), "ud").getPath());
}
LOG = Logger.getLogger("Test." + getName());
root = FileUtil.getConfigRoot();
for (FileObject fo : root.getChildren()) {
fo.delete();
}
super.setUp();
}
示例4: setUp
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
@Override
protected void setUp() throws Exception {
MockLookup.setInstances(new Repository(FileUtil.createMemoryFileSystem()));
FileObject root = FileUtil.getConfigRoot();
toolbars = root.getFileObject("Toolbars");
assertNull("Not created yet", toolbars);
}
示例5: getExistingProfile
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
private static DataFolder getExistingProfile(String profile) {
FileObject root = FileUtil.getConfigRoot ();
FileObject fo1 = root.getFileObject(KEYMAPS_FOLDER);
if (fo1 == null) {
return null;
}
FileObject fo2 = fo1.getFileObject(profile);
if (fo2 == null) {
return null;
}
return DataFolder.findFolder(fo2);
}
示例6: testIgnoresSimplefolders
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
public void testIgnoresSimplefolders() throws Exception {
FileObject root = FileUtil.getConfigRoot();
FileObject fo = FileUtil.createFolder(root, "Templates/SimpleFolder");
try {
fo.setAttribute("simple", Boolean.FALSE);
Node n = TemplatesPanel.getTemplateRootNode();
Node[] arr = n.getChildren().getNodes(true);
assertEquals("Empty: " + Arrays.asList(arr), 0, arr.length);
} finally {
// Cleanup Templates folder
fo.getParent().delete();
}
}
示例7: testIgnoresSimpleNonFolders
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
public void testIgnoresSimpleNonFolders() throws Exception {
FileObject root = FileUtil.getConfigRoot();
FileObject fo = FileUtil.createData(root, "Templates/SimpleFolder.java");
try {
fo.setAttribute("simple", Boolean.FALSE);
fo.setAttribute("template", Boolean.TRUE);
Node n = TemplatesPanel.getTemplateRootNode();
Node[] arr = n.getChildren().getNodes(true);
assertEquals("Empty: " + Arrays.asList(arr), 0, arr.length);
} finally {
// Cleanup Templates folder
fo.getParent().delete();
}
}
示例8: tearDown
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
@Override
public void tearDown() throws IOException {
dataObjects = null;
FileObject configRoot = FileUtil.getConfigRoot();
FileObject shadowFile = configRoot.getFileObject(
"testDataShadows/testShadowFile");
if (shadowFile != null) {
shadowFile.delete();
}
FileObject testDataShadowsFolder = configRoot.getFileObject(
"testDataShadows");
if (testDataShadowsFolder != null) {
testDataShadowsFolder.delete();
}
}
示例9: testUnknownTaskGroup
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
public void testUnknownTaskGroup() throws FileStateInvalidException {
String description = "task description";
int lineNo = 123;
FileObject resource = FileUtil.getConfigRoot();
Task t = Task.create(resource, "unknown task group name", description, lineNo );
assertEquals( description, t.getDescription() );
assertEquals( lineNo, t.getLine() );
assertEquals( resource, t.getFile() );
assertEquals( TaskGroupFactory.getDefault().getDefaultGroup(), t.getGroup() );
}
示例10: createModel
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
/** Creates a new OptionsExportModel based on given template. Model looks
* like this:
*
* <folder name="OptionsExport">
* <folder name="Category0">
* <attr name="displayName" stringvalue="Category0"/>
* <file name="Item00">
* <attr name="displayName" stringvalue="Item00"/>
* <attr name="include" stringvalue="dir0/subdir0/.*"/>
* </file>
* </folder>
* <folder name="Category1">
* <attr name="displayName" stringvalue="Category1"/>
* <file name="Item10">
* <attr name="displayName" stringvalue="Item11"/>
* <attr name="include" stringvalue="dir0/subdir0/file0[.]properties|dir1/subdir1/file1.*"/>
* </file>
* </folder>
* </folder>
*
* @param modelTemplate array of category display name, item display name,
* include pattern, exclude pattern
* @param source source userdir or zip file
* @throws Exception
*/
private void createModel(String[][] modelTemplate, File source) throws Exception {
FileObject root = FileUtil.getConfigRoot();
optionsExportFolder = root.getFileObject("OptionsExport");
if (optionsExportFolder != null) {
optionsExportFolder.delete();
}
optionsExportFolder = FileUtil.createFolder(root, "OptionsExport");
for (String[] fields : modelTemplate) {
String categoryName = fields[0];
String itemName = fields[1];
String include = fields[2];
String exclude = fields[3];
createCategory(categoryName, 0);
createItem(categoryName, itemName, include, exclude);
}
model = new OptionsExportModel(source);
// enable all and print model
for (OptionsExportModel.Category category : model.getCategories()) {
LOGGER.info("category=" + category); //NOI18N
List<OptionsExportModel.Item> items = category.getItems();
for (OptionsExportModel.Item item : items) {
item.setEnabled(true);
LOGGER.info(" item=" + item); //NOI18N
}
}
}
示例11: setUp
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
@Override
protected void setUp() throws Exception {
FileObject root = FileUtil.getConfigRoot();
toolbars = FileUtil.createFolder (root, "Toolbars");
toolbarsFolder = DataFolder.findFolder (toolbars);
FileObject[] arr = toolbars.getChildren ();
for (int i = 0; i < arr.length; i++) {
arr[i].delete ();
}
ToolbarPool tp = ToolbarPool.getDefault ();
tp.waitFinished ();
}
示例12: setUp
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
protected void setUp() throws java.lang.Exception {
super.setUp();
Lookup.getDefault().lookup(ModuleInfo.class);
java.net.URL layer = this.getClass().getResource("data/layer.xml");
fs = new XMLFileSystem(layer);
root = FileUtil.getConfigRoot();
assertNotNull("SFS root not found", root);
FileObject serdata = FileUtil.getConfigFile("xml/lookups/NetBeans/DTD_Session_settings_1_0.instance");
assertNotNull("missing registration for serialdata format", serdata);
Object attr = serdata.getAttribute("instanceCreate");
assertNotNull("core's registration for serialdata format", attr);
assertEquals(SerialDataConvertor.Provider.class, attr.getClass());
}
示例13: testFSNameAndPath
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
/**
* Checks translation on Shadows, which use FS name + path, not URI
* @throws Exception
*/
public void testFSNameAndPath() throws Exception {
FileObject fo = FileUtil.getConfigRoot();
FileObject origDir = fo.createFolder("origFolder3");
// create empty real file with special and non-ASCII chars
FileObject newFile = origDir.createData("moved-here.txt");
// createa a fake file, just to get its URI right:
FileObject fake = fo.createData("dead-file-location.old");
final FileObject d = fo.createFolder("subfolder3");
OutputStream ostm = d.createAndOpen("regularShadowURI.shadow");
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(ostm));
bw.write(fake.getPath());
bw.newLine();
bw.write(fake.getFileSystem().getSystemName());
bw.newLine();
fake.delete();
bw.close();
FileObject fob = d.getFileObject("regularShadowURI.shadow");
DataObject dd = DataObject.find(fob);
assertTrue("Shadow must be translated, not broken", dd instanceof DataShadow);
DataShadow ds = (DataShadow)dd;
assertEquals("Shadow's original must be on the translated location", newFile, ds.getOriginal().getPrimaryFile());
}
示例14: initializeProviders
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
private void initializeProviders() {
PROVIDERS = new LinkedList<>();
FileObject rootFolder = FileUtil.getConfigRoot();
FileObject dtdFolder = rootFolder.getFileObject(DTD_FOLDER);
if (dtdFolder != null) {
processSubfolders(dtdFolder);
}
}
示例15: testGetters
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
public void testGetters() throws FileStateInvalidException {
String description = "task description";
int lineNo = 123;
FileObject resource = FileUtil.getConfigRoot();
Task t = Task.create(resource, TASK_GROUP_NAME, description, lineNo );
assertEquals( description, t.getDescription() );
assertEquals( lineNo, t.getLine() );
assertEquals( resource, t.getFile() );
assertNull( t.getURL() );
assertNull( t.getActions() );
assertEquals( TaskGroupFactory.getDefault().getGroup( TASK_GROUP_NAME), t.getGroup() );
assertNull( t.getDefaultAction() );
ActionListener al = new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
throw new UnsupportedOperationException("Not supported yet.");
}
};
t = Task.create(resource, TASK_GROUP_NAME, description, al );
assertEquals( description, t.getDescription() );
assertEquals( -1, t.getLine() );
assertEquals( resource, t.getFile() );
assertNull( t.getURL() );
assertNull( t.getActions() );
assertEquals( TaskGroupFactory.getDefault().getGroup( TASK_GROUP_NAME), t.getGroup() );
assertEquals( al, t.getDefaultAction() );
URL url = resource.getURL();
t = Task.create(url, TASK_GROUP_NAME, description );
assertEquals( description, t.getDescription() );
assertEquals( -1, t.getLine() );
assertEquals( url, t.getURL() );
assertNull( t.getFile() );
assertNull( t.getActions() );
assertEquals( TaskGroupFactory.getDefault().getGroup( TASK_GROUP_NAME), t.getGroup() );
assertNull( t.getDefaultAction() );
Action[] actions = new Action[1];
t = Task.create(url, TASK_GROUP_NAME, description, al, actions );
assertEquals( description, t.getDescription() );
assertEquals( -1, t.getLine() );
assertEquals( url, t.getURL() );
assertNull( t.getFile() );
assertEquals( TaskGroupFactory.getDefault().getGroup( TASK_GROUP_NAME), t.getGroup() );
assertEquals( al, t.getDefaultAction() );
assertSame( actions, t.getActions() );
}