Example #1
0
  public JComponent createComponent(Category category, Lookup context) {
    Project p = context.lookup(Project.class);
    CheckstyleSettingsProvider checkstyleSettingsProvider =
        p.getLookup().lookup(CheckstyleSettingsProvider.class);
    if (checkstyleSettingsProvider == null) {
      return new JLabel("<not available>");
    }
    final CheckstyleSettings checkstyleSettings =
        checkstyleSettingsProvider.getCheckstyleSettings();

    final CheckstyleConfiguration checkstyleConfiguration = new CheckstyleConfiguration();
    FileObject checkstyleConfigurationFile = checkstyleSettings.getCheckstyleConfigurationFile();
    if (checkstyleConfigurationFile != null) {
      String cleanAbsoluteFile = FileUtil.toFile(checkstyleConfigurationFile).getAbsolutePath();
      checkstyleConfiguration.setConfigFilePath(cleanAbsoluteFile);
    } else {
      checkstyleConfiguration.setConfigFilePath("");
    }
    FileObject checkstylePropertiesFile = checkstyleSettings.getPropertiesFile();
    if (null != checkstylePropertiesFile) {
      String propertiesFilePath = FileUtil.toFile(checkstylePropertiesFile).getAbsolutePath();
      checkstyleConfiguration.setPropertiesFilePath(propertiesFilePath);
    } else {
      checkstyleConfiguration.setPropertiesFilePath("");
    }
    checkstyleConfiguration.setProperties(checkstyleSettings.getPropertiesAsString());

    category.setOkButtonListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            if (checkstyleSettings instanceof CheckstyleSettingsProviderImpl.Settings) {
              CheckstyleSettingsProviderImpl.Settings checkstyleSettingsImpl =
                  (CheckstyleSettingsProviderImpl.Settings) checkstyleSettings;
              checkstyleSettingsImpl.setCheckstyleConfigurationPath(
                  checkstyleConfiguration.getConfigFilePath());
              checkstyleSettingsImpl.setPropertiesPath(
                  checkstyleConfiguration.getPropertiesFilePath());
              checkstyleSettingsImpl.setProperties(checkstyleConfiguration.getProperties());
            }
          }
        });

    return checkstyleConfiguration;
  }
  private Map<Category, JPanel> lookupCategoriesPanels(
      final Properties properties, final List<Category> categories) {
    final Map<Category, JPanel> result = new HashMap<Category, JPanel>();

    final Map<PropertiesPanelProvider, Category> categoriesMap =
        new TreeMap<PropertiesPanelProvider, Category>(
            new Comparator<PropertiesPanelProvider>() {

              @Override
              public int compare(
                  final PropertiesPanelProvider panel1, final PropertiesPanelProvider panel2) {
                final int priority1 = panel1.getPriority();
                final int priority2 = panel2.getPriority();

                if (priority1 == priority2) {
                  return panel1.getDisplayName().compareTo(panel2.getDisplayName());
                }

                return priority2 - priority1;
              }
            });

    final Lookup lkp = Lookup.getDefault();
    for (final PropertiesPanelProvider propPanelProvider :
        lkp.lookupAll(PropertiesPanelProvider.class)) {
      final Category category =
          Category.create(propPanelProvider.getName(), propPanelProvider.getDisplayName(), null);

      final String moduleName = propPanelProvider.getName();
      final AbstractPropertiesPanel panel =
          propPanelProvider.getPanel(new ModuleProperties(moduleName, properties));
      panel.load();

      result.put(category, panel);
      categoriesMap.put(propPanelProvider, category);
    }

    categories.addAll(categoriesMap.values());

    return result;
  }
Example #3
0
 public Category createCategory(Lookup lookup) {
   return Category.create("CheckStyle", "CheckStyle", null);
 }