本文整理匯總了Java中org.openide.loaders.DataObject.getFolder方法的典型用法代碼示例。如果您正苦於以下問題:Java DataObject.getFolder方法的具體用法?Java DataObject.getFolder怎麽用?Java DataObject.getFolder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.openide.loaders.DataObject
的用法示例。
在下文中一共展示了DataObject.getFolder方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: updateSettings
import org.openide.loaders.DataObject; //導入方法依賴的package包/類
/**
* Updates settings used by this generator. It should be called outside locks.
* @param file a file where the generated content will be added
*/
public void updateSettings(FileObject file) {
DataObject dobj = null;
DataFolder folder = null;
try {
dobj = DataObject.find(file);
folder = dobj.getFolder();
} catch (DataObjectNotFoundException ex) {
Exceptions.printStackTrace(ex);
}
if (dobj == null || folder == null) {
return;
}
for (CreateFromTemplateAttributesProvider provider
: Lookup.getDefault().lookupAll(CreateFromTemplateAttributesProvider.class)) {
Map<String, ?> attrs = provider.attributesFor(dobj, folder, "XXX"); // NOI18N
if (attrs == null) {
continue;
}
Object aName = attrs.get("user"); // NOI18N
if (aName != null) {
author = aName.toString();
break;
}
}
}
示例2: addSource
import org.openide.loaders.DataObject; //導入方法依賴的package包/類
/** Adds source to source map (I18N wizard settings). If there is already no change is done.
* If it's added anew then it is tried to find correspondin reousrce, i.e.
* first resource from the same folder.
* @param sourceMap settings where to add teh sources
* @param source source to add */
public static void addSource(Map<DataObject,SourceData> sourceMap,
DataObject source) {
if (sourceMap.containsKey(source)) {
return;
}
DataFolder folder = source.getFolder();
if (folder == null) {
sourceMap.put(source, null);
return;
}
// try to associate Bundle file
for (DataObject child : folder.getChildren()) {
if (child instanceof PropertiesDataObject) { // PENDING
sourceMap.put(source, new SourceData(child));
return;
}
}
// No resource found in the same folder.
sourceMap.put(source, null);
}
示例3: enable
import org.openide.loaders.DataObject; //導入方法依賴的package包/類
/** Enabled only if the current project is ProjectDataObject.
*/
@Override
public boolean enable (Node[] arr) {
if ((arr == null) || (arr.length == 0)) return false;
for (int i = 0; i < arr.length; i++) {
DataObject shad = arr[i].getCookie(DataObject.class);
//Disable when node is not shadow in Favorites folder.
if (shad == null || shad.getFolder() != FavoritesNode.getFolder()) {
return false;
}
}
return true;
}
示例4: performAction
import org.openide.loaders.DataObject; //導入方法依賴的package包/類
/**
* Removes the links.
*
* @param arr gives array of actually activated nodes.
*/
@Override
protected void performAction (Node[] arr) {
for (int i = 0; i < arr.length; i++) {
DataObject shad = arr[i].getCookie(DataObject.class);
if (shad != null && shad.getFolder() == FavoritesNode.getFolder()) {
try {
shad.delete();
} catch (IOException ex) {
LOG.log(Level.WARNING, null, ex);
}
}
}
}