本文整理了Java中org.openide.filesystems.FileUtil.getOrder()
方法的一些代码示例,展示了FileUtil.getOrder()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtil.getOrder()
方法的具体详情如下:
包路径:org.openide.filesystems.FileUtil
类名称:FileUtil
方法名:getOrder
[英]Sorts some sibling file objects.
Normally this is done by looking for numeric file attributes named position
on the children; children with a lower position number are placed first. Now-deprecated relative ordering attributes of the form earlier/later
may also be used; if the above attribute has a boolean value of true
, then the file named earlier
will be sorted somewhere (not necessarily directly) before the file named later
. Numeric and relative attributes may also be mixed.
The sort is stable at least to the extent that if there is no ordering information whatsoever, the returned list will be in the same order as the incoming collection.
[中]对某些同级文件对象进行排序。
通常,这是通过在子对象上查找名为position
的数字文件属性来完成的;位置号较低的儿童排在第一位。现在也可以使用earlier/later
形式的不推荐的相对排序属性;如果上述属性的布尔值为true
,则名为earlier
的文件将排序在名为later
的文件之前的某个位置(不一定直接排序)。数字属性和相对属性也可以混合使用。
排序是稳定的,至少在某种程度上,如果没有任何排序信息,返回的列表将与传入集合的顺序相同。
代码示例来源:origin: org.netbeans.api/org-openide-filesystems
private static List<FOItem> order(List<FOItem> items) {
Map<FileObject,FOItem> m = new LinkedHashMap<FileObject,FOItem>();
for (FOItem item : items) {
m.put(item.fo, item);
}
List<FileObject> files = FileUtil.getOrder(m.keySet(), true);
List<FOItem> r = new ArrayList<FOItem>(files.size());
for (FileObject f : files) {
r.add(m.get(f));
}
return r;
}
代码示例来源:origin: senbox-org/snap-desktop
private static void registerLayerEditors() {
FileObject[] files = FileUtil.getConfigFile("LayerEditors").getChildren();
//System.out.println("Files in SNAP/LayerEditors: " + Arrays.toString(files));
List<FileObject> orderedFiles = FileUtil.getOrder(Arrays.asList(files), true);
for (FileObject file : orderedFiles) {
try {
registerLayerEditorDescriptor(file);
LOG.info(String.format("New layer editor registered from layer.xml path '%s'", file.getPath()));
} catch (Exception e) {
LOG.log(Level.SEVERE, String.format("Failed to register layer editor from layer.xml path '%s'", file.getPath()), e);
}
}
}
代码示例来源:origin: senbox-org/snap-desktop
private void addAboutBoxPlugins(JTabbedPane tabbedPane, FileObject configFile) {
FileObject aboutBoxPanels[] = configFile.getChildren();
List<FileObject> orderedAboutBoxPanels = FileUtil.getOrder(Arrays.asList(aboutBoxPanels), true);
for (FileObject aboutBoxFileObject : orderedAboutBoxPanels) {
JComponent panel = FileUtil.getConfigObject(aboutBoxFileObject.getPath(), JComponent.class);
if (panel != null) {
String displayName = (String) aboutBoxFileObject.getAttribute("displayName");
if (displayName != null && !displayName.trim().isEmpty()) {
Icon icon = null;
String iconPath = (String) aboutBoxFileObject.getAttribute("iconPath");
if (iconPath != null && !iconPath.trim().isEmpty()) {
Image image = ImageUtilities.loadImage(iconPath, false);
if (image != null) {
icon = new ImageIcon(image);
}
}
tabbedPane.addTab(displayName, icon, panel);
}
}
}
}
}
代码示例来源:origin: senbox-org/snap-desktop
private static Map<String, LayerSourceDescriptor> lookupLayerSourceDescriptors() {
Map<String, LayerSourceDescriptor> layerSourceDescriptors = new LinkedHashMap<>();
FileObject[] files = FileUtil.getConfigFile("LayerSources").getChildren();
//System.out.println("Files in SNAP/LayerSources: " + Arrays.toString(files));
List<FileObject> orderedFiles = FileUtil.getOrder(Arrays.asList(files), true);
for (FileObject file : orderedFiles) {
LayerSourceDescriptor layerSourceDescriptor = null;
try {
layerSourceDescriptor = createLayerSourceDescriptor(file);
} catch (Exception e) {
LOG.log(Level.SEVERE, String.format("Failed to create layer source from layer.xml path '%s'", file.getPath()), e);
}
if (layerSourceDescriptor != null) {
layerSourceDescriptors.put(layerSourceDescriptor.getId(), layerSourceDescriptor);
LOG.info(String.format("New layer source added from layer.xml path '%s': %s",
file.getPath(), layerSourceDescriptor.getName()));
}
}
return layerSourceDescriptors;
}
代码示例来源:origin: org.netbeans.api/org-netbeans-spi-quicksearch
private static List<Category> loadCategories () {
FileObject[] categoryFOs = FileUtil.getConfigFile(SEARCH_PROVIDERS_FOLDER).getChildren();
// respect ordering defined in layers
List<FileObject> sortedCats = FileUtil.getOrder(Arrays.asList(categoryFOs), false);
List<ProviderModel.Category> categories = new ArrayList<ProviderModel.Category>(sortedCats.size());
for (FileObject curFO : sortedCats) {
String displayName = null;
try {
displayName = curFO.getFileSystem().getStatus().annotateName(
curFO.getNameExt(), Collections.singleton(curFO));
} catch (FileStateInvalidException ex) {
Logger.getLogger(ProviderModel.class.getName()).log(Level.WARNING,
"Obtaining display name for " + curFO + " failed.", ex);
}
String commandPrefix = null;
Object cpAttr = curFO.getAttribute(COMMAND_PREFIX);
if (cpAttr instanceof String) {
commandPrefix = (String)cpAttr;
}
categories.add(new Category(curFO, displayName, commandPrefix));
}
return categories;
}
代码示例来源:origin: senbox-org/snap-desktop
private void registerWWLayers() {
final FileObject fileObj = FileUtil.getConfigFile("WorldWindLayers");
if (fileObj == null) {
SystemUtils.LOG.warning("No World Wind layers found.");
return;
}
final FileObject[] files = fileObj.getChildren();
final List<FileObject> orderedFiles = FileUtil.getOrder(Arrays.asList(files), true);
for (FileObject file : orderedFiles) {
WWLayerDescriptor WWLayerDescriptor = null;
try {
WWLayerDescriptor = createWWLayerDescriptor(file);
} catch (Exception e) {
SystemUtils.LOG.severe(String.format("Failed to create WWLayerDescriptor from layer.xml path '%s'", file.getPath()));
}
if (WWLayerDescriptor != null) {
final WWLayerDescriptor existingDescriptor = wwLayerDescriptors.get(WWLayerDescriptor.getId());
if (existingDescriptor != null) {
SystemUtils.LOG.warning(String.format("WWLayer [%s] has been redeclared!\n",
WWLayerDescriptor.getId()));
}
wwLayerDescriptors.put(WWLayerDescriptor.getId(), WWLayerDescriptor);
SystemUtils.LOG.fine(String.format("New WWLayer added from layer.xml path '%s': %s",
file.getPath(), WWLayerDescriptor.getId()));
}
}
}
代码示例来源:origin: senbox-org/snap-desktop
private void registerOperatorUIs() {
FileObject fileObj = FileUtil.getConfigFile("OperatorUIs");
if(fileObj == null) {
SystemUtils.LOG.warning("No operatorUIs found.");
return;
}
final FileObject[] files = fileObj.getChildren();
final List<FileObject> orderedFiles = FileUtil.getOrder(Arrays.asList(files), true);
for (FileObject file : orderedFiles) {
OperatorUIDescriptor operatorUIDescriptor = null;
try {
operatorUIDescriptor = createOperatorUIDescriptor(file);
} catch (Exception e) {
SystemUtils.LOG.severe(String.format("Failed to create operatorUI from layer.xml path '%s'", file.getPath()));
}
if (operatorUIDescriptor != null) {
// must have only one operatorUI per operator
final OperatorUIDescriptor existingDescriptor = operatorUIDescriptors.get(operatorUIDescriptor.getOperatorName());
if (existingDescriptor != null) {
SystemUtils.LOG.info(String.format("OperatorUI [%s] has been redeclared for [%s]!\n",
operatorUIDescriptor.getId(), operatorUIDescriptor.getOperatorName()));
}
operatorUIDescriptors.put(operatorUIDescriptor.getOperatorName(), operatorUIDescriptor);
SystemUtils.LOG.fine(String.format("New operatorUI added from layer.xml path '%s': %s",
file.getPath(), operatorUIDescriptor.getOperatorName()));
}
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-utils
private void initialize(FileObject configFolder) {
mime2ext.clear();
if (configFolder != null) {
for (FileObject fo : FileUtil.getOrder(Arrays.asList(configFolder.getChildren()), false)) {
MIMEExtensions data = create(fo);
if (!mime2ext.containsKey(data.getMIMEType())) {
mime2ext.put(data.getMIMEType(), data);
if (MIMENames.HEADER_MIME_TYPE.equals(data.getMIMEType())) {
MIMEExtensions cHeader = new MIMEExtensions(MIMENames.C_HEADER_MIME_TYPE, data);
// check if newly created or already has custom value in prefs
String defExt = preferences.get(MIMENames.C_HEADER_MIME_TYPE, ""); // NOI18N
if (defExt.length() == 0) {
// for newly created use normal headers extension
cHeader.setDefaultExtension(data.getDefaultExtension());
}
mime2ext.put(MIMENames.C_HEADER_MIME_TYPE, cHeader);
}
}
}
// also cache shell files
MIMEExtensions shell = new MIMEExtensions(MIMENames.SHELL_MIME_TYPE, ""); // NOI18N
mime2ext.put(MIMENames.SHELL_MIME_TYPE, shell);
}
}
代码示例来源:origin: org.netbeans.api/org-netbeans-modules-editor-settings-lib
List<Object []> osSpecificFiles = new ArrayList<Object []>();
List<FileObject> ff = FileUtil.getOrder(Arrays.asList(folder.getChildren()), false);
for(FileObject f : ff) {
if (!f.isData()) {
代码示例来源:origin: senbox-org/snap-desktop
private void registerActions() {
final FileObject fileObj = FileUtil.getConfigFile("ProductLibraryActions");
if (fileObj == null) {
SystemUtils.LOG.warning("No ProductLibrary Action found.");
return;
}
final FileObject[] files = fileObj.getChildren();
final List<FileObject> orderedFiles = FileUtil.getOrder(Arrays.asList(files), true);
for (FileObject file : orderedFiles) {
ProductLibraryActionExtDescriptor actionExtDescriptor = null;
try {
actionExtDescriptor = createDescriptor(file);
} catch (Exception e) {
SystemUtils.LOG.severe(String.format("Failed to create ProductLibrary action from layer.xml path '%s'", file.getPath()));
}
if (actionExtDescriptor != null) {
if(!actionExtDescriptor.isSeperator()) {
final ProductLibraryActionExtDescriptor existingDescriptor = actionExtDescriptors.get(actionExtDescriptor.getId());
if (existingDescriptor != null) {
SystemUtils.LOG.warning(String.format("ProductLibrary action [%s] has been redeclared!\n",
actionExtDescriptor.getId()));
}
}
actionExtDescriptors.put(actionExtDescriptor.getId(), actionExtDescriptor);
SystemUtils.LOG.fine(String.format("New ProductLibrary action added from layer.xml path '%s': %s",
file.getPath(), actionExtDescriptor.getId()));
}
}
}
内容来源于网络,如有侵权,请联系作者删除!