PropertySupport.Reflection support = new PropertySupport.Reflection( bean, p.getPropertyType(), p.getReadMethod(), p.getWriteMethod() );
/** * Used to build property for each position coordinate of various nodes * (x,y,z) in the same way. * * @return Property for that coordinate */ private Property buildMultipleNodesGeneralPositionProperty(MultipleNodesPropertiesWrapper nodesWrapper, String coordinate) throws NoSuchMethodException { //Position: Property p = new PropertySupport.Reflection(nodesWrapper, Float.class, "getNodes" + coordinate.toUpperCase(), "setNodes" + coordinate.toUpperCase()); p.setDisplayName(NbBundle.getMessage(EditNodes.class, "EditNodes.position.text", coordinate)); p.setName(coordinate); return p; } }
/** * Used to build property for each position coordinate (x,y,z) in the same * way. * * @return Property for that coordinate */ private Property buildGeneralPositionProperty(Node node, String coordinate) throws NoSuchMethodException { //Position: Property p = new PropertySupport.Reflection(node, Float.TYPE, coordinate, "set" + coordinate.toUpperCase()); p.setDisplayName(NbBundle.getMessage(EditNodes.class, "EditNodes.position.text", coordinate)); p.setName(coordinate); return p; }
p = new PropertySupport.Reflection(wrap, type, "getValue" + type.getSimpleName(), "setValue" + type.getSimpleName()); } else {//Use the AttributeType as String: p = new PropertySupport.Reflection(wrap, String.class, "getValueAsString", "setValueAsString"); p = new PropertySupport.Reflection(wrap, type, "getValue" + type.getSimpleName(), null); } else {//Use the AttributeType as String: p = new PropertySupport.Reflection(wrap, String.class, "getValueAsString", null);
Sheet.Set basicProps = sheet.get(Sheet.PROPERTIES); try { Node.Property<?> id = new PropertySupport.Reflection<String>(info, String.class, "getId", null); //NOI18N id.setDisplayName(LBL_Id()); id.setShortDescription(""); //NOI18N Node.Property<?> name = new PropertySupport.Reflection<String>(info, String.class, "getName", null); //NOI18N name.setDisplayName(LBL_Name()); name.setShortDescription(""); //NOI18N Node.Property<?> local = new PropertySupport.Reflection<Boolean>(info, Boolean.TYPE, "isLocal", null); //NOI18N local.setName("local"); //NOI18N local.setDisplayName(LBL_Local()); local.setShortDescription(""); Node.Property<?> localRepoLocation = new PropertySupport.Reflection<String>(info, String.class, "getRepositoryPath", null); //NOI18N localRepoLocation.setDisplayName(LBL_Local_repository_path()); Node.Property<?> remoteDownloadable = new PropertySupport.Reflection<Boolean>(info, Boolean.TYPE, "isRemoteDownloadable", null); //NOI18N remoteDownloadable.setDisplayName(LBL_Remote_Index()); Node.Property<?> repoURL = new PropertySupport.Reflection<String>(info, String.class, "getRepositoryUrl", null); //NOI18N repoURL.setDisplayName(LBL_Remote_URL()); Node.Property<?> indexURL = new PropertySupport.Reflection<String>(info, String.class, "getIndexUpdateUrl", null); //NOI18N indexURL.setDisplayName(LBL_Remote_Index_URL()); Node.Property<?> lastIndexed = new PropertySupport.ReadOnly<Date>("lastIndexed", Date.class, LBL_last_indexed(), null) {
Sheet.Set basicProps = sheet.get(Sheet.PROPERTIES); try { PropertySupport.Reflection artifactId = new PropertySupport.Reflection<String>(art, String.class, "getArtifactId", null); //NOI18N artifactId.setName("artifactId"); //NOI18N artifactId.setDisplayName(org.openide.util.NbBundle.getMessage(DependencyNode.class, "PROP_Artifact")); artifactId.setShortDescription(""); //NOI18N PropertySupport.Reflection groupId = new PropertySupport.Reflection<String>(art, String.class, "getGroupId", null); //NOI18N groupId.setName("groupId"); //NOI18N groupId.setDisplayName(org.openide.util.NbBundle.getMessage(DependencyNode.class, "PROP_Group")); groupId.setShortDescription(""); //NOI18N PropertySupport.Reflection version = new PropertySupport.Reflection<String>(art, String.class, "getVersion", null); //NOI18N version.setName("version"); //NOI18N version.setDisplayName(org.openide.util.NbBundle.getMessage(DependencyNode.class, "PROP_Version")); version.setShortDescription(org.openide.util.NbBundle.getMessage(DependencyNode.class, "HINT_Version")); PropertySupport.Reflection type = new PropertySupport.Reflection<String>(art, String.class, "getType", null); //NOI18N type.setName("type"); //NOI18N type.setDisplayName(org.openide.util.NbBundle.getMessage(DependencyNode.class, "PROP_Type")); PropertySupport.Reflection scope = new PropertySupport.Reflection<String>(art, String.class, "getScope", null); //NOI18N scope.setName("scope"); //NOI18N scope.setDisplayName(org.openide.util.NbBundle.getMessage(DependencyNode.class, "PROP_Scope")); PropertySupport.Reflection classifier = new PropertySupport.Reflection<String>(art, String.class, "getClassifier", null); //NOI18N classifier.setName("classifier"); //NOI18N classifier.setDisplayName(org.openide.util.NbBundle.getMessage(DependencyNode.class, "PROP_Classifier")); PropertySupport.Reflection hasJavadoc = new PropertySupport.Reflection<Boolean>(this, Boolean.TYPE, "hasJavadocInRepository", null); //NOI18N hasJavadoc.setName("javadoc"); //NOI18N hasJavadoc.setDisplayName(org.openide.util.NbBundle.getMessage(DependencyNode.class, "PROP_Javadoc_Locally")); PropertySupport.Reflection hasSources = new PropertySupport.Reflection<Boolean>(this, Boolean.TYPE, "hasSourceInRepository", null); //NOI18N hasSources.setName("sources"); //NOI18N hasSources.setDisplayName(org.openide.util.NbBundle.getMessage(DependencyNode.class, "PROP_Sources_Locally"));
Sheet.Set basicProps = sheet.get(Sheet.PROPERTIES); try { PropertySupport.Reflection id = new PropertySupport.Reflection<String>(info, String.class, "getId", null); //NOI18N id.setName("Id"); //NOI18N id.setDisplayName("Id"); id.setShortDescription(""); //NOI18N PropertySupport.Reflection name = new PropertySupport.Reflection<String>(info, String.class, "getName", null); //NOI18N name.setName("name"); //NOI18N name.setDisplayName("Name"); name.setShortDescription(""); //NOI18N PropertySupport.Reflection type = new PropertySupport.Reflection<String>(info, String.class, "getType", null); //NOI18N type.setName("type"); //NOI18N type.setDisplayName("Repository Manager Type"); PropertySupport.Reflection local = new PropertySupport.Reflection<Boolean>(info, Boolean.TYPE, "isLocal", null); //NOI18N local.setName("local"); //NOI18N local.setDisplayName("Local"); local.setShortDescription(""); PropertySupport.Reflection localRepoLocation = new PropertySupport.Reflection<String>(info, String.class, "getRepositoryPath", null); //NOI18N localRepoLocation.setName("repositoryPath"); //NOI18N localRepoLocation.setDisplayName("Local repository path"); PropertySupport.Reflection remoteDownloadable = new PropertySupport.Reflection<Boolean>(info, Boolean.TYPE, "isRemoteDownloadable", null); //NOI18N remoteDownloadable.setName("remoteDownloadable"); //NOI18N remoteDownloadable.setDisplayName("Remote Index Downloadable"); PropertySupport.Reflection repoURL = new PropertySupport.Reflection<String>(info, String.class, "getRepositoryUrl", null); //NOI18N repoURL.setName("repositoryUrl"); //NOI18N repoURL.setDisplayName("Remote Repository URL"); PropertySupport.Reflection indexURL = new PropertySupport.Reflection<String>(info, String.class, "getIndexUpdateUrl", null); //NOI18N indexURL.setName("indexUpdateUrl"); //NOI18N indexURL.setDisplayName("Remote Index URL");
PropertySupport.Reflection property = new PropertySupport.Reflection( layout, valueType, getMethod, setMethod);
@Override protected Sheet createSheet() { Sheet s = Sheet.createDefault(); Set ss = s.get("general"); // NOI18N if (ss == null) { ss = new Sheet.Set(); ss.setName("general"); // NOI18N ss.setDisplayName(NbBundle.getMessage(Pin.class, "General")); // NOI18N ss.setShortDescription(NbBundle.getMessage(Pin.class, "GeneralHint")); // NOI18N s.put(ss); } Set gs = ss; try { PropertySupport.Reflection p = new Reflection<String>(pageContentItem, String.class, "getName", "setName"); // NOI18N p.setName("fromView"); // NOI18N p.setDisplayName(NbBundle.getMessage(Pin.class, "FromView")); // NOI18N p.setShortDescription(NbBundle.getMessage(Pin.class, "FromViewHint")); // NOI18N ss.put(p); p = new Reflection<String>(pageContentItem, String.class, "getFromOutcome", "setFromOutcome"); // NOI18N p.setName("fromOutcome"); // NOI18N p.setDisplayName(NbBundle.getMessage(Pin.class, "Outcome")); // NOI18N p.setShortDescription(NbBundle.getMessage(Pin.class, "OutcomeHint")); // NOI18N ss.put(p); } catch (NoSuchMethodException nsme) { ErrorManager.getDefault().notify(nsme); } return s; } }
/** * Creates a node property of the given key (same as the column keys) * and specific getter/setter methods on the given object. * * @param key property name (same as matching column). * @param type Class of the property (e.g. String.class). * @param inst object on which to reflect. * @param getter name of getter method for property value. * @param setter name of setter method for property value (may be null). * @return new property. */ private Node.Property createProperty(String key, Class type, Object inst, String getter, String setter) { Property prop = null; try { prop = new Reflection(inst, type, getter, setter); prop.setName(key); prop.setDisplayName(NbBundle.getMessage( ExternalReferenceDataNode.class, "CTL_ExternalReferenceCreator_Column_Name_" + key)); prop.setShortDescription(NbBundle.getMessage( ExternalReferenceDataNode.class, "CTL_ExternalReferenceCreator_Column_Desc_" + key)); } catch (NoSuchMethodException nsme) { ErrorManager.getDefault().notify(nsme); } return prop; }
/** * Create a property, with a particular {@link PropertyEditor}. A particular * editor must be specified when the property type don't have a registered * editor class. * The parameter <code>propertyName</code> will be used as the canonical name of the <code>LayoutProperty</code>. * @param layout The layout instance * @param valueType The type of the property value, ex: <code>Double.class</code> * @param propertyName The display name of the property * @param propertyCategory A category string or <code>null</code> for using * default category * @param propertyDescription A description string for the property * @param getMethod The name of the get method for this property, must exist * to make Java reflexion working. * @param setMethod The name of the set method for this property, must exist * to make Java reflexion working. * @param editorClass A <code>PropertyEditor</code> class for the given type * @return the created property * @throws NoSuchMethodException if the getter or setter methods cannot be found */ public static LayoutProperty createProperty(Layout layout, Class valueType, String propertyName, String propertyCategory, String propertyDescription, String getMethod, String setMethod, Class<? extends PropertyEditor> editorClass) throws NoSuchMethodException { PropertySupport.Reflection property = new PropertySupport.Reflection( layout, valueType, getMethod, setMethod); property.setName(propertyName); property.setShortDescription(propertyDescription); property.setPropertyEditorClass(editorClass); return new LayoutProperty(property, propertyCategory, propertyName); }
/** * Create a property. * The parameter <code>propertyName</code> will be used as the canonical name of the <code>LayoutProperty</code>. * @param layout The layout instance * @param valueType The type of the property value, ex: <code>Double.class</code> * @param propertyName The display name of the property * @param propertyCategory A category string or <code>null</code> for using * default category * @param propertyCanonicalName Canonical name for the <code>LayoutProperty</code>. It should be unique and not localized * @param propertyDescription A description string for the property * @param getMethod The name of the get method for this property, must exist * to make Java reflexion working. * @param setMethod The name of the set method for this property, must exist * to make Java reflexion working. * @return the created property * @throws NoSuchMethodException if the getter or setter methods cannot be found */ public static LayoutProperty createProperty(Layout layout, Class valueType, String propertyName, String propertyCategory, String propertyCanonicalName, String propertyDescription, String getMethod, String setMethod) throws NoSuchMethodException { Property property = new PropertySupport.Reflection( layout, valueType, getMethod, setMethod); property.setName(propertyName); property.setShortDescription(propertyDescription); return new LayoutProperty(property, propertyCategory, propertyCanonicalName); }
protected Sheet createSheet () { Sheet s = Sheet.createDefault (); Sheet.Set ss = s.get (Sheet.PROPERTIES); Node.Property p; p = createNameProperty (obj); ss.put (p); FileObject fo = getDataObject().getPrimaryFile(); if (couldBeTemplate(fo) && !fo.isReadOnly()) { try { p = new PropertySupport.Reflection(obj, Boolean.TYPE, "isTemplate", "setTemplate"); // NOI18N p.setName(DataObject.PROP_TEMPLATE); p.setDisplayName(DataObject.getString("PROP_template")); p.setShortDescription(DataObject.getString("HINT_template")); ss.put(p); } catch (Exception ex) { throw new InternalError(); } } if (fo.isData()) { ss.put(new AllFilesProperty()); ss.put(new SizeProperty()); ss.put(new LastModifiedProperty()); } return s; }
/** * Creates a property. * * @param filter filter instance * @param valueType type of the property value, ex: * <code>Double.class</code> * @param fieldName java field name of the property * @return the created property * @throws NoSuchMethodException if the getter or setter methods cannot be * found */ public static FilterProperty createProperty(Filter filter, Class valueType, String fieldName) throws NoSuchMethodException { if (valueType == Boolean.class) { valueType = boolean.class; } final FilterProperty filterProperty = new FilterProperty(filter); PropertySupport.Reflection property = new PropertySupport.Reflection(filter, valueType, fieldName); property.setName(fieldName); filterProperty.property = property; return filterProperty; } }
/** * Create a property. * The parameter <code>propertyName</code> will be used as the canonical name of the <code>LayoutProperty</code>. * @param layout The layout instance * @param valueType The type of the property value, ex: <code>Double.class</code> * @param propertyName The display name of the property * @param propertyCategory A category string or <code>null</code> for using * default category * @param propertyDescription A description string for the property * @param getMethod The name of the get method for this property, must exist * to make Java reflexion working. * @param setMethod The name of the set method for this property, must exist * to make Java reflexion working. * @return the created property * @throws NoSuchMethodException if the getter or setter methods cannot be found */ public static LayoutProperty createProperty(Layout layout, Class valueType, String propertyName, String propertyCategory, String propertyDescription, String getMethod, String setMethod) throws NoSuchMethodException { Property property = new PropertySupport.Reflection( layout, valueType, getMethod, setMethod); property.setName(propertyName); property.setShortDescription(propertyDescription); return new LayoutProperty(property, propertyCategory, propertyName); }
/** * Creates a property. * * @param filter The filter instance * @param valueType The type of the property value, ex: * <code>Double.class</code> * @param propertyName The display name of the property * @param getMethod The name of the get method for this property, must exist * to make Java reflexion working. * @param setMethod The name of the set method for this property, must exist * to make Java reflexion working. * @return the created property * @throws NoSuchMethodException if the getter or setter methods cannot be * found */ public static FilterProperty createProperty(Filter filter, Class valueType, String propertyName, String getMethod, String setMethod) throws NoSuchMethodException { final FilterProperty filterProperty = new FilterProperty(filter); PropertySupport.Reflection property = new PropertySupport.Reflection(filter, valueType, getMethod, setMethod); property.setName(propertyName); filterProperty.property = property; return filterProperty; }
protected Property[] getProperties() throws NoSuchMethodException{ ServoConfig obj = getLookup().lookup(ServoConfig.class); Property logIdProp = new PropertySupport.Reflection(obj, Integer.class, ServoConfig.PROP_ID); logIdProp.setName("Servo Id"); Property nameProp = new PropertySupport.Reflection(obj, String.class, ServoConfig.PROP_NAME); nameProp.setName("Name"); Property minPosProp = new PropertySupport.Reflection(obj, Integer.class, ServoConfig.PROP_MIN_POSITION); minPosProp.setName("Minimum Position"); Property maxPosProp = new PropertySupport.Reflection(obj, Integer.class, ServoConfig.PROP_MAX_POSITION); maxPosProp.setName("Maximum Position"); Property defPosProp = new PropertySupport.Reflection(obj, Integer.class, ServoConfig.PROP_DEF_POSITION); defPosProp.setName("Default Position"); return new Property[]{logIdProp, nameProp, minPosProp, maxPosProp, defPosProp}; }
public static Property[] getVersionPropertyParts(String propName, String displayName, Object instance) throws NoSuchMethodException { Property versionProp = new PropertySupport.Reflection(instance, VersionProperty.class, propName); Property nameProp = getNameProp(versionProp, displayName); Property numProp = getNumProp(versionProp, displayName); return new Property[]{nameProp, numProp}; }
protected Property[] getProperties() throws NoSuchMethodException{ ServoController obj = getLookup().lookup(ServoController.class); if(obj == null){ return new Property[0]; } Property enabledProp = new PropertySupport.Reflection(obj, Boolean.class, Joint.PROP_ENABLED); enabledProp.setName("Enabled"); return new Property[]{enabledProp}; }
protected Property[] getProperties() throws NoSuchMethodException{ Joint obj = getLookup().lookup(Joint.class); Property goalPosProp = new PropertySupport.Reflection(obj, Double.class, Joint.PROP_GOAL_POSITION); goalPosProp.setName("Goal Position"); Property enabledProp = new PropertySupport.Reflection(obj, Boolean.class, Joint.PROP_ENABLED); enabledProp.setName("Enabled"); return new Property[]{goalPosProp, enabledProp}; }