本文整理匯總了Java中java.beans.FeatureDescriptor類的典型用法代碼示例。如果您正苦於以下問題:Java FeatureDescriptor類的具體用法?Java FeatureDescriptor怎麽用?Java FeatureDescriptor使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
FeatureDescriptor類屬於java.beans包,在下文中一共展示了FeatureDescriptor類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: _getSelection
import java.beans.FeatureDescriptor; //導入依賴的package包/類
/** Internal implementation of getSelection() which returns the selected feature
* descriptor whether or not the component has focus. */
public final FeatureDescriptor _getSelection() {
int i = getSelectedRow();
FeatureDescriptor result;
//Check bounds - a change can be fired after the model has been changed, but
//before the table has received the event and updated itself, in which case
//you get an AIOOBE
if (i < getPropertySetModel().getCount()) {
result = getSheetModel().getPropertySetModel().getFeatureDescriptor(getSelectedRow());
} else {
result = null;
}
return result;
}
示例2: select
import java.beans.FeatureDescriptor; //導入依賴的package包/類
/**
* Select (and start editing) the given property.
* @param fd
* @param startEditing
*/
public void select( FeatureDescriptor fd, boolean startEditing ) {
PropertySetModel psm = getPropertySetModel();
final int index = psm.indexOf( fd );
if( index < 0 ) {
return; //not in our list
}
getSelectionModel().setSelectionInterval( index, index );
if( startEditing && psm.isProperty( index ) ) {
editCellAt( index, 1, new MouseEvent( SheetTable.this, 0, System.currentTimeMillis(), 0, 0, 0, 1, false) );
SwingUtilities.invokeLater( new Runnable() {
@Override
public void run() {
SheetCellEditor cellEditor = getEditor();
if( null != cellEditor ) {
InplaceEditor inplace = cellEditor.getInplaceEditor();
if( null != inplace && null != inplace.getComponent() ) {
inplace.getComponent().requestFocus();
}
}
}
});
}
}
示例3: actionPerformed
import java.beans.FeatureDescriptor; //導入依賴的package包/類
@Override
public void actionPerformed(ActionEvent ae) {
int i = getSelectedRow();
if (i != -1) {
FeatureDescriptor fd = getPropertySetModel().getFeatureDescriptor(i);
if (fd instanceof Property) {
java.beans.PropertyEditor ped = PropUtils.getPropertyEditor((Property) fd);
System.err.println(ped.getClass().getName());
} else {
System.err.println("PropertySets - no editor"); //NOI18N
}
} else {
System.err.println("No selection"); //NOI18N
}
}
示例4: createTransferable
import java.beans.FeatureDescriptor; //導入依賴的package包/類
@Override
protected Transferable createTransferable(JComponent c) {
if (c instanceof SheetTable) {
SheetTable table = (SheetTable) c;
FeatureDescriptor fd = table.getSelection();
if (fd == null) {
return null;
}
String res = fd.getDisplayName();
if (fd instanceof Node.Property) {
Node.Property prop = (Node.Property) fd;
res += ("\t" + PropUtils.getPropertyEditor(prop).getAsText());
}
return new SheetTableTransferable(res);
}
return null;
}
示例5: toggleExpanded
import java.beans.FeatureDescriptor; //導入依賴的package包/類
/**
* Expand or collapse the PropertySet the given property belongs to.
* @param fd
* @since 6.47
*/
protected final void toggleExpanded( FeatureDescriptor fd ) {
int index = table.getPropertySetModel().indexOf( fd );
if( index >= 0 ) {
table.getPropertySetModel().toggleExpanded( index );
}
}
示例6: ModelProperty
import java.beans.FeatureDescriptor; //導入依賴的package包/類
/** Creates a new instance of ModelProperty */
private ModelProperty(PropertyModel pm) {
super(pm.getPropertyType());
this.mdl = pm;
if (mdl instanceof ExPropertyModel) {
FeatureDescriptor fd = ((ExPropertyModel) mdl).getFeatureDescriptor();
Boolean result = (Boolean) fd.getValue("canEditAsText"); // NOI18N
if (result != null) {
this.setValue("canEditAsText", result);
}
}
//System.err.println(
//"Created ModelProperty wrapper for mystery PropertyModel " + pm);
}
示例7: setFeatureDescriptor
import java.beans.FeatureDescriptor; //導入依賴的package包/類
/**
* Feature descritor that describes the property. It is feature
* descriptor so one can plug in PropertyDescritor and also Node.Property
* which both inherit from FeatureDescriptor
*/
void setFeatureDescriptor(FeatureDescriptor desc) {
if (desc == null) {
throw new IllegalArgumentException("Cannot set FeatureDescriptor to null."); //NOI18N
}
this.featureDescriptor = desc;
if (featureDescriptor != null) {
Object obj = featureDescriptor.getValue(PROP_CHANGE_IMMEDIATE);
if (obj instanceof Boolean) {
setChangeImmediate(((Boolean) obj).booleanValue());
}
}
}
示例8: readEnv
import java.beans.FeatureDescriptor; //導入依賴的package包/類
void readEnv (FeatureDescriptor desc) {
if (desc instanceof Node.Property){
Node.Property prop = (Node.Property)desc;
editable = prop.canWrite();
//enh 29294 - support one-line editor & suppression of custom
//editor
instructions = (String) prop.getValue ("instructions"); //NOI18N
oneline = Boolean.TRUE.equals (prop.getValue ("oneline")); //NOI18N
customEd = !Boolean.TRUE.equals (prop.getValue
("suppressCustomEditor")); //NOI18N
}
Object obj = desc.getValue(ObjectEditor.PROP_NULL);
if (Boolean.TRUE.equals(obj)) {
nullValue = NbBundle.getMessage(StringEditor.class, "CTL_NullValue");
} else {
if (obj instanceof String) {
nullValue = (String)obj;
} else {
nullValue = null;
}
}
}
示例9: getFeatureDescriptors
import java.beans.FeatureDescriptor; //導入依賴的package包/類
@Override
public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base) {
if (base == null) {
return null;
}
try {
BeanInfo info = Introspector.getBeanInfo(base.getClass());
PropertyDescriptor[] pds = info.getPropertyDescriptors();
for (int i = 0; i < pds.length; i++) {
pds[i].setValue(RESOLVABLE_AT_DESIGN_TIME, Boolean.TRUE);
pds[i].setValue(TYPE, pds[i].getPropertyType());
}
return Arrays.asList((FeatureDescriptor[]) pds).iterator();
} catch (IntrospectionException e) {
//
}
return null;
}
示例10: getFeatureDescriptors
import java.beans.FeatureDescriptor; //導入依賴的package包/類
@Override
public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base) {
if (base == null) {
return null;
}
try {
BeanInfo info = Introspector.getBeanInfo(base.getClass());
PropertyDescriptor[] pds = info.getPropertyDescriptors();
for (int i = 0; i < pds.length; i++) {
pds[i].setValue(RESOLVABLE_AT_DESIGN_TIME, Boolean.TRUE);
pds[i].setValue(TYPE, pds[i].getPropertyType());
}
return Arrays.asList((FeatureDescriptor[]) pds).iterator();
} catch (IntrospectionException e) {
//
}
return null;
}
示例11: testGetFeatureDescriptors02
import java.beans.FeatureDescriptor; //導入依賴的package包/類
/**
* Tests that a valid FeatureDescriptors are returned.
*/
@Test
public void testGetFeatureDescriptors02() {
BeanELResolver resolver = new BeanELResolver();
ELContext context = new ELContextImpl();
Iterator<FeatureDescriptor> result = resolver.getFeatureDescriptors(context, new Bean());
while (result.hasNext()) {
PropertyDescriptor featureDescriptor = (PropertyDescriptor) result.next();
Assert.assertEquals(featureDescriptor.getPropertyType(),
featureDescriptor.getValue(ELResolver.TYPE));
Assert.assertEquals(Boolean.TRUE,
featureDescriptor.getValue(ELResolver.RESOLVABLE_AT_DESIGN_TIME));
}
}
示例12: testGetFeatureDescriptors02
import java.beans.FeatureDescriptor; //導入依賴的package包/類
/**
* Tests that a valid FeatureDescriptors are returned.
*/
@Test
public void testGetFeatureDescriptors02() {
MapELResolver mapELResolver = new MapELResolver();
ELContext context = new ELContextImpl();
Map<String, String> map = new HashMap<String, String>();
map.put("key", "value");
Iterator<FeatureDescriptor> result = mapELResolver
.getFeatureDescriptors(context, map);
while (result.hasNext()) {
FeatureDescriptor featureDescriptor = result.next();
Assert.assertEquals("key", featureDescriptor.getDisplayName());
Assert.assertEquals("key", featureDescriptor.getName());
Assert.assertEquals("", featureDescriptor.getShortDescription());
Assert.assertFalse(featureDescriptor.isExpert());
Assert.assertFalse(featureDescriptor.isHidden());
Assert.assertTrue(featureDescriptor.isPreferred());
Assert.assertEquals("key".getClass(),
featureDescriptor.getValue(ELResolver.TYPE));
Assert.assertEquals(Boolean.TRUE, featureDescriptor
.getValue(ELResolver.RESOLVABLE_AT_DESIGN_TIME));
}
}
示例13: testGetFeatureDescriptors02
import java.beans.FeatureDescriptor; //導入依賴的package包/類
/**
* Tests that a valid FeatureDescriptors are returned.
*/
@Test
public void testGetFeatureDescriptors02() {
ResourceBundleELResolver resolver = new ResourceBundleELResolver();
ELContext context = new ELContextImpl();
ResourceBundle resourceBundle = new TesterResourceBundle(
new Object[][] { { "key", "value" } });
@SuppressWarnings("unchecked")
Iterator<FeatureDescriptor> result = resolver.getFeatureDescriptors(
context, resourceBundle);
while (result.hasNext()) {
FeatureDescriptor featureDescriptor = result.next();
Assert.assertEquals("key", featureDescriptor.getDisplayName());
Assert.assertEquals("key", featureDescriptor.getName());
Assert.assertEquals("", featureDescriptor.getShortDescription());
Assert.assertFalse(featureDescriptor.isExpert());
Assert.assertFalse(featureDescriptor.isHidden());
Assert.assertTrue(featureDescriptor.isPreferred());
Assert.assertEquals(String.class,
featureDescriptor.getValue(ELResolver.TYPE));
Assert.assertEquals(Boolean.TRUE, featureDescriptor
.getValue(ELResolver.RESOLVABLE_AT_DESIGN_TIME));
}
}
示例14: __addFeatureValues
import java.beans.FeatureDescriptor; //導入依賴的package包/類
/**
* Add all of the attributes of one FeatureDescriptor to thos
* of another, replacing any attributes that conflict.
*/
static void __addFeatureValues(
FeatureDescriptor addingDescriptor,
FeatureDescriptor destinationDescriptor
)
{
Enumeration<String> keys = addingDescriptor.attributeNames();
if (keys != null)
{
while (keys.hasMoreElements())
{
String key = keys.nextElement();
Object value = addingDescriptor.getValue(key);
destinationDescriptor.setValue(key, value);
}
}
}
示例15: print
import java.beans.FeatureDescriptor; //導入依賴的package包/類
private static void print(FeatureDescriptor descriptor) {
String name = descriptor.getName();
String display = descriptor.getDisplayName();
String description = descriptor.getShortDescription();
System.out.println("name: " + name);
if (!Objects.equals(name, display)) {
System.out.println("display name: " + display);
}
if (!Objects.equals(display, description)) {
System.out.println("description: " + description.trim());
}
print("expert", descriptor.isExpert());
print("hidden", descriptor.isHidden());
print("preferred", descriptor.isPreferred());
TreeMap<String,Object> map = new TreeMap<>();
Enumeration<String> enumeration = descriptor.attributeNames();
while (enumeration.hasMoreElements()) {
String id = enumeration.nextElement();
Object value = descriptor.getValue(id);
if (value.getClass().isArray()) {
TreeSet<String> set = new TreeSet<>();
int index = 0;
int length = Array.getLength(value);
while (index < length) {
set.add(Array.get(value, index++) + ", " +
Array.get(value, index++) + ", " +
Array.get(value, index++));
}
value = set.toString();
}
map.put(id, value);
}
for (Entry<String,Object> entry : map.entrySet()) {
System.out.println(entry.getKey() + ": " + entry.getValue());
}
}