Search in sources :

Example 96 with PropertyEditor

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()));
    }
}
Also used : JasperException(org.apache.jasper.JasperException) PropertyEditor(java.beans.PropertyEditor) ServletException(javax.servlet.ServletException) JspException(javax.servlet.jsp.JspException) IOException(java.io.IOException) JasperException(org.apache.jasper.JasperException)

Example 97 with PropertyEditor

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);
    }
}
Also used : PropertyRendererRegistry(com.l2fprod.common.propertysheet.PropertyRendererRegistry) TableCellRenderer(javax.swing.table.TableCellRenderer) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer) VisualMappingFunction(org.cytoscape.view.vizmap.VisualMappingFunction) PropertyEditorRegistry(com.l2fprod.common.propertysheet.PropertyEditorRegistry) DiscreteMapping(org.cytoscape.view.vizmap.mappings.DiscreteMapping) PropertySheetTable(com.l2fprod.common.propertysheet.PropertySheetTable) VisualPropertyEditor(org.cytoscape.view.vizmap.gui.editor.VisualPropertyEditor) PropertyEditor(java.beans.PropertyEditor) VisualPropertyEditor2(org.cytoscape.view.vizmap.gui.editor.VisualPropertyEditor2)

Example 98 with PropertyEditor

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);
}
Also used : PropertyEditor(java.beans.PropertyEditor)

Example 99 with PropertyEditor

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;
    }
}
Also used : AttributeValueWrapper(org.gephi.ui.tools.plugin.edit.EditWindowUtils.AttributeValueWrapper) Column(org.gephi.graph.api.Column) AttributeColumnsController(org.gephi.datalab.api.AttributeColumnsController) PropertyEditor(java.beans.PropertyEditor) Sheet(org.openide.nodes.Sheet) Edge(org.gephi.graph.api.Edge) PropertySupport(org.openide.nodes.PropertySupport)

Example 100 with PropertyEditor

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;
    }
}
Also used : Node(org.gephi.graph.api.Node) AbstractNode(org.openide.nodes.AbstractNode) AttributeValueWrapper(org.gephi.ui.tools.plugin.edit.EditWindowUtils.AttributeValueWrapper) Column(org.gephi.graph.api.Column) AttributeColumnsController(org.gephi.datalab.api.AttributeColumnsController) PropertyEditor(java.beans.PropertyEditor) Sheet(org.openide.nodes.Sheet) PropertySupport(org.openide.nodes.PropertySupport)

Aggregations

PropertyEditor (java.beans.PropertyEditor)167 Test (org.junit.jupiter.api.Test)59 HashMap (java.util.HashMap)14 Test (org.junit.Test)13 Map (java.util.Map)11 File (java.io.File)10 URI (java.net.URI)9 TestBean (org.springframework.beans.testfixture.beans.TestBean)9 IOException (java.io.IOException)7 Path (java.nio.file.Path)7 Resource (org.springframework.core.io.Resource)7 Method (java.lang.reflect.Method)6 URL (java.net.URL)6 ITestBean (org.springframework.beans.testfixture.beans.ITestBean)6 IndexedTestBean (org.springframework.beans.testfixture.beans.IndexedTestBean)6 PropertyDescriptor (java.beans.PropertyDescriptor)5 Field (java.lang.reflect.Field)4 ArrayList (java.util.ArrayList)4 MutablePropertyValues (org.springframework.beans.MutablePropertyValues)4 StringArrayPropertyEditor (org.springframework.beans.propertyeditors.StringArrayPropertyEditor)4