/** Create a support with method objects specified. * The methods must be public. * @param instance (Bean) object to work on * @param valueType type of the property * @param getter getter method, can be <code>null</code> * @param setter setter method, can be <code>null</code> * @throws IllegalArgumentException if the methods are not public */ public Reflection(Object instance, Class<T> valueType, Method getter, Method setter) { super(valueType); if ((getter != null) && !Modifier.isPublic(getter.getModifiers())) { throw new IllegalArgumentException("Cannot use a non-public getter " + getter); // NOI18N } if ((setter != null) && !Modifier.isPublic(setter.getModifiers())) { throw new IllegalArgumentException("Cannot use a non-public setter " + setter); // NOI18N } if (getter != null) { setName(Introspector.decapitalize(getter.getName().replaceFirst("^(get|is|has)", ""))); } else if (setter != null) { setName(Introspector.decapitalize(setter.getName().replaceFirst("^set", ""))); } this.instance = instance; this.setter = setter; this.getter = getter; }
bean, p.getPropertyType(), p.getReadMethod(), p.getWriteMethod() ); support.setName(p.getName()); support.setDisplayName(p.getDisplayName()); support.setShortDescription(p.getShortDescription());
p.getReadMethod (), p.getWriteMethod () ); support.setName (p.getName ()); support.setDisplayName (p.getDisplayName ()); support.setShortDescription (p.getShortDescription ());
p.getReadMethod (), p.getWriteMethod () ); support.setName (p.getName ()); support.setDisplayName (p.getDisplayName ()); support.setShortDescription (p.getShortDescription ());
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"); basicProps.put(new Node.Property[] {
p.setName("fromOutcome"); // NOI18N p.setDisplayName(NbBundle.getMessage(NavigationCaseEdge.class, "Outcome")); // NOI18N p.setShortDescription(NbBundle.getMessage(NavigationCaseEdge.class, "OutcomeHint")); // NOI18N p.setName("fromView"); // NOI18N p.setDisplayName(NbBundle.getMessage(NavigationCaseEdge.class, "FromAction")); // NOI18N p.setShortDescription(NbBundle.getMessage(NavigationCaseEdge.class, "FromActionHint")); // NOI18N p.setName("toViewId"); // NOI18N p.setDisplayName(NbBundle.getMessage(NavigationCaseEdge.class, "ToViewId")); // NOI18N p.setShortDescription(NbBundle.getMessage(NavigationCaseEdge.class, "ToViewHint")); // NOI18N
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")); PropertySupport.Reflection transitive = new PropertySupport.Reflection<Boolean>(this, Boolean.TYPE, "isTransitive", null); //NOI18N
layout, valueType, getMethod, setMethod); property.setName(propertyName); property.setShortDescription(propertyDescription); property.setPropertyEditorClass(editorClass);
@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; } }
/** * 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); }
/** * 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; } }
/** * 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; }