com.intellij.openapi.util.WriteExternalException Java Examples

The following examples show how to use com.intellij.openapi.util.WriteExternalException. 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: TodoAttributes.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void writeExternal(Element element) throws WriteExternalException {
  String icon;
  if (myIcon == AllIcons.General.TodoDefault) {
    icon = ICON_DEFAULT;
  }
  else if (myIcon == AllIcons.General.TodoQuestion) {
    icon = ICON_QUESTION;
  }
  else if (myIcon == AllIcons.General.TodoImportant) {
    icon = ICON_IMPORTANT;
  }
  else {
    throw new WriteExternalException("");
  }
  element.setAttribute(ATTRIBUTE_ICON, icon);
  myTextAttributes.writeExternal(element);

  // default color setting
  element.setAttribute(USE_CUSTOM_COLORS_ATT, Boolean.toString(shouldUseCustomTodoColor()));
}
 
Example #2
Source File: BlazeAndroidRunConfigurationCommonStateTest.java    From intellij with Apache License 2.0 6 votes vote down vote up
@Test
public void repeatedWriteShouldNotChangeElement() throws WriteExternalException {
  final XMLOutputter xmlOutputter = new XMLOutputter(Format.getCompactFormat());

  state.getBlazeFlagsState().setRawFlags(ImmutableList.of("--flag1", "--flag2"));
  state.getExeFlagsState().setRawFlags(ImmutableList.of("--exe1", "--exe2"));
  state.setNativeDebuggingEnabled(true);

  Element firstWrite = new Element("test");
  state.writeExternal(firstWrite);
  Element secondWrite = firstWrite.clone();
  state.writeExternal(secondWrite);

  assertThat(xmlOutputter.outputString(secondWrite))
      .isEqualTo(xmlOutputter.outputString(firstWrite));
}
 
Example #3
Source File: DaemonCodeAnalyzerSettingsImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public boolean isCodeHighlightingChanged(DaemonCodeAnalyzerSettings oldSettings) {
  try {
    Element rootNew = new Element(ROOT_TAG);
    writeExternal(rootNew);
    Element rootOld = new Element(ROOT_TAG);
    ((DaemonCodeAnalyzerSettingsImpl)oldSettings).writeExternal(rootOld);

    return !JDOMUtil.areElementsEqual(rootOld, rootNew);
  }
  catch (WriteExternalException e) {
    LOG.error(e);
  }

  return false;
}
 
Example #4
Source File: BlazeAndroidRunConfigurationCommonStateTest.java    From intellij with Apache License 2.0 6 votes vote down vote up
@Test
public void readAndWriteShouldMatch() throws InvalidDataException, WriteExternalException {
  state.getBlazeFlagsState().setRawFlags(ImmutableList.of("--flag1", "--flag2"));
  state.getExeFlagsState().setRawFlags(ImmutableList.of("--exe1", "--exe2"));
  state.setNativeDebuggingEnabled(true);

  Element element = new Element("test");
  state.writeExternal(element);
  BlazeAndroidRunConfigurationCommonState readState =
      new BlazeAndroidRunConfigurationCommonState(buildSystem().getName(), false);
  readState.readExternal(element);

  assertThat(readState.getBlazeFlagsState().getRawFlags())
      .containsExactly("--flag1", "--flag2")
      .inOrder();
  assertThat(readState.getExeFlagsState().getRawFlags())
      .containsExactly("--exe1", "--exe2")
      .inOrder();
  assertThat(readState.isNativeDebuggingEnabled()).isTrue();
}
 
Example #5
Source File: BlazeAndroidBinaryRunConfigurationStateTest.java    From intellij with Apache License 2.0 6 votes vote down vote up
@Test
public void repeatedWriteShouldNotChangeElement() throws WriteExternalException {
  final XMLOutputter xmlOutputter = new XMLOutputter(Format.getCompactFormat());

  BlazeAndroidRunConfigurationCommonState commonState = state.getCommonState();
  commonState.getBlazeFlagsState().setRawFlags(ImmutableList.of("--flag1", "--flag2"));
  commonState.setNativeDebuggingEnabled(true);

  state.setActivityClass("com.example.TestActivity");
  state.setMode(BlazeAndroidBinaryRunConfigurationState.LAUNCH_SPECIFIC_ACTIVITY);
  state.setLaunchMethod(AndroidBinaryLaunchMethod.MOBILE_INSTALL);
  state.setUseSplitApksIfPossible(false);
  state.setUseWorkProfileIfPresent(true);
  state.setUserId(2);
  state.setShowLogcatAutomatically(true);
  state.setDeepLink("http://deeplink");

  Element firstWrite = new Element("test");
  state.writeExternal(firstWrite);
  Element secondWrite = firstWrite.clone();
  state.writeExternal(secondWrite);

  assertThat(xmlOutputter.outputString(secondWrite))
      .isEqualTo(xmlOutputter.outputString(firstWrite));
}
 
Example #6
Source File: ScopeToolState.java    From consulo with Apache License 2.0 6 votes vote down vote up
public boolean equalTo(@Nonnull ScopeToolState state2) {
  if (isEnabled() != state2.isEnabled()) return false;
  if (getLevel() != state2.getLevel()) return false;
  InspectionToolWrapper toolWrapper = getTool();
  InspectionToolWrapper toolWrapper2 = state2.getTool();
  if (!toolWrapper.isInitialized() && !toolWrapper2.isInitialized()) return true;
  try {
    @NonNls String tempRoot = "root";
    Element oldToolSettings = new Element(tempRoot);
    toolWrapper.getTool().writeSettings(oldToolSettings);
    Element newToolSettings = new Element(tempRoot);
    toolWrapper2.getTool().writeSettings(newToolSettings);
    return JDOMUtil.areElementsEqual(oldToolSettings, newToolSettings);
  }
  catch (WriteExternalException e) {
    LOG.error(e);
  }
  return false;
}
 
Example #7
Source File: AbstractColorsScheme.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void writeAttributes(Element attrElements) throws WriteExternalException {
  List<TextAttributesKey> list = new ArrayList<TextAttributesKey>(myAttributesMap.keySet());
  Collections.sort(list);

  for (TextAttributesKey key: list) {
    TextAttributes defaultAttr = myParentScheme != null ? myParentScheme.getAttributes(key) : new TextAttributes();
    TextAttributes value = myAttributesMap.get(key);
    if (!haveToWrite(key,value,defaultAttr)) continue;
    Element element = new Element(OPTION_ELEMENT);
    element.setAttribute(NAME_ATTR, key.getExternalName());
    Element valueElement = new Element(VALUE_ELEMENT);
    value.writeExternal(valueElement);
    element.addContent(valueElement);
    attrElements.addContent(element);
  }
}
 
Example #8
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 #9
Source File: RoboVmRunConfiguration.java    From robovm-idea with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void writeExternal(Element element) throws WriteExternalException {
    super.writeExternal(element);

    setModuleName(moduleName);
    writeModule(element);
    JDOMExternalizerUtil.writeField(element, "moduleName", moduleName);
    JDOMExternalizerUtil.writeField(element, "targetType", targetType == null? null: targetType.toString());
    JDOMExternalizerUtil.writeField(element, "deviceArch", deviceArch == null? null: deviceArch.toString());
    JDOMExternalizerUtil.writeField(element, "signingIdentity", signingIdentity);
    JDOMExternalizerUtil.writeField(element, "provisioningProfile", provisioningProfile);
    JDOMExternalizerUtil.writeField(element, "simArch", simArch == null? null: simArch.toString());
    JDOMExternalizerUtil.writeField(element, "simulatorName", simulatorName);
    JDOMExternalizerUtil.writeField(element, "arguments", arguments == null? "": arguments);
    JDOMExternalizerUtil.writeField(element, "workingDir", workingDir == null? "": workingDir);
}
 
Example #10
Source File: BaseCoverageSuite.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void writeExternal(final Element element) throws WriteExternalException {
  final String fileName =
    FileUtil.getRelativePath(new File(ContainerPathManager.get().getSystemPath()), new File(myCoverageDataFileProvider.getCoverageDataFilePath()));
  element.setAttribute(FILE_PATH, fileName != null ? FileUtil.toSystemIndependentName(fileName) : myCoverageDataFileProvider.getCoverageDataFilePath());
  element.setAttribute(NAME_ATTRIBUTE, myName);
  element.setAttribute(MODIFIED_STAMP, String.valueOf(myLastCoverageTimeStamp));
  element.setAttribute(SOURCE_PROVIDER, myCoverageDataFileProvider instanceof DefaultCoverageFileProvider
                                        ? ((DefaultCoverageFileProvider)myCoverageDataFileProvider).getSourceProvider()
                                        : myCoverageDataFileProvider.getClass().getName());
  // runner
  if (getRunner() != null) {
    element.setAttribute(COVERAGE_RUNNER, myRunner.getId());
  }

  // cover by test
  element.setAttribute(COVERAGE_BY_TEST_ENABLED_ATTRIBUTE_NAME, String.valueOf(myCoverageByTestEnabled));

  // tracing
  element.setAttribute(TRACING_ENABLED_ATTRIBUTE_NAME, String.valueOf(myTracingEnabled));
}
 
Example #11
Source File: CppSupportSettings.java    From CppTools with Apache License 2.0 6 votes vote down vote up
public void writeExternal(Element element) throws WriteExternalException {
  if (myGccPath != null) element.setAttribute(GCC_PATH_KEY, myGccPath);
  if (myClangPath != null) element.setAttribute(CLANG_PATH_KEY, myClangPath);
  if (myMingToolsDirectory != null) element.setAttribute(MINGW_TOOLS_DIR_KEY, myMingToolsDirectory);

  if (myVSCDir != null) element.setAttribute(VS_DIR_KEY, myVSCDir);
  if (myDefines != null) element.setAttribute(DEFINES_KEY, myDefines);
  if (myAdditionalIncludeDirs != null) element.setAttribute(ADDITIONAL_INCLUDES_KEY, myAdditionalIncludeDirs);

  if (myMailServer != null) element.setAttribute(MAIL_SERVER_KEY, myMailServer);
  if (myMailUser != null) element.setAttribute(MAIL_USER_KEY, myMailUser);
  if (myLaunchGdbOnFailure) {
    element.setAttribute(LAUNCH_GDB_ON_FAIL_KEY, Boolean.toString(myLaunchGdbOnFailure));
  }
  if (myLaunchGdbOnFailureCommand != null) {
    element.setAttribute(LAUNCH_GDB_ON_FAIL_COMMAND_KEY, myLaunchGdbOnFailureCommand);
  }

  if (myGdbPath != null) {
    element.setAttribute(GDB_PATH_KEY, myGdbPath);
  }
}
 
Example #12
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 #13
Source File: HighlightInfoType.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void writeExternal(Element element) {
  try {
    mySeverity.writeExternal(element);
  }
  catch (WriteExternalException e) {
    throw new RuntimeException(e);
  }
  myAttributesKey.writeExternal(element);
}
 
Example #14
Source File: EmbeddedLinuxJVMRunConfiguration.java    From embeddedlinux-jvmdebugger-intellij with Apache License 2.0 5 votes vote down vote up
/**
 * Write External
 * @param element
 * @throws WriteExternalException
 */
@Override
public void writeExternal(Element element) throws WriteExternalException {
    super.writeExternal(element);
    if (embeddedLinuxJVMRunConfigurationRunnerParameters != null) {
        XmlSerializer.serializeInto(embeddedLinuxJVMRunConfigurationRunnerParameters, element);
    }
}
 
Example #15
Source File: LocatableConfigurationBase.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void writeExternal(Element element) throws WriteExternalException {
  super.writeExternal(element);
  if (myNameIsGenerated && suggestedName() != null) {
    element.setAttribute(ATTR_NAME_IS_GENERATED, "true");
  }
}
 
Example #16
Source File: FixShebangInspection.java    From BashSupport with Apache License 2.0 5 votes vote down vote up
@Override
public void writeSettings(@NotNull Element node) throws WriteExternalException {
    for (String shebangCommand : validShebangCommands) {
        Element shebandElement = new Element(ELEMENT_NAME_SHEBANG);
        shebandElement.setText(shebangCommand.trim());
        node.addContent(shebandElement);
    }
}
 
Example #17
Source File: ReplRunConfiguration.java    From reasonml-idea-plugin with MIT License 5 votes vote down vote up
@Override
public void writeExternal(@NotNull Element element) throws WriteExternalException {
    super.writeExternal(element);
    element.addContent(new Element("sdk").
            setAttribute("name", m_sdk == null ? "" : m_sdk.getName()).
            setAttribute("cygwin", Boolean.toString(m_cygwinEnabled)).
            setAttribute("cygwinPath", m_cygwinPath == null ? "" : m_cygwinPath));
}
 
Example #18
Source File: ToolsProcessor.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public Parent writeScheme(@Nonnull final ToolsGroup<T> scheme) throws WriteExternalException {
  Element groupElement = new Element(TOOL_SET);
  if (scheme.getName() != null) {
    groupElement.setAttribute(ATTRIBUTE_NAME, scheme.getName());
  }

  for (T tool : scheme.getElements()) {
    saveTool(tool, groupElement);
  }

  return groupElement;
}
 
Example #19
Source File: TemplateContext.java    From consulo with Apache License 2.0 5 votes vote down vote up
void writeTemplateContext(Element element, @Nullable TemplateContext defaultContext) throws WriteExternalException {
  Map<TemplateContextType, Boolean> diff = getDifference(defaultContext);
  for (TemplateContextType type : diff.keySet()) {
    Element optionElement = new Element("option");
    optionElement.setAttribute("name", type.getContextId());
    optionElement.setAttribute("value", diff.get(type).toString());
    element.addContent(optionElement);
  }
}
 
Example #20
Source File: BlazeCommandRunConfiguration.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("ThrowsUncheckedException")
public void writeExternal(Element element) throws WriteExternalException {
  super.writeExternal(element);

  blazeElementState.removeChildren(TARGET_TAG);
  for (String target : targetPatterns) {
    if (target.isEmpty()) {
      continue;
    }
    Element targetElement = new Element(TARGET_TAG);
    targetElement.setText(target);
    blazeElementState.addContent(targetElement);
  }
  if (targetKindString != null) {
    blazeElementState.setAttribute(KIND_ATTR, targetKindString);
  }
  if (keepInSync != null) {
    blazeElementState.setAttribute(KEEP_IN_SYNC_TAG, Boolean.toString(keepInSync));
  } else {
    blazeElementState.removeAttribute(KEEP_IN_SYNC_TAG);
  }
  blazeElementState.setAttribute(HANDLER_ATTR, handlerProvider.getId());
  if (contextElementString != null) {
    blazeElementState.setAttribute(CONTEXT_ELEMENT_ATTR, contextElementString);
  }

  handler.getState().writeExternal(blazeElementState);
  // copy our internal state to the provided Element
  element.addContent(blazeElementState.clone());
}
 
Example #21
Source File: GaugeRunConfiguration.java    From Intellij-Plugin with Apache License 2.0 5 votes vote down vote up
@Override
public void writeExternal(Element element) throws WriteExternalException {
    super.writeExternal(element);
    JDOMExternalizer.write(element, "environment", environment);
    JDOMExternalizer.write(element, "specsToExecute", specsToExecute);
    JDOMExternalizer.write(element, "tags", tags);
    JDOMExternalizer.write(element, "parallelNodes", parallelNodes);
    JDOMExternalizer.write(element, "execInParallel", execInParallel);
    JDOMExternalizer.write(element, "programParameters", programParameters.getProgramParameters());
    JDOMExternalizer.write(element, "workingDirectory", programParameters.getWorkingDirectory());
    JDOMExternalizer.write(element, "moduleName", moduleName);
    JDOMExternalizer.writeMap(element, programParameters.getEnvs(), "envMap", "envMap");
    JDOMExternalizer.write(element, "rowsRange", rowsRange);
}
 
Example #22
Source File: RunConfigurationCompositeState.java    From intellij with Apache License 2.0 5 votes vote down vote up
/** Updates the element with the handler's state. */
@Override
@SuppressWarnings("ThrowsUncheckedException")
public final void writeExternal(Element element) throws WriteExternalException {
  for (RunConfigurationState state : getStates()) {
    state.writeExternal(element);
  }
}
 
Example #23
Source File: DebugPortState.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Override
public void writeExternal(Element element) throws WriteExternalException {
  if (port != defaultPort) {
    element.setAttribute(ATTRIBUTE_TAG, Integer.toString(port));
  } else {
    element.removeAttribute(ATTRIBUTE_TAG);
  }
}
 
Example #24
Source File: EnvironmentVariablesState.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Override
public void writeExternal(Element element) throws WriteExternalException {
  element.removeChildren(ELEMENT_TAG);
  Element child = new Element(ELEMENT_TAG);
  data.writeExternal(child);
  element.addContent(child);
}
 
Example #25
Source File: MongoRunConfiguration.java    From nosql4idea with Apache License 2.0 5 votes vote down vote up
@Override
    public void writeExternal(Element element) throws WriteExternalException {
        super.writeExternal(element);
        JDOMExternalizer.write(element, "path", scriptPath);
        JDOMExternalizer.write(element, "shellParams", shellParameters);
//        JDOMExternalizer.write(element, "serverConfiguration", serverConfiguration);

        PathMacroManager.getInstance(getProject()).collapsePathsRecursively(element);
    }
 
Example #26
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 #27
Source File: CppRunConfiguration.java    From CppTools with Apache License 2.0 5 votes vote down vote up
@Override
public void writeExternal(Element element) throws WriteExternalException {
  super.writeExternal(element);

  String parameters = myRunnerParameters != null ? myRunnerParameters.getExecutableParameters():null;
  if (parameters != null) element.setAttribute(EXECUTABLE_PARAMETERS, parameters);

  String launchingPath = myRunnerParameters != null ? myRunnerParameters.getWorkingDir():null;
  if (launchingPath != null) element.setAttribute(WORKING_DIR, launchingPath);
}
 
Example #28
Source File: ActionMacroManager.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void writeExternal(Element element) throws WriteExternalException {
  for (ActionMacro macro : myMacros) {
    Element macroElement = new Element(ELEMENT_MACRO);
    macro.writeExternal(macroElement);
    element.addContent(macroElement);
  }
}
 
Example #29
Source File: CppHighlightingSettings.java    From CppTools with Apache License 2.0 5 votes vote down vote up
public void writeExternal(Element element) throws WriteExternalException {
  if (!myReportImplicitCastToBool) element.setAttribute(REPORT_IMPLICIT_CAST_TO_BOOL_KEY, "false");
  if (!myReportNameNeverReferenced) element.setAttribute(REPORT_NAME_NEVER_REFERENCED_KEY, "false");
  if (!myReportNameUsedOnce) element.setAttribute(REPORT_NAME_REFERENCED_ONCE_KEY, "false");
  if (!myReportRedundantCast) element.setAttribute(REPORT_REDUNDANT_CAST_KEY, "false");
  if (!myReportRedundantQualifier) element.setAttribute(REPORT_REDUNDANT_QUALIFIER_KEY, "false");
  if (!myReportStaticCallFromInstance) element.setAttribute(REPORT_STATIC_CALL_FROM_INSTANCE_KEY, "false");
  if (myReportUnneededBraces) element.setAttribute(REPORT_UNNEEDED_BRACES_KEY, "true");
  if (!myReportDuplicatedSymbols) element.setAttribute(REPORT_DUPLICATED_SYMBOLS_KEY, "false");
}
 
Example #30
Source File: RunConfigurationBase.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void writeExternal(Element element) throws WriteExternalException {
  for (final LogFileOptions options : myLogFiles) {
    Element logFile = new Element(LOG_FILE);
    options.writeExternal(logFile);
    element.addContent(logFile);
  }
  for (PredefinedLogFile predefinedLogFile : myPredefinedLogFiles) {
    Element fileElement = new Element(PREDEFINED_LOG_FILE_ELEMENT);
    predefinedLogFile.writeExternal(fileElement);
    element.addContent(fileElement);
  }
  final Element fileOutputPathElement = new Element(FILE_OUTPUT);
  if (myFileOutputPath != null) {
    fileOutputPathElement.setAttribute(OUTPUT_FILE, myFileOutputPath);
  }
  fileOutputPathElement.setAttribute(SAVE, String.valueOf(mySaveOutput));
  if (myFileOutputPath != null || mySaveOutput) {
    element.addContent(fileOutputPathElement);
  }
  if (myShowConsoleOnStdOut) {//default value shouldn't be written
    element.setAttribute(SHOW_CONSOLE_ON_STD_OUT, String.valueOf(myShowConsoleOnStdOut));
  }
  if (myShowConsoleOnStdErr) {//default value shouldn't be written
    element.setAttribute(SHOW_CONSOLE_ON_STD_ERR, String.valueOf(myShowConsoleOnStdErr));
  }
}