下面列出了怎么用org.eclipse.ui.views.properties.PropertyDescriptor的API类实例代码及写法,或者点击链接到github查看源代码。
public MarkerPropertySource(IMarker marker) {
this.marker = marker;
List<IPropertyDescriptor> props = new ArrayList<>();
try {
Map<?, ?> attributes = marker.getAttributes();
Set<?> keySet = new TreeSet<Object>(attributes.keySet());
for (Object object : keySet) {
props.add(new PropertyDescriptor(object, "" + object));
}
} catch (CoreException e) {
FindbugsPlugin.getDefault().logException(e, "MarkerPropertySource: marker access failed");
}
props.add(new PropertyDescriptor(PropId.Bug, "Bug"));
props.add(new PropertyDescriptor(PropId.Resource, "Resource"));
props.add(new PropertyDescriptor(PropId.Id, "Marker id"));
props.add(new PropertyDescriptor(PropId.Type, "Marker type"));
props.add(new PropertyDescriptor(PropId.CreationTime, "Creation time"));
propertyDescriptors = props.toArray(new PropertyDescriptor[0]);
}
public IPropertyDescriptor[] getPropertyDescriptors()
{
List<IPropertyDescriptor> result = new ArrayList<IPropertyDescriptor>();
for (P p : getPropertyInfoSet())
{
PropertyDescriptor descriptor = new PropertyDescriptor(p, p.getHeader());
String category = p.getCategory();
if (!StringUtil.isEmpty(category))
{
descriptor.setCategory(category);
}
result.add(descriptor);
}
return result.toArray(new IPropertyDescriptor[result.size()]);
}
public IPropertyDescriptor[] getPropertyDescriptors()
{
List<IPropertyDescriptor> result = new ArrayList<IPropertyDescriptor>();
for (P p : getPropertyInfoSet())
{
PropertyDescriptor descriptor = new PropertyDescriptor(p, p.getHeader());
String category = p.getCategory();
if (!StringUtil.isEmpty(category))
{
descriptor.setCategory(category);
}
result.add(descriptor);
}
return result.toArray(new IPropertyDescriptor[result.size()]);
}
public IPropertyDescriptor[] getPropertyDescriptors()
{
List<IPropertyDescriptor> result = new ArrayList<IPropertyDescriptor>();
for (P p : getPropertyInfoSet())
{
PropertyDescriptor descriptor = new PropertyDescriptor(p, p.getHeader());
String category = p.getCategory();
if (!StringUtil.isEmpty(category))
{
descriptor.setCategory(category);
}
result.add(descriptor);
}
return result.toArray(new IPropertyDescriptor[result.size()]);
}
public PropertySource(Object object) {
this.object = object;
List<IPropertyDescriptor> props = new ArrayList<>();
List<Method> getters = getGetters(object);
for (Method method : getters) {
props.add(new PropertyDescriptor(method, getReadableName(method)));
}
propertyDescriptors = props.toArray(new PropertyDescriptor[0]);
}
public ArrayPropertySource(Object[] object) {
this.array = object;
List<IPropertyDescriptor> props = new ArrayList<>();
for (Object obj : array) {
props.add(new PropertyDescriptor(obj, getDisplayName(obj)));
}
propertyDescriptors = props.toArray(new PropertyDescriptor[0]);
}
public IPropertyDescriptor[] getPropertyDescriptors()
{
List<IPropertyDescriptor> result = new ArrayList<IPropertyDescriptor>();
for (P p : getPropertyInfoSet())
{
result.add(new PropertyDescriptor(p, p.getHeader()));
}
return result.toArray(new IPropertyDescriptor[result.size()]);
}
private static IPropertyDescriptor createPropertyDescriptor(String field, String label){
PropertyDescriptor descriptor = new PropertyDescriptor(field, label);
descriptor.setCategory("Cordova Plugin");
descriptor.setAlwaysIncompatible(true);
return descriptor;
}
private static IPropertyDescriptor createPropertyDescriptor(String field, String label){
PropertyDescriptor descriptor = new PropertyDescriptor(field, label);
descriptor.setCategory("Cordova Platform");
descriptor.setAlwaysIncompatible(true);
return descriptor;
}
/**
* <p>
* The default implementation that provides one property descriptor.
* </p>
*
* @return <p>
* The array of descriptors
* </p>
*
* @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors()
*/
@Override
public IPropertyDescriptor[] getPropertyDescriptors() {
IPropertyDescriptor[] descriptors = new IPropertyDescriptor[] { new PropertyDescriptor(
"NONE", "No property") };
return descriptors;
}