Java Code Examples for com.intellij.openapi.util.InvalidDataException

The following are top voted examples for showing how to use com.intellij.openapi.util.InvalidDataException. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: AppleScript-IDEA   File: AppleScriptRunConfiguration.java   View source code 6 votes vote down vote up
@Override
public void readExternal(Element element) throws InvalidDataException {
  super.readExternal(element);
  String scriptUrl = element.getAttributeValue(SCRIPT_PATH_URL);
  String scriptParams = element.getAttributeValue(SCRIPT_PARAMETERS);
  String scriptOptions = element.getAttributeValue(SCRIPT_OPTIONS);
  String logEvents = element.getAttributeValue(SCRIPT_SHOW_EVENTS);
  if (!StringUtil.isEmpty(scriptUrl)) {
    scriptPath = scriptUrl;
  }
  if (!StringUtil.isEmpty(scriptParams)) {
    scriptParameters = scriptParams;
  }
  if (!StringUtil.isEmpty(scriptOptions)) {
    this.scriptOptions = scriptOptions;
  }
  if (!StringUtil.isEmpty(logEvents)) myShowAppleEvents = "true".equals(logEvents);
}
 
Example 2
Project: educational-plugin   File: EduRemoteCourseModuleBuilder.java   View source code 6 votes vote down vote up
@NotNull
@Override
public Module createModule(@NotNull ModifiableModuleModel moduleModel)
  throws InvalidDataException, IOException, ModuleWithNameAlreadyExists, JDOMException, ConfigurationException {
  Module baseModule = super.createModule(moduleModel);
  String languageName = myCourse.getLanguageID();
  Language language = Language.findLanguageByID(languageName);
  if (language != null) {
    EduPluginConfigurator configurator = EduPluginConfigurator.INSTANCE.forLanguage(language);
    if (configurator != null) {
      Project project = baseModule.getProject();
      myGenerator.setSelectedCourse(myCourse);
      myGenerator.generateProject(project, project.getBaseDir());
      Course course = StudyTaskManager.getInstance(project).getCourse();
      if (course == null) {
        LOG.info("failed to generate course");
        return baseModule;
      }
      configurator.createCourseModuleContent(moduleModel, project, course, getModuleFileDirectory());
    }
  }
  return baseModule;
}
 
Example 3
Project: educational-plugin   File: EduTaskModuleBuilder.java   View source code 6 votes vote down vote up
@NotNull
@Override
public Module createModule(@NotNull ModifiableModuleModel moduleModel) throws InvalidDataException, IOException, ModuleWithNameAlreadyExists, JDOMException, ConfigurationException {
  Module module = super.createModule(moduleModel);
  Course course = myTask.getLesson().getCourse();
  String directory = getModuleFileDirectory();
  if (directory == null) {
    return module;
  }
  VirtualFile moduleDir = VfsUtil.findFileByIoFile(new File(directory), true);
  if (moduleDir == null) {
    return module;
  }
  VirtualFile src = moduleDir.findChild(EduNames.SRC);
  if (src == null) {
    return module;
  }
  createTask(module.getProject(), course, src);
  ModuleRootModificationUtil.addDependency(module, myUtilModule);
  EduIntellijUtils.addJUnit(module);
  return module;
}
 
Example 4
Project: educational-plugin   File: EduCustomCourseModuleBuilder.java   View source code 6 votes vote down vote up
@NotNull
@Override
public Module createModule(@NotNull ModifiableModuleModel moduleModel)
  throws InvalidDataException, IOException, ModuleWithNameAlreadyExists, JDOMException, ConfigurationException {
  Module baseModule = super.createModule(moduleModel);
  if (mySelectedCourse != null) {
    String languageName = mySelectedCourse.getLanguageID();
    Language language = Language.findLanguageByID(languageName);
    if (language != null) {
      EduPluginConfigurator configurator = EduPluginConfigurator.INSTANCE.forLanguage(language);
      if (configurator != null) {
        myGenerator.setSelectedCourse(mySelectedCourse);
        Project project = baseModule.getProject();
        myGenerator.generateProject(project, project.getBaseDir());
        Course course = StudyTaskManager.getInstance(project).getCourse();
        if (course == null) {
          LOG.info("failed to generate course");
          return baseModule;
        }
        configurator.createCourseModuleContent(moduleModel, project, course, getModuleFileDirectory());
      }
    }
  }
  return baseModule;
}
 
Example 5
Project: educational-plugin   File: EduKotlinKoansModuleBuilder.java   View source code 6 votes vote down vote up
@NotNull
@Override
public Module createModule(@NotNull ModifiableModuleModel moduleModel) throws InvalidDataException, IOException, ModuleWithNameAlreadyExists, JDOMException, ConfigurationException {
  Module baseModule = super.createModule(moduleModel);
  Project project = baseModule.getProject();
  EduProjectGenerator generator = new EduProjectGenerator();
  if (myCourse == null) {
    File courseRoot = StudyUtils.getBundledCourseRoot(DEFAULT_COURSE_NAME, EduKotlinKoansModuleBuilder.class);
    final Course course = generator.addLocalCourse(FileUtil.join(courseRoot.getPath(), DEFAULT_COURSE_NAME));
    if (course == null) {
      LOG.info("Failed to find course " + DEFAULT_COURSE_NAME);
      return baseModule;
    }
  }
  myCourse.setLanguage("kotlin");
  EduModuleBuilderUtils.createCourseFromCourseInfo(moduleModel, project, generator, myCourse, getModuleFileDirectory());
  return baseModule;
}
 
Example 6
Project: processing-idea   File: ProcessingRunConfiguration.java   View source code 6 votes vote down vote up
@Override
public void readExternal(Element element) throws InvalidDataException {
    super.readExternal(element);

    String name = ProcessingRunSettings.class.getSimpleName();
    Element settingsElement = element.getChild(name);

    if (settingsElement == null) return;

    ProcessingRunSettings deserializedConfig = XmlSerializer.deserialize(settingsElement, ProcessingRunSettings.class);

    runSettings.setModule(deserializedConfig.getModule());
    runSettings.setSketchClass(deserializedConfig.getSketchClass());
    runSettings.setFullscreen(deserializedConfig.isFullscreen());
    runSettings.setHideStopButton(deserializedConfig.isHideStopButton());
    runSettings.setJvmArguments(deserializedConfig.getJvmArguments());
    runSettings.setSketchArguments(deserializedConfig.getSketchArguments());
    runSettings.setWindowBackgroundColor(deserializedConfig.getWindowBackgroundColor());
    runSettings.setStopButtonColor(deserializedConfig.getStopButtonColor());
    runSettings.setSketchOutputPath(deserializedConfig.getSketchOutputPath());
    runSettings.setLocation(deserializedConfig.getLocation());

    readModule(element);
}
 
Example 7
Project: Goal-Intellij-Plugin   File: GoalDebugConfiguration.java   View source code 6 votes vote down vote up
@Override
public void readExternal(final Element element) throws InvalidDataException {
    super.readExternal(element);

    final Element fileElement = element.getChild("file");
    if (fileElement != null) {
        this.runFilePath = fileElement.getText();
    }
}
 
Example 8
Project: Goal-Intellij-Plugin   File: GoalRunConfiguration.java   View source code 6 votes vote down vote up
@Override
public void readExternal(final Element element) throws InvalidDataException {
    super.readExternal(element);

    final Element fileElement = element.getChild("file");
    if (fileElement != null) {
        this.runFilePath = fileElement.getText();
    }
}
 
Example 9
Project: intellij   File: BlazeAndroidRunConfigurationCommonState.java   View source code 6 votes vote down vote up
@Override
public void readExternal(Element element) throws InvalidDataException {
  blazeFlags.readExternal(element);
  exeFlags.readExternal(element);
  setNativeDebuggingEnabled(Boolean.parseBoolean(element.getAttributeValue(NATIVE_DEBUG_ATTR)));

  Element deployTargetStatesElement = element.getChild(DEPLOY_TARGET_STATES_TAG);
  if (deployTargetStatesElement != null) {
    deployTargetManager.readExternal(deployTargetStatesElement);
  }

  Element debuggerStatesElement = element.getChild(DEBUGGER_STATES_TAG);
  if (debuggerStatesElement != null) {
    debuggerManager.readExternal(debuggerStatesElement);
  }
}
 
Example 10
Project: mule-intellij-plugins   File: WeaveConfiguration.java   View source code 6 votes vote down vote up
@Override
public void readExternal(Element element) throws InvalidDataException
{
    super.readExternal(element);
    this.weaveHome = JDOMExternalizerUtil.readField(element, WEAVE_HOME_FIELD);
    this.weaveFile = JDOMExternalizerUtil.readField(element, WEAVE_FILE);
    this.weaveOutput = JDOMExternalizerUtil.readField(element, WEAVE_OUTPUT);
    final List<Element> children = element.getChildren(WEAVE_INPUT);
    this.weaveInputs = new ArrayList<>();
    for (Element child : children)
    {
        final WeaveInput weaveInput = new WeaveInput();
        weaveInput.readExternal(child);
        weaveInputs.add(weaveInput);
    }
    getConfigurationModule().readExternal(element);
}
 
Example 11
Project: intellij   File: BlazeAndroidRunConfigurationCommonStateTest.java   View source code 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 12
Project: intellij-ce-playground   File: MvcRunConfiguration.java   View source code 6 votes vote down vote up
@Override
public void readExternal(Element element) throws InvalidDataException {
  PathMacroManager.getInstance(getProject()).expandPaths(element);
  super.readExternal(element);
  readModule(element);
  vmParams = JDOMExternalizer.readString(element, "vmparams");
  cmdLine = JDOMExternalizer.readString(element, "cmdLine");

  String sPassParentEnviroment = JDOMExternalizer.readString(element, "passParentEnv");
  passParentEnv = StringUtil.isEmpty(sPassParentEnviroment) || Boolean.parseBoolean(sPassParentEnviroment);

  envs.clear();
  JDOMExternalizer.readMap(element, envs, null, "env");

  JavaRunConfigurationExtensionManager.getInstance().readExternal(this, element);

  depsClasspath = !"false".equals(JDOMExternalizer.readString(element, "depsClasspath"));
}
 
Example 13
Project: intellij-ce-playground   File: ShelvedChangeList.java   View source code 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));
  //noinspection unchecked
  final List<Element> children = element.getChildren(ELEMENT_BINARY);
  myBinaryFiles = new ArrayList<ShelvedBinaryFile>(children.size());
  for (Element child : children) {
    ShelvedBinaryFile binaryFile = new ShelvedBinaryFile();
    binaryFile.readExternal(child);
    myBinaryFiles.add(binaryFile);
  }
}
 
Example 14
Project: intellij-ce-playground   File: EclipseEmlTest.java   View source code 6 votes vote down vote up
private static Module doLoadModule(@NotNull String path, @NotNull Project project) throws IOException, JDOMException, InvalidDataException {
  Module module;
  AccessToken token = WriteAction.start();
  try {
    module = ModuleManager.getInstance(project).newModule(path + '/' + EclipseProjectFinder.findProjectName(path) + IdeaXml.IML_EXT, StdModuleTypes.JAVA.getId());
  }
  finally {
    token.finish();
  }

  replaceRoot(path, EclipseXml.DOT_CLASSPATH_EXT, project);

  ModifiableRootModel rootModel = ModuleRootManager.getInstance(module).getModifiableModel();
  new EclipseClasspathConverter(module).readClasspath(rootModel);
  token = WriteAction.start();
  try {
    rootModel.commit();
  }
  finally {
    token.finish();
  }
  return module;
}
 
Example 15
Project: intellij-ce-playground   File: JavaCoverageSuite.java   View source code 6 votes vote down vote up
public void readExternal(Element element) throws InvalidDataException {
  super.readExternal(element);

  // filters
  final List children = element.getChildren(FILTER);
  List<String> filters = new ArrayList<String>();
  //noinspection unchecked
  for (Element child : ((Iterable<Element>)children)) {
    filters.add(child.getValue());
  }
  myFilters = filters.isEmpty() ? null : ArrayUtil.toStringArray(filters);

  // suite to merge
  mySuiteToMerge = element.getAttributeValue(MERGE_SUITE);

  if (getRunner() == null) {
    setRunner(CoverageRunner.getInstance(IDEACoverageRunner.class)); //default
  }
}
 
Example 16
Project: intellij-ce-playground   File: LogConsolePreferences.java   View source code 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 17
Project: intellij-ce-playground   File: ModuleJdkOrderEntryImpl.java   View source code 6 votes vote down vote up
ModuleJdkOrderEntryImpl(@NotNull Element element, @NotNull RootModelImpl rootModel, @NotNull ProjectRootManagerImpl projectRootManager) throws InvalidDataException {
  super(rootModel, projectRootManager);
  if (!element.getName().equals(OrderEntryFactory.ORDER_ENTRY_ELEMENT_NAME)) {
    throw new InvalidDataException();
  }
  final Attribute jdkNameAttribute = element.getAttribute(JDK_NAME_ATTR);
  if (jdkNameAttribute == null) {
    throw new InvalidDataException();
  }

  final String jdkName = jdkNameAttribute.getValue();
  final String jdkType = element.getAttributeValue(JDK_TYPE_ATTR);
  final Sdk jdkByName = findJdk(jdkName, jdkType);
  if (jdkByName == null) {
    init(null, jdkName, jdkType);
  }
  else {
    init(jdkByName, null, null);
  }
}
 
Example 18
Project: intellij-ce-playground   File: AbstractPythonRunConfiguration.java   View source code 6 votes vote down vote up
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);
}
 
Example 19
Project: intellij   File: RunConfigurationSerializerTest.java   View source code 6 votes vote down vote up
@Test
public void testRunConfigurationUnalteredBySerializationRoundTrip() throws InvalidDataException {
  configuration.setTarget(Label.create("//package:rule"));
  configuration.setKeepInSync(true);

  final Element initialElement = runManager.getState();

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

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

  final Element newElement = runManager.getState();
  final XMLOutputter xmlOutputter = new XMLOutputter(Format.getCompactFormat());
  assertThat(xmlOutputter.outputString(newElement))
      .isEqualTo(xmlOutputter.outputString(initialElement));
}
 
Example 20
Project: intellij-ce-playground   File: HistoryEntry.java   View source code 6 votes vote down vote up
public HistoryEntry(@NotNull Project project, @NotNull Element e) throws InvalidDataException {
  myFile = getVirtualFile(e);
  myProvider2State = new HashMap<FileEditorProvider, FileEditorState>();

  List providers = e.getChildren(PROVIDER_ELEMENT);
  for (final Object provider1 : providers) {
    Element _e = (Element)provider1;

    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))) {
      mySelectedProvider = provider;
    }

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

    FileEditorState state = provider.readState(stateElement, project, myFile);
    putState(provider, state);
  }
}
 
Example 21
Project: LaravelStorm   File: LaravelRunConf.java   View source code 5 votes vote down vote up
@Override
public void readExternal(Element element) throws InvalidDataException {
    super.readExternal(element);
    Settings settings = XmlSerializer.deserialize(element, Settings.class);
    this.host = settings.host;
    this.port = settings.port;
    this.route = settings.route;
    this.browser = WebBrowserManager.getInstance().findBrowserById(settings.browser);
    this.interpreter = PhpInterpretersManagerImpl.getInstance(getProject()).findInterpreter(settings.interpreterName);

}
 
Example 22
Project: SmartTomcat   File: TomcatRunConfiguration.java   View source code 5 votes vote down vote up
@Override
    public void readExternal(Element element) throws InvalidDataException {
        super.readExternal(element);
        this.tomcatInfo = TomcatInfoConfigs.getInstance(getProject()).getCurrent();
//        this.tomcatInstallation = PropertiesComponent.getInstance().getValue("TOMCAT_INSTALLATION");
//        this.tomcatInstallation = JDOMExternalizerUtil.readField(element, "TOMCAT_INSTALLATION");
        this.docBase = JDOMExternalizerUtil.readField(element, "DOC_BASE");
        this.contextPath = JDOMExternalizerUtil.readField(element, "CONTEXT_PATH");
        this.port = JDOMExternalizerUtil.readField(element, "TOMCAT_PORT");
        this.vmOptions = JDOMExternalizerUtil.readField(element, "VM_OPTIONS");
    }
 
Example 23
Project: educational-plugin   File: EduModuleBuilderUtils.java   View source code 5 votes vote down vote up
private static void createLessonModules(@NotNull ModifiableModuleModel moduleModel, Course course, String moduleDir, Module utilModule)
  throws InvalidDataException, IOException, ModuleWithNameAlreadyExists, JDOMException, ConfigurationException {
  List<Lesson> lessons = course.getLessons();
  for (int i = 0; i < lessons.size(); i++) {
    int lessonVisibleIndex = i + 1;
    Lesson lesson = lessons.get(i);
    lesson.setIndex(lessonVisibleIndex);
    EduLessonModuleBuilder eduLessonModuleBuilder = new EduLessonModuleBuilder(moduleDir, lesson, utilModule);
    eduLessonModuleBuilder.createModule(moduleModel);
  }
}
 
Example 24
Project: educational-plugin   File: EduLessonModuleBuilder.java   View source code 5 votes vote down vote up
@NotNull
@Override
public Module createModule(@NotNull ModifiableModuleModel moduleModel) throws InvalidDataException, IOException, ModuleWithNameAlreadyExists, JDOMException, ConfigurationException {
    Module baseModule = super.createModule(moduleModel);
    List<Task> taskList = myLesson.getTaskList();
    for (int i = 0; i < taskList.size(); i++) {
        int visibleTaskIndex = i + 1;
        Task task = taskList.get(i);
        task.setIndex(visibleTaskIndex);
        createTaskModule(moduleModel, task);
    }
    return baseModule;

}
 
Example 25
Project: educational-plugin   File: EduUtilModuleBuilder.java   View source code 5 votes vote down vote up
@NotNull
@Override
public Module createModule(@NotNull ModifiableModuleModel moduleModel) throws InvalidDataException, IOException, ModuleWithNameAlreadyExists, JDOMException, ConfigurationException {
  Module baseModule = super.createModule(moduleModel);
  String directory = getModuleFileDirectory();
  if (directory == null) {
    return baseModule;
  }
  VirtualFile moduleDir = VfsUtil.findFileByIoFile(new File(directory), true);
  if (moduleDir == null) {
    return baseModule;
  }
  VirtualFile src = moduleDir.findChild(EduNames.SRC);
  if (src == null) {
    return baseModule;
  }
  Project project = baseModule.getProject();
  StartupManager.getInstance(project).registerPostStartupActivity(() -> DumbService.getInstance(project).runWhenSmart(() -> ApplicationManager.getApplication().runWriteAction(() -> {
    EduIntellijUtils.addTemplate(project, src, "EduTestRunner.java");
  })));
  EduIntellijUtils.addJUnit(baseModule);

  if (myAdditionalMaterials != null) {
    final List<Task> taskList = myAdditionalMaterials.getTaskList();
    if (taskList.size() == 1) {
      final Task task = taskList.get(0);
      for (Map.Entry<String, String> entry : task.getTestsText().entrySet()) {
        StudyGenerator.createChildFile(project.getBaseDir(), entry.getKey(), entry.getValue());
      }
    }
  }
  return baseModule;
}
 
Example 26
Project: educational-plugin   File: EduCCModuleBuilder.java   View source code 5 votes vote down vote up
@NotNull
@Override
public Module createModule(@NotNull ModifiableModuleModel moduleModel)
  throws InvalidDataException, IOException, ModuleWithNameAlreadyExists,
         JDOMException, ConfigurationException {
  Module module = super.createModule(moduleModel);
  Project project = module.getProject();
  final Course course = new Course();
  course.setName(myPanel.getName());
  course.setAuthorsAsString(myPanel.getAuthors());
  course.setDescription(myPanel.getDescription());
  LanguageWrapper wrapper = (LanguageWrapper)myLanguageComboBox.getSelectedItem();
  Language language = wrapper.getLanguage();
  course.setLanguage(language.getID());
  course.setCourseMode(CCUtils.COURSE_MODE);
  StudyTaskManager.getInstance(project).setCourse(course);
  EduPluginConfigurator configurator = EduPluginConfigurator.INSTANCE.forLanguage(language);
  String languageName = language.getDisplayName();
  if (configurator == null) {
    LOG.error("EduPluginConfigurator for language " + languageName + " not found");
    return module;
  }
  configurator.createCourseModuleContent(moduleModel, project, course, getModuleFileDirectory());
  StartupManager.getInstance(project).runWhenProjectIsInitialized(() -> new WriteCommandAction.Simple(project) {
    @Override
    protected void run() throws Throwable {
      PsiDirectory baseDir = PsiManager.getInstance(project).findDirectory(project.getBaseDir());
      if (baseDir == null) {
        return;
      }
      PsiDirectory lessonDir = new CCCreateLesson().createItem(null, project, baseDir, course);
      if (lessonDir == null) {
        LOG.error("Failed to create lesson");
        return;
      }
      new CCCreateTask().createItem(null, project, lessonDir, course);
    }
  }.execute());
  return module;
}
 
Example 27
Project: intellij-ce-playground   File: ProjectViewContextProvider.java   View source code 5 votes vote down vote up
public void loadContext(Element fromElement) throws InvalidDataException {
  for (AbstractProjectViewPane pane : myPanes) {
    Element paneElement = fromElement.getChild(pane.getId());
    if (paneElement != null) {
      pane.readExternal(paneElement);
      if (pane.getTree() != null) {
        pane.restoreExpandedPaths();
      }
    }
  }
}
 
Example 28
Project: intellij   File: BlazeCommandRunConfiguration.java   View source code 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(null);
  handler = handlerProvider.createHandler(this);
  try {
    handler.getState().readExternal(elementState);
  } catch (InvalidDataException e) {
    logger.error(e);
  }
}
 
Example 29
Project: intellij-ce-playground   File: TrailingSpacesInPropertyInspection.java   View source code 5 votes vote down vote up
@Override
public void readSettings(@NotNull Element node) throws InvalidDataException {
  final String attributeValue = node.getAttributeValue("ignoreVisibleSpaces");
  if (attributeValue != null) {
    myIgnoreVisibleSpaces = Boolean.valueOf(attributeValue);
  }
}
 
Example 30
Project: intellij-ce-playground   File: NullableNotNullManager.java   View source code 5 votes vote down vote up
@Override
public void loadState(Element state) {
  try {
    DefaultJDOMExternalizer.readExternal(this, state);
    if (myNullables.isEmpty()) {
      Collections.addAll(myNullables, DEFAULT_NULLABLES);
    }
    if (myNotNulls.isEmpty()) {
      Collections.addAll(myNotNulls, DEFAULT_NOT_NULLS);
    }
  }
  catch (InvalidDataException e) {
    LOG.error(e);
  }
}
 
Example 31
Project: intellij-ce-playground   File: ToStringRenderer.java   View source code 5 votes vote down vote up
@SuppressWarnings({"HardCodedStringLiteral"})
public void readExternal(Element element) throws InvalidDataException {
  super.readExternal(element);
  final String value = JDOMExternalizerUtil.readField(element, "USE_CLASS_FILTERS");
  USE_CLASS_FILTERS = "true".equalsIgnoreCase(value);
  myClassFilters = DebuggerUtilsEx.readFilters(element.getChildren("filter"));
}
 
Example 32
Project: intellij-ce-playground   File: CodeStyleSettingsManager.java   View source code 5 votes vote down vote up
@Override
public void loadState(Element state) {
  try {
    readExternal(state);
    myIsLoaded = true;
  }
  catch (InvalidDataException e) {
    LOG.error(e);
  }
}
 
Example 33
Project: intellij-ce-playground   File: ExpressionChildrenRenderer.java   View source code 5 votes vote down vote up
public void readExternal(Element element) throws InvalidDataException {
  super.readExternal(element);
  DefaultJDOMExternalizer.readExternal(this, element);

  TextWithImports childrenExpression = DebuggerUtils.getInstance().readTextWithImports(element, "CHILDREN_EXPRESSION");
  if(childrenExpression != null) {
    setChildrenExpression(childrenExpression);
  }

  TextWithImports childrenExpandable = DebuggerUtils.getInstance().readTextWithImports(element, "CHILDREN_EXPANDABLE");
  if(childrenExpandable != null) {
    myChildrenExpandable.setReferenceExpression(childrenExpandable);
  }
}
 
Example 34
Project: intellij-ce-playground   File: ExternalizablePath.java   View source code 5 votes vote down vote up
@Override
public void readExternal(final Element element) throws InvalidDataException {
  final String value = element.getAttributeValue(VALUE_ATTRIBUTE);
  myUrl = value != null ? value : "";
  final String protocol = VirtualFileManager.extractProtocol(myUrl);
  if (protocol == null) myUrl = urlValue(myUrl);
}
 
Example 35
Project: intellij-ce-playground   File: CloneDeclaresCloneNotSupportedInspection.java   View source code 5 votes vote down vote up
@Override
public void readSettings(@NotNull Element node) throws InvalidDataException {
  super.readSettings(node);
  for (Element option : node.getChildren("option")) {
    if ("onlyWarnOnProtectedClone".equals(option.getAttributeValue("name"))) {
      onlyWarnOnProtectedClone = Boolean.parseBoolean(option.getAttributeValue("value"));
    }
  }
}
 
Example 36
Project: intellij-ce-playground   File: FacetUtil.java   View source code 5 votes vote down vote up
public static void loadFacetConfiguration(final @NotNull FacetConfiguration configuration, final @Nullable Element config)
    throws InvalidDataException {
  if (config != null) {
    if (configuration instanceof PersistentStateComponent) {
      ComponentSerializationUtil.loadComponentState((PersistentStateComponent)configuration, config);
    }
    else {
      configuration.readExternal(config);
    }
  }
}
 
Example 37
Project: intellij   File: BlazeAndroidRunConfigurationCommonStateTest.java   View source code 5 votes vote down vote up
@Test
public void readAndWriteShouldHandleNulls() throws InvalidDataException, WriteExternalException {
  Element element = new Element("test");
  state.writeExternal(element);
  BlazeAndroidRunConfigurationCommonState readState =
      new BlazeAndroidRunConfigurationCommonState(buildSystem().getName(), false);
  readState.readExternal(element);

  assertThat(readState.getBlazeFlagsState().getRawFlags())
      .isEqualTo(state.getBlazeFlagsState().getRawFlags());
  assertThat(readState.getExeFlagsState().getRawFlags())
      .isEqualTo(state.getExeFlagsState().getRawFlags());
  assertThat(readState.isNativeDebuggingEnabled()).isEqualTo(state.isNativeDebuggingEnabled());
}
 
Example 38
Project: intellij-ce-playground   File: IntroduceVariableValidatorTest.java   View source code 5 votes vote down vote up
private String processFile(String fileText) throws IncorrectOperationException, InvalidDataException, IOException {
  String result = "";
  int startOffset = fileText.indexOf(TestUtils.BEGIN_MARKER);
  if (startOffset < 0) {
    startOffset = fileText.indexOf(ALL_MARKER);
    replaceAllOccurences = true;
    fileText = IntroduceVariableTest.removeAllMarker(fileText);
  } else {
    replaceAllOccurences = false;
    fileText = TestUtils.removeBeginMarker(fileText);
  }
  int endOffset = fileText.indexOf(TestUtils.END_MARKER);
  fileText = TestUtils.removeEndMarker(fileText);
  myFixture.configureByText(GroovyFileType.GROOVY_FILE_TYPE, fileText);

  Editor myEditor = myFixture.getEditor();

  myEditor.getSelectionModel().setSelection(startOffset, endOffset);

  GrExpression selectedExpr = PsiImplUtil.findElementInRange(myFixture.getFile(), startOffset, endOffset, GrExpression.class);

  Assert.assertNotNull("Selected expression reference points to null", selectedExpr);

  final PsiElement tempContainer = GrIntroduceHandlerBase.getEnclosingContainer(selectedExpr);
  Assert.assertTrue(tempContainer instanceof GroovyPsiElement);

  PsiElement[] occurences = GroovyRefactoringUtil.getExpressionOccurrences(PsiUtil.skipParentheses(selectedExpr, false), tempContainer);
  String varName = "preved";
  GroovyVariableValidator validator =
    new GroovyVariableValidator(new GrIntroduceContextImpl(getProject(), myEditor, selectedExpr, null, null, occurences, tempContainer));
  result = validator.isOKTest(varName, replaceAllOccurences);
  return result;
}
 
Example 39
Project: intellij   File: RunConfigurationSerializer.java   View source code 5 votes vote down vote up
/**
 * Deserializes the configuration represented by the given XML element, then searches for an
 * existing run configuration in the project with the same name and type.
 */
@Nullable
@VisibleForTesting
static RunnerAndConfigurationSettings findExisting(Project project, Element element)
    throws InvalidDataException {
  RunManagerImpl manager = RunManagerImpl.getInstanceImpl(project);
  RunnerAndConfigurationSettingsImpl settings = new RunnerAndConfigurationSettingsImpl(manager);
  RunnerAndConfigurationSettingsCompatUtils.readConfiguration(settings, element);
  RunConfiguration config = settings.getConfiguration();
  if (config == null) {
    return null;
  }
  return manager.findConfigurationByTypeAndName(config.getType().getId(), config.getName());
}
 
Example 40
Project: intellij-ce-playground   File: ExternalizableStringSet.java   View source code 5 votes vote down vote up
@Override
public void readExternal(Element element) throws InvalidDataException {
  boolean dataFound = false;
  for (Element item : (List<Element>)element.getChildren(ITEM)) {
    if (!dataFound) {
      clear();
      dataFound = true;
    }
    add(StringUtil.unescapeXml(item.getAttributeValue(VALUE)));
  }
}