示例#1
0
 public static void delete(
     Language sourceLanguage, GeneratorDescriptor generatorDescriptor, boolean deleteFiles) {
   LanguageDescriptor languageDescriptor = sourceLanguage.getModuleDescriptor();
   languageDescriptor.getGenerators().remove(generatorDescriptor);
   sourceLanguage.setLanguageDescriptor(languageDescriptor, true);
   sourceLanguage.save();
 }
示例#2
0
  private static void safeDelete(
      final Project project,
      Language sourceLanguage,
      final Generator generator,
      GeneratorDescriptor generatorDescriptor,
      boolean deleteFiles) {
    List<Generator> dependant = new ArrayList<Generator>();
    for (Generator gen :
        (List<Generator>) ModuleRepositoryFacade.getInstance().getAllModules(Generator.class)) {
      if (gen.getReferencedGenerators().contains(generator)) {
        dependant.add(gen);
      }
    }
    if (!dependant.isEmpty()) {
      final StringBuilder report = new StringBuilder();
      report.append("Can't delete generator ").append(generator.getModuleName()).append(".\n");
      report.append("The following generators depend on it:\n\n");
      for (Generator gen : dependant) {
        report.append(gen.getModuleName()).append("\n");
      }

      SwingUtilities.invokeLater(
          new Runnable() {
            @Override
            public void run() {
              Messages.showErrorDialog(
                  ProjectHelper.toIdeaProject(project), report.toString(), "Deleting Generator");
            }
          });
      return;
    }

    LanguageDescriptor languageDescriptor = sourceLanguage.getModuleDescriptor();
    languageDescriptor.getGenerators().remove(generator.getModuleDescriptor());
    sourceLanguage.setLanguageDescriptor(languageDescriptor, true);
    if (deleteFiles) {
      LOG.error("DELETE GENERATOR FILES - NOT IMPLEMENTED", new Throwable());
      // todo
    }
    sourceLanguage.save();
  }