本文整理汇总了Java中com.intellij.openapi.components.Storage类的典型用法代码示例。如果您正苦于以下问题:Java Storage类的具体用法?Java Storage怎么用?Java Storage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Storage类属于com.intellij.openapi.components包,在下文中一共展示了Storage类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: serializeState
import com.intellij.openapi.components.Storage; //导入依赖的package包/类
@Nullable
static Element serializeState(@Nonnull Object state, @Nullable final Storage storage) throws WriteExternalException {
if (state instanceof Element) {
return (Element)state;
}
else if (state instanceof JDOMExternalizable) {
Element element = new Element("temp_element");
((JDOMExternalizable)state).writeExternal(element);
return element;
}
else {
return XmlSerializer.serializeIfNotDefault(state, new SkipDefaultValuesSerializationFilters());
}
}
示例2: getExportableComponentsMap
import com.intellij.openapi.components.Storage; //导入依赖的package包/类
@Nonnull
public static MultiMap<File, ExportableItem> getExportableComponentsMap(final boolean onlyExisting) {
final MultiMap<File, ExportableItem> result = MultiMap.createLinkedSet();
ApplicationImpl application = (ApplicationImpl)ApplicationManager.getApplication();
final StateStorageManager storageManager = application.getStateStore().getStateStorageManager();
ServiceManagerImpl.processAllImplementationClasses(application, (aClass, pluginDescriptor) -> {
State stateAnnotation = aClass.getAnnotation(State.class);
if (stateAnnotation != null && !StringUtil.isEmpty(stateAnnotation.name())) {
int storageIndex;
Storage[] storages = stateAnnotation.storages();
if (storages.length == 1) {
storageIndex = 0;
}
else if (storages.length > 1) {
storageIndex = storages.length - 1;
}
else {
return true;
}
Storage storage = storages[storageIndex];
if (storage.roamingType() != RoamingType.DISABLED) {
String fileSpec = storageManager.buildFileSpec(storage);
if (!fileSpec.startsWith(StoragePathMacros.APP_CONFIG)) {
return true;
}
File file = new File(storageManager.expandMacros(fileSpec));
File additionalExportFile = null;
if (!StringUtil.isEmpty(stateAnnotation.additionalExportFile())) {
additionalExportFile = new File(storageManager.expandMacros(stateAnnotation.additionalExportFile()));
if (onlyExisting && !additionalExportFile.exists()) {
additionalExportFile = null;
}
}
boolean fileExists = !onlyExisting || file.exists();
if (fileExists || additionalExportFile != null) {
File[] files;
if (additionalExportFile == null) {
files = new File[]{file};
}
else {
files = fileExists ? new File[]{file, additionalExportFile} : new File[]{additionalExportFile};
}
ExportableItem item = new ExportableItem(files, getComponentPresentableName(stateAnnotation, aClass, pluginDescriptor));
result.putValue(file, item);
if (additionalExportFile != null) {
result.putValue(additionalExportFile, item);
}
}
}
}
return true;
});
return result;
}