com.intellij.openapi.util.InvalidDataException Java Examples

The following examples show how to use com.intellij.openapi.util.InvalidDataException. 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: RunConfigurationSerializer.java    From intellij with Apache License 2.0 6 votes vote down vote up
/**
 * Parses a RunConfiguration from the given XML element, and adds it to the project, if there's
 * not already a run configuration with the same name and type,
 */
@VisibleForTesting
static void loadFromXmlElementIgnoreExisting(Project project, Element element)
    throws InvalidDataException {
  if (!shouldLoadConfiguration(project, element)) {
    return;
  }
  runWithPathVariableSet(
      project,
      () -> {
        RunnerAndConfigurationSettings settings =
            RunManagerImpl.getInstanceImpl(project).loadConfiguration(element, false);
        RunConfiguration config = settings != null ? settings.getConfiguration() : null;
        if (config instanceof BlazeRunConfiguration) {
          ((BlazeRunConfiguration) config).setKeepInSync(true);
        }
      });
}
 
Example #2
Source File: BlazeAndroidTestRunConfigurationStateTest.java    From intellij with Apache License 2.0 6 votes vote down vote up
@Test
public void readAndWriteShouldHandleNulls() throws InvalidDataException, WriteExternalException {
  Element element = new Element("test");
  state.writeExternal(element);
  BlazeAndroidTestRunConfigurationState readState =
      new BlazeAndroidTestRunConfigurationState(buildSystem().getName());
  readState.readExternal(element);

  BlazeAndroidRunConfigurationCommonState commonState = state.getCommonState();
  BlazeAndroidRunConfigurationCommonState readCommonState = readState.getCommonState();
  assertThat(readCommonState.getBlazeFlagsState().getRawFlags())
      .isEqualTo(commonState.getBlazeFlagsState().getRawFlags());
  assertThat(readCommonState.getExeFlagsState().getRawFlags())
      .isEqualTo(commonState.getExeFlagsState().getRawFlags());
  assertThat(readCommonState.isNativeDebuggingEnabled())
      .isEqualTo(commonState.isNativeDebuggingEnabled());

  assertThat(readState.getTestingType()).isEqualTo(state.getTestingType());
  assertThat(readState.getInstrumentationRunnerClass())
      .isEqualTo(state.getInstrumentationRunnerClass());
  assertThat(readState.getMethodName()).isEqualTo(state.getMethodName());
  assertThat(readState.getClassName()).isEqualTo(state.getClassName());
  assertThat(readState.getPackageName()).isEqualTo(state.getPackageName());
  assertThat(readState.getLaunchMethod()).isEqualTo(state.getLaunchMethod());
  assertThat(readState.getExtraOptions()).isEqualTo(state.getExtraOptions());
}
 
Example #3
Source File: DeployToServerRunConfiguration.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void readExternal(Element element) throws InvalidDataException {
  super.readExternal(element);
  ConfigurationState state = XmlSerializer.deserialize(element, ConfigurationState.class);
  myServerName =  null;
  myDeploymentSource = null;
  if (state != null) {
    myServerName = state.myServerName;
    Element deploymentTag = state.myDeploymentTag;
    if (deploymentTag != null) {
      String typeId = deploymentTag.getAttributeValue(DEPLOYMENT_SOURCE_TYPE_ATTRIBUTE);
      DeploymentSourceType<?> type = findDeploymentSourceType(typeId);
      if (type != null) {
        myDeploymentSource = type.load(deploymentTag, getProject());
        myDeploymentConfiguration = myDeploymentConfigurator.createDefaultConfiguration(myDeploymentSource);
        ComponentSerializationUtil.loadComponentState(myDeploymentConfiguration.getSerializer(), deploymentTag.getChild(SETTINGS_ELEMENT));
      }
      else {
        LOG.warn("Cannot load deployment source for '" + getName() + "' run configuration: unknown deployment type '" + typeId + "'");
      }
    }
  }
}
 
Example #4
Source File: BlazeCommandRunConfiguration.java    From intellij with Apache License 2.0 6 votes vote down vote up
@Override
public BlazeCommandRunConfiguration clone() {
  final BlazeCommandRunConfiguration configuration = (BlazeCommandRunConfiguration) super.clone();
  configuration.blazeElementState = blazeElementState.clone();
  configuration.targetPatterns = targetPatterns;
  configuration.targetKindString = targetKindString;
  configuration.contextElementString = contextElementString;
  configuration.pendingContext = pendingContext;
  configuration.keepInSync = keepInSync;
  configuration.handlerProvider = handlerProvider;
  configuration.handler = handlerProvider.createHandler(this);
  try {
    configuration.handler.getState().readExternal(configuration.blazeElementState);
  } catch (InvalidDataException e) {
    logger.error(e);
  }

  return configuration;
}
 
Example #5
Source File: BlazeCommandRunConfiguration.java    From intellij with Apache License 2.0 6 votes vote down vote up
private void updateHandlerEditor(BlazeCommandRunConfiguration config) {
  handlerProvider = config.handlerProvider;
  handler = handlerProvider.createHandler(config);
  try {
    handler.getState().readExternal(config.blazeElementState);
  } catch (InvalidDataException e) {
    logger.error(e);
  }
  handlerStateEditor = handler.getState().getEditor(config.getProject());

  if (handlerStateComponent != null) {
    editorWithoutSyncCheckBox.remove(handlerStateComponent);
  }
  handlerStateComponent = handlerStateEditor.createComponent();
  editorWithoutSyncCheckBox.add(handlerStateComponent);
}
 
Example #6
Source File: RunConfigurationSerializerTest.java    From intellij with Apache License 2.0 6 votes vote down vote up
@Test
public void testRunConfigurationUnalteredBySerializationRoundTrip() throws InvalidDataException {
  configuration.setTarget(Label.create("//package:rule"));
  configuration.setKeepInSync(true);

  Element initialElement = runManager.getState();

  Element element = RunConfigurationSerializer.writeToXml(configuration);
  assertThat(RunConfigurationSerializer.findExisting(getProject(), element)).isNotNull();

  clearRunManager(); // remove configuration from project
  RunConfigurationSerializer.loadFromXmlElementIgnoreExisting(getProject(), element);

  Element newElement = runManager.getState();
  XMLOutputter xmlOutputter = new XMLOutputter(Format.getCompactFormat());
  assertThat(xmlOutputter.outputString(newElement))
      .isEqualTo(xmlOutputter.outputString(initialElement));
}
 
Example #7
Source File: P4VcsRootSettingsImpl.java    From p4ic4idea with Apache License 2.0 6 votes vote down vote up
@Override
public void readExternal(Element element)
        throws InvalidDataException {
    Element configElement = element.getChild("p4-config");
    if (configElement == null || configElement.getChildren().isEmpty()) {
        // not set.
        LOG.debug("No configuration settings in the external store.");
        // do not change the existing parts list.
        //setConfigParts(Collections.emptyList());
        return;
    }
    final PersistentRootConfigComponent config = PersistentRootConfigComponent.getInstance(project);
    if (config == null) {
        LOG.warn("Loaded persistent root directory " + rootDir +
                ", but PersistentRootConfigComponent not initialized");
    } else if (!config.hasConfigPartsForRoot(rootDir)) {
        LOG.warn("Loaded persistent root directory " + rootDir + ", but has no persistent config parts loaded");
    }
}
 
Example #8
Source File: RunConfigurationBase.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void readExternal(Element element) throws InvalidDataException {
  myLogFiles.clear();
  for (final Object o : element.getChildren(LOG_FILE)) {
    LogFileOptions logFileOptions = new LogFileOptions();
    logFileOptions.readExternal((Element)o);
    myLogFiles.add(logFileOptions);
  }
  myPredefinedLogFiles.clear();
  final List list = element.getChildren(PREDEFINED_LOG_FILE_ELEMENT);
  for (Object fileElement : list) {
    final PredefinedLogFile logFile = new PredefinedLogFile();
    logFile.readExternal((Element)fileElement);
    myPredefinedLogFiles.add(logFile);
  }
  final Element fileOutputElement = element.getChild(FILE_OUTPUT);
  if (fileOutputElement != null) {
    myFileOutputPath = fileOutputElement.getAttributeValue(OUTPUT_FILE);
    final String isSave = fileOutputElement.getAttributeValue(SAVE);
    mySaveOutput = isSave != null && Boolean.parseBoolean(isSave);
  }
  myShowConsoleOnStdOut = Boolean.parseBoolean(element.getAttributeValue(SHOW_CONSOLE_ON_STD_OUT));
  myShowConsoleOnStdErr = Boolean.parseBoolean(element.getAttributeValue(SHOW_CONSOLE_ON_STD_ERR));
}
 
Example #9
Source File: ReplRunConfiguration.java    From reasonml-idea-plugin with MIT License 6 votes vote down vote up
@Override
public void readExternal(@NotNull Element element) throws InvalidDataException {
    super.readExternal(element);
    Element node = element.getChild("sdk");
    if (node != null) {
        String sdkName = node.getAttributeValue("name");
        if (!sdkName.isEmpty()) {
            ProjectSdksModel model = new ProjectSdksModel();
            model.reset(getProject());
            for (Sdk sdk : model.getSdks()) {
                if (sdkName.equals(sdk.getName())) {
                    m_sdk = sdk;
                    break;
                }
            }
        }
        m_cygwinEnabled = Boolean.parseBoolean(node.getAttributeValue("cygwin"));
        m_cygwinPath = node.getAttributeValue("cygwinPath");
    }
}
 
Example #10
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 #11
Source File: RunConfigurationSerializerTest.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Test
public void testKeepInSyncRespectedWhenImporting() throws InvalidDataException {
  Element element = RunConfigurationSerializer.writeToXml(configuration);

  configuration.setKeepInSync(false);
  assertThat(RunConfigurationSerializer.shouldLoadConfiguration(getProject(), element)).isFalse();

  configuration.setKeepInSync(true);
  assertThat(RunConfigurationSerializer.shouldLoadConfiguration(getProject(), element)).isTrue();
}
 
Example #12
Source File: CodeStyleSettingsManager.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void loadState(Element state) {
  try {
    readExternal(state);
    myIsLoaded = true;
  }
  catch (InvalidDataException e) {
    LOG.error(e);
  }
}
 
Example #13
Source File: ExternalSystemRunConfiguration.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void readExternal(Element element) throws InvalidDataException {
  super.readExternal(element);
  Element e = element.getChild(ExternalSystemTaskExecutionSettings.TAG_NAME);
  if (e != null) {
    mySettings = XmlSerializer.deserialize(e, ExternalSystemTaskExecutionSettings.class);
  }
}
 
Example #14
Source File: HistoryEntry.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
private static EntryData parseEntry(@Nonnull Project project, @Nonnull Element e) throws InvalidDataException {
  if (!e.getName().equals(TAG)) {
    throw new IllegalArgumentException("unexpected tag: " + e);
  }

  String url = e.getAttributeValue(FILE_ATTR);
  List<Pair<FileEditorProvider, FileEditorState>> providerStates = new ArrayList<>();
  FileEditorProvider selectedProvider = null;

  VirtualFile file = VirtualFileManager.getInstance().findFileByUrl(url);

  for (Element _e : e.getChildren(PROVIDER_ELEMENT)) {
    String typeId = _e.getAttributeValue(EDITOR_TYPE_ID_ATTR);
    FileEditorProvider provider = FileEditorProviderManager.getInstance().getProvider(typeId);
    if (provider == null) {
      continue;
    }
    if (Boolean.valueOf(_e.getAttributeValue(SELECTED_ATTR_VALUE))) {
      selectedProvider = provider;
    }

    Element stateElement = _e.getChild(STATE_ELEMENT);
    if (stateElement == null) {
      throw new InvalidDataException();
    }

    if (file != null) {
      FileEditorState state = provider.readState(stateElement, project, file);
      providerStates.add(Pair.create(provider, state));
    }
  }

  return new EntryData(url, providerStates, selectedProvider);
}
 
Example #15
Source File: MongoRunConfiguration.java    From nosql4idea 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);
        scriptPath = JDOMExternalizer.readString(element, "path");
        shellParameters = JDOMExternalizer.readString(element, "shellParams");
//        serverConfiguration = JDOMExternalizer.readBoolean(element, "serverConfiguration");
    }
 
Example #16
Source File: LogFileOptions.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void readExternal(Element element) throws InvalidDataException {
  String file = element.getAttributeValue(PATH);
  if (file != null){
    file = FileUtil.toSystemDependentName(file);
  }
  setPathPattern(file);

  Boolean checked = Boolean.valueOf(element.getAttributeValue(CHECKED));
  setEnable(checked.booleanValue());

  final String skipped = element.getAttributeValue(SKIPPED);
  Boolean skip = skipped != null ? Boolean.valueOf(skipped) : Boolean.TRUE;
  setSkipContent(skip.booleanValue());

  final String all = element.getAttributeValue(SHOW_ALL);
  Boolean showAll = skipped != null ? Boolean.valueOf(all) : Boolean.TRUE;
  setShowAll(showAll.booleanValue());

  setName(element.getAttributeValue(ALIAS));

  final String charsetStr = element.getAttributeValue(CHARSET);
  try {
    setCharset(Charset.forName(charsetStr));
  }
  catch (Exception e) {
    setCharset(Charset.defaultCharset());
  }
}
 
Example #17
Source File: PathMacrosImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void loadState(Element state) {
  try {
    myLock.writeLock().lock();

    final List<Element> children = state.getChildren(MACRO_ELEMENT);
    for (Element aChildren : children) {
      final String name = aChildren.getAttributeValue(NAME_ATTR);
      String value = aChildren.getAttributeValue(VALUE_ATTR);
      if (name == null || value == null) {
        throw new InvalidDataException();
      }

      if (SYSTEM_MACROS.contains(name)) {
        continue;
      }

      if (value.length() > 1 && value.charAt(value.length() - 1) == '/') {
        value = value.substring(0, value.length() - 1);
      }

      myMacros.put(name, value);
    }

    final List<Element> ignoredChildren = state.getChildren(IGNORED_MACRO_ELEMENT);
    for (final Element child : ignoredChildren) {
      final String ignoredName = child.getAttributeValue(NAME_ATTR);
      if (ignoredName != null && !ignoredName.isEmpty() && !myIgnoredMacros.contains(ignoredName)) {
        myIgnoredMacros.add(ignoredName);
      }
    }
  }
  finally {
    myModificationStamp++;
    myLock.writeLock().unlock();
  }
}
 
Example #18
Source File: HistoryEntry.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static HistoryEntry createLight(@Nonnull Project project, @Nonnull Element e) throws InvalidDataException {
  EntryData entryData = parseEntry(project, e);

  VirtualFilePointer pointer = new LightFilePointer(entryData.url);
  HistoryEntry entry = new HistoryEntry(pointer, entryData.selectedProvider, null);
  for (Pair<FileEditorProvider, FileEditorState> state : entryData.providerStates) {
    entry.putState(state.first, state.second);
  }
  return entry;
}
 
Example #19
Source File: ProjectFilesViewPane.java    From intellij-pants-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public void readExternal(@NotNull Element element) throws InvalidDataException {
  super.readExternal(element);
  final String showExcludedOption = JDOMExternalizerUtil.readField(element, SHOW_EXCLUDED_FILES_OPTION);
  myShowExcludedFiles = showExcludedOption == null || Boolean.parseBoolean(showExcludedOption);

  final String showOnlyLoadedOption = JDOMExternalizerUtil.readField(element, SHOW_ONLY_LOADED_FILES_OPTION);
  myShowOnlyLoadedFiles = showOnlyLoadedOption == null || Boolean.parseBoolean(showOnlyLoadedOption);
}
 
Example #20
Source File: DebugPortState.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Override
public void readExternal(Element element) throws InvalidDataException {
  String value = element.getAttributeValue(ATTRIBUTE_TAG);
  if (value == null) {
    return;
  }
  try {
    port = Integer.parseInt(value);
  } catch (NumberFormatException e) {
    // ignore
  }
}
 
Example #21
Source File: TemplateContext.java    From consulo with Apache License 2.0 5 votes vote down vote up
void readTemplateContext(Element element) throws InvalidDataException {
  List options = element.getChildren("option");
  for (Object e : options) {
    if (e instanceof Element) {
      Element option = (Element)e;
      String name = option.getAttributeValue("name");
      String value = option.getAttributeValue("value");
      if (name != null && value != null) {
        myContextStates.put(name, Boolean.parseBoolean(value));
      }
    }
  }
}
 
Example #22
Source File: UpdateInfo.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void readExternal(Element element) throws InvalidDataException {
  myDate = element.getAttributeValue(DATE_ATTR);
  Element fileInfoElement = element.getChild(FILE_INFO_ELEMENTS);
  if (fileInfoElement == null) return;

  String actionInfoName = element.getAttributeValue(ACTION_INFO_ATTRIBUTE_NAME);

  myActionInfo = getActionInfoByName(actionInfoName);
  if (myActionInfo == null) return;

  UpdatedFiles updatedFiles = UpdatedFiles.create();
  updatedFiles.readExternal(fileInfoElement);
  myUpdatedFiles = updatedFiles;

}
 
Example #23
Source File: CoverageEnabledConfiguration.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void readExternal(Element element) throws InvalidDataException {
  // is enabled
  final String coverageEnabledValueStr = element.getAttributeValue(COVERAGE_ENABLED_ATTRIBUTE_NAME);
  myIsCoverageEnabled = Boolean.valueOf(coverageEnabledValueStr).booleanValue();

  // track per test coverage
  final String collectLineInfoAttribute = element.getAttributeValue(TRACK_PER_TEST_COVERAGE_ATTRIBUTE_NAME);
  myTrackPerTestCoverage = collectLineInfoAttribute == null || Boolean.valueOf(collectLineInfoAttribute).booleanValue();

  // sampling
  final String sampling = element.getAttributeValue(SAMPLING_COVERAGE_ATTRIBUTE_NAME);
  mySampling = sampling != null && Boolean.valueOf(sampling).booleanValue();

  // track test folders
  final String trackTestFolders = element.getAttributeValue(TRACK_TEST_FOLDERS);
  myTrackTestFolders = trackTestFolders != null && Boolean.valueOf(trackTestFolders).booleanValue();

  // coverage runner
  final String runnerId = element.getAttributeValue(COVERAGE_RUNNER);
  if (runnerId != null) {
    myRunnerId = runnerId;
    myCoverageRunner = null;
    for (CoverageRunner coverageRunner : CoverageRunner.EP_NAME.getExtensionList()) {
      if (Comparing.strEqual(coverageRunner.getId(), myRunnerId)) {
        myCoverageRunner = coverageRunner;
        break;
      }
    }
  }
}
 
Example #24
Source File: BlazeCommandRunConfiguration.java    From intellij with Apache License 2.0 5 votes vote down vote up
public BlazeCommandRunConfiguration(Project project, ConfigurationFactory factory, String name) {
  super(project, factory, name);
  // start with whatever fallback is present
  handlerProvider =
      BlazeCommandRunConfigurationHandlerProvider.findHandlerProvider(TargetState.KNOWN, null);
  handler = handlerProvider.createHandler(this);
  try {
    handler.getState().readExternal(blazeElementState);
  } catch (InvalidDataException e) {
    logger.error(e);
  }
}
 
Example #25
Source File: HistoryEntry.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static HistoryEntry createHeavy(@Nonnull Project project, @Nonnull Element e) throws InvalidDataException {
  if (project.isDisposed()) return createLight(project, e);

  EntryData entryData = parseEntry(project, e);

  Disposable disposable = Disposable.newDisposable();
  VirtualFilePointer pointer = VirtualFilePointerManager.getInstance().create(entryData.url, disposable, null);

  HistoryEntry entry = new HistoryEntry(pointer, entryData.selectedProvider, disposable);
  for (Pair<FileEditorProvider, FileEditorState> state : entryData.providerStates) {
    entry.putState(state.first, state.second);
  }
  return entry;
}
 
Example #26
Source File: QuarkusModuleBuilder.java    From intellij-quarkus with Eclipse Public License 2.0 5 votes vote down vote up
@NotNull
@Override
public Module createModule(@NotNull ModifiableModuleModel moduleModel) throws InvalidDataException, IOException, ModuleWithNameAlreadyExists, JDOMException, ConfigurationException {
    processDownload();
    Module module = super.createModule(moduleModel);
    wizardContext.getUserData(QuarkusConstants.WIZARD_TOOL_KEY).processImport(module);
    return module;
}
 
Example #27
Source File: EnvironmentVariablesState.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Override
public void readExternal(Element element) throws InvalidDataException {
  Element child = element.getChild(ELEMENT_TAG);
  if (child != null) {
    data = EnvironmentVariablesData.readExternal(child);
  }
}
 
Example #28
Source File: InspectionProfileManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void loadState(Element state) {
  try {
    mySeverityRegistrar.readExternal(state);
  }
  catch (InvalidDataException e) {
    throw new RuntimeException(e);
  }
}
 
Example #29
Source File: CppRemoteDebugConfiguration.java    From CppTools with Apache License 2.0 5 votes vote down vote up
@Override
public void readExternal(Element element) throws InvalidDataException {
  super.readExternal(element);
  myRunnerParameters.setHost(element.getAttributeValue(HOST_NAME));
  myRunnerParameters.setPort(element.getAttributeValue(PORT_NAME));
  myRunnerParameters.setPid(element.getAttributeValue(PID_NAME));
}
 
Example #30
Source File: DaemonCodeAnalyzerSettingsImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void loadState(final Element state) {
  try {
    readExternal(state);
  }
  catch (InvalidDataException e) {
    LOG.error(e);
  }
}