當前位置: 首頁>>代碼示例>>Java>>正文


Java Storage類代碼示例

本文整理匯總了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());
  }
}
 
開發者ID:consulo,項目名稱:consulo,代碼行數:15,代碼來源:DefaultStateSerializer.java

示例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;
}
 
開發者ID:consulo,項目名稱:consulo,代碼行數:61,代碼來源:ExportSettingsAction.java


注:本文中的com.intellij.openapi.components.Storage類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。