本文整理汇总了Java中org.openide.filesystems.FileObject.getAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java FileObject.getAttribute方法的具体用法?Java FileObject.getAttribute怎么用?Java FileObject.getAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openide.filesystems.FileObject
的用法示例。
在下文中一共展示了FileObject.getAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testGetAttributeClonedOnlyPush
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public void testGetAttributeClonedOnlyPush() throws HgException, IOException {
File folder = createFolder("folder");
File file = createFile(folder, "file");
commit(folder);
File cloned = clone(getWorkTreeDir());
String defaultPush = "http://a.repository.far.far/away";
new HgConfigFiles(cloned).removeProperty(HgConfigFiles.HG_PATHS_SECTION, HgConfigFiles.HG_DEFAULT_PULL);
new HgConfigFiles(cloned).removeProperty(HgConfigFiles.HG_PATHS_SECTION, HgConfigFiles.HG_DEFAULT_PULL_VALUE);
new HgConfigFiles(cloned).setProperty(HgConfigFiles.HG_DEFAULT_PUSH, defaultPush);
HgRepositoryContextCache.getInstance().reset();
FileObject fo = FileUtil.toFileObject(new File(new File(cloned, folder.getName()), file.getName()));
String attr = (String) fo.getAttribute("ProvidedExtensions.RemoteLocation");
assertNotNull(attr);
assertEquals(defaultPush, attr);
}
示例2: testBasicUsageWithEnablerFromLayer
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public void testBasicUsageWithEnablerFromLayer() throws Exception {
FileObject folder;
folder = FileUtil.getConfigFile("actions/support/test");
assertNotNull("testing layer is loaded: ", folder);
FileObject fo = folder.getFileObject("testContextEnabler.instance");
Object obj = fo.getAttribute("instanceCreate");
if (!(obj instanceof ContextAwareAction)) {
fail("Shall create an action: " + obj);
}
ContextAwareAction caa = (ContextAwareAction)obj;
Action action = caa.createContextAwareInstance(lookupProxy);
doBasicUsageWithEnabler(action);
}
示例3: setStartOffset
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public void setStartOffset(int offset) {
currentWord = null;
currentStartOffset = (-1);
CharSequence content = DocumentUtilities.getText(doc);
while (offset > 0 && offset < content.length()) {
if (!Character.isLetter(content.charAt(offset))) {
break;
}
offset--;
}
this.nextSearchOffset = offset;
FileObject fileObject = FileUtil.getConfigFile ("Spellcheckers/Plain");
Boolean b = (Boolean) fileObject.getAttribute ("Hidden");
hidden = Boolean.TRUE.equals (b);
}
示例4: testContextAction
import org.openide.filesystems.FileObject; //导入方法依赖的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);
}
示例5: write
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public void write(java.io.Writer w, Object inst) throws IOException {
w.write("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"+XMLSettingsSupport.LINE_SEPARATOR); // NOI18N
w.write("<!DOCTYPE properties PUBLIC \""); // NOI18N
FileObject foEntity = Env.findEntityRegistration(providerFO);
if (foEntity == null) foEntity = providerFO;
Object publicId = foEntity.getAttribute(Env.EA_PUBLICID);
if (publicId == null || !(publicId instanceof String)) {
throw new IOException("missing or invalid attribute: " + //NOI18N
Env.EA_PUBLICID + ", provider: " + foEntity); //NOI18N
}
w.write((String) publicId);
w.write("\" \"http://www.netbeans.org/dtds/properties-1_0.dtd\">"+XMLSettingsSupport.LINE_SEPARATOR); // NOI18N
w.write("<properties>"+XMLSettingsSupport.LINE_SEPARATOR); // NOI18N
Properties p = getProperties(inst);
if (p != null && !p.isEmpty()) writeProperties(w, p);
w.write("</properties>"+XMLSettingsSupport.LINE_SEPARATOR); // NOI18N
}
示例6: DelegatingVCS
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private DelegatingVCS(VersioningSystem delegate) {
this.delegate = delegate;
String serviceName = "Services/VersioningSystem/"+delegate.getClass().getName().replace('.', '-')+".instance"; // NOI18N
FileObject serviceFO = FileUtil.getConfigFile(serviceName); // NOI18N
metadataFolderNames = new HashSet<String>();
int i = 0;
while(true) {
String name = (String) serviceFO.getAttribute("metadataFolderName" + i++); // NOI18N
if(name == null) {
break;
}
name = parseName(name);
if(name == null) {
continue;
}
metadataFolderNames.add(name);
}
HashMap<String,String> aMap = new HashMap<String,String>();
aMap.put("actionsCategory", (String) serviceFO.getAttribute("actionsCategory")); // NOI18N
map = aMap;
this.displayName = (String) serviceFO.getAttribute("displayName"); // NOI18N
this.menuLabel = (String) serviceFO.getAttribute("menuLabel"); // NOI18N
this.isLocalHistory = false;
VersioningManager.LOG.log(Level.FINE, "Created DelegatingVCS for : {0}", displayName); // NOI18N
}
示例7: testGetRemoteLocationAttribute
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public void testGetRemoteLocationAttribute () throws Exception {
File file = new File(repositoryLocation, "attrfile");
file.createNewFile();
FileObject fo = FileUtil.toFileObject(file);
String str = (String) fo.getAttribute(PROVIDED_EXTENSIONS_REMOTE_LOCATION);
// TODO implement getRemoteRepositoryURL
// assertNotNull(str);
// assertEquals(repositoryLocation.getAbsolutePath().toString(), str);
}
示例8: getCurrentProfile
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public String getCurrentProfile() {
if (cachedProfile == null) {
FileObject fo = FileUtil.getConfigFile (KEYMAPS_FOLDER);
if (fo != null) {
Object o = fo.getAttribute (FATTR_CURRENT_KEYMAP_PROFILE);
if (o instanceof String) {
cachedProfile = (String) o;
}
}
if (cachedProfile == null) {
cachedProfile = DEFAULT_PROFILE;
}
}
return cachedProfile;
}
示例9: instanceAttribute
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
/**
* Tries to find the instance associated with a file.
* If it is a folder, or not a {@code *.instance} file, null is returned.
* If it has an {@code instanceCreate} attribute, that is used, else
* {@code instanceClass}, and finally the class implied by the filename.
* @param file any file
* @return a methodvalue or newvalue attribute, or null
* @see #findAndModifyDeclaration
*/
public @CheckForNull Object instanceAttribute(FileObject file) {
if (!file.isData() || !file.hasExt("instance")) {
return null; // not supporting *.settings etc. for now
}
Object instanceCreate = file.getAttribute("literal:instanceCreate");
if (instanceCreate != null) {
return instanceCreate;
}
Object clazz = file.getAttribute("instanceClass");
if (clazz != null) {
return "new:" + clazz;
}
return "new:" + file.getName().replace('-', '.');
}
示例10: openLayersForFile
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private void openLayersForFile(FileObject f) {
URL[] location = (URL[]) f.getAttribute("layers"); // NOI18N
if (location != null) {
for (URL u : location) {
FileObject layer = URLMapper.findFileObject(u);
if (layer != null) {
try {
openLayerFileAndFind(DataObject.find(layer), f);
} catch (DataObjectNotFoundException ex) {
Exceptions.printStackTrace(ex);
}
}
}
}
}
示例11: testMultiContextActionLookup
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public void testMultiContextActionLookup() throws Exception {
FileObject fo = FileUtil.getConfigFile(
"actions/support/test/testInjectContextLookup.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);
ic.add(3L);
assertEquals("Number lover!", clone.getValue(Action.NAME));
clone.actionPerformed(new ActionEvent(this, 300, ""));
assertEquals("Global Action not called", 13, LookupContext.cnt);
ic.remove(10);
clone.actionPerformed(new ActionEvent(this, 200, ""));
assertEquals("Adds 3", 16, LookupContext.cnt);
ic.remove(3L);
assertFalse("It is disabled", clone.isEnabled());
clone.actionPerformed(new ActionEvent(this, 200, ""));
assertEquals("No change", 16, LookupContext.cnt);
}
示例12: getDisableFilterAction
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
/**
* Checks if the parsing errors are filtered for this file or any of its
* parent folders.
*
* @param file
* @return
*/
private static SetFilterAction getDisableFilterAction(@NonNull FileObject file) {
FileObject source = file;
for (; file != null && FileOwnerQuery.getOwner(file) != null; file = file.getParent()) {
if (file.getAttribute(DISABLE_ERROR_CHECKS_KEY) != null) {
return new SetFileFilterAction(source, file, false);
}
}
return null;
}
示例13: getLocalizedName
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private static String getLocalizedName(FileObject f) {
Object displayName = f.getAttribute("displayName"); //NOI18N
if (displayName instanceof String) {
return (String) displayName;
} else {
try {
return f.getFileSystem().getDecorator().annotateName(
f.getNameExt(),
Collections.singleton(f));
} catch (FileStateInvalidException e) {
return f.getNameExt();
}
}
}
示例14: getCurrentKeyMapProfile
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public static String getCurrentKeyMapProfile() {
String currentKeyMapProfile = null;
FileObject fo = FileUtil.getConfigFile(KEYMAPS_FOLDER);
if (fo != null) {
Object o = fo.getAttribute(FATTR_CURRENT_KEYMAP_PROFILE);
if (o instanceof String) {
currentKeyMapProfile = (String) o;
}
}
if (currentKeyMapProfile == null) {
currentKeyMapProfile = DEFAULT_PROFILE;
}
return currentKeyMapProfile;
}
示例15: getAccelerator
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
/**
* Get single-key accelerator for a given declared action.
* Only a single-key accelerators are supported.
*/
public static KeyStroke getAccelerator(FileObject fo) {
if (fo == null) {
throw new IllegalArgumentException("Must be called with non-null fileObject"); // NOI18N
}
boolean fineLoggable = LOG.isLoggable(Level.FINE);
String path = fo.getParent().getPath();
String actionName = (String) fo.getAttribute(Action.NAME);
KeyStroke ks = null;
if (path.startsWith("Editors/")) {
path = path.substring(7); // Leave ending '/' to support "Editors/Actions"
if (path.endsWith("/Actions")) {
path = path.substring(0, path.length() - 8);
if (path.startsWith("/")) {
path = path.substring(1);
}
String mimeType = path;
if (!MimePath.validate(mimeType)) {
LOG.info("Invalid mime-type='" + mimeType + "' of action's fileObject=" + fo); // NOI18N
}
ks = getAccelerator(mimeType, actionName);
} else if (fineLoggable) {
LOG.fine("No \"/Actions\" at end of mime-type='" + path +
"' of action's fileObject=" + fo); // NOI18N
}
} else if (fineLoggable) {
LOG.fine("No \"Editors/\" at begining of mime-type='" + path + // NOI18N
"' of action's fileObject=" + fo); // NOI18N
}
if (LOG.isLoggable(Level.FINER)) {
LOG.finer("Accelerator for action \"" + actionName + "\" is " + ks);
}
return ks;
}