Java Code Examples for com.intellij.openapi.util.DefaultJDOMExternalizer#readExternal()

The following examples show how to use com.intellij.openapi.util.DefaultJDOMExternalizer#readExternal() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PluginErrorSubmitDialog.java    From BashSupport with Apache License 2.0 6 votes vote down vote up
public void prepare(String additionalInfo, String stacktrace, String versionId) {
    reportComponent.descriptionField.setText(additionalInfo);
    reportComponent.stacktraceField.setText(stacktrace);
    reportComponent.versionField.setText(versionId);

    File file = new File(getOptionsFilePath());
    if (file.exists()) {
        try {
            Document document = JDOMUtil.loadDocument(file);
            Element applicationElement = document.getRootElement();
            if (applicationElement == null) {
                throw new InvalidDataException("Expected root element >application< not found");
            }
            Element componentElement = applicationElement.getChild("component");
            if (componentElement == null) {
                throw new InvalidDataException("Expected element >component< not found");
            }

            DefaultJDOMExternalizer.readExternal(this, componentElement);
            reportComponent.nameField.setText(USERNAME);
        } catch (Exception e) {
            LOGGER.info("Unable to read configuration file", e);
        }
    }
}
 
Example 2
Source File: LogConsolePreferences.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void loadState(final Element object) {
  try {
    final List children = object.getChildren(FILTER);
    for (Object child : children) {
      Element filterElement = (Element)child;
      final LogFilter filter = new LogFilter();
      filter.readExternal(filterElement);
      setFilterSelected(filter, Boolean.parseBoolean(filterElement.getAttributeValue(IS_ACTIVE)));
    }
    DefaultJDOMExternalizer.readExternal(this, object);
  }
  catch (InvalidDataException e) {
    LOG.error(e);
  }
}
 
Example 3
Source File: ShelvedChangeList.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void readExternal(Element element) throws InvalidDataException {
  DefaultJDOMExternalizer.readExternal(this, element);
  PATH = FileUtil.toSystemIndependentName(PATH);
  mySchemeName = element.getAttributeValue(NAME_ATTRIBUTE);
  DATE = new Date(Long.parseLong(element.getAttributeValue(ATTRIBUTE_DATE)));
  myRecycled = Boolean.parseBoolean(element.getAttributeValue(ATTRIBUTE_RECYCLED_CHANGELIST));
  myToDelete = Boolean.parseBoolean(element.getAttributeValue(ATTRIBUTE_TOBE_DELETED_CHANGELIST));
  //noinspection unchecked
  final List<Element> children = element.getChildren(ELEMENT_BINARY);
  myBinaryFiles = new ArrayList<>(children.size());
  for (Element child : children) {
    ShelvedBinaryFile binaryFile = new ShelvedBinaryFile();
    binaryFile.readExternal(child);
    myBinaryFiles.add(binaryFile);
  }
}
 
Example 4
Source File: BashRunConfiguration.java    From BashSupport with Apache License 2.0 5 votes vote down vote up
@Override
public void readExternal(Element element) throws InvalidDataException {
    PathMacroManager.getInstance(getProject()).expandPaths(element);
    super.readExternal(element);

    DefaultJDOMExternalizer.readExternal(this, element);
    readModule(element);
    EnvironmentVariablesComponent.readExternal(element, getEnvs());

    // common config
    interpreterOptions = JDOMExternalizerUtil.readField(element, "INTERPRETER_OPTIONS");
    interpreterPath = JDOMExternalizerUtil.readField(element, "INTERPRETER_PATH");
    workingDirectory = JDOMExternalizerUtil.readField(element, "WORKING_DIRECTORY");

    // 1.7.0 to 1.7.2 broke the run configs by defaulting to useProjectInterpreter, using field USE_PROJECT_INTERPRETER
    // we try to workaround for config saved by these versions by using another field and a smart fallback
    String useProjectInterpreterValue = JDOMExternalizerUtil.readField(element, "PROJECT_INTERPRETER");
    String oldUseProjectInterpreterValue = JDOMExternalizerUtil.readField(element, "USE_PROJECT_INTERPRETER");
    if (useProjectInterpreterValue != null) {
        useProjectInterpreter = Boolean.parseBoolean(useProjectInterpreterValue);
    } else if (StringUtils.isEmpty(interpreterPath) && oldUseProjectInterpreterValue != null) {
        // only use old "use project interpreter" setting when there's no interpreter in the run config and a configured project interpreter
        Project project = getProject();
        if (!BashProjectSettings.storedSettings(project).getProjectInterpreter().isEmpty()) {
            useProjectInterpreter = Boolean.parseBoolean(oldUseProjectInterpreterValue);
        }
    }

    String parentEnvValue = JDOMExternalizerUtil.readField(element, "PARENT_ENVS");
    if (parentEnvValue != null) {
        setPassParentEnvs(Boolean.parseBoolean(parentEnvValue));
    }

    // run config
    scriptName = JDOMExternalizerUtil.readField(element, "SCRIPT_NAME");
    setProgramParameters(JDOMExternalizerUtil.readField(element, "PARAMETERS"));
}
 
Example 5
Source File: BlazeAndroidRunConfigurationDeployTargetManagerBase.java    From intellij with Apache License 2.0 4 votes vote down vote up
@Override
public void readExternal(Element element) throws InvalidDataException {
  for (DeployTargetState state : deployTargetStates.values()) {
    DefaultJDOMExternalizer.readExternal(state, element);
  }
}
 
Example 6
Source File: EnvironmentVariable.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void readExternal(Element element) throws InvalidDataException {
  DefaultJDOMExternalizer.readExternal(this, element);
}
 
Example 7
Source File: CustomCodeStyleSettings.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void readExternal(Element parentElement) throws InvalidDataException {
  DefaultJDOMExternalizer.readExternal(this, parentElement.getChild(myTagName));
}
 
Example 8
Source File: CodeStyleSettingsManager.java    From consulo with Apache License 2.0 4 votes vote down vote up
private void readExternal(Element element) throws InvalidDataException {
  DefaultJDOMExternalizer.readExternal(this, element);
}
 
Example 9
Source File: CreatePatchCommitExecutor.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void readExternal(Element element) throws InvalidDataException {
  DefaultJDOMExternalizer.readExternal(this, element);
}
 
Example 10
Source File: ShelvedBinaryFile.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void readExternal(Element element) throws InvalidDataException {
  DefaultJDOMExternalizer.readExternal(this, element);
}
 
Example 11
Source File: DaemonCodeAnalyzerSettingsImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
private void readExternal(Element element) throws InvalidDataException {
  DefaultJDOMExternalizer.readExternal(this, element);
  myManager.getConverter().storeEditorHighlightingProfile(element, new InspectionProfileImpl(InspectionProfileConvertor.OLD_HIGHTLIGHTING_SETTINGS_PROFILE));
  myManager.setRootProfile(element.getAttributeValue(PROFILE_ATT));
}