use of java.beans.PropertyEditor in project tomcat70 by apache.
the class JspRuntimeLibrary method getValueFromBeanInfoPropertyEditor.
// *********************************************************************
// PropertyEditor Support
public static Object getValueFromBeanInfoPropertyEditor(Class<?> attrClass, String attrName, String attrValue, Class<?> propertyEditorClass) throws JasperException {
try {
PropertyEditor pe = (PropertyEditor) propertyEditorClass.newInstance();
pe.setAsText(attrValue);
return pe.getValue();
} catch (Exception ex) {
throw new JasperException(Localizer.getMessage("jsp.error.beans.property.conversion", attrValue, attrClass.getName(), attrName, ex.getMessage()));
}
}
use of java.beans.PropertyEditor in project cytoscape-impl by cytoscape.
the class VizMapPropertyBuilder method setDiscreteProps.
/**
* Set value, title, and renderer for each property in the category. This
* list should be created against all available attribute values.
*/
private <K, V> void setDiscreteProps(VisualProperty<V> vp, VisualMappingFunction<K, V> mapping, SortedSet<Object> attrSet, VisualPropertyEditor<V> vpEditor, PropertySheetPanel propertySheetPanel) {
if (attrSet == null)
return;
final Map<K, V> discMapping = ((DiscreteMapping<K, V>) mapping).getAll();
V val = null;
VizMapperProperty<K, V, VisualMappingFunction<K, V>> valProp;
String strVal;
final PropertySheetTable table = propertySheetPanel.getTable();
final PropertyRendererRegistry cellRendererFactory = (PropertyRendererRegistry) table.getRendererFactory();
final PropertyEditorRegistry cellEditorFactory = (PropertyEditorRegistry) table.getEditorFactory();
for (final Object key : attrSet) {
valProp = new VizMapperProperty<K, V, VisualMappingFunction<K, V>>(CellType.DISCRETE, (K) key, mapping.getVisualProperty().getRange().getType());
strVal = key.toString();
valProp.setDisplayName(strVal);
// but we don't know the type of the list items.
if (mapping.getMappingColumnType() == String.class && !(key instanceof String))
val = discMapping.get(key.toString());
else
val = discMapping.get(key);
if (val != null)
valProp.setType(val.getClass());
propertySheetPanel.addProperty(valProp);
if (vpEditor != null) {
final TableCellRenderer renderer = vpEditor.getDiscreteTableCellRenderer();
if (renderer != null)
cellRendererFactory.registerRenderer(valProp, renderer);
PropertyEditor cellEditor = null;
if (vpEditor instanceof VisualPropertyEditor2) {
cellEditor = ((VisualPropertyEditor2) vpEditor).getPropertyEditor(vp);
} else {
cellEditor = vpEditor.getPropertyEditor();
}
if (cellEditor != null)
cellEditorFactory.registerEditor(valProp, cellEditor);
}
valProp.setValue(val);
valProp.setInternalValue(mapping);
}
}
use of java.beans.PropertyEditor in project cytoscape-impl by cytoscape.
the class VizMapEventHandlerManagerImpl method registerCellEditorListeners.
/**
* Register listeners for editors.
*/
private void registerCellEditorListeners() {
for (final PropertyEditor p : editorManager.getCellEditors()) {
// First remove the listener to prevent adding it more than once
p.removePropertyChangeListener(this);
p.addPropertyChangeListener(this);
}
for (final PropertyEditor p : editorManager.getAttributeSelectors()) {
// First remove the listener to prevent adding it more than once
p.removePropertyChangeListener(this);
p.addPropertyChangeListener(this);
}
// Add Mapping type editor: continuous, discrete, or passthrough.
final PropertyEditor mappingSelector = editorManager.getMappingFunctionSelector();
mappingSelector.addPropertyChangeListener(this);
}
use of java.beans.PropertyEditor in project gephi by gephi.
the class EditEdges method prepareEdgesAttributes.
/**
* Prepare set of attributes of the edges.
*
* @return Set of these attributes
*/
private Sheet.Set prepareEdgesAttributes() {
try {
// DynamicModel dm=Lookup.getDefault().lookup(DynamicController.class).getModel();
// if(dm!=null){
// currentTimeFormat=dm.getTimeFormat();
// }
AttributeColumnsController ac = Lookup.getDefault().lookup(AttributeColumnsController.class);
Sheet.Set set = new Sheet.Set();
set.setName("attributes");
if (edges.length > 1) {
set.setDisplayName(NbBundle.getMessage(EditEdges.class, "EditEdges.attributes.text.multiple"));
} else {
set.setDisplayName(NbBundle.getMessage(EditEdges.class, "EditEdges.attributes.text", edges[0].getLabel()));
}
Edge row = edges[0];
AttributeValueWrapper wrap;
for (Column column : row.getAttributeColumns()) {
if (multipleEdges) {
wrap = new MultipleRowsAttributeValueWrapper(edges, column, currentTimeFormat, dateTimeZone);
} else {
wrap = new SingleRowAttributeValueWrapper(edges[0], column, currentTimeFormat, dateTimeZone);
}
Class<?> type = column.getTypeClass();
Property p;
PropertyEditor propEditor = PropertyEditorManager.findEditor(type);
if (ac.canChangeColumnData(column)) {
// Editable column, provide "set" method:
if (propEditor != null && !type.isArray()) {
// The type can be edited by default:
p = new PropertySupport.Reflection(wrap, type, "getValue" + type.getSimpleName(), "setValue" + type.getSimpleName());
} else {
// Use the AttributeType as String:
p = new PropertySupport.Reflection(wrap, String.class, "getValueAsString", "setValueAsString");
}
} else // Not editable column, do not provide "set" method:
{
if (propEditor != null) {
// The type can be edited by default:
p = new PropertySupport.Reflection(wrap, type, "getValue" + type.getSimpleName(), null);
} else {
// Use the AttributeType as String:
p = new PropertySupport.Reflection(wrap, String.class, "getValueAsString", null);
}
}
p.setDisplayName(column.getTitle());
p.setName(column.getId());
set.put(p);
}
return set;
} catch (Exception ex) {
Exceptions.printStackTrace(ex);
return null;
}
}
use of java.beans.PropertyEditor in project gephi by gephi.
the class EditNodes method prepareNodesAttributes.
/**
* Prepare set of attributes of the node(s).
*
* @return Set of these attributes
*/
private Sheet.Set prepareNodesAttributes() {
try {
// DynamicModel dm=Lookup.getDefault().lookup(DynamicController.class).getModel();
// if(dm!=null){
// currentTimeFormat=dm.getTimeFormat();
// }
AttributeColumnsController ac = Lookup.getDefault().lookup(AttributeColumnsController.class);
Sheet.Set set = new Sheet.Set();
set.setName("attributes");
if (nodes.length > 1) {
set.setDisplayName(NbBundle.getMessage(EditNodes.class, "EditNodes.attributes.text.multiple"));
} else {
set.setDisplayName(NbBundle.getMessage(EditNodes.class, "EditNodes.attributes.text", nodes[0].getLabel()));
}
Node row = nodes[0];
AttributeValueWrapper wrap;
for (Column column : row.getAttributeColumns()) {
if (multipleNodes) {
wrap = new MultipleRowsAttributeValueWrapper(nodes, column, currentTimeFormat, dateTimeZone);
} else {
wrap = new SingleRowAttributeValueWrapper(nodes[0], column, currentTimeFormat, dateTimeZone);
}
Property p;
Class<?> type = column.getTypeClass();
PropertyEditor propEditor = PropertyEditorManager.findEditor(type);
if (ac.canChangeColumnData(column)) {
// Editable column, provide "set" method:
if (propEditor != null && !type.isArray()) {
// The type can be edited by default:
p = new PropertySupport.Reflection(wrap, type, "getValue" + type.getSimpleName(), "setValue" + type.getSimpleName());
} else {
// Use the AttributeType as String:
p = new PropertySupport.Reflection(wrap, String.class, "getValueAsString", "setValueAsString");
}
} else // Not editable column, do not provide "set" method:
if (propEditor != null) {
// The type can be edited by default:
p = new PropertySupport.Reflection(wrap, type, "getValue" + type.getSimpleName(), null);
} else {
// Use the AttributeType as String:
p = new PropertySupport.Reflection(wrap, String.class, "getValueAsString", null);
}
p.setDisplayName(column.getTitle());
p.setName(column.getId());
set.put(p);
}
return set;
} catch (Exception ex) {
Exceptions.printStackTrace(ex);
return null;
}
}
Aggregations