예제 #1
0
  private <T> PropertySheetPanel createPropertiesPanelForClass(PropertiesProvider funcClass) {
    initEditorRegistry();
    initRenderRegistry();
    final PropertySheetPanel propertiesPanel = new PropertySheetPanel();
    propertiesPanel.setEditorFactory(pEditorRegistry);
    propertiesPanel.setRendererFactory(pRenderRegistry);
    propertiesPanel.setMode(PropertySheet.VIEW_AS_CATEGORIES);
    propertiesPanel.setSortingCategories(true);
    propertiesPanel.setDescriptionVisible(true);
    propertiesPanel.setSorting(true);
    propertiesPanel.setToolBarVisible(false);

    NeptusProperty neptusProperty = null;
    LEVEL userLevel;
    //        for (Field f : funcClass.getClass().getFields()) {
    for (Field f : funcClass.getClass().getDeclaredFields()) {
      neptusProperty = f.getAnnotation(NeptusProperty.class);
      if (neptusProperty == null) continue;

      f.setAccessible(true); // To be able to access private and protected NeptusProperties

      // CLIENT / DEVELOPER
      if (clientConsole && neptusProperty.distribution() == DistributionEnum.DEVELOPER) continue;
      // ADVANCED / REGULAR
      userLevel = neptusProperty.userLevel();
      if (permissionLvl.getLevel() < userLevel.getLevel()) continue;
      PluginProperty pp;
      try {
        pp = extractPluginProperty(f, funcClass);
      } catch (Exception e) {
        NeptusLog.pub().error(funcClass.getClass().getSimpleName() + "." + f.getName(), e);
        throw e;
      }
      if (pp != null) propertiesPanel.addProperty(pp);
    }
    return propertiesPanel;
  }