Exemplo n.º 1
0
  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);
  }
Exemplo n.º 2
0
 /**
  * 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;
 }
 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;
 }
  @Override
  protected Sheet createSheet() {
    Sheet s = super.createSheet();
    Sheet.Set ss = s.get(Sheet.PROPERTIES);
    if (ss == null) {
      ss = Sheet.createPropertiesSet();
      s.put(ss);
    }

    Map<String, Object> map = new LinkedHashMap<String, Object>();
    AbstractAbstractFileNode.fillPropertyMap(map, content);

    AbstractFilePropertyType[] fsTypes = AbstractFilePropertyType.values();
    final int FS_PROPS_LEN = fsTypes.length;
    final String NO_DESCR = "no description";
    for (int i = 0; i < FS_PROPS_LEN; ++i) {
      final AbstractFilePropertyType propType = AbstractFilePropertyType.values()[i];
      final String propString = propType.toString();
      ss.put(new NodeProperty<>(propString, propString, NO_DESCR, map.get(propString)));
    }
    if (directoryBrowseMode) {
      ss.put(new NodeProperty<>(HIDE_PARENT, HIDE_PARENT, HIDE_PARENT, HIDE_PARENT));
    }

    return s;
  }
Exemplo n.º 5
0
 /**
  * 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;
 }
Exemplo n.º 6
0
  private void initProperties() {
    Sheet sheet = Sheet.createDefault();
    Sheet.Set ps = Sheet.createPropertiesSet();

    ps.put(nameProperty);
    ps.put(pathProperty);
    ps.put(new GitStatusProperty(this));

    sheet.put(ps);
    setSheet(sheet);
  }
Exemplo n.º 7
0
  @Override
  protected Sheet createSheet() {
    Sheet s = super.createSheet();
    Sheet.Set ss = s.get(Sheet.PROPERTIES);
    if (ss == null) {
      ss = Sheet.createPropertiesSet();
      s.put(ss);
    }

    ss.put(new NodeProperty("Name", "Name", "no description", NAME));
    return s;
  }
  protected Sheet createSheet() {
    Sheet s = Sheet.createDefault();
    Sheet.Set ss = s.get(Sheet.PROPERTIES);
    ss.put(
        new PropertySupport.ReadOnly("name", String.class, "name", "name of module") {
          public Object getValue() {
            return _module.getName();
          }
        });

    return s;
  }
 /** Creates properties of this node */
 private void createProperties() {
   // default sheet with "properties" property set // NOI18N
   Sheet sheet = Sheet.createDefault();
   Sheet.Set props = sheet.get(Sheet.PROPERTIES);
   props.put(
       new PropertySupport.ReadOnly(
           PROPERTY_CLASS_NAME,
           String.class,
           getLocalizedString("PROP_call_stack_class_name"),
           getLocalizedString("HINT_call_stack_class_name")) {
         public Object getValue() throws InvocationTargetException {
           try {
             return stackFrame.getClassName();
           } catch (Exception e) {
             throw new InvocationTargetException(e);
           }
         }
       });
   props.put(
       new PropertySupport.ReadOnly(
           PROPERTY_METHOD_NAME,
           String.class,
           getLocalizedString("PROP_call_stack_method_name"),
           getLocalizedString("HINT_call_stack_method_name")) {
         public Object getValue() throws InvocationTargetException {
           try {
             return stackFrame.getMethodName();
           } catch (Exception e) {
             throw new InvocationTargetException(e);
           }
         }
       });
   props.put(
       new PropertySupport.ReadOnly(
           PROPERTY_LINE_NUMBER,
           Integer.TYPE,
           getLocalizedString("PROP_call_stack_line_number"),
           getLocalizedString("HINT_call_stack_line_number")) {
         public Object getValue() throws InvocationTargetException {
           try {
             return new Integer(stackFrame.getLineNumber());
           } catch (Exception e) {
             throw new InvocationTargetException(e);
           }
         }
       });
   // and set new sheet
   setSheet(sheet);
 }
Exemplo n.º 10
0
  protected void addProperty(
      Sheet.Set sheet,
      Object target,
      Class valueType,
      Class editorType,
      String name,
      String description) {
    PropertySupport.Reflection prop = null;

    try {
      prop = new PropertySupport.Reflection(target, valueType, name);
    } catch (NoSuchMethodException ex) {
      try {
        prop = new PropertySupport.Reflection(target, valueType, "get" + name, null);
      } catch (NoSuchMethodException ex1) {
        // Exceptions.printStackTrace(ex1);
      }
    }

    if (prop != null) {
      prop.setName(name);
      prop.setShortDescription(description);

      if (editorType != null) prop.setPropertyEditorClass(editorType);

      sheet.put(prop);
    }
  }
Exemplo n.º 11
0
    @Override
    protected Sheet createSheet() {
      Sheet s = super.createSheet();
      Sheet.Set ss = s.get(Sheet.PROPERTIES);
      if (ss == null) {
        ss = Sheet.createPropertiesSet();
        s.put(ss);
      }

      ss.put(
          new NodeProperty<>(
              NbBundle.getMessage(this.getClass(), "FileSize.createSheet.name.name"),
              NbBundle.getMessage(this.getClass(), "FileSize.createSheet.name.displayName"),
              NbBundle.getMessage(this.getClass(), "FileSize.createSheet.name.desc"),
              NAME));
      return s;
    }
 @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;
 }
Exemplo n.º 13
0
  @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();
    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
  protected Sheet createSheet() {

    Sheet sheet = Sheet.createDefault();
    Sheet.Set set = Sheet.createPropertiesSet();
    Element obj = getLookup().lookup(Element.class);

    try {

      Node.Property idProp =
          new PropertySupport.Reflection(obj.getAttribute("id"), String.class, "toString", null);
      idProp.setName("index");
      set.put(idProp);

    } catch (NoSuchMethodException ex) {
      ErrorManager.getDefault();
    }

    sheet.put(set);
    return sheet;
  }
Exemplo n.º 16
0
  @Override
  protected Sheet createSheet() {
    Sheet s = super.createSheet();
    Sheet.Set ss = s.get(Sheet.PROPERTIES);
    if (ss == null) {
      ss = Sheet.createPropertiesSet();
      s.put(ss);
    }

    Map<String, Object> map = new LinkedHashMap<String, Object>();
    fillPropertyMap(map, content);

    ss.put(new NodeProperty("Name", "Name", "no description", getName()));

    final String NO_DESCR = "no description";
    for (Map.Entry<String, Object> entry : map.entrySet()) {
      ss.put(new NodeProperty(entry.getKey(), entry.getKey(), NO_DESCR, entry.getValue()));
    }
    // @@@ add more properties here...

    return s;
  }
Exemplo n.º 17
0
 @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;
  }
Exemplo n.º 19
0
 @Override
 protected Sheet createSheet() {
   Sheet result = Sheet.createDefault();
   Sheet.Set props = Sheet.createPropertiesSet();
   try {
     Property id = new PropertySupport.Reflection(msc, int.class, "id");
     Property name = new PropertySupport.Reflection(msc, String.class, "componentName");
     Property type = new PropertySupport.Reflection(msc, ComponentType.class, "type");
     PropertySupport.Reflection position =
         new PropertySupport.Reflection(msc, Point3d.class, "position");
     Property scale = new PropertySupport.Reflection(msc, double.class, "scale");
     PropertySupport.Reflection rotations =
         new PropertySupport.Reflection(msc, Point3d.class, "rotation");
     Property source = new PropertySupport.Reflection(msc, File.class, "getSource", null);
     id.setName("ID");
     name.setName("Name");
     type.setName("Type");
     position.setName("Position");
     scale.setName("Scale");
     source.setName("Source");
     rotations.setName("Rotation");
     position.setPropertyEditorClass(Tuple3dEditor.class);
     rotations.setPropertyEditorClass(Tuple3dEditor.class);
     //            source.setPropertyEditorClass(FilePropertyEditor.clas);
     props.put(id);
     props.put(name);
     props.put(type);
     props.put(position);
     props.put(scale);
     props.put(rotations);
     props.put(source);
   } catch (NoSuchMethodException ex) {
     System.err.println(ex.getMessage());
   }
   result.put(props);
   return result;
 }
Exemplo n.º 20
0
  @SuppressWarnings("unchecked")
  protected @Override Sheet createSheet() {
    Sheet sheet = Sheet.createDefault();
    Sheet.Set set = getPropertiesSet();
    sheet.put(set);

    try {
      // Label
      set.put(
          getProperty(
              "Label", // property name
              "Sets the label", // property description
              IndicatorProperties.class, // properties class
              String.class, // property class
              PropertyEditorSupport.class, // property editor class (null if none)
              "getLabel", // get method name
              "setLabel", // set method name
              IndicatorProperties.LABEL // default property value
              ));
      // Marker Visibility
      set.put(
          getProperty(
              "Marker Visibility", // property name
              "Sets the marker visibility", // property description
              IndicatorProperties.class, // properties class
              boolean.class, // property class
              null, // property editor class (null if none)
              "getMarker", // get method name
              "setMarker", // set method name
              IndicatorProperties.MARKER // default property value
              ));
      // Fast Period
      set.put(
          getProperty(
              "Fast Period", // property name
              "Sets the Fast Period", // property description
              IndicatorProperties.class, // properties class
              int.class, // property class
              null, // property editor class (null if none)
              "getFastPeriod", // get method name
              "setFastPeriod", // set method name
              IndicatorProperties.FAST_PERIOD // default property value
              ));
      // Slow Period
      set.put(
          getProperty(
              "Slow Period", // property name
              "Sets the Slow Period", // property description
              IndicatorProperties.class, // properties class
              int.class, // property class
              null, // property editor class (null if none)
              "getSlowPeriod", // get method name
              "setSlowPeriod", // set method name
              IndicatorProperties.SLOW_PERIOD // default property value
              ));
      // Line Color
      set.put(
          getProperty(
              "Line Color", // property name
              "Sets the line color", // property description
              IndicatorProperties.class, // properties class
              Color.class, // property class
              null, // property editor class (null if none)
              "getColor", // get method name
              "setColor", // set method name
              IndicatorProperties.COLOR // default property value
              ));
      // Line Style
      set.put(
          getProperty(
              "Line Style", // property name
              "Sets the line style", // property description
              IndicatorProperties.class, // properties class
              Stroke.class, // property class
              StrokePropertyEditor.class, // property editor class (null if none)
              "getStroke", // get method name
              "setStroke", // set method name
              StrokeGenerator.getStroke(IndicatorProperties.STROKE_INDEX) // default property value
              ));
    } catch (NoSuchMethodException ex) {
      LOG.log(Level.SEVERE, "[Absolute Price Oscillator Node] : Method does not exist.", ex);
    }

    return sheet;
  }
Exemplo n.º 21
0
  private Sheet.Set createPropertySet() {
    Sheet.Set r = new Sheet.Set();
    r.setName("Parameters");
    try {
      r.put(
          new MyProperty<Double>(
              Double.TYPE,
              "coplanarity",
              "Coplanarity",
              "Dot product of face normals to detect feature edges"));
      r.put(
          new MyProperty<Boolean>(
              Boolean.TYPE,
              "useTolerance",
              "Use tolerance",
              "Use tolerance parameter instead of triangle number parameter."));
      r.put(
          new MyProperty<Double>(
              Double.TYPE,
              "tolerance",
              "Tolerance",
              "Geometry absolute distance error allowed when decimating.") {
            @Override
            public boolean canWrite() {
              return useTolerance;
            }
          });
      r.put(
          new MyProperty<Integer>(
              Integer.TYPE,
              "triangles",
              "Target triangles",
              "Stops iterations when mesh contains this number of triangles.") {
            @Override
            public boolean canWrite() {
              return !useTolerance;
            }
          });
      r.put(
          new MyProperty<Boolean>(
              Boolean.TYPE,
              "preserveGroups",
              "Preserve groups",
              "Edges adjacent to two different groups are handled like free edges."));
      r.put(
          new MyProperty<Boolean>(
              Boolean.TYPE, "useMaxLength", "Use max length", "Enable max length parameter."));

      r.put(
          new MyProperty<Double>(
              Double.TYPE,
              "maxLength",
              "Maximum length",
              "No edges longer than this value are created.") {
            @Override
            public boolean canWrite() {
              return useMaxLength;
            }
          });

      r.put(
          new MyProperty<Boolean>(
              Boolean.TYPE,
              "keepBorder",
              "Keep border",
              "No geometric transformation on free edges."));

      r.put(
          new MyProperty<Boolean>(
              Boolean.TYPE,
              "keepBorderGroups",
              "Keep border groups",
              "ENo geometric transformation on border group edges."));

    } catch (NoSuchMethodException ex) {
      Exceptions.printStackTrace(ex);
    }
    return r;
  }
Exemplo n.º 22
0
  @Override
  protected Sheet createSheet() {
    Sheet sheet = Sheet.createDefault();
    Sheet.Set set = Sheet.createPropertiesSet();
    NetworkElementApi obj = getLookup().lookup(NetworkElementApi.class);
    try {
      Property<String> valueProp =
          new PropertySupport.Reflection<String>(obj, String.class, "getValue", null);
      Property<String> caseIdListProp =
          new PropertySupport.Reflection<String>(obj, String.class, "getCaseIdListAsString", null);
      Property<NetworkElementType> elementTypeProp =
          new PropertySupport.Reflection<NetworkElementType>(
              obj, NetworkElementType.class, "getNetworkElementType", null);
      Property<Integer> caseIdListSizeProp =
          new PropertySupport.Reflection<Integer>(obj, Integer.class, "getCaseFrequency", null);

      Property<Double> MDPValueProp =
          new PropertySupport.Reflection<Double>(obj, Double.class, "getMDPValue", null);

      Property<Integer> ClusterIDProp =
          new PropertySupport.Reflection<Integer>(obj, int.class, "getClusterID", null);
      Property<Integer> uniqueCaseSizeProp =
          new PropertySupport.Reflection<Integer>(obj, Integer.class, "getUniqueFrequency", null);
      Property<String> uniqueCaseIdListProp =
          new PropertySupport.Reflection<String>(
              obj, String.class, "getUniqueCaseIdSetAsString", null);

      // Optional properties:
      Property<Boolean> errorProp =
          new PropertySupport.Reflection<Boolean>(obj, Boolean.class, "getErrorValue", null);
      Property<Boolean> goalProp =
          new PropertySupport.Reflection<Boolean>(obj, Boolean.class, "getGoalValue", null);
      Property<String> preConditionProp =
          new PropertySupport.Reflection<String>(
              obj, String.class, "getPreConditionStringList", null);
      // Property<String> postConditionProp = new PropertySupport.Reflection<String>(obj,
      // String.class, "getPostConditionStringList", null);

      PropertySupport.Reflection<MultiValueMap> postConditionProp =
          new PropertySupport.Reflection<MultiValueMap>(
              obj, MultiValueMap.class, "getPostCondition", null);
      postConditionProp.setPropertyEditorClass(MultiValueMapPropertyEditor.class);

      Property<Boolean> goalPathValueProp =
          new PropertySupport.Reflection<Boolean>(obj, Boolean.class, "getGoalPathValue", null);
      Property<Integer> goalCaseCountProp =
          new PropertySupport.Reflection<Integer>(obj, Integer.class, "getGoalCaseCount", null);

      valueProp.setName("Value");
      caseIdListProp.setName("Case IDs");
      elementTypeProp.setName("Type");
      caseIdListSizeProp.setName("Case Count");
      uniqueCaseSizeProp.setName("Unique Case Count");
      uniqueCaseIdListProp.setName("Unique Case IDs");

      MDPValueProp.setName("MDP Value");
      ClusterIDProp.setName("ClusterID");

      // TODO: it would be nice to have the list of the actions for the
      // currently selected node...

      // Optional properties:
      errorProp.setName("Error");
      goalProp.setName("Goal");
      preConditionProp.setName("Pre Condition");
      postConditionProp.setName("Post Condition");
      goalPathValueProp.setName("Goal Path");
      goalCaseCountProp.setName("Goal Cases Count");

      set.put(valueProp);
      set.put(caseIdListProp);
      set.put(elementTypeProp);
      set.put(caseIdListSizeProp);
      set.put(uniqueCaseSizeProp);
      set.put(uniqueCaseIdListProp);
      set.put(MDPValueProp);
      set.put(ClusterIDProp);

      if (mNEA.getOptionalData().contains("ERROR")) {
        set.put(errorProp);
      }
      if (mNEA.getOptionalData().contains("GOAL")) {
        set.put(goalProp);
        set.put(goalPathValueProp);
        set.put(goalCaseCountProp);
      }
      if (mNEA.getOptionalData().contains("PRE_CONDITION")) {
        set.put(preConditionProp);
      }
      if (mNEA.getOptionalData().contains("POST_CONDITION")) {
        set.put(postConditionProp);
      }
    } catch (NoSuchMethodException ex) {
    }
    sheet.put(set);
    return (sheet);
  }
Exemplo n.º 23
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;
  }
Exemplo n.º 24
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);
  }
Exemplo n.º 25
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);
      }
    }
  }
Exemplo n.º 26
0
  @Override
  protected Sheet createSheet() {
    Sheet s = super.createSheet();
    Sheet.Set set = s.createPropertiesSet();

    Property host =
        new PropertySupport.ReadOnly<String>(
            "Host", String.class, "Host", "The host of the connection") {

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

    Property port =
        new PropertySupport.ReadOnly<Integer>(
            "Port", Integer.class, "Port", "Port of the connection") {

          @Override
          public Integer getValue() throws IllegalAccessException, InvocationTargetException {
            return url.getPort();
          }
        };

    Property bus =
        new PropertySupport.ReadOnly<String>(
            "Bus name", String.class, "Bus name", "Name of the bus on the host") {

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

    Property description =
        new PropertySupport.ReadOnly<String>(
            "Description",
            String.class,
            "Description",
            "Human readable description of the socketcand service") {

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

    Property hostName =
        new PropertySupport.ReadOnly<String>(
            "Host name",
            String.class,
            "Host name",
            "The name of the machine the socketcand is running on") {

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

    set.put(host);
    set.put(port);
    set.put(bus);
    set.put(description);
    set.put(hostName);

    s.put(set);

    return s;
  }