/**
  * Convenience method to create new sheet set named {@link #PROPERTIES}.
  *
  * @return a new properties sheet set
  */
 public static Sheet.Set createPropertiesSet() {
   Sheet.Set ps = new Sheet.Set();
   ps.setName(PROPERTIES);
   ps.setDisplayName(Node.getString("Properties"));
   ps.setShortDescription(Node.getString("HINT_Properties"));
   return ps;
 }
  public static void initializeSheet(final Properties properties, Sheet s) {

    Sheet.Set set1 = Sheet.createPropertiesSet();
    set1.setDisplayName("Properties");
    for (final Property p : properties) {
      Node.Property<String> prop =
          new Node.Property<String>(String.class) {

            @Override
            public boolean canRead() {
              return true;
            }

            @Override
            public String getValue() throws IllegalAccessException, InvocationTargetException {
              return p.getValue();
            }

            @Override
            public boolean canWrite() {
              return false;
            }

            @Override
            public void setValue(String arg0)
                throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
              properties.setProperty(p.getName(), arg0);
            }
          };
      prop.setName(p.getName());
      set1.put(prop);
    }
    s.put(set1);
  }
 protected Sheet.Set getPropertiesSet(String name, String description) {
   Sheet.Set set = new Sheet.Set();
   set.setName(name);
   set.setDisplayName(name);
   set.setShortDescription(description);
   return set;
 }
 /**
  * Convenience method to create new sheet set named {@link #EXPERT}.
  *
  * @return a new expert properties sheet set
  */
 public static Sheet.Set createExpertSet() {
   Sheet.Set ps = new Sheet.Set();
   ps.setName(EXPERT);
   ps.setDisplayName(Node.getString("Expert"));
   ps.setShortDescription(Node.getString("HINT_Expert"));
   return ps;
 }
  @Override
  protected Sheet createSheet() {
    // TODO: multithreading..
    Sheet sheet = super.createSheet();
    Sheet.Set set = Sheet.createPropertiesSet();
    set.setDisplayName("SpotLight");
    set.setName(SpotLight.class.getName());
    SpotLight obj = spotLight;
    if (obj == null) {
      return sheet;
    }

    createFields(SpotLight.class, set, obj);

    sheet.put(set);
    return sheet;
  }
 @Override
 protected Sheet createSheet() {
   Sheet sheet = super.createSheet();
   Sheet.Set set = Sheet.createPropertiesSet();
   set.setDisplayName("Posterization");
   set.setName(Node.class.getName());
   PosterizationFilter obj = (PosterizationFilter) filter;
   if (obj == null) {
     return sheet;
   }
   //        set.put(makeProperty(obj, float.class, "getGamma", "setGamma", "Gamma"));
   //        set.put(makeProperty(obj, int.class, "getNumColors", "setNumColors", "Color Number"));
   //        set.put(makeProperty(obj, float.class, "getStrength", "setStrength", "Strength"));
   createFields(PosterizationFilter.class, set, obj);
   sheet.put(set);
   return sheet;
 }
  @Override
  protected Sheet createSheet() {
    Sheet sheet = super.createSheet();
    MatDefBlock def = lookup.lookup(MatDefBlock.class);
    List<MatParamBlock> params = def.getMatParams();

    Sheet.Set set = new Sheet.Set();
    set.setName("MaterialParameters");
    set.setDisplayName("Material Parameters");
    for (MatParamBlock matParamBlock : params) {
      set.put(MatParamProperty.makeProperty(matParamBlock, lookup));
    }

    sheet.put(set);

    return sheet;
  }
 @Override
 public PropertySet[] getPropertySets() {
   if (propertySets == null) {
     try {
       Map<String, Sheet.Set> sheetMap = new HashMap<String, Sheet.Set>();
       for (LayoutProperty layoutProperty : layout.getProperties()) {
         Sheet.Set set = sheetMap.get(layoutProperty.getCategory());
         if (set == null) {
           set = Sheet.createPropertiesSet();
           set.setDisplayName(layoutProperty.getCategory());
           sheetMap.put(layoutProperty.getCategory(), set);
         }
         set.put(layoutProperty.getProperty());
       }
       propertySets = sheetMap.values().toArray(new PropertySet[0]);
     } catch (Exception ex) {
       Exceptions.printStackTrace(ex);
       return null;
     }
   }
   return propertySets;
 }
  @Override
  protected Sheet createSheet() {
    Sheet sheet = super.createSheet();
    Sheet.Set set = Sheet.createPropertiesSet();
    set.setDisplayName("Blur");
    set.setName(Node.class.getName());
    LightScatteringFilter obj = (LightScatteringFilter) filter;
    if (obj == null) {
      return sheet;
    }
    //        set.put(makeProperty(obj, float.class, "getBlurStart", "setBlurStart", "Blur Start"));
    //        set.put(makeProperty(obj, float.class, "getBlurWidth", "setBlurWidth", "Blur Width"));
    //        set.put(makeProperty(obj, float.class, "getLightDensity", "setLightDensity", "Light
    // Density"));
    //        set.put(makeProperty(obj, Vector3f.class, "getLightPosition", "setLightPosition",
    // "Light Position"));
    //        set.put(makeProperty(obj, int.class, "getNbSamples", "setNbSamples", "Sample
    // Number"));

    createFields(LightScatteringFilter.class, set, obj);
    sheet.put(set);
    return sheet;
  }
Beispiel #10
0
  /**
   * DOCUMENT ME!
   *
   * @param project backend map DOCUMENT ME!
   * @param sheet DOCUMENT ME!
   * @param group DOCUMENT ME!
   * @param user DOCUMENT ME!
   * @throws IllegalArgumentException DOCUMENT ME!
   * @throws IllegalStateException DOCUMENT ME!
   */
  public static void populateLegacyConfigAttrSet(
      final DomainserverProject project,
      final Sheet sheet,
      final UserGroup group,
      final User user) {
    if ((user == null) && (group == null)) {
      throw new IllegalArgumentException("group and user must not be null"); // NOI18N
    }
    final ReadOnly<String> propCAttr =
        new ReadOnly<String>(
            "configattrs", // NOI18N
            String.class,
            NbBundle.getMessage(
                UserNode.class, "UserNode.createSheet().propCAttr.displayName"), // NOI18N
            null) {

          @Override
          public String getHtmlDisplayName() {
            return "<html><b>" // NOI18N
                + NbBundle.getMessage(
                    UserNode.class, "UserNode.createSheet().propCAttr.displayName")
                + "</b></html>"; // NOI18N
          }

          @Override
          public String getValue() throws IllegalAccessException, InvocationTargetException {
            return ""; // NOI18N
          }
        };

    final ReadOnly<String> propAAttr =
        new ReadOnly<String>(
            "actionattrs", // NOI18N
            String.class,
            NbBundle.getMessage(
                UserNode.class, "UserNode.createSheet().propAAttr.displayName"), // NOI18N
            null) {

          @Override
          public String getHtmlDisplayName() {
            return "<html><b>" // NOI18N
                + NbBundle.getMessage(
                    UserNode.class, "UserNode.createSheet().propAAttr.displayName")
                + "</b></html>"; // NOI18N
          }

          @Override
          public String getValue() throws IllegalAccessException, InvocationTargetException {
            return ""; // NOI18N
          }
        };

    final ReadOnly<String> propXAttr =
        new ReadOnly<String>(
            "xmlattrs", // NOI18N
            String.class,
            NbBundle.getMessage(
                UserNode.class, "UserNode.createSheet().propXAttr.displayName"), // NOI18N
            null) {

          @Override
          public String getHtmlDisplayName() {
            return "<html><b>" // NOI18N
                + NbBundle.getMessage(
                    UserNode.class, "UserNode.createSheet().propXAttr.displayName")
                + "</b></html>"; // NOI18N
          }

          @Override
          public String getValue() throws IllegalAccessException, InvocationTargetException {
            return ""; // NOI18N
          }
        };

    final List<UserGroup> ugs;
    if (user == null) {
      ugs = new ArrayList<UserGroup>(1);
      ugs.add(group);
    } else {
      ugs = new ArrayList<UserGroup>(user.getUserGroups());
      Collections.sort(ugs, new Comparators.UserGroups());
    }

    for (final UserGroup ug : ugs) {
      final List<ConfigAttrEntry> caes =
          project
              .getCidsDataObjectBackend()
              .getEntries(
                  ug.getDomain(),
                  ug,
                  user,
                  project.getRuntimeProps().getProperty("serverName"), // NOI18N
                  true);
      Collections.sort(caes, new Comparators.ConfigAttrEntries());

      if (!caes.isEmpty()) {
        final Sheet.Set ugSet = Sheet.createPropertiesSet();
        ugSet.setName(ug.toString());
        ugSet.setDisplayName(ug.getName() + "@" + ug.getDomain().getName()); // NOI18N

        final Map<ReadOnly<String>, List<ReadOnly<String>>> map =
            new TreeMap<ReadOnly<String>, List<ReadOnly<String>>>(
                new Comparator<ReadOnly<String>>() {

                  @Override
                  public int compare(final ReadOnly<String> o1, final ReadOnly<String> o2) {
                    return o1.getDisplayName().compareTo(o2.getDisplayName());
                  }
                });

        for (final ConfigAttrEntry cae : caes) {
          final PropertySupport.ReadOnly<String> p =
              new PropertySupport.ReadOnly<String>(
                  cae.getKey().getKey() + cae.getId(),
                  String.class,
                  cae.getKey().getKey()
                      + " [" // NOI18N
                      + ((cae.getUser() == null)
                          ? ((cae.getUsergroup() == null)
                              ? NbBundle.getMessage(
                                  UserNode.class,
                                  "UserNode.createSheet().caentryProp.displayName.category.domain") // NOI18N
                              : NbBundle.getMessage(
                                  UserNode.class,
                                  "UserNode.createSheet().caentryProp.displayName.category.ug")) // NOI18N
                          : NbBundle.getMessage(
                              UserNode.class,
                              "UserNode.createSheet().caentryProp.displayName.category.user")) // NOI18N
                      + "]", // NOI18N
                  null) {

                @Override
                public String getHtmlDisplayName() {
                  return "<html>"
                      + cae.getKey().getKey() // NOI18N
                      + " <font color=\"!controlShadow\"> [" // NOI18N
                      + ((cae.getUser() == null)
                          ? ((cae.getUsergroup() == null)
                              ? NbBundle.getMessage(
                                  UserNode.class,
                                  "UserNode.createSheet().caentryProp.displayName.category.domain") // NOI18N
                              : NbBundle.getMessage(
                                  UserNode.class,
                                  "UserNode.createSheet().caentryProp.displayName.category.ug")) // NOI18N
                          : NbBundle.getMessage(
                              UserNode.class,
                              "UserNode.createSheet().caentryProp.displayName.category.user")) // NOI18N
                      + "]</font></html>"; // NOI18N
                }

                @Override
                public String getValue() throws IllegalAccessException, InvocationTargetException {
                  return cae.getValue().getValue();
                }
              };

          List<ReadOnly<String>> attrList;
          switch (cae.getType().getAttrType()) {
            case CONFIG_ATTR:
              {
                attrList = map.get(propCAttr);
                if (attrList == null) {
                  attrList = new ArrayList<ReadOnly<String>>();
                  map.put(propCAttr, attrList);
                }

                break;
              }
            case ACTION_TAG:
              {
                attrList = map.get(propAAttr);
                if (attrList == null) {
                  attrList = new ArrayList<ReadOnly<String>>();
                  map.put(propAAttr, attrList);
                }

                break;
              }
            case XML_ATTR:
              {
                attrList = map.get(propXAttr);
                if (attrList == null) {
                  attrList = new ArrayList<ReadOnly<String>>();
                  map.put(propXAttr, attrList);
                }

                break;
              }
            default:
              {
                throw new IllegalStateException(
                    "unknown type: " + cae.getType().getAttrType()); // NOI18N
              }
          }

          attrList.add(p);
        }

        for (final ReadOnly<String> typeProp : map.keySet()) {
          ugSet.put(typeProp);
          for (final ReadOnly<String> entryProp : map.get(typeProp)) {
            ugSet.put(entryProp);
          }
        }

        sheet.put(ugSet);
      }
    }
  }
Beispiel #11
0
  /**
   * DOCUMENT ME!
   *
   * @param sheet DOCUMENT ME!
   * @throws IllegalStateException DOCUMENT ME!
   */
  private void populateConfigAttrSet(final Sheet sheet) {
    final ReadOnly<String> propCAttr =
        new ReadOnly<String>(
            "configattrs", // NOI18N
            String.class,
            NbBundle.getMessage(
                UserNode.class, "UserNode.createSheet().propCAttr.displayName"), // NOI18N
            null) {

          @Override
          public String getHtmlDisplayName() {
            return "<html><b>" // NOI18N
                + NbBundle.getMessage(
                    UserNode.class, "UserNode.createSheet().propCAttr.displayName")
                + "</b></html>"; // NOI18N
          }

          @Override
          public String getValue() throws IllegalAccessException, InvocationTargetException {
            return ""; // NOI18N
          }
        };

    final ReadOnly<String> propAAttr =
        new ReadOnly<String>(
            "actionattrs", // NOI18N
            String.class,
            NbBundle.getMessage(
                UserNode.class, "UserNode.createSheet().propAAttr.displayName"), // NOI18N
            null) {

          @Override
          public String getHtmlDisplayName() {
            return "<html><b>" // NOI18N
                + NbBundle.getMessage(
                    UserNode.class, "UserNode.createSheet().propAAttr.displayName")
                + "</b></html>"; // NOI18N
          }

          @Override
          public String getValue() throws IllegalAccessException, InvocationTargetException {
            return ""; // NOI18N
          }
        };

    final ReadOnly<String> propXAttr =
        new ReadOnly<String>(
            "xmlattrs", // NOI18N
            String.class,
            NbBundle.getMessage(
                UserNode.class, "UserNode.createSheet().propXAttr.displayName"), // NOI18N
            null) {

          @Override
          public String getHtmlDisplayName() {
            return "<html><b>" // NOI18N
                + NbBundle.getMessage(
                    UserNode.class, "UserNode.createSheet().propXAttr.displayName")
                + "</b></html>"; // NOI18N
          }

          @Override
          public String getValue() throws IllegalAccessException, InvocationTargetException {
            return ""; // NOI18N
          }
        };

    final List<Object[]> entries =
        project.getCidsDataObjectBackend().getEntriesNewCollect(user, true);
    // entries sorted by key id, thus we create the attr entries right away and sort later
    final Map<ReadOnly<String>, List<ConflictAwareCfgAttrProperty>> map =
        new TreeMap<ReadOnly<String>, List<ConflictAwareCfgAttrProperty>>(
            new Comparator<ReadOnly<String>>() {

              @Override
              public int compare(final ReadOnly<String> o1, final ReadOnly<String> o2) {
                return o1.getDisplayName().compareTo(o2.getDisplayName());
              }
            });
    for (final Object[] obj : entries) {
      final ConfigAttrEntry cae = (ConfigAttrEntry) obj[0];
      final ReadOnly<String> prop;
      switch (cae.getType().getAttrType()) {
        case CONFIG_ATTR:
          {
            prop = propCAttr;
            break;
          }
        case ACTION_TAG:
          {
            prop = propAAttr;
            break;
          }
        case XML_ATTR:
          {
            prop = propXAttr;
            break;
          }
        default:
          {
            throw new IllegalStateException(
                "unknown type: " + cae.getType().getAttrType()); // NOI18N
          }
      }

      List<ConflictAwareCfgAttrProperty> props = map.get(prop);
      if (props == null) {
        props = new ArrayList<ConflictAwareCfgAttrProperty>();
        map.put(prop, props);
      }

      if (props.isEmpty()
          || !props.get(props.size() - 1).getMainEntry().getKey().equals(cae.getKey())) {
        props.add(new ConflictAwareCfgAttrProperty(cae, (String) obj[1]));
      } else {
        props.get(props.size() - 1).putConflictEntry(cae, (String) obj[1]);
      }
    }

    for (final List<ConflictAwareCfgAttrProperty> props : map.values()) {
      Collections.sort(
          props,
          new Comparator<ConflictAwareCfgAttrProperty>() {

            private final transient Comparator<ConfigAttrEntry> comp =
                new Comparators.ConfigAttrEntries();

            @Override
            public int compare(
                final ConflictAwareCfgAttrProperty o1, final ConflictAwareCfgAttrProperty o2) {
              return comp.compare(o1.mainEntry, o2.getMainEntry());
            }
          });
    }

    final Sheet.Set setConflictAwareCfgAttr = Sheet.createPropertiesSet();

    for (final ReadOnly<String> prop : map.keySet()) {
      setConflictAwareCfgAttr.put(prop);
      for (final ConflictAwareCfgAttrProperty p : map.get(prop)) {
        setConflictAwareCfgAttr.put(p);
      }
    }

    setConflictAwareCfgAttr.setName("conflictAwareConfigAttrProperties"); // NOI18N
    setConflictAwareCfgAttr.setDisplayName(
        NbBundle.getMessage(
            UserNode.class,
            "UserNode.populateConfigAttrSet(Sheet).setConflictAwareCfgAttr.displayName")); // NOI18N

    sheet.put(setConflictAwareCfgAttr);
  }
Beispiel #12
0
  @Override
  protected Sheet createSheet() {
    sheetInitialised = true;
    final Sheet sheet = Sheet.createDefault();
    final Sheet.Set set = Sheet.createPropertiesSet();
    final Sheet.Set setUG = Sheet.createPropertiesSet();

    try {
      // <editor-fold defaultstate="collapsed" desc=" Create Property: ID ">
      final Property<Integer> idProp =
          new PropertySupport.Reflection<Integer>(user, Integer.class, "getId", null); // NOI18N
      idProp.setName(
          NbBundle.getMessage(UserNode.class, "UserNode.createSheet().idProp.name")); // NOI18N
      // </editor-fold>
      // <editor-fold defaultstate="collapsed" desc=" Create Property: PasswordChange ">
      final Property<Date> pwchangeProp =
          new PropertySupport<Date>(
              "lastPWChange", // NOI18N
              Date.class,
              NbBundle.getMessage(
                  UserNode.class, "UserNode.createSheet().pwchangeProp.lastPWChange"), // NOI18N
              NbBundle.getMessage(
                  UserNode.class,
                  "UserNode.createSheet().pwchangeProp.timestampLastPWChange"), // NOI18N
              true,
              false) {

            @Override
            public Date getValue() throws IllegalAccessException, InvocationTargetException {
              return user.getLastPwdChange();
            }

            @Override
            public void setValue(final Date object)
                throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
              // not needed
            }
          }; // </editor-fold>

      // <editor-fold defaultstate="collapsed" desc=" Create Property: Name ">
      final Property<String> nameProp =
          new PropertySupport<String>(
              "name", // NOI18N
              String.class,
              NbBundle.getMessage(UserNode.class, "UserNode.createSheet().nameProp.name"), // NOI18N
              NbBundle.getMessage(
                  UserNode.class, "UserNode.createSheet().nameProp.userLogin"), // NOI18N
              true,
              true) {

            @Override
            public String getValue() throws IllegalAccessException, InvocationTargetException {
              return user.getLoginname();
            }

            @Override
            public void setValue(final String object)
                throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
              final User old = user;
              try {
                user.setLoginname(object);
                user = project.getCidsDataObjectBackend().store(user);
              } catch (final Exception ex) {
                LOG.error("could not store user", ex); // NOI18N
                user = old;
                ErrorManager.getDefault().notify(ex);
              }
              fireDisplayNameChange(null, object);
            }
          }; // </editor-fold>

      // <editor-fold defaultstate="collapsed" desc=" Create Property: Password ">
      final PasswordPropertyEditor pwEditor = new PasswordPropertyEditor();
      final Property<String> passProp =
          new PropertySupport<String>(
              "password", // NOI18N
              String.class,
              NbBundle.getMessage(
                  UserNode.class, "UserNode.createSheet().passProp.password"), // NOI18N
              NbBundle.getMessage(
                  UserNode.class, "UserNode.createSheet().passProp.passwordOfUser"), // NOI18N
              true,
              true) {

            @Override
            public String getValue() throws IllegalAccessException, InvocationTargetException {
              return "****"; // NOI18N
            }

            @Override
            public PropertyEditor getPropertyEditor() {
              return pwEditor;
            }

            @Override
            public void setValue(final String object)
                throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
              if ((object == null) || object.toString().equals("****")) { // NOI18N
                // ignore
                return;
              }

              final User old = user;
              try {
                user.setPassword(object);
                user.setLastPwdChange(Calendar.getInstance().getTime());
                user = project.getCidsDataObjectBackend().store(user);
              } catch (final Exception ex) {
                LOG.error("could not store user", ex); // NOI18N
                user = old;
                ErrorManager.getDefault().notify(ex);
              }
              firePropertyChange(
                  "lastPWChange", // NOI18N
                  null,
                  user.getLastPwdChange());
            }
          };
      passProp.setValue("canEditAsText", Boolean.FALSE); // NOI18N
      // </editor-fold>

      // <editor-fold defaultstate="collapsed" desc=" Create Property: Administrator ">
      final Property<Boolean> adminProp =
          new PropertySupport<Boolean>(
              "admin", // NOI18N
              Boolean.class,
              NbBundle.getMessage(
                  UserNode.class, "UserNode.createSheet().adminProp.admin"), // NOI18N
              NbBundle.getMessage(
                  UserNode.class, "UserNode.createSheet().adminProp.isUserAdmin"), // NOI18N
              true,
              true) {

            @Override
            public Boolean getValue() throws IllegalAccessException, InvocationTargetException {
              return user.isAdmin();
            }

            @Override
            public void setValue(final Boolean object)
                throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
              final User old = user;
              try {
                user.setAdmin(object);
                user = project.getCidsDataObjectBackend().store(user);
              } catch (final Exception ex) {
                LOG.error("could not store user", ex); // NOI18N
                user = old;
                ErrorManager.getDefault().notify(ex);
              }
              fireIconChange();
            }
          }; // </editor-fold>

      // <editor-fold defaultstate="collapsed" desc=" Create Property: GroupInfo ">
      final List<UserGroup> ugs = new ArrayList<UserGroup>(user.getUserGroups());
      Collections.sort(ugs, new Comparators.UserGroups());
      for (final UserGroup ug : user.getUserGroups()) {
        setUG.put(
            new PropertySupport.ReadOnly<Integer>(
                "ug" // NOI18N
                    + ug.getId(),
                Integer.class,
                ug.getName(),
                ug.getDescription()) {

              @Override
              public Integer getValue() throws IllegalAccessException, InvocationTargetException {
                return ug.getId();
              }
            });
      } // </editor-fold>

      setUG.setName("usergroups"); // NOI18N
      setUG.setDisplayName(
          NbBundle.getMessage(
              UserNode.class, "UserNode.createSheet().setUG.displayName")); // NOI18N

      set.put(nameProp);
      set.put(passProp);
      set.put(pwchangeProp);
      set.put(adminProp);
      set.put(idProp);

      sheet.put(set);
      sheet.put(setUG);

      // <editor-fold defaultstate="collapsed" desc=" Create Property: ConfigAttrs legacy">
      if (Boolean.valueOf(
          project
              .getProperties()
              .getProperty(
                  DomainserverProjectCustomizer.PROP_USER_SHOW_LEGACY_CFGATTR_PROPS,
                  "false"))) { // NOI18N
        populateLegacyConfigAttrSet(project, sheet, null, user);
      }
      // </editor-fold>

      // <editor-fold defaultstate="collapsed" desc=" Create Property: ConfigAttrs">
      if (Boolean.valueOf(
          project
              .getProperties()
              .getProperty(
                  DomainserverProjectCustomizer.PROP_USER_SHOW_CFGATTR_PROPS, "false"))) { // NOI18N
        populateConfigAttrSet(sheet);
      }
      // </editor-fold>
    } catch (final Exception ex) {
      LOG.error("could not create property sheet", ex); // NOI18N
      ErrorManager.getDefault().notify(ex);
    }

    return sheet;
  }