本文整理汇总了Java中org.openide.loaders.DataFolder.findFolder方法的典型用法代码示例。如果您正苦于以下问题:Java DataFolder.findFolder方法的具体用法?Java DataFolder.findFolder怎么用?Java DataFolder.findFolder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openide.loaders.DataFolder
的用法示例。
在下文中一共展示了DataFolder.findFolder方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCreateFromTemplateEncodingProperty
import org.openide.loaders.DataFolder; //导入方法依赖的package包/类
public void testCreateFromTemplateEncodingProperty() throws Exception {
FileObject root = FileUtil.createMemoryFileSystem().getRoot();
FileObject fo = FileUtil.createData(root, "simpleObject.txt");
OutputStream os = fo.getOutputStream();
os.write("print(encoding)".getBytes());
os.close();
assertEquals("content/unknown", fo.getMIMEType());
fo.setAttribute ("template", Boolean.TRUE);
assertEquals("content/unknown", fo.getMIMEType());
fo.setAttribute(ScriptingCreateFromTemplateHandler.SCRIPT_ENGINE_ATTR, "js");
DataObject obj = DataObject.find(fo);
DataFolder folder = DataFolder.findFolder(FileUtil.createFolder(root, "target"));
Map<String,String> parameters = Collections.emptyMap();
DataObject inst = obj.createFromTemplate(folder, "complex", parameters);
FileObject instFO = inst.getPrimaryFile();
Charset targetEnc = FileEncodingQuery.getEncoding(instFO);
assertNotNull("Template encoding is null", targetEnc);
String instText = stripNewLines(instFO.asText());
assertEquals("Encoding in template doesn't match", targetEnc.name(), instText);
}
示例2: testContextLookupIsConsistentAfterMove
import org.openide.loaders.DataFolder; //导入方法依赖的package包/类
@RandomlyFails
public void testContextLookupIsConsistentAfterMove() throws Exception {
ConsistencyCheckProvider.setCalled(0);
// Prepare the data object (to initialize the lookup)
FileObject fo = fs.getRoot().createData("test2", "txt");
DataObject data = DataObject.find(fo);
EditorCookie ec = data.getCookie(EditorCookie.class);
// now move it (the lookup should update itself)
FileObject fld = fs.getRoot().createFolder("folder1");
DataFolder df = DataFolder.findFolder(fld);
data.move(df);
// now open the editor (invoke AnnotationProviders)
// and check the lookup
ec.open();
assertEquals("Consistent lookup content", data.getPrimaryFile(),ConsistencyCheckProvider.getInLkp());
}
示例3: testOriginalFileIgnored
import org.openide.loaders.DataFolder; //导入方法依赖的package包/类
public void testOriginalFileIgnored() throws Exception {
FileObject def1 = make("Actions/hey.instance");
def1.setAttribute("instanceCreate", new DummyAction("hey"));
FileObject def2 = make("Actions/now.instance");
def2.setAttribute("instanceCreate", new DummyAction("now"));
DataFolder netbeans = DataFolder.findFolder(makeFolder("Shortcuts"));
DataShadow s1 = DataShadow.create(netbeans, "C-F4", DataObject.find(def1));
DataShadow s2 = DataShadow.create(netbeans, "F4", DataObject.find(def2));
s1.getPrimaryFile().setAttribute("originalFile", "nowhere");
s2.getPrimaryFile().setAttribute("originalFile", def1.getParent().getPath());
NbKeymap km = new NbKeymap();
assertMapping(km, KeyStroke.getKeyStroke(KeyEvent.VK_F4, KeyEvent.CTRL_MASK), def1, "hey");
assertMapping(km, KeyStroke.getKeyStroke(KeyEvent.VK_F4, 0), def2, "now");
}
示例4: createNodeForSourceGroup
import org.openide.loaders.DataFolder; //导入方法依赖的package包/类
@CheckForNull
static Node createNodeForSourceGroup(
@NonNull final SourceGroup group,
@NonNull final Project project) {
if ("sharedlibraries".equals(group.getName())) { //NOI18N
//HACK - ignore shared libs group in UI, it's only useful for version control commits.
return null;
}
final FileObject rootFolder = group.getRootFolder();
if (!rootFolder.isValid() || !rootFolder.isFolder()) {
return null;
}
final FileObject projectDirectory = project.getProjectDirectory();
return new ProjectIconNode(new GroupNode(
project,
group,
projectDirectory.equals(rootFolder) || FileUtil.isParentOf(rootFolder, projectDirectory),
DataFolder.findFolder(rootFolder)),
true);
}
示例5: recognize
import org.openide.loaders.DataFolder; //导入方法依赖的package包/类
private void recognize(int count) throws IOException {
clearWorkDir();
FileUtil.refreshAll();
File wd = getWorkDir();
while (count-- > 0) {
new FileOutputStream(new File(wd, "f" + count + ".java")).close();
new FileOutputStream(new File(wd, "f" + count + ".bbb")).close();
}
long s = System.currentTimeMillis();
FileUtil.refreshAll();
FileObject f = FileUtil.toFileObject(wd);
DataFolder df = DataFolder.findFolder(f);
System.err.println("preparation took: " + (System.currentTimeMillis() - s));
System.err.println(df.getChildren().length);
System.err.println("recognition took:" + (System.currentTimeMillis() - s));
}
示例6: fillWebBrowsersCombo
import org.openide.loaders.DataFolder; //导入方法依赖的package包/类
private void fillWebBrowsersCombo(List<String> list, String select) {
// PENDING need to get rid of this filtering
FileObject fo = FileUtil.getConfigFile (BROWSERS_FOLDER);
if (fo != null) {
DataFolder folder = DataFolder.findFolder (fo);
DataObject [] dobjs = folder.getChildren ();
for (int i = 0; i<dobjs.length; i++) {
// Must not be hidden and have to provide instances (we assume instance is HtmlBrowser.Factory)
if (Boolean.TRUE.equals(dobjs[i].getPrimaryFile().getAttribute(EA_HIDDEN)) ||
dobjs[i].getLookup().lookup(InstanceCookie.class) == null) {
FileObject fo2 = dobjs[i].getPrimaryFile();
String n = fo2.getName();
try {
n = fo2.getFileSystem().getDecorator().annotateName(n, dobjs[i].files());
} catch (FileStateInvalidException e) {
// Never mind.
}
list.remove(n);
}
}
}
comboBoxWebBrowser.removeAllItems ();
if (!list.isEmpty()) {
for (String tag : list) {
comboBoxWebBrowser.addItem(tag);
}
if(select != null) {
comboBoxWebBrowser.setSelectedItem(select);
}
labelWebBrowser.setEnabled(true);
comboBoxWebBrowser.setEnabled(true);
jSeparator2.setEnabled(true);
} else {
labelWebBrowser.setEnabled(false);
comboBoxWebBrowser.setEnabled(false);
jSeparator2.setEnabled(false);
}
}
示例7: testOneItemFilesList
import org.openide.loaders.DataFolder; //导入方法依赖的package包/类
public void testOneItemFilesList() throws IOException {
FileSystem fs = FileUtil.createMemoryFileSystem();
FileObject fsRoot = fs.getRoot();
FileObject dir = fsRoot.createFolder("dir");
dir.createData("a", DummyDataLoader.dummyExt);
dir.createData("b", DummyDataLoader.dummyExt);
dir.createData("c", DummyDataLoader.dummyExt);
DataFolder folder = DataFolder.findFolder(dir);
SearchInfo.Files refSearchInfo;
SearchInfo.Files testSearchInfo;
Iterator refIt;
Iterator testIt;
Set testSet = new HashSet();
refSearchInfo = new SimpleSearchInfo(folder, false, null);
testSearchInfo = new CompoundSearchInfo(new SearchInfo[] {refSearchInfo});
assertTrue(testSearchInfo.canSearch());
for(testIt = testSearchInfo.filesToSearch(); testIt.hasNext();){
testSet.add(testIt.next());
}
refIt = refSearchInfo.filesToSearch();
while (refIt.hasNext()) {
assertTrue(testSet.remove(refIt.next()));
}
assertTrue(testSet.isEmpty());
refSearchInfo = new SimpleSearchInfo(folder, false, null) {
public boolean canSearch() {
return false;
}
};
testSearchInfo = new CompoundSearchInfo(new SearchInfo[] {refSearchInfo});
assertEquals(refSearchInfo.canSearch(), testSearchInfo.canSearch());
}
示例8: testWhoCreatesConstructor
import org.openide.loaders.DataFolder; //导入方法依赖的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);
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);
}
示例9: testSubfolder
import org.openide.loaders.DataFolder; //导入方法依赖的package包/类
public void testSubfolder() throws Exception {
DataFolder sub = DataFolder.findFolder(folder.getPrimaryFile().createFolder("sub"));
InstanceDataObject.create(sub, null, NoIcon.class);
InstanceDataObject.create(sub, null, SmallIcon.class);
Node[] arr = node.getChildren().getNodes(true);
assertEquals(1, arr.length);
arr = node.getChildren().getNodeAt(0).getChildren().getNodes(true);
assertEquals(1, arr.length);
}
示例10: setUp
import org.openide.loaders.DataFolder; //导入方法依赖的package包/类
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 ();
}
示例11: testWhoCreatesConstructor
import org.openide.loaders.DataFolder; //导入方法依赖的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);
}
示例12: setUp
import org.openide.loaders.DataFolder; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
FileObject root = FileUtil.getConfigRoot();
toolbars = FileUtil.createFolder (root, "Toolbars");
toolbars.createFolder("Tool1");
toolbarsFolder = DataFolder.findFolder (toolbars);
InstanceDataObject.create(toolbarsFolder, null, MyConf.class);
}
示例13: findSessionFolder
import org.openide.loaders.DataFolder; //导入方法依赖的package包/类
/**
* Returns a DataFolder subfolder of the session folder. In the DataFolder
* folders go first (sorted by name) followed by the rest of objects sorted
* by name.
*/
public static DataFolder findSessionFolder (String name) {
try {
FileObject fo = FileUtil.getConfigFile(name);
if (fo == null) {
// resource not found, try to create new folder
fo = FileUtil.createFolder(FileUtil.getConfigRoot(), name);
}
return DataFolder.findFolder(fo);
} catch (IOException ex) {
throw (IllegalStateException) new IllegalStateException("Folder not found and cannot be created: " + name).initCause(ex); // NOI18N
}
}
示例14: setUp
import org.openide.loaders.DataFolder; //导入方法依赖的package包/类
protected @Override void setUp() throws Exception {
super.setUp();
MockLookup.setLayersAndInstances(new SimplePlatformProvider());
scratch = TestUtil.makeScratchDir(this);
projdir = scratch.createFolder("proj");
J2SEProjectGenerator.setDefaultSourceLevel(new SpecificationVersion ("1.6")); //NOI18N
helper = J2SEProjectGenerator.createProject(FileUtil.toFile(projdir),"proj","foo.Main","manifest.mf",null, false); //NOI18N
EditableProperties ep = helper.getProperties(AntProjectHelper.PRIVATE_PROPERTIES_PATH);
ep.put(ProjectProperties.DO_DEPEND, "true"); // to avoid too many changes in tests from issue #118079
helper.putProperties(AntProjectHelper.PRIVATE_PROPERTIES_PATH, ep);
J2SEProjectGenerator.setDefaultSourceLevel(null);
pm = ProjectManager.getDefault();
pp = pm.findProject(projdir).getLookup().lookup(J2SEProject.class);
actionProvider = new J2SEActionProvider(pp, pp.getUpdateHelper());
actionProvider.startFSListener();
sources = projdir.getFileObject("src");
tests = projdir.getFileObject("test");
// projdir.createData("build.xml");
build = projdir.createFolder("build");
build.createFolder("classes");
FileObject pkg = sources.getFileObject("foo");
FileObject fo = pkg.createData("Bar.java");
sourcePkg1 = DataFolder.findFolder (pkg);
pkg = sources.createFolder("foo2");
sourcePkg2 = DataFolder.findFolder (pkg);
someSource1 = DataObject.find(fo);
fo = sources.getFileObject("foo").getFileObject("Main.java");
createMain(fo);
someSource2 = DataObject.find(fo);
fo = sources.getFileObject("foo").createData("Third.java");
someSource3 = DataObject.find(fo);
pkg = tests.createFolder("foo");
fo = pkg.createData("BarTest.java");
testPkg1 = DataFolder.findFolder (pkg);
pkg = tests.createFolder("foo2");
testPkg2 = DataFolder.findFolder (pkg);
someTest1 = DataObject.find(fo);
fo = tests.getFileObject("foo").createData("MainTest.java");
someTest2 = DataObject.find(fo);
assertNotNull(someSource1);
assertNotNull(someSource2);
assertNotNull(someTest1);
assertNotNull(someTest2);
}
示例15: createMainClass
import org.openide.loaders.DataFolder; //导入方法依赖的package包/类
private static void createMainClass(
final @NonNull String mainClassName,
final @NonNull FileObject srcFolder,
@NullAllowed String mainClassTemplate) throws IOException {
int lastDotIdx = mainClassName.lastIndexOf( '.' );
String mName, pName;
if ( lastDotIdx == -1 ) {
mName = mainClassName.trim();
pName = null;
}
else {
mName = mainClassName.substring( lastDotIdx + 1 ).trim();
pName = mainClassName.substring( 0, lastDotIdx ).trim();
}
if ( mName.length() == 0 ) {
return;
}
if (mainClassTemplate == null) {
mainClassTemplate = "Templates/Classes/Main.java"; //NOI18N
}
final FileObject mainTemplate = FileUtil.getConfigFile(mainClassTemplate);
if ( mainTemplate == null ) {
LOG.log(
Level.WARNING,
"Template {0} not found!", //NOI18N
mainClassTemplate);
return; // Don't know the template
}
DataObject mt = DataObject.find( mainTemplate );
FileObject pkgFolder = srcFolder;
if ( pName != null ) {
String fName = pName.replace( '.', '/' ); // NOI18N
pkgFolder = FileUtil.createFolder( srcFolder, fName );
}
DataFolder pDf = DataFolder.findFolder( pkgFolder );
DataObject res = mt.createFromTemplate( pDf, mName );
if (res == null || !res.isValid()) {
LOG.log(
Level.WARNING,
"Template {0} created an invalid DataObject in folder {1}!", //NOI18N
new Object[] {
mainClassTemplate,
FileUtil.getFileDisplayName(pkgFolder)
});
}
}