Java 类com.intellij.openapi.components.RoamingType 实例源码

项目:tools-idea    文件:SchemesManagerImpl.java   
public SchemesManagerImpl(final String fileSpec,
                          final SchemeProcessor<E> processor,
                          final RoamingType roamingType,
                          StreamProvider[] providers,
                          File baseDir) {

  myFileSpec = fileSpec;
  myProcessor = processor;
  myRoamingType = roamingType;
  myProviders = providers;
  myBaseDir = baseDir;
  if (processor instanceof SchemeExtensionProvider) {
    mySchemeExtension = ((SchemeExtensionProvider)processor).getSchemeExtension();
    myUpgradeExtension = ((SchemeExtensionProvider)processor).isUpgradeNeeded();
  }

  myBaseDir.mkdirs();

  if (ApplicationManager.getApplication().isUnitTestMode() || !ApplicationManager.getApplication().isCommandLine()) {
    addVFSListener();
  }
}
项目:tools-idea    文件:SchemesManagerImpl.java   
public void exportScheme(final E scheme, final String name, final String description) throws WriteExternalException, IOException {
  final StreamProvider[] providers = ((ApplicationImpl)ApplicationManager.getApplication()).getStateStore().getStateStorageManager()
      .getStreamProviders(RoamingType.GLOBAL);
  if (providers != null) {
    Document document = myProcessor.writeScheme(scheme);
    if (document != null) {
      Document wrapped = wrap(document, name, description);
      for (StreamProvider provider : providers) {
        if (provider instanceof CurrentUserHolder) {
          wrapped = (Document)wrapped.clone();
          String userName = ((CurrentUserHolder)provider).getCurrentUserName();
          if (userName != null) {
            wrapped.getRootElement().setAttribute(USER, userName);
          }
        }
        StorageUtil.sendContent(provider, getFileFullPath(UniqueFileNamesProvider.convertName(scheme.getName())) + mySchemeExtension,
                                wrapped, RoamingType.GLOBAL, false);
      }
    }
  }

}
项目:tools-idea    文件:EditorColorsManagerImpl.java   
public EditorColorsManagerImpl(DefaultColorSchemesManager defaultColorSchemesManager, SchemesManagerFactory schemesManagerFactory) {
  myDefaultColorSchemesManager = defaultColorSchemesManager;

  mySchemesManager = schemesManagerFactory.createSchemesManager(
    FILE_SPEC,
    new MySchemeProcessor(), RoamingType.PER_USER);

  addDefaultSchemes();

  // Load default schemes from providers
  if (!isUnitTestOrHeadlessMode()) {
    loadSchemesFromBeans();
  }

  loadAllSchemes();

  loadAdditionalTextAttributes();

  setGlobalScheme(myDefaultColorSchemesManager.getAllSchemes()[0]);
}
项目:intellij-ce-playground    文件:MockSchemesManagerFactory.java   
@NotNull
@Override
public <T extends Scheme, E extends ExternalizableScheme> SchemesManager<T, E> createSchemesManager(@NotNull String directoryName,
                                                                                                    @NotNull SchemeProcessor<E> processor,
                                                                                                    @NotNull RoamingType roamingType) {
  //noinspection unchecked
  return EMPTY;
}
项目:tools-idea    文件:SchemesManagerImpl.java   
@Nullable
private static Document loadGlobalScheme(final String schemePath) throws IOException {
  final StreamProvider[] providers = ((ApplicationImpl)ApplicationManager.getApplication()).getStateStore().getStateStorageManager()
      .getStreamProviders(RoamingType.GLOBAL);
  for (StreamProvider provider : providers) {
    if (provider.isEnabled()) {
      Document document = StorageUtil.loadDocument(provider.loadContent(schemePath, RoamingType.GLOBAL));
      if (document != null) return document;
    }
  }

  return null;
}
项目:tools-idea    文件:SchemesManagerImpl.java   
public boolean isImportAvailable() {
  final StreamProvider[] providers = ((ApplicationImpl)ApplicationManager.getApplication()).getStateStore().getStateStorageManager()
      .getStreamProviders(RoamingType.GLOBAL);

  if (providers == null) return false;

  for (StreamProvider provider : providers) {
    if (provider.isEnabled()) return true;
  }

  return false;
}
项目:tools-idea    文件:ComponentRoamingManager.java   
public RoamingType getRoamingType(String name){
  if (myRoamingTypeMap.containsKey(name)) {
    return myRoamingTypeMap.get(name);
  }

  return RoamingType.PER_USER;
}
项目:tools-idea    文件:StorageUtil.java   
public static void sendContent(StreamProvider provider, String fileSpec, Document copy, RoamingType type, boolean async) throws IOException {
  byte[] content = printDocument(copy);
  ByteArrayInputStream in = new ByteArrayInputStream(content);
  try {
    if (provider.isEnabled()) {
      provider.saveContent(fileSpec, in, content.length, type, async);
    }
  }
  finally {
    in.close();
  }
}
项目:tools-idea    文件:BaseToolManager.java   
public BaseToolManager(ActionManagerEx actionManagerEx, SchemesManagerFactory factory) {
  myActionManager = actionManagerEx;

  mySchemesManager = factory.createSchemesManager(
    getSchemesPath(), createProcessor(), RoamingType.PER_USER);

  mySchemesManager.loadSchemes();
  registerActions();
}
项目:consulo    文件:StateStorageManagerImplTest.java   
public void testCreateStateStorageAssertionThrownWhenUnknownMacro() {
  try {
    myStateStorageManager.getStateStorage("$UNKNOWN_MACRO$/test.xml", RoamingType.PER_USER);
    fail("Exception expected");
  }
  catch (IllegalArgumentException e) {
    assertEquals("Unknown macro: $UNKNOWN_MACRO$ in storage file spec: $UNKNOWN_MACRO$/test.xml", e.getMessage());
  }
}
项目:consulo    文件:ExternalStorage.java   
public void saveContent(@Nonnull String fileSpec, @Nonnull RoamingType roamingType, byte[] content, int size) throws IOException {
  UnsyncByteArrayOutputStream out = new UnsyncByteArrayOutputStream(size);
  try (SnappyOutputStream snappyOutputStream = new SnappyOutputStream(out)) {
    snappyOutputStream.write(content, 0, size);
  }

  byte[] compressedContent = out.toByteArray();

  myQueue.wantSave(myProxyDirectory, fileSpec, roamingType, compressedContent);
}
项目:consulo    文件:ExternalStorage.java   
@Nonnull
public Collection<String> listSubFiles(@Nonnull String fileSpec, @Nonnull RoamingType roamingType) {
  fileSpec = buildFileSpec(roamingType, fileSpec);

  File proxy = new File(myProxyDirectory, fileSpec);
  if (proxy.isDirectory() && proxy.isDirectory()) {
    return Arrays.asList(proxy.list());
  }
  return Collections.emptyList();
}
项目:consulo    文件:ExternalStorage.java   
@Nonnull
public static String buildFileSpec(@Nonnull RoamingType roamingType, @Nonnull String fileSpec) {
  switch (roamingType) {
    case PER_PLATFORM:
      return "$OS$/" + getOsPrefix() + "/" + fileSpec;
    case PER_USER:
      return "$GLOBAL$/" + fileSpec;
    default:
      throw new UnsupportedOperationException(roamingType.name());
  }
}
项目:consulo    文件:ExternalStorageQueue.java   
void wantSave(@Nonnull File proxyDirectory, @Nonnull String fileSpec, RoamingType roamingType, byte[] content) throws IOException {
  File file = new File(proxyDirectory, ExternalStorage.buildFileSpec(roamingType, fileSpec));
  FileUtil.createParentDirs(file);
  FileUtil.writeToFile(file, content);

  try (CloseableHttpClient client = HttpClients.createDefault()) {
    URIBuilder urlBuilder = new URIBuilder(WebServiceApi.SYNCHRONIZE_API.buildUrl("pushFile"));
    urlBuilder.addParameter("filePath", ExternalStorage.buildFileSpec(roamingType, fileSpec));

    HttpPost request = new HttpPost(urlBuilder.build());
    request.setEntity(new ByteArrayEntity(content));
    String authKey = WebServicesConfiguration.getInstance().getOAuthKey(WebServiceApi.SYNCHRONIZE_API);
    if (authKey != null) {
      request.addHeader("Authorization", authKey);
    }

    PushFile pushFile = client.execute(request, response -> {
      if (response.getStatusLine().getStatusCode() == HttpURLConnection.HTTP_UNAUTHORIZED) {
        throw new AuthorizationFailedException();
      }
      return new Gson().fromJson(EntityUtils.toString(response.getEntity()), PushFile.class);
    });

    File modCountFile = ExternalStorageUtil.getModCountFile(file);
    FileUtil.writeToFile(modCountFile, String.valueOf(pushFile.modCount));
  }
  catch (URISyntaxException e) {
    throw new IOException(e);
  }
}
项目:consulo    文件:SchemesManagerFactoryImpl.java   
@Override
public <T extends Named, E extends ExternalizableScheme> SchemesManager<T, E> createSchemesManager(final String fileSpec,
                                                                                                    final SchemeProcessor<E> processor,
                                                                                                    final RoamingType roamingType) {
  final Application application = ApplicationManager.getApplication();
  if (!(application instanceof ApplicationEx2)) return null;
  String baseDirPath = ((ApplicationEx2)application).getStateStore().getStateStorageManager().expandMacros(fileSpec);

  StreamProvider
          provider = ((ApplicationEx2)ApplicationManager.getApplication()).getStateStore().getStateStorageManager().getStreamProvider();
  SchemesManagerImpl<T, E> manager = new SchemesManagerImpl<T, E>(fileSpec, processor, roamingType, provider, new File(baseDirPath));
  myRegisteredManagers.add(manager);
  return manager;
}
项目:consulo    文件:StorageUtil.java   
public static void sendContent(@Nonnull StreamProvider provider, @Nonnull String fileSpec, @Nonnull Parent element, @Nonnull RoamingType type) {
  if (!provider.isApplicable(fileSpec, type)) {
    return;
  }

  try {
    doSendContent(provider, fileSpec, element, type);
  }
  catch (IOException e) {
    LOG.warn(e);
  }
}
项目:consulo    文件:XmlElementStorage.java   
protected XmlElementStorage(@Nonnull String fileSpec,
                            @Nullable RoamingType roamingType,
                            @Nullable TrackingPathMacroSubstitutor pathMacroSubstitutor,
                            @Nonnull String rootElementName,
                            @Nullable StreamProvider streamProvider) {
  super(pathMacroSubstitutor);

  myFileSpec = fileSpec;
  myRoamingType = roamingType == null ? RoamingType.PER_USER : roamingType;
  myRootElementName = rootElementName;
  myStreamProvider = myRoamingType == RoamingType.DISABLED ? null : streamProvider;
}
项目:consulo    文件:XmlElementStorage.java   
private void doSaveForProvider(@Nonnull Element element, @Nonnull RoamingType roamingType, @Nullable BufferExposingByteArrayOutputStream content) throws IOException {
  if (content == null) {
    StorageUtil.sendContent(myStreamProvider, myFileSpec, element, roamingType);
  }
  else {
    myStreamProvider.saveContent(myFileSpec, content.getInternalBuffer(), content.size(), myRoamingType);
  }
}
项目:consulo    文件:BaseToolManager.java   
public BaseToolManager(ActionManagerEx actionManagerEx, SchemesManagerFactory factory) {
  myActionManager = actionManagerEx;

  mySchemesManager = factory.createSchemesManager(
    getSchemesPath(), createProcessor(), RoamingType.PER_USER);

  mySchemesManager.loadSchemes();
  registerActions();
}
项目:intellij-ce-playground    文件:SchemesManagerFactory.java   
/**
 * directoryName — like "keymaps".
 */
@NotNull
public abstract <T extends Scheme, E extends ExternalizableScheme> SchemesManager<T, E> createSchemesManager(@NotNull String directoryName,
                                                                                                             @NotNull SchemeProcessor<E> processor,
                                                                                                             @NotNull RoamingType roamingType);
项目:intellij-ce-playground    文件:SchemesManagerFactory.java   
@NotNull
public final <T extends Scheme, E extends ExternalizableScheme> SchemesManager<T, E> create(@NotNull String directoryName, @NotNull SchemeProcessor<E> processor) {
  return createSchemesManager(directoryName, processor, RoamingType.DEFAULT);
}
项目:tools-idea    文件:StreamProvider.java   
public InputStream loadContent(final String fileSpec, final RoamingType roamingType) throws IOException {
  return null;
}
项目:tools-idea    文件:StreamProvider.java   
@Nullable
InputStream loadContent(final String fileSpec, final RoamingType roamingType) throws IOException;
项目:tools-idea    文件:SchemesManagerFactory.java   
public abstract <T extends Scheme, E extends ExternalizableScheme> SchemesManager<T,E> createSchemesManager(String fileSpec, SchemeProcessor<E> processor,
RoamingType roamingType);
项目:tools-idea    文件:MockSchemesManagerFactory.java   
@Override
public <T extends Scheme,E extends ExternalizableScheme> SchemesManager<T,E> createSchemesManager(final String fileSpec,
                                                                 final SchemeProcessor<E> processor, final RoamingType roamingType) {
  return SchemesManager.EMPTY;
}
项目:tools-idea    文件:SchemesManagerImpl.java   
@NotNull
public Collection<SharedScheme<E>> loadSharedSchemes(Collection<T> currentSchemeList) {
  Collection<String> names = new HashSet<String>(getAllSchemeNames(currentSchemeList));

  final StreamProvider[] providers = ((ApplicationImpl)ApplicationManager.getApplication()).getStateStore().getStateStorageManager()
      .getStreamProviders(RoamingType.GLOBAL);
  final HashMap<String, SharedScheme<E>> result = new HashMap<String, SharedScheme<E>>();
  if (providers != null) {
    for (StreamProvider provider : providers) {
      if (provider.isEnabled()) {
        String[] paths = provider.listSubFiles(myFileSpec);
        for (String subpath : paths) {
          try {
            final Document subDocument = StorageUtil.loadDocument(provider.loadContent(getFileFullPath(subpath), RoamingType.GLOBAL));
            if (subDocument != null) {
              SharedSchemeData original = unwrap(subDocument);
              final E scheme = myProcessor.readScheme(original.original);
              if (!alreadyShared(subpath, currentSchemeList)) {
                String schemeName = original.name;
                String uniqueName = UniqueNameGenerator.generateUniqueName("[shared] " + schemeName, names);
                renameScheme(scheme, uniqueName);
                schemeName = uniqueName;
                scheme.getExternalInfo().setOriginalPath(getFileFullPath(subpath));
                scheme.getExternalInfo().setIsImported(true);
                result.put(schemeName,
                           new SharedScheme<E>(original.user == null ? "unknown" : original.user, original.description, scheme));
              }
            }
          }
          catch (Exception e) {
            LOG.debug("Cannot load data from IDEAServer: " + e.getLocalizedMessage());
          }
        }
      }
    }
  }

  for (SharedScheme<E> t : result.values()) {
    myProcessor.initScheme(t.getScheme());
  }

  return result.values();

}
项目:tools-idea    文件:ComponentRoamingManager.java   
public void setRoamingType(final String name, final RoamingType roamingType) {
   myRoamingTypeMap.put(name, roamingType);
}
项目:consulo    文件:MockSchemesManagerFactory.java   
@Override
public <T extends Named,E extends ExternalizableScheme> SchemesManager<T,E> createSchemesManager(final String fileSpec,
                                                                 final SchemeProcessor<E> processor, final RoamingType roamingType) {
  return new EmptySchemesManager();
}
项目:consulo    文件:StateStorageManagerImplTest.java   
public void testCreateFileStateStorageMacroSubstituted() {
  StateStorage data = myStateStorageManager.getStateStorage("$MACRO1$/test.xml", RoamingType.PER_USER);
  assertThat(data, is(notNullValue()));
}
项目:consulo    文件:StateStorageManagerImplTest.java   
public void testCreateFileStateStorageMacroSubstitutedWhenExpansionHas$() {
  myStateStorageManager.addMacro("$DOLLAR_MACRO$", "/temp/d$");
  StateStorage data = myStateStorageManager.getStateStorage("$DOLLAR_MACRO$/test.xml", RoamingType.PER_USER);
  assertThat(data, is(notNullValue()));
}
项目:consulo    文件:XmlElementStorageTest.java   
public MyXmlElementStorage(Element element) throws StateStorageException {
  super("", RoamingType.PER_USER, new MyPathMacroManager(), "root", null);
  myElement = element;
}
项目:consulo    文件:SchemesManagerFactory.java   
public abstract <T extends Named, E extends ExternalizableScheme> SchemesManager<T,E> createSchemesManager(String fileSpec, SchemeProcessor<E> processor,
RoamingType roamingType);
项目:consulo    文件:ExternalStorageStreamProvider.java   
@Nonnull
@Override
public Collection<String> listSubFiles(@Nonnull String fileSpec, @Nonnull RoamingType roamingType) {
  return myStorage.listSubFiles(fileSpec, roamingType);
}
项目:consulo    文件:ExternalStorageStreamProvider.java   
@Override
public void saveContent(@Nonnull String fileSpec, @Nonnull byte[] content, int size, @Nonnull RoamingType roamingType) throws IOException {
  myStorage.saveContent(fileSpec, roamingType, content, size);
}
项目:consulo    文件:ExternalStorageStreamProvider.java   
@javax.annotation.Nullable
@Override
public InputStream loadContent(@Nonnull String fileSpec, @Nonnull RoamingType roamingType) throws IOException {
  return myStorage.loadContent(fileSpec, roamingType, myStateStorageManager);
}
项目:consulo    文件:ExternalStorageStreamProvider.java   
@Override
public void delete(@Nonnull String fileSpec, @Nonnull RoamingType roamingType) {
  myStorage.delete(fileSpec, roamingType);
}
项目:consulo    文件:ExternalStorage.java   
public void delete(@Nonnull String fileSpec, @Nonnull RoamingType roamingType) {
  fileSpec = buildFileSpec(roamingType, fileSpec);

  File file = new File(myProxyDirectory, fileSpec);
  file.delete();
}
项目:consulo    文件:ExternalStorageQueue.java   
LoadItem(String fileSpec, RoamingType roamingType, int modCount, StateStorageManager stateStorageManager) {
  myFileSpec = fileSpec;
  myRoamingType = roamingType;
  myModCount = modCount;
  myStateStorageManager = stateStorageManager;
}
项目:consulo    文件:ExternalStorageQueue.java   
@Nullable
public Ref<byte[]> getContent(String fileSpec, RoamingType roamingType) {
  return myLoadedBytes.remove(ExternalStorage.buildFileSpec(roamingType, fileSpec));
}
项目:consulo    文件:StreamProvider.java   
/**
 * fileSpec Only main fileSpec, not version
 */
public boolean isApplicable(@Nonnull String fileSpec, @Nonnull RoamingType roamingType) {
  return true;
}