本文整理汇总了Java中org.openide.filesystems.FileSystem类的典型用法代码示例。如果您正苦于以下问题:Java FileSystem类的具体用法?Java FileSystem怎么用?Java FileSystem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FileSystem类属于org.openide.filesystems包,在下文中一共展示了FileSystem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setFiles
import org.openide.filesystems.FileSystem; //导入依赖的package包/类
protected final void setFiles(final Set<FileObject> files) {
fileSystemListeners = new HashSet<FileStatusListener>();
this.files = files;
if (files == null) {
return;
}
Set<FileSystem> hookedFileSystems = new HashSet<FileSystem>();
for (FileObject fo : files) {
try {
FileSystem fs = fo.getFileSystem();
if (hookedFileSystems.contains(fs)) {
continue;
}
hookedFileSystems.add(fs);
FileStatusListener fsl = FileUtil.weakFileStatusListener(this, fs);
fs.addFileStatusListener(fsl);
fileSystemListeners.add(fsl);
} catch (FileStateInvalidException e) {
ErrorManager err = ErrorManager.getDefault();
err.annotate(e, "Cannot get " + fo + " filesystem, ignoring..."); // NOI18N
err.notify(ErrorManager.INFORMATIONAL, e);
}
}
}
示例2: getLoaderDisplayName
import org.openide.filesystems.FileSystem; //导入依赖的package包/类
/** Returns localized display name of loader for given MIME type or null if not defined. */
private static String getLoaderDisplayName(String mimeType) {
FileSystem filesystem = null;
try {
filesystem = FileUtil.getConfigRoot().getFileSystem();
} catch (FileStateInvalidException ex) {
Exceptions.printStackTrace(ex);
}
FileObject factoriesFO = FileUtil.getConfigFile("Loaders/" + mimeType + "/Factories"); //NOI18N
if(factoriesFO != null) {
FileObject[] children = factoriesFO.getChildren();
for (FileObject child : children) {
String childName = child.getNameExt();
String displayName = filesystem.getDecorator().annotateName(childName, Collections.singleton(child));
if(!childName.equals(displayName)) {
return displayName;
}
}
}
return null;
}
示例3: PackageRootNode
import org.openide.filesystems.FileSystem; //导入依赖的package包/类
private PackageRootNode( SourceGroup group, Children ch) {
super(ch, new ProxyLookup(createLookup(group), Lookups.singleton(
SearchInfoDefinitionFactory.createSearchInfoBySubnodes(ch))));
this.group = group;
file = group.getRootFolder();
files = Collections.singleton(file);
try {
FileSystem fs = file.getFileSystem();
fileSystemListener = FileUtil.weakFileStatusListener(this, fs);
fs.addFileStatusListener(fileSystemListener);
} catch (FileStateInvalidException e) {
Exceptions.printStackTrace(Exceptions.attachMessage(e,"Can not get " + file + " filesystem, ignoring...")); //NOI18N
}
setName( group.getName() );
setDisplayName( group.getDisplayName() );
// setIconBase("org/netbeans/modules/java/j2seproject/ui/resources/packageRoot");
}
示例4: setUp
import org.openide.filesystems.FileSystem; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
FileSystem fs = FileUtil.createMemoryFileSystem();
FileObject fo = fs.getRoot().createData("JFrame.java");
source = convertStreamToString(getClass().getResourceAsStream("resources/JFrame.txt"));
writeFile(source, fo);
DataObject sourceDataObject = DataObject.find(fo);
EditorCookie editorCookie = sourceDataObject.getCookie(EditorCookie.class);
if (editorCookie == null) {
throw new IllegalArgumentException("I18N: Illegal data object type"+ sourceDataObject); // NOI18N
}
StyledDocument document = editorCookie.getDocument();
while(document == null) {
document = editorCookie.openDocument();
}
instance = new JavaI18nFinder(document);
}
示例5: createDataObjectWithContent
import org.openide.filesystems.FileSystem; //导入依赖的package包/类
private DataObject createDataObjectWithContent(byte singleByteContent)
throws IOException {
FileSystem fs = FileUtil.createMemoryFileSystem();
FileObject fob = fs.getRoot().createData("test.txt");
OutputStream os = fob.getOutputStream();
try {
os.write(new byte[]{singleByteContent});
} finally {
os.close();
}
DataObject dob = DataObject.find(fob);
if (!(dob instanceof DefaultDataObject)) {
fail("Expected an instance of DefaultDataObject");
}
return dob;
}
示例6: getCachedLayers
import org.openide.filesystems.FileSystem; //导入依赖的package包/类
/**
* Returns possibly cached list of filesystems representing the XML layers of the supplied platform module JARs.
* If cache is not ready yet, this call blocks until the cache is created.
* Layer filesystems are already ordered to handle masked ("_hidden") files correctly.
* @param platformJars
* @return List of read-only layer filesystems
* @throws java.io.IOException
*/
private Collection<FileSystem> getCachedLayers(File rootDir, final Set<File> platformJars) throws IOException {
if (rootDir == null) {
return Collections.emptySet();
}
File[] clusters = rootDir.listFiles(new FileFilter() {
@Override public boolean accept(File pathname) {
return ClusterUtils.isValidCluster(pathname);
}
});
Collection<FileSystem> cache = PlatformLayersCacheManager.getCache(clusters, new FileFilter() {
@Override public boolean accept(File jar) {
return platformJars.contains(jar);
}
});
return cache;
}
示例7: setUp
import org.openide.filesystems.FileSystem; //导入依赖的package包/类
protected void setUp () throws Exception {
clearWorkDir();
MockServices.setServices(new Class[] {ErrManager.class, Pool.class});
if (previous != null) {
previous.waitFinished ();
}
TestUtilHid.destroyLocalFileSystem (getName());
String fsstruct [] = new String [] {
"AA/X.txt",
"AA/Y.txt",
"BB/X.slow",
};
FileSystem lfs = TestUtilHid.createLocalFileSystem (getWorkDir (), fsstruct);
aa = DataFolder.findFolder (lfs.findResource ("AA"));
bb = DataFolder.findFolder (lfs.findResource ("BB"));
aa.addPropertyChangeListener (this);
}
示例8: testXMLMultiFS
import org.openide.filesystems.FileSystem; //导入依赖的package包/类
public void testXMLMultiFS() throws Exception {
clearWorkDir();
// b-layer.xml overrides a-layer.xml now and then:
List<File> files = new ArrayList<File>(Arrays.asList(
new File(getDataDir(), "layers/b-layer.xml"),
new File(getDataDir(), "layers/a-layer.xml")
));
FileSystem xfs0 = new XMLFileSystem(Utilities.toURI(files.get(0)).toURL());
FileSystem xfs1 = new XMLFileSystem(Utilities.toURI(files.get(1)).toURL());
FileSystem mfs = new MultiFileSystem(xfs0, xfs1);
assertNotNull(xfs1.findResource("Menu/A Folder"));
assertNotNull(mfs.findResource("Menu/File"));
assertNotNull(mfs.findResource("Menu/A Folder"));
assertNull(mfs.findResource("Menu/A Folder/org-example-a-AAction.shadow")); // hidden by b-layer
FileObject mf = mfs.findResource("Actions/File");
assertEquals(2, mf.getChildren().length);
FileObject ba = mfs.findResource("Actions/File/org-example-b-BAction.instance");
assertEquals("BBBBB", ba.getAttribute("displayName"));
FileObject aa = mfs.findResource("Actions/File/org-example-a-AAction.instance");
assertEquals("AAAA", aa.getAttribute("displayName"));
}
示例9: testCachedMultiFS
import org.openide.filesystems.FileSystem; //导入依赖的package包/类
public void testCachedMultiFS() throws Exception {
clearWorkDir();
LayerCacheManager m = LayerCacheManager.manager(true);
// b-layer.xml overrides a-layer.xml now and then:
List<File> files = new ArrayList<File>(Arrays.asList(
new File(getDataDir(), "layers/b-layer.xml"),
new File(getDataDir(), "layers/a-layer.xml")
));
FileSystem cfs = memoryStoreAndLoad(m, files);
assertNotNull(cfs.findResource("Menu/File"));
assertNotNull(cfs.findResource("Menu/A Folder"));
assertNull(cfs.findResource("Menu/A Folder/org-example-a-AAction.shadow")); // hidden by b-layer
FileObject mf = cfs.findResource("Actions/File");
assertEquals(2, mf.getChildren().length);
FileObject ba = cfs.findResource("Actions/File/org-example-b-BAction.instance");
assertEquals("BBBBB", ba.getAttribute("displayName"));
FileObject aa = cfs.findResource("Actions/File/org-example-a-AAction.instance");
assertEquals("AAAA", aa.getAttribute("displayName"));
}
示例10: testMixedMultiFS
import org.openide.filesystems.FileSystem; //导入依赖的package包/类
public void testMixedMultiFS() throws Exception {
clearWorkDir();
LayerCacheManager m = LayerCacheManager.manager(true);
// b-layer.xml overrides a-layer.xml now and then:
File lb = new File(getDataDir(), "layers/b-layer.xml");
File la = new File(getDataDir(), "layers/a-layer.xml");
FileSystem cfs = createCachedFS(m, lb);
FileSystem xfs = new XMLFileSystem(Utilities.toURI(la).toURL());
FileSystem mfs = new MultiFileSystem(cfs, xfs);
assertNotNull(mfs.findResource("Menu/File"));
assertNotNull(mfs.findResource("Menu/A Folder"));
assertNull(mfs.findResource("Menu/A Folder/org-example-a-AAction.shadow")); // hidden by b-layer
FileObject mf = mfs.findResource("Actions/File");
assertEquals(2, mf.getChildren().length);
FileObject ba = mfs.findResource("Actions/File/org-example-b-BAction.instance");
assertEquals("BBBBB", ba.getAttribute("displayName"));
FileObject aa = mfs.findResource("Actions/File/org-example-a-AAction.instance");
assertEquals("AAAA", aa.getAttribute("displayName"));
}
示例11: rebuild
import org.openide.filesystems.FileSystem; //导入依赖的package包/类
/**
* Create a new tracker for tracking mime types under the <code>basePath</code>
* folder.
*
* @param settingsType The type of settings to track mime types for. If not
* <code>null</code> the tracker will only list mime types that declare
* settings of this type.
* @param basePath The path on the system <code>FileSystem</code> where the
* mime types should be tracked.
*/
/* package */ MimeTypesTracker(SettingsType.Locator locator, String basePath) {
this.locator = locator;
this.basePath = basePath;
this.basePathElements = basePath.split("/"); //NOI18N
rebuild();
// Start listening
this.listener = new Listener();
FileSystem sfs = null;
try {
sfs = FileUtil.getConfigRoot().getFileSystem();
} catch (FileStateInvalidException ex) {
Exceptions.printStackTrace(ex);
}
sfs.addFileChangeListener(WeakListeners.create(FileChangeListener.class,listener, sfs));
}
示例12: isFinishable
import org.openide.filesystems.FileSystem; //导入依赖的package包/类
static boolean isFinishable(FileSystem fs, String buildContext, String dockerfile) {
if (buildContext == null) {
return false;
}
String realDockerfile;
if (dockerfile == null) {
realDockerfile = buildContext + "/" + DockerAction.DOCKER_FILE;
} else {
realDockerfile = buildContext + "/" + dockerfile;
}
FileObject build = fs.getRoot().getFileObject(buildContext);
FileObject fo = fs.getRoot().getFileObject(realDockerfile);
// the last check avoids entires like Dockerfile/ to be considered valid files
if (fo == null || !fo.isData() || !realDockerfile.endsWith(fo.getNameExt())) {
return false;
}
if (build == null) {
return false;
}
return FileUtil.isParentOf(build, fo);
}
示例13: testGetIteratorHonoursDataObjectsCookies
import org.openide.filesystems.FileSystem; //导入依赖的package包/类
/** Does getIterator honours DataObject's cookies?
*/
public void testGetIteratorHonoursDataObjectsCookies () throws Exception {
FileSystem fs = FileUtil.createMemoryFileSystem();
DataObject obj;
Loader l = Loader.findObject (Loader.class, true);
try {
AddLoaderManuallyHid.addRemoveLoader (l, true);
obj = DataObject.find (fs.getRoot ());
} finally {
AddLoaderManuallyHid.addRemoveLoader (l, false);
}
TemplateWizard.Iterator it = TemplateWizard.getIterator (obj);
assertEquals ("Iterator obtained from the object's cookie", obj, it);
}
示例14: getURL
import org.openide.filesystems.FileSystem; //导入依赖的package包/类
public @Override URL getURL(FileObject fo, int type) {
if (type != URLMapper.INTERNAL) {
return null;
}
try {
FileSystem fs = fo.getFileSystem();
if (fs instanceof SourceFS) {
String path = fo.getPath();
if (fo.isFolder() && !fo.isRoot()) {
path += '/';
}
return url((SourceFS) fs, path);
}
} catch (FileStateInvalidException x) {
// ignore
}
return null;
}
示例15: testHandleDataShadow
import org.openide.filesystems.FileSystem; //导入依赖的package包/类
public void testHandleDataShadow() throws Exception {
String fsstruct [] = new String [] {
"AA/",
"BB/",
"BB/java-io-IOException.instance"
};
TestUtilHid.destroyLocalFileSystem (getName());
FileSystem lfs = TestUtilHid.createLocalFileSystem (getWorkDir(), fsstruct);
FileObject aa = lfs.findResource("/AA");
FileObject bb = lfs.findResource("/BB");
DataFolder a = DataFolder.findFolder (aa);
DataFolder b = DataFolder.findFolder (bb);
b.createShadow(a);
FolderLookup fl = new FolderLookup(b);
IOException io = fl.getLookup().lookup(IOException.class);
assertNotNull("IO Exception found", io);
}