本文整理匯總了Java中org.openide.filesystems.FileUtil.findBrother方法的典型用法代碼示例。如果您正苦於以下問題:Java FileUtil.findBrother方法的具體用法?Java FileUtil.findBrother怎麽用?Java FileUtil.findBrother使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.openide.filesystems.FileUtil
的用法示例。
在下文中一共展示了FileUtil.findBrother方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: findPrimaryFile
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
protected FileObject findPrimaryFile(FileObject fo)
{
LOG.info("FormKitDataLoader.findPrimaryFile(): " + fo.getNameExt());
cnt++;
String ext = fo.getExt();
if (ext.equals(FORM_EXTENSION))
{
return FileUtil.findBrother(fo, JAVA_EXTENSION);
}
if (ext.equals(JAVA_EXTENSION) && FileUtil.findBrother(fo, FORM_EXTENSION) != null)
{
return fo;
}
return null;
}
示例2: findPrimaryFile
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
@Override
protected FileObject findPrimaryFile(FileObject fo)
{
LOG.info("FXKitDataLoader.findPrimaryFile(): " + fo.getNameExt());
cnt++;
String ext = fo.getExt();
if (ext.equals(FX_EXT))
{
return FileUtil.findBrother(fo, JAVA_EXTENSION);
}
if (ext.equals(JAVA_EXTENSION) && FileUtil.findBrother(fo, FX_EXT) != null)
{
return fo;
}
return null;
}
示例3: findPrimaryFile
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
@Override
protected FileObject findPrimaryFile(FileObject fo)
{
LOG.info("FormKitDataLoader.findPrimaryFile(): " + fo.getNameExt());
cnt++;
String ext = fo.getExt();
if (ext.equals(FORM_EXTENSION))
{
return FileUtil.findBrother(fo, JAVA_EXTENSION);
}
if (ext.equals(JAVA_EXTENSION) && FileUtil.findBrother(fo, FORM_EXTENSION) != null)
{
return fo;
}
return null;
}
示例4: run
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
@Override
public void run() throws IOException {
FileObject target = FileUtil.createData(getProject().getProjectDirectory(), path);
if (tokens == null) {
copyByteAfterByte(content, target);
} else {
copyAndSubstituteTokens(content, target, tokens);
}
// #129446: form editor doesn't work sanely unless you do this:
if (target.hasExt("form")) { // NOI18N
FileObject java = FileUtil.findBrother(target, "java"); // NOI18N
if (java != null) {
java.setAttribute("justCreatedByNewWizard", true); // NOI18N
}
} else if (target.hasExt("java") && FileUtil.findBrother(target, "form") != null) { // NOI18N
target.setAttribute("justCreatedByNewWizard", true); // NOI18N
}
}
示例5: findPrimaryFile
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
/** For a given file finds a primary file.
* @param fo the file to find primary file for
*
* @return the primary file for the file or null if the file is not
* recognized by this loader
*/
@Override
protected FileObject findPrimaryFile(FileObject fo) {
// never recognize folders.
if (fo.isFolder()) return null;
String ext = fo.getExt();
if (ext.equals(FORM_EXTENSION))
return FileUtil.findBrother(fo, JAVA_EXTENSION);
FileObject javaFile = findJavaPrimaryFile(fo);
return javaFile != null
&& FileUtil.findBrother(javaFile, FORM_EXTENSION) != null ?
javaFile : null;
}
示例6: createMultiObject
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
/** Creates the right data object for given primary file.
* It is guaranteed that the provided file is realy primary file
* returned from the method findPrimaryFile.
*
* @param primaryFile the primary file
* @return the data object for this file
* @exception DataObjectExistsException if the primary file already has data object
*/
@Override
protected MultiDataObject createMultiObject(FileObject primaryFile)
throws DataObjectExistsException
{
return new FormDataObject(FileUtil.findBrother(primaryFile, FORM_EXTENSION),
primaryFile,
this);
}
示例7: createAction
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
/**
* Returns instance of GlobalAction encapsulating action, or null.
*/
private GlobalAction createAction (DataObject dataObject, String prefix, String name, boolean ignoreUserRemoves) {
InstanceCookie ic = dataObject.getCookie(InstanceCookie.class);
// handle any non-IC file as instruction to remove the action
FileObject pf = dataObject.getPrimaryFile();
if (ignoreUserRemoves && pf.canRevert()) {
return null;
}
if (ic == null) {
if (!EXT_REMOVED.equals(pf.getExt())) {
LOG.log(Level.WARNING, "Invalid shortcut: {0}", dataObject);
return null;
}
// ignore the 'remove' file, if there's a shadow (= real action) present
if (FileUtil.findBrother(pf, "shadow") != null) {
// handle redefinition + removal: ignore the removal.
return null;
}
return REMOVED;
}
try {
Object action = ic.instanceCreate ();
if (action == null) return null;
if (!(action instanceof Action)) return null;
return createAction((Action) action, prefix, name);
} catch (Exception ex) {
ex.printStackTrace ();
return null;
}
}
示例8: findPrimaryFile
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
@Override
protected FileObject findPrimaryFile(FileObject fo) {
if (!fo.isFolder()) {
// here is the common code for the worse behaviour
if (fo.hasExt("prima")) {
return FileUtil.findBrother(fo, "seconda") != null ? fo : null;
}
if (fo.hasExt("seconda")) {
return FileUtil.findBrother(fo, "prima");
}
}
return null;
}
示例9: findPrimaryFile
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
protected FileObject findPrimaryFile(FileObject fo) {
if (!fo.isFolder()) {
// here is the common code for the worse behaviour
if (fo.hasExt("prima")) {
return FileUtil.findBrother(fo, "seconda") != null ? fo : null;
}
if (fo.hasExt("seconda")) {
return FileUtil.findBrother(fo, "prima");
}
}
return null;
}
示例10: createMultiObject
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
protected MultiDataObject createMultiObject(FileObject primaryFile) throws DataObjectExistsException, java.io.IOException
{
LOG.info("FormKitDataLoader.createMultiObject(): " + primaryFile.getNameExt());
return new FormKitDataObject(FileUtil.findBrother(primaryFile, FORM_EXTENSION),
primaryFile,
this);
}
示例11: createMultiObject
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
@Override
protected MultiDataObject createMultiObject(FileObject primaryFile) throws DataObjectExistsException, java.io.IOException
{
LOG.info("FXKitDataLoader.createMultiObject(): " + primaryFile.getNameExt());
return new FXKitDataObject(FileUtil.findBrother(primaryFile, FX_EXT),
primaryFile,
this);
}
示例12: createMultiObject
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
@Override
protected MultiDataObject createMultiObject(FileObject primaryFile) throws DataObjectExistsException, java.io.IOException
{
LOG.info("FormKitDataLoader.createMultiObject(): " + primaryFile.getNameExt());
return new FormKitDataObject(FileUtil.findBrother(primaryFile, FORM_EXTENSION),
primaryFile,
this);
}
示例13: testCreateWithNameAndExtForForm
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
public void testCreateWithNameAndExtForForm() throws Exception {
LocalFileSystem lfs = new LocalFileSystem();
lfs.setRootDirectory(getWorkDir());
FileObject root = lfs.getRoot();
FileObject fo = FileUtil.createData(root, "j.java");
OutputStream os = fo.getOutputStream();
String txt = "print('<html><h1>', nameAndExt, '</h1></html>')";
os.write(txt.getBytes());
os.close();
fo.setAttribute(ScriptingCreateFromTemplateHandler.SCRIPT_ENGINE_ATTR, "js");
FileObject fo2 = FileUtil.createData(root, "j.form");
OutputStream os2 = fo2.getOutputStream();
String txt2 = "print('<html><h2>', nameAndExt, '</h2></html>')";
os2.write(txt2.getBytes());
os2.close();
fo2.setAttribute(ScriptingCreateFromTemplateHandler.SCRIPT_ENGINE_ATTR, "js");
DataObject obj = DataObject.find(fo);
assertEquals("Both files", 2, obj.files().size());
DataFolder folder = DataFolder.findFolder(FileUtil.createFolder(root, "target"));
Map<String,String> parameters = Collections.emptyMap();
DataObject n = obj.createFromTemplate(folder, "complex", parameters);
assertEquals("Two files", 2, n.files().size());
FileObject newForm = FileUtil.findBrother(n.getPrimaryFile(), "form");
assertEquals("Primary file is java", "java", n.getPrimaryFile().getExt());
assertNotNull("Form copied", newForm);
DataObject frm = DataObject.find(newForm);
assertSame("Form belongs to java", n, frm);
assertEquals("Created in right place", folder, n.getFolder());
assertEquals("Created with right name", "complex", n.getName());
String exp = "<html><h1> complex.java </h1></html>\n";
assertEquals("Primary file" + n.getPrimaryFile(), exp, readFile(n.getPrimaryFile()));
String exp2 = "<html><h2> complex.form </h2></html>\n";
assertEquals(exp2, readFile(newForm));
}
示例14: readOriginalKeymap
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
/**
* Reads original keymap entries, which are now replaced or deleted by the user's
* writable layer.
*
* @param root
* @return
*/
private Map<ShortcutAction, Set<String>> readOriginalKeymap(DataFolder root) {
Map<ShortcutAction, Set<String>> keymap =
new HashMap<ShortcutAction, Set<String>> ();
if (root == null) return keymap;
FileObject fo = root.getPrimaryFile();
Collection<FileObject> entries = (Collection<FileObject>)fo.getAttribute("revealEntries");
Set<String> names = new HashSet<String>();
for (FileObject f : entries) {
try {
GlobalAction action;
names.add(f.getName());
if (EXT_REMOVED.equals(f.getExt()) && FileUtil.findBrother(f, "shadow") == null) {
action = REMOVED;
} else {
FileObject orig = DataShadow.findOriginal(f);
if (orig == null) {
continue;
}
DataObject dataObject = DataObject.find(orig);
if (dataObject instanceof DataFolder) continue;
action = createActionWithLookup (dataObject, null, f.getName(), false);
}
if (action == null) continue;
String shortcut = f.getName();
LOG.log(Level.FINEST, "Overriden action {0}: {1}, by {2}", new Object[] {
action.getId(),
shortcut,
f.getPath()
});
Set<String> s = keymap.get (action);
if (s == null) {
s = new HashSet<String> ();
keymap.put (action, s);
}
s.add (shortcut);
} catch (IOException ex) {
// handle somehow
}
}
return keymap;
}
示例15: testCreateWithNameAndExtForForm
import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
public void testCreateWithNameAndExtForForm() throws Exception {
LocalFileSystem lfs = new LocalFileSystem();
lfs.setRootDirectory(getWorkDir());
FileObject root = lfs.getRoot();
FileObject fo = FileUtil.createData(root, "j.java");
OutputStream os = fo.getOutputStream();
String txt = "<html><h1>${nameAndExt}</h1></html>";
os.write(txt.getBytes());
os.close();
fo.setAttribute("javax.script.ScriptEngine", "freemarker");
FileObject fo2 = FileUtil.createData(root, "j.form");
OutputStream os2 = fo2.getOutputStream();
String txt2 = "<html><h2>${nameAndExt}</h2></html>";
os2.write(txt2.getBytes());
os2.close();
fo2.setAttribute("javax.script.ScriptEngine", "freemarker");
DataObject obj = DataObject.find(fo);
assertEquals("Both files", 2, obj.files().size());
DataFolder folder = DataFolder.findFolder(FileUtil.createFolder(root, "target"));
Map<String,String> parameters = Collections.emptyMap();
DataObject n = obj.createFromTemplate(folder, "complex", parameters);
assertEquals("Two files", 2, n.files().size());
FileObject newForm = FileUtil.findBrother(n.getPrimaryFile(), "form");
assertEquals("Primary file is java", "java", n.getPrimaryFile().getExt());
assertNotNull("Form copied", newForm);
DataObject frm = DataObject.find(newForm);
assertSame("Form belongs to java", n, frm);
assertEquals("Created in right place", folder, n.getFolder());
assertEquals("Created with right name", "complex", n.getName());
String exp = "<html><h1>complex.java</h1></html>";
assertEquals("Primary file" + n.getPrimaryFile(), exp, readFile(n.getPrimaryFile()));
String exp2 = "<html><h2>complex.form</h2></html>";
assertEquals(exp2, readFile(newForm));
}