/** 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;
}
java类java.beans.FeatureDescriptor的实例源码
SheetTable.java 文件源码
项目:incubator-netbeans
阅读 30
收藏 0
点赞 0
评论 0
SheetTable.java 文件源码
项目:incubator-netbeans
阅读 30
收藏 0
点赞 0
评论 0
/**
* 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();
}
}
}
});
}
}
SheetTable.java 文件源码
项目:incubator-netbeans
阅读 28
收藏 0
点赞 0
评论 0
@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
}
}
SheetTable.java 文件源码
项目:incubator-netbeans
阅读 33
收藏 0
点赞 0
评论 0
@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;
}
PropertySheet.java 文件源码
项目:incubator-netbeans
阅读 21
收藏 0
点赞 0
评论 0
/**
* 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 );
}
}
ModelProperty.java 文件源码
项目:incubator-netbeans
阅读 18
收藏 0
点赞 0
评论 0
/** 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);
}
PropertyEnv.java 文件源码
项目:incubator-netbeans
阅读 22
收藏 0
点赞 0
评论 0
/**
* 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());
}
}
}
StringEditor.java 文件源码
项目:incubator-netbeans
阅读 22
收藏 0
点赞 0
评论 0
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;
}
}
}
BeanELResolver.java 文件源码
项目:lazycat
阅读 19
收藏 0
点赞 0
评论 0
@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;
}
BeanELResolver.java 文件源码
项目:tomcat7
阅读 18
收藏 0
点赞 0
评论 0
@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;
}
TestBeanELResolver.java 文件源码
项目:tomcat7
阅读 20
收藏 0
点赞 0
评论 0
/**
* 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));
}
}
TestMapELResolver.java 文件源码
项目:tomcat7
阅读 16
收藏 0
点赞 0
评论 0
/**
* 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));
}
}
TestResourceBundleELResolver.java 文件源码
项目:tomcat7
阅读 18
收藏 0
点赞 0
评论 0
/**
* 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));
}
}
JavaIntrospector.java 文件源码
项目:myfaces-trinidad
阅读 21
收藏 0
点赞 0
评论 0
/**
* 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);
}
}
}
BeanELResolver.java 文件源码
项目:apache-tomcat-7.0.73-with-comment
阅读 18
收藏 0
点赞 0
评论 0
@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;
}
TestBeanELResolver.java 文件源码
项目:apache-tomcat-7.0.73-with-comment
阅读 23
收藏 0
点赞 0
评论 0
/**
* 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));
}
}
TestMapELResolver.java 文件源码
项目:apache-tomcat-7.0.73-with-comment
阅读 18
收藏 0
点赞 0
评论 0
/**
* 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));
}
}
TestResourceBundleELResolver.java 文件源码
项目:apache-tomcat-7.0.73-with-comment
阅读 18
收藏 0
点赞 0
评论 0
/**
* 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));
}
}
StringEditor.java 文件源码
项目:incubator-netbeans
阅读 20
收藏 0
点赞 0
评论 0
@Override
public void attachEnv(PropertyEnv env) {
FeatureDescriptor desc = env.getFeatureDescriptor();
if (desc instanceof Node.Property){
Node.Property prop = (Node.Property)desc;
editable = prop.canWrite();
if (textComp != null)
textComp.setEditable(editable);
}
}
ValuePropertyEditor.java 文件源码
项目:incubator-netbeans
阅读 24
收藏 0
点赞 0
评论 0
@Override
public void attachEnv(PropertyEnv env) {
//System.out.println("ValuePropertyEditor.attachEnv("+env+"), feature descriptor = "+env.getFeatureDescriptor());
env.setState(PropertyEnv.STATE_NEEDS_VALIDATION);
env.addVetoableChangeListener(validate);
if (delegatePropertyEditor instanceof ExPropertyEditor) {
//System.out.println(" attaches to "+delegatePropertyEditor);
if (delegateValue instanceof String) {
ShortenedStrings.StringInfo shortenedInfo = ShortenedStrings.getShortenedInfo((String) delegateValue);
if (shortenedInfo != null) {
// The value is too large, do not allow editing!
FeatureDescriptor desc = env.getFeatureDescriptor();
if (desc instanceof Node.Property){
Node.Property prop = (Node.Property)desc;
// Need to make it uneditable
try {
Method forceNotEditableMethod = prop.getClass().getDeclaredMethod("forceNotEditable");
forceNotEditableMethod.setAccessible(true);
forceNotEditableMethod.invoke(prop);
} catch (Exception ex){}
//editable = prop.canWrite();
}
}
}
((ExPropertyEditor) delegatePropertyEditor).attachEnv(env);
this.env = env;
}
}
RuleEditorPanel.java 文件源码
项目:incubator-netbeans
阅读 21
收藏 0
点赞 0
评论 0
private void call_PropertySheet_select(PropertySheet sheet, FeatureDescriptor descriptor, boolean edit) throws NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
//private so far, will be public later
Class clz = PropertySheet.class;
Method select_method = clz.getDeclaredMethod("select", FeatureDescriptor.class, boolean.class); //NOI18N
select_method.setAccessible(true);
select_method.invoke(sheet, descriptor, edit);
}
RuleEditorPanel.java 文件源码
项目:incubator-netbeans
阅读 23
收藏 0
点赞 0
评论 0
@Override
protected JPopupMenu createPopupMenu() {
FeatureDescriptor fd = getSelection();
if (fd != null) {
if (fd instanceof RuleEditorNode.DeclarationProperty) {
//property
//
//actions:
//remove
//hide
//????
//custom popop for the whole panel
JPopupMenu pm = new JPopupMenu();
if(!addPropertyMode) {
pm.add(new GoToSourceAction(RuleEditorPanel.this, (RuleEditorNode.DeclarationProperty) fd));
pm.addSeparator();
pm.add(new RemovePropertyAction(RuleEditorPanel.this, (RuleEditorNode.DeclarationProperty) fd));
}
return pm;
} else if (fd instanceof RuleEditorNode.PropertyCategoryPropertySet) {
//property category
//TODO possibly add "add property" action which would
//preselect the css category in the "add property dialog".
}
}
//no context popup - create the generic popup
return genericPopupMenu;
}
SheetTable.java 文件源码
项目:incubator-netbeans
阅读 31
收藏 0
点赞 0
评论 0
private TableCellRenderer getCustomRenderer( int row ) {
FeatureDescriptor fd = getPropertySetModel().getFeatureDescriptor(row);
if (fd instanceof PropertySet)
return null;
Object res = fd.getValue( "custom.cell.renderer"); //NOI18N
if( res instanceof TableCellRenderer ) {
prepareCustomEditor( res );
return ( TableCellRenderer ) res;
}
return null;
}
SheetTable.java 文件源码
项目:incubator-netbeans
阅读 32
收藏 0
点赞 0
评论 0
private TableCellEditor getCustomEditor( int row ) {
FeatureDescriptor fd = getPropertySetModel().getFeatureDescriptor(row);
if (fd instanceof PropertySet)
return null;
Object res = fd.getValue( "custom.cell.editor"); //NOI18N
if( res instanceof TableCellEditor ) {
prepareCustomEditor( res );
return ( TableCellEditor ) res;
}
return null;
}
SheetTable.java 文件源码
项目:incubator-netbeans
阅读 25
收藏 0
点赞 0
评论 0
/** Overridden to cast value to FeatureDescriptor and return true if the
* text matches its display name. The popup search field uses this method
* to check matches. */
@Override
protected boolean matchText(Object value, String text) {
if (value instanceof FeatureDescriptor) {
return ((FeatureDescriptor) value).getDisplayName().toUpperCase().startsWith(text.toUpperCase());
} else {
return false;
}
}
SheetTable.java 文件源码
项目:incubator-netbeans
阅读 30
收藏 0
点赞 0
评论 0
/** We only use a single listener on the selected node, PropertySheet.SheetPCListener,
* to centralize things. It will call this method if a property change is detected
* so that it can be repainted. */
void repaintProperty(String name) {
if (!isShowing()) {
return;
}
if (PropUtils.isLoggable(SheetTable.class)) {
PropUtils.log(SheetTable.class, "RepaintProperty: " + name);
}
PropertySetModel psm = getPropertySetModel();
int min = getFirstVisibleRow();
if (min == -1) {
return;
}
int max = min + getVisibleRowCount();
for (int i = min; i < max; i++) {
FeatureDescriptor fd = psm.getFeatureDescriptor(i);
if (null != fd && fd.getName().equals(name)) {
//repaint property value & name
paintRow( i );
return;
}
}
if (PropUtils.isLoggable(SheetTable.class)) {
PropUtils.log(SheetTable.class, "Property is either scrolled offscreen or property name is bogus: " + name);
}
}
SheetTable.java 文件源码
项目:incubator-netbeans
阅读 29
收藏 0
点赞 0
评论 0
/**Overridden to do the assorted black magic by which one determines if
* a property is editable */
@Override
public boolean isCellEditable(int row, int column) {
if (column == 0) {
return null != getCustomEditor( row );
}
FeatureDescriptor fd = getPropertySetModel().getFeatureDescriptor(row);
boolean result;
if (fd instanceof PropertySet) {
result = false;
} else {
Property p = (Property) fd;
result = p.canWrite();
if (result) {
Object val = p.getValue("canEditAsText"); //NOI18N
if (val != null) {
result &= Boolean.TRUE.equals(val);
if( !result ) {
//#227661 - combo box editor should be allowed to show its popup
PropertyEditor ped = PropUtils.getPropertyEditor(p);
result |= ped.getTags() != null;
}
}
}
}
return result;
}
SheetTable.java 文件源码
项目:incubator-netbeans
阅读 28
收藏 0
点赞 0
评论 0
@Override
public void actionPerformed(ActionEvent ae) {
FeatureDescriptor fd = _getSelection();
if (fd instanceof PropertySet) {
int row = SheetTable.this.getSelectedRow();
boolean b = getPropertySetModel().isExpanded(fd);
if (b) {
toggleExpanded(row);
}
}
}
SheetTable.java 文件源码
项目:incubator-netbeans
阅读 38
收藏 0
点赞 0
评论 0
@Override
public void actionPerformed(ActionEvent ae) {
FeatureDescriptor fd = _getSelection();
if (fd instanceof PropertySet) {
int row = SheetTable.this.getSelectedRow();
boolean b = getPropertySetModel().isExpanded(fd);
if (!b) {
toggleExpanded(row);
}
}
}
EditablePropertyDisplayer.java 文件源码
项目:incubator-netbeans
阅读 36
收藏 0
点赞 0
评论 0
public void valueChanged(PropertyEditor editor) {
failed = false;
try {
// System.err.println("ValueChanged - new value " + editor.getValue());
if (getInplaceEditor() != null) {
setEnteredValue(getProperty().getValue());
} else {
//Handle case where our parent PropertyPanel is no longer showing, but
//the custom editor we invoked still is. Issue 38004
PropertyModel mdl = (modelRef != null) ? modelRef.get() : null;
if (mdl != null) {
FeatureDescriptor fd = null;
if (mdl instanceof ExPropertyModel) {
fd = ((ExPropertyModel) mdl).getFeatureDescriptor();
}
String title = null;
if (fd != null) {
title = fd.getDisplayName();
}
failed = PropUtils.updateProp(mdl, editor, title); //XXX
}
}
} catch (Exception e) {
throw (IllegalStateException) new IllegalStateException("Problem setting entered value from custom editor").initCause(e);
}
}