Java 类com.intellij.util.PathMappingSettings 实例源码

项目:intellij-ce-playground    文件:PydevConsoleRunner.java   
@Nullable
public static PyRemotePathMapper getPathMapper(@NotNull Project project, Sdk sdk) {
  if (PySdkUtil.isRemote(sdk)) {
    PythonRemoteInterpreterManager instance = PythonRemoteInterpreterManager.getInstance();
    if (instance != null) {
      //noinspection ConstantConditions
      PyRemotePathMapper remotePathMapper =
        instance.setupMappings(project, (PyRemoteSdkAdditionalDataBase)sdk.getSdkAdditionalData(), null);

      PathMappingSettings mappingSettings = PyConsoleOptions.getInstance(project).getPythonConsoleSettings().getMappingSettings();

      remotePathMapper.addAll(mappingSettings.getPathMappings(), PyRemotePathMapper.PyPathMappingType.USER_DEFINED);

      return remotePathMapper;
    }
  }
  return null;
}
项目:intellij-ce-playground    文件:AbstractPythonRunConfiguration.java   
public void readExternal(Element element) throws InvalidDataException {
  super.readExternal(element);
  myInterpreterOptions = JDOMExternalizerUtil.readField(element, "INTERPRETER_OPTIONS");
  readEnvs(element);
  mySdkHome = JDOMExternalizerUtil.readField(element, "SDK_HOME");
  myWorkingDirectory = JDOMExternalizerUtil.readField(element, "WORKING_DIRECTORY");
  myUseModuleSdk = Boolean.parseBoolean(JDOMExternalizerUtil.readField(element, "IS_MODULE_SDK"));
  final String addContentRoots = JDOMExternalizerUtil.readField(element, "ADD_CONTENT_ROOTS");
  myAddContentRoots = addContentRoots == null || Boolean.parseBoolean(addContentRoots);
  final String addSourceRoots = JDOMExternalizerUtil.readField(element, "ADD_SOURCE_ROOTS");
  myAddSourceRoots = addSourceRoots == null || Boolean.parseBoolean(addSourceRoots);
  getConfigurationModule().readExternal(element);

  setMappingSettings(PathMappingSettings.readExternal(element));
  // extension settings:
  PythonRunConfigurationExtensionsManager.getInstance().readExternal(this, element);
}
项目:intellij-ce-playground    文件:AbstractPythonRunConfiguration.java   
public void writeExternal(Element element) throws WriteExternalException {
  super.writeExternal(element);
  JDOMExternalizerUtil.writeField(element, "INTERPRETER_OPTIONS", myInterpreterOptions);
  writeEnvs(element);
  JDOMExternalizerUtil.writeField(element, "SDK_HOME", mySdkHome);
  JDOMExternalizerUtil.writeField(element, "WORKING_DIRECTORY", myWorkingDirectory);
  JDOMExternalizerUtil.writeField(element, "IS_MODULE_SDK", Boolean.toString(myUseModuleSdk));
  JDOMExternalizerUtil.writeField(element, "ADD_CONTENT_ROOTS", Boolean.toString(myAddContentRoots));
  JDOMExternalizerUtil.writeField(element, "ADD_SOURCE_ROOTS", Boolean.toString(myAddSourceRoots));
  getConfigurationModule().writeExternal(element);

  // extension settings:
  PythonRunConfigurationExtensionsManager.getInstance().writeExternal(this, element);

  PathMappingSettings.writeExternal(element, getMappingSettings());
}
项目:intellij-ce-playground    文件:PyRemotePathMapperTest.java   
@Test
public void testFromSettings() throws Exception {
  PathMappingSettings settings = new PathMappingSettings();
  PyRemotePathMapper emptyMapper = PyRemotePathMapper.fromSettings(settings, PyPathMappingType.USER_DEFINED);

  assertTrue(emptyMapper.isEmpty());

  settings.add(new PathMappingSettings.PathMapping("C:\\local\\folder", "/remote/folder"));
  settings.add(new PathMappingSettings.PathMapping("C:\\local\\folder\\child", "/remote/child-from-local"));
  settings.add(new PathMappingSettings.PathMapping("C:\\local\\child-from-remote", "/remote/folder/child"));
  PyRemotePathMapper mapper = PyRemotePathMapper.fromSettings(settings, PyPathMappingType.HELPERS);

  assertFalse(mapper.isEmpty());
  assertConvertsOneToAnother(mapper, "C:\\local\\folder\\src\\main.py", "/remote/folder/src/main.py");
  assertConvertsOneToAnother(mapper, "C:\\local\\folder\\child\\test\\all.py", "/remote/child-from-local/test/all.py");
  assertConvertsOneToAnother(mapper, "C:/local/child-from-remote/README", "/remote/folder/child/README");

  assertEquals("/unmapped/list.txt", mapper.convertToLocal("/unmapped/list.txt"));
  assertEquals("C:\\unmapped\\list.txt", mapper.convertToRemote("C:\\unmapped\\list.txt"));
}
项目:intellij-ce-playground    文件:RemoteSdkPropertiesHolder.java   
@Override
public void setPathMappings(@Nullable PathMappingSettings pathMappings) {
  myPathMappings = new PathMappingSettings();
  if (pathMappings != null) {
    myPathMappings.addAll(pathMappings);
  }
}
项目:intellij-ce-playground    文件:RemoteSdkPropertiesHolder.java   
public void save(Element rootElement) {
  rootElement.setAttribute(INTERPRETER_PATH, StringUtil.notNullize(getInterpreterPath()));
  rootElement.setAttribute(HELPERS_PATH, StringUtil.notNullize(getHelpersPath()));

  rootElement.setAttribute(INITIALIZED, Boolean.toString(isInitialized()));
  rootElement.setAttribute(VALID, Boolean.toString(isValid()));

  PathMappingSettings.writeExternal(rootElement, myPathMappings);

  for (String remoteRoot : getRemoteRoots()) {
    final Element child = new Element(REMOTE_ROOTS);
    child.setAttribute(REMOTE_PATH, remoteRoot);
    rootElement.addContent(child);
  }
}
项目:intellij-ce-playground    文件:PathMappingsComponent.java   
public void setMappingSettings(@Nullable final PathMappingSettings mappingSettings) {
  if (mappingSettings == null) {
    myMappingSettings = new PathMappingSettings();
  }
  else {
    myMappingSettings = mappingSettings;
  }

  setTextRepresentation(myMappingSettings);

  fireStateChanged();
}
项目:intellij-ce-playground    文件:PathMappingsComponent.java   
private void setTextRepresentation(@NotNull PathMappingSettings mappingSettings) {
  final StringBuilder sb = new StringBuilder();
  for (PathMappingSettings.PathMapping mapping : mappingSettings.getPathMappings()) {
    sb.append(mapping.getLocalRoot()).append("=").append(mapping.getRemoteRoot()).append(";");
  }
  if (sb.length() > 0) {
    sb.deleteCharAt(sb.length() - 1); //trim last ;
  }
  getComponent().setText(sb.toString());
}
项目:intellij-ce-playground    文件:PyConsoleOptions.java   
public void apply(AbstractPythonRunConfigurationParams form) {
  mySdkHome = form.getSdkHome();
  myInterpreterOptions = form.getInterpreterOptions();
  myEnvs = form.getEnvs();
  myUseModuleSdk = form.isUseModuleSdk();
  myModuleName = form.getModule() == null ? null : form.getModule().getName();
  myWorkingDirectory = form.getWorkingDirectory();

  myAddContentRoots = form.shouldAddContentRoots();
  myAddSourceRoots = form.shouldAddSourceRoots();
  myMappings = form.getMappingSettings() == null ? new PathMappingSettings() : form.getMappingSettings();
}
项目:intellij-ce-playground    文件:PyRemotePathMapper.java   
@NotNull
public static PyRemotePathMapper cloneMapper(@Nullable PyRemotePathMapper mapper) {
  PyRemotePathMapper pathMapper = new PyRemotePathMapper();
  if (mapper != null) {
    for (Map.Entry<PyPathMappingType, Collection<PathMappingSettings.PathMapping>> entry : mapper.myPathMappings.entrySet()) {
      for (PathMappingSettings.PathMapping pathMapping : entry.getValue()) {
        pathMapper.addMapping(pathMapping.getLocalRoot(), pathMapping.getRemoteRoot(), entry.getKey());
      }
    }
  }
  return pathMapper;
}
项目:intellij-ce-playground    文件:PythonSdkDetailsDialog.java   
@Override
protected VirtualFile[] doAddItems() {
  Project project = CommonDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext(myPanel));
  try {
    String[] files = PythonRemoteInterpreterManager
      .getInstance().chooseRemoteFiles(project, (PyRemoteSdkAdditionalDataBase)mySdk.getSdkAdditionalData(), false);

    final String sourcesLocalPath = PySdkUtil.getRemoteSourcesLocalPath(mySdk.getHomePath());

    VirtualFile[] vFiles = new VirtualFile[files.length];

    int i = 0;
    for (String file : files) {
      String localRoot = PyRemoteSourceItem.localPathForRemoteRoot(sourcesLocalPath, file);

      myNewMappings.add(new PathMappingSettings.PathMapping(localRoot, file));
      myRemoteSdkData.getPathMappings().addMappingCheckUnique(localRoot, file);

      if (!new File(localRoot).exists()) {
        new File(localRoot).mkdirs();
      }
      vFiles[i++] = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(new File(localRoot));
    }

    vFiles = adjustAddedFileSet(myPanel, vFiles);
    List<VirtualFile> added = new ArrayList<VirtualFile>(vFiles.length);
    for (VirtualFile vFile : vFiles) {
      if (addElement(vFile)) {
        added.add(vFile);
      }
    }
    return VfsUtilCore.toVirtualFileArray(added);
  }
  catch (Exception e) {
    LOG.error(e);
  }
  return new VirtualFile[0];
}
项目:intellij-ce-playground    文件:PythonSdkDetailsDialog.java   
@Override
public void apply(SdkModificator sdkModificator) {
  if (sdkModificator.getSdkAdditionalData() instanceof PyRemoteSdkAdditionalDataBase) {
    for (PathMappingSettings.PathMapping mapping : myNewMappings) {
      ((PyRemoteSdkAdditionalDataBase)sdkModificator.getSdkAdditionalData()).getPathMappings()
        .addMappingCheckUnique(mapping.getLocalRoot(), mapping.getRemoteRoot());
    }
  }
  super.apply(sdkModificator);
}
项目:intellij-ce-playground    文件:PyIdeCommonOptionsForm.java   
@Override
@Nullable
public PathMappingSettings getMappingSettings() {
  if (myInterpreterRemote) {
    return myPathMappingsComponent.getMappingSettings();
  }
  else {
    return new PathMappingSettings();
  }
}
项目:tools-idea    文件:PathMappingsComponent.java   
public void setMappingSettings(@Nullable final PathMappingSettings mappingSettings) {
  if (mappingSettings == null) {
    myMappingSettings = new PathMappingSettings();
  }
  else {
    myMappingSettings = mappingSettings;
  }

  setTextRepresentation(myMappingSettings);

  fireStateChanged();
}
项目:tools-idea    文件:PathMappingsComponent.java   
private void setTextRepresentation(@NotNull PathMappingSettings mappingSettings) {
  final StringBuilder sb = new StringBuilder();
  for (PathMappingSettings.PathMapping mapping : mappingSettings.getPathMappings()) {
    sb.append(mapping.getLocalRoot()).append("=").append(mapping.getRemoteRoot()).append(";");
  }
  if (sb.length() > 0) {
    sb.deleteCharAt(sb.length() - 1); //trim last ;
  }
  getComponent().setText(sb.toString());
}
项目:consulo    文件:RemoteSdkPropertiesHolder.java   
@Override
public void setPathMappings(@Nullable PathMappingSettings pathMappings) {
  myPathMappings = new PathMappingSettings();
  if (pathMappings != null) {
    myPathMappings.addAll(pathMappings);
  }
}
项目:consulo    文件:RemoteSdkPropertiesHolder.java   
public void save(Element rootElement) {
  rootElement.setAttribute(INTERPRETER_PATH, StringUtil.notNullize(getInterpreterPath()));
  rootElement.setAttribute(HELPERS_PATH, StringUtil.notNullize(getHelpersPath()));

  rootElement.setAttribute(INITIALIZED, Boolean.toString(isInitialized()));
  rootElement.setAttribute(VALID, Boolean.toString(isValid()));

  PathMappingSettings.writeExternal(rootElement, myPathMappings);

  for (String remoteRoot : getRemoteRoots()) {
    final Element child = new Element(REMOTE_ROOTS);
    child.setAttribute(REMOTE_PATH, remoteRoot);
    rootElement.addContent(child);
  }
}
项目:consulo    文件:PathMappingsComponent.java   
public void setMappingSettings(@Nullable final PathMappingSettings mappingSettings) {
  if (mappingSettings == null) {
    myMappingSettings = new PathMappingSettings();
  }
  else {
    myMappingSettings = mappingSettings;
  }

  setTextRepresentation(myMappingSettings);

  fireStateChanged();
}
项目:consulo    文件:PathMappingsComponent.java   
private void setTextRepresentation(@Nonnull PathMappingSettings mappingSettings) {
  final StringBuilder sb = new StringBuilder();
  for (PathMappingSettings.PathMapping mapping : mappingSettings.getPathMappings()) {
    sb.append(mapping.getLocalRoot()).append("=").append(mapping.getRemoteRoot()).append(";");
  }
  if (sb.length() > 0) {
    sb.deleteCharAt(sb.length() - 1); //trim last ;
  }
  getComponent().setText(sb.toString());
}
项目:intellij-ce-playground    文件:RemoteSdkPropertiesHolder.java   
@NotNull
@Override
public PathMappingSettings getPathMappings() {
  return myPathMappings;
}
项目:intellij-ce-playground    文件:RemoteSdkCredentialsHolder.java   
@NotNull
@Override
public PathMappingSettings getPathMappings() {
  return myRemoteSdkProperties.getPathMappings();
}
项目:intellij-ce-playground    文件:RemoteSdkCredentialsHolder.java   
@Override
public void setPathMappings(@Nullable PathMappingSettings pathMappings) {
  myRemoteSdkProperties.setPathMappings(pathMappings);
}
项目:intellij-ce-playground    文件:RemoteSdkProperties.java   
@NotNull
PathMappingSettings getPathMappings();
项目:intellij-ce-playground    文件:PathMappingProvider.java   
@NotNull
public abstract PathMappingSettings getPathMappingSettings(@NotNull Project project, @NotNull RemoteSdkAdditionalData data);
项目:intellij-ce-playground    文件:PathMappingTable.java   
public PathMappingSettings getPathMappingSettings() {
  return new PathMappingSettings(getElements());
}
项目:intellij-ce-playground    文件:PathMappingTable.java   
@Override
protected PathMappingSettings.PathMapping createElement() {
  return new PathMappingSettings.PathMapping();
}
项目:intellij-ce-playground    文件:PathMappingTable.java   
@Override
protected boolean isEmpty(PathMappingSettings.PathMapping element) {
  return element.getLocalRoot().isEmpty() && element.getRemoteRoot().isEmpty();
}
项目:intellij-ce-playground    文件:PathMappingTable.java   
@Override
protected PathMappingSettings.PathMapping cloneElement(PathMappingSettings.PathMapping envVariable) {
  return envVariable.clone();
}
项目:intellij-ce-playground    文件:PathMappingTable.java   
@Override
protected boolean canDeleteElement(PathMappingSettings.PathMapping selection) {
  return true;
}
项目:intellij-ce-playground    文件:PathMappingsComponent.java   
@NotNull
public PathMappingSettings getMappingSettings() {
  return myMappingSettings;
}
项目:intellij-ce-playground    文件:PyPluginCommonOptionsForm.java   
@Override
public PathMappingSettings getMappingSettings() {
  return myPathMappingsComponent.getMappingSettings();
}
项目:intellij-ce-playground    文件:PyPluginCommonOptionsForm.java   
@Override
public void setMappingSettings(@Nullable PathMappingSettings mappingSettings) {
  myPathMappingsComponent.setMappingSettings(mappingSettings);
}
项目:intellij-ce-playground    文件:PythonRunParams.java   
@Nullable
PathMappingSettings getMappingSettings();
项目:intellij-ce-playground    文件:PyConsoleOptions.java   
@AbstractCollection(surroundWithTag = false)
public PathMappingSettings getMappings() {
  return myMappings;
}
项目:intellij-ce-playground    文件:PyConsoleOptions.java   
@Nullable
@Override
public PathMappingSettings getMappingSettings() {
  return getMappings();
}
项目:intellij-ce-playground    文件:PyConsoleOptions.java   
public void setMappings(@Nullable PathMappingSettings mappings) {
  myMappings = mappings != null ? mappings : new PathMappingSettings();
}
项目:intellij-ce-playground    文件:PydevConsoleRunner.java   
@Nullable
@Override
public PathMappingSettings getMappingSettings() {
  throw new UnsupportedOperationException();
}
项目:intellij-ce-playground    文件:PydevConsoleRunner.java   
@Override
public void setMappingSettings(@Nullable PathMappingSettings mappingSettings) {
  throw new UnsupportedOperationException();
}
项目:intellij-ce-playground    文件:PyRemotePathMapper.java   
@NotNull
public static PyRemotePathMapper fromSettings(@NotNull PathMappingSettings settings, @NotNull PyPathMappingType mappingType) {
  PyRemotePathMapper mapper = new PyRemotePathMapper();
  mapper.addAll(settings.getPathMappings(), mappingType);
  return mapper;
}
项目:intellij-ce-playground    文件:PyRemotePathMapper.java   
public void addMapping(String local, String remote, @NotNull PyPathMappingType type) {
  myPathMappings.putValue(type, new PathMappingSettings.PathMapping(local, remote));
}