com.intellij.openapi.util.DefaultJDOMExternalizer Java Examples

The following examples show how to use com.intellij.openapi.util.DefaultJDOMExternalizer. 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: BashRunConfiguration.java    From BashSupport with Apache License 2.0 6 votes vote down vote up
@Override
public void writeExternal(Element element) throws WriteExternalException {
    super.writeExternal(element);

    // common config
    JDOMExternalizerUtil.writeField(element, "INTERPRETER_OPTIONS", interpreterOptions);
    JDOMExternalizerUtil.writeField(element, "INTERPRETER_PATH", interpreterPath);
    JDOMExternalizerUtil.writeField(element, "PROJECT_INTERPRETER", Boolean.toString(useProjectInterpreter));
    JDOMExternalizerUtil.writeField(element, "WORKING_DIRECTORY", workingDirectory);
    JDOMExternalizerUtil.writeField(element, "PARENT_ENVS", Boolean.toString(isPassParentEnvs()));

    // run config
    JDOMExternalizerUtil.writeField(element, "SCRIPT_NAME", scriptName);
    JDOMExternalizerUtil.writeField(element, "PARAMETERS", getProgramParameters());

    //JavaRunConfigurationExtensionManager.getInstance().writeExternal(this, element);
    DefaultJDOMExternalizer.writeExternal(this, element);
    writeModule(element);
    EnvironmentVariablesComponent.writeExternal(element, getEnvs());

    PathMacroManager.getInstance(getProject()).collapsePathsRecursively(element);
}
 
Example #2
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 #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: LogConsolePreferences.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public Element getState() {
  @NonNls Element element = new Element("LogFilters");
  try {
    for (LogFilter filter : myRegisteredLogFilters.keySet()) {
      Element filterElement = new Element(FILTER);
      filterElement.setAttribute(IS_ACTIVE, myRegisteredLogFilters.get(filter).toString());
      filter.writeExternal(filterElement);
      element.addContent(filterElement);
    }
    DefaultJDOMExternalizer.writeExternal(this, element);
  }
  catch (WriteExternalException e) {
    LOG.error(e);
  }
  return element;
}
 
Example #5
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 #6
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 #7
Source File: PluginErrorSubmitDialog.java    From BashSupport with Apache License 2.0 5 votes vote down vote up
public void persist() {
    try {
        Element applicationElement = new Element("application");
        Element componentElement = new Element("component");
        applicationElement.addContent(componentElement);

        USERNAME = reportComponent.nameField.getText();
        DefaultJDOMExternalizer.writeExternal(this, componentElement);

        Document document = new Document(applicationElement);
        JDOMUtil.writeDocument(document, getOptionsFilePath(), "\r\n");
    } catch (Exception e) {
        LOGGER.info("Unable to persist configuration file", e);
    }
}
 
Example #8
Source File: AttributesFlyweight.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static AttributesFlyweight create(@Nonnull Element element) throws InvalidDataException {
  Color FOREGROUND = DefaultJDOMExternalizer.toColor(JDOMExternalizerUtil.readField(element, "FOREGROUND"));
  Color BACKGROUND = DefaultJDOMExternalizer.toColor(JDOMExternalizerUtil.readField(element, "BACKGROUND"));
  Color EFFECT_COLOR = DefaultJDOMExternalizer.toColor(JDOMExternalizerUtil.readField(element, "EFFECT_COLOR"));
  Color ERROR_STRIPE_COLOR = DefaultJDOMExternalizer.toColor(JDOMExternalizerUtil.readField(element, "ERROR_STRIPE_COLOR"));
  int fontType = DefaultJDOMExternalizer.toInt(JDOMExternalizerUtil.readField(element, "FONT_TYPE", "0"));
  if (fontType < 0 || fontType > 3) {
    fontType = 0;
  }
  int FONT_TYPE = fontType;
  int EFFECT_TYPE = DefaultJDOMExternalizer.toInt(JDOMExternalizerUtil.readField(element, "EFFECT_TYPE", "0"));
  // todo additionalEffects are not serialized yet, we have no user-controlled additional effects
  return create(FOREGROUND, BACKGROUND, FONT_TYPE, EFFECT_COLOR, toEffectType(EFFECT_TYPE), Collections.emptyMap(), ERROR_STRIPE_COLOR);
}
 
Example #9
Source File: ShelvedChangeList.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static void writeExternal(@Nonnull Element element, @Nonnull ShelvedChangeList shelvedChangeList) throws WriteExternalException {
  DefaultJDOMExternalizer.writeExternal(shelvedChangeList, element);
  element.setAttribute(NAME_ATTRIBUTE, shelvedChangeList.getName());
  element.setAttribute(ATTRIBUTE_DATE, Long.toString(shelvedChangeList.DATE.getTime()));
  element.setAttribute(ATTRIBUTE_RECYCLED_CHANGELIST, Boolean.toString(shelvedChangeList.isRecycled()));
  if (shelvedChangeList.isMarkedToDelete()) {
    element.setAttribute(ATTRIBUTE_TOBE_DELETED_CHANGELIST, Boolean.toString(shelvedChangeList.isMarkedToDelete()));
  }
  for (ShelvedBinaryFile file : shelvedChangeList.getBinaryFiles()) {
    Element child = new Element(ELEMENT_BINARY);
    file.writeExternal(child);
    element.addContent(child);
  }
}
 
Example #10
Source File: CustomCodeStyleSettings.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void writeExternal(Element parentElement, @Nonnull final CustomCodeStyleSettings parentSettings) throws WriteExternalException {
  final Element childElement = new Element(myTagName);
  DefaultJDOMExternalizer.writeExternal(this, childElement, new DifferenceFilter<CustomCodeStyleSettings>(this, parentSettings));
  if (!childElement.getContent().isEmpty()) {
    parentElement.addContent(childElement);
  }
}
 
Example #11
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 #12
Source File: DaemonCodeAnalyzerSettingsImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
private void writeExternal(Element element) throws WriteExternalException {
  DefaultJDOMExternalizer.writeExternal(this, element);
  element.setAttribute(PROFILE_ATT, myManager.getRootProfile().getName());
}
 
Example #13
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));
}
 
Example #14
Source File: ShelvedBinaryFile.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void writeExternal(Element element) throws WriteExternalException {
  DefaultJDOMExternalizer.writeExternal(this, element);
}
 
Example #15
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 #16
Source File: CreatePatchCommitExecutor.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void writeExternal(Element element) throws WriteExternalException {
  DefaultJDOMExternalizer.writeExternal(this, element);
}
 
Example #17
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 #18
Source File: CodeStyleSettingsManager.java    From consulo with Apache License 2.0 4 votes vote down vote up
private void writeExternal(Element element) throws WriteExternalException {
  DefaultJDOMExternalizer.writeExternal(this, element, new DifferenceFilter<CodeStyleSettingsManager>(this, new CodeStyleSettingsManager()));
}
 
Example #19
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 #20
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 #21
Source File: EnvironmentVariable.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void writeExternal(Element element) throws WriteExternalException {
  DefaultJDOMExternalizer.writeExternal(this, element);
}
 
Example #22
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 #23
Source File: HighlightSeverity.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void writeExternal(final Element element) throws WriteExternalException {
  DefaultJDOMExternalizer.writeExternal(this, element);
}
 
Example #24
Source File: BlazeAndroidRunConfigurationDeployTargetManagerBase.java    From intellij with Apache License 2.0 4 votes vote down vote up
@Override
public void writeExternal(Element element) throws WriteExternalException {
  for (DeployTargetState state : deployTargetStates.values()) {
    DefaultJDOMExternalizer.writeExternal(state, element);
  }
}