Пример #1
0
 private void setProperties(ClassPropertiesInfo classInfo) {
   DefaultProperty[] beforeProps;
   PropertiesProvider provider;
   String[] errors;
   beforeProps = convertPropertyType(classInfo.getPropertiesPanel().getProperties());
   provider = classInfo.getClassInstance();
   errors = provider.getPropertiesErrors(beforeProps);
   if (errors != null && errors.length > 0) {
     printErrors(errors);
   } else {
     provider.setProperties(beforeProps);
   }
 }
Пример #2
0
 private DefaultMutableTreeNode createNode(
     PropertiesProvider funcClass, PropertySheetPanel propertiesPanel) {
   PluginDescription pluginAnnotation =
       funcClass.getClass().getAnnotation(PluginDescription.class);
   String name, icon;
   if (pluginAnnotation == null) {
     name = funcClass.getPropertiesDialogTitle();
     if (name == null || name.isEmpty()) name = funcClass.getClass().getSimpleName();
     icon = "";
   } else {
     name = pluginAnnotation.name();
     if (name == null || name.length() == 0) {
       name = funcClass.getPropertiesDialogTitle();
       if (name == null || name.isEmpty()) name = funcClass.getClass().getSimpleName();
       char firstLetter = Character.toUpperCase(name.charAt(0));
       name = firstLetter + name.substring(1);
     }
     icon = pluginAnnotation.icon();
   }
   ClassPropertiesInfo classInfo =
       new ClassPropertiesInfo(funcClass, null, name, propertiesPanel, icon);
   return new DefaultMutableTreeNode(classInfo);
 }
Пример #3
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;
  }