本文整理汇总了Java中com.intellij.psi.util.PropertyUtil.getReadableProperties方法的典型用法代码示例。如果您正苦于以下问题:Java PropertyUtil.getReadableProperties方法的具体用法?Java PropertyUtil.getReadableProperties怎么用?Java PropertyUtil.getReadableProperties使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.util.PropertyUtil
的用法示例。
在下文中一共展示了PropertyUtil.getReadableProperties方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTableCellEditorComponent
import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
public Component getTableCellEditorComponent(
final JTable table,
final Object value,
final boolean isSelected,
final int row,
final int column
) {
myEditingRow = row;
final DefaultComboBoxModel model = (DefaultComboBoxModel)myCbx.getModel();
model.removeAllElements();
model.addElement(null/*<not defined>*/);
// Fill combobox with available bean's properties
final String[] rProps = PropertyUtil.getReadableProperties(myData.myBeanClass, true);
final String[] wProps = PropertyUtil.getWritableProperties(myData.myBeanClass, true);
final ArrayList<BeanProperty> rwProps = new ArrayList<BeanProperty>();
outer: for(int i = rProps.length - 1; i >= 0; i--){
final String propName = rProps[i];
if(ArrayUtil.find(wProps, propName) != -1){
LOG.assertTrue(!rwProps.contains(propName));
final PsiMethod getter = PropertyUtil.findPropertyGetter(myData.myBeanClass, propName, false, true);
if (getter == null) {
// possible if the getter is static: getReadableProperties() does not filter out static methods, and
// findPropertyGetter() checks for static/non-static
continue;
}
final PsiType returnType = getter.getReturnType();
LOG.assertTrue(returnType != null);
// There are two possible types: boolean and java.lang.String
@NonNls final String typeName = returnType.getCanonicalText();
LOG.assertTrue(typeName != null);
if(!"boolean".equals(typeName) && !"java.lang.String".equals(typeName)){
continue;
}
// Check that the property is not in use yet
for(int j = myData.myBindings.length - 1; j >= 0; j--){
final BeanProperty _property = myData.myBindings[j].myBeanProperty;
if(j != row && _property != null && propName.equals(_property.myName)){
continue outer;
}
}
// Check that we conver types
if(
!canConvert(
myData.myBindings[row].myFormProperty.getComponentPropertyClassName(),
typeName
)
){
continue;
}
rwProps.add(new BeanProperty(propName, typeName));
}
}
Collections.sort(rwProps);
for (BeanProperty rwProp : rwProps) {
model.addElement(rwProp);
}
// Set initially selected item
if(myData.myBindings[row].myBeanProperty != null){
myCbx.setSelectedItem(myData.myBindings[row].myBeanProperty);
}
else{
myCbx.setSelectedIndex(0/*<not defined>*/);
}
return myCbx;
}