GVKun编程网logo

java.beans.PropertyEditor的实例源码(java.beans.introspection)

20

本文将带您了解关于java.beans.PropertyEditor的实例源码的新内容,同时我们还将为您解释java.beans.introspection的相关知识,另外,我们还将为您提供关于com

本文将带您了解关于java.beans.PropertyEditor的实例源码的新内容,同时我们还将为您解释java.beans.introspection的相关知识,另外,我们还将为您提供关于com.intellij.uiDesigner.propertyInspector.PropertyEditor的实例源码、java.beans.IndexedPropertyDescriptor的实例源码、java.beans.PropertyDescriptor的实例源码、java.beans.PropertyEditorManager的实例源码的实用信息。

本文目录一览:

java.beans.PropertyEditor的实例源码(java.beans.introspection)

java.beans.PropertyEditor的实例源码(java.beans.introspection)

项目:incubator-netbeans    文件:FormCustomEditor.java   
/**
 * Used by PropertyAction to mimic property sheet behavior - trying to invoke
 * PropertyEnv listener of the current property editor (we can't create our
 * own PropertyEnv instance).
 * 
 * @return current value
 * @throws java.beans.PropertyVetoException if someone vetoes this change.
 */
public Object commitChanges() throws PropertyVetoException {
    int currentIndex = editorsCombo.getSelectedindex();
    propertyeditor currentEditor = currentIndex > -1 ? allEditors[currentIndex] : null;
    if (currentEditor instanceof Expropertyeditor) {
        // we can only guess - according to the typical pattern the propetry
        // editor itself or the custom editor usually implement the listener
        // registered in PropertyEnv
        PropertyChangeEvent evt = new PropertyChangeEvent(
                this,PropertyEnv.PROP_STATE,null,PropertyEnv.STATE_VALID);
        if (currentEditor instanceof Vetoablechangelistener) {
            ((Vetoablechangelistener)currentEditor).vetoableChange(evt);
        }
        Component currentCustEd = currentIndex > -1 ? allCustomEditors[currentIndex] : null;
        if (currentCustEd instanceof Vetoablechangelistener) {
            ((Vetoablechangelistener)currentCustEd).vetoableChange(evt);
        }
        if (currentEditor instanceof Propertychangelistener) {
            ((Propertychangelistener)currentEditor).propertyChange(evt);
        }
        if (currentCustEd instanceof Propertychangelistener) {
            ((Propertychangelistener)currentCustEd).propertyChange(evt);
        }
    }
    return commitChanges0();
}
项目:gemini.blueprint    文件:OsgipropertyeditorRegistrar.java   
@SuppressWarnings("unchecked")
private void createEditors(Properties configuration) {

    boolean trace = log.isTraceEnabled();
    // load properties using this class class loader
    ClassLoader classLoader = getClass().getClassLoader();

    for (Map.Entry<Object,Object> entry : configuration.entrySet()) {
        // key represents type
        Class<?> key;
        // value represents property editor
        Class<?> editorClass;
        try {
            key = classLoader.loadClass((String) entry.getKey());
            editorClass = classLoader.loadClass((String) entry.getValue());
        } catch (ClassNotFoundException ex) {
            throw (RuntimeException) new IllegalArgumentException("Cannot load class").initCause(ex);
        }

        Assert.isAssignable(propertyeditor.class,editorClass);

        if (trace)
            log.trace("Adding property editor[" + editorClass + "] for type[" + key + "]");
        editors.put(key,(Class<? extends propertyeditor>) editorClass);
    }
}
项目:MaxSim    文件:FontChooserDialog.java   
public static Font show(Font initialFont) {
    propertyeditor pe = propertyeditorManager.findEditor(Font.class);
    if (pe == null) {
        throw new RuntimeException("Could not find font editor component.");
    }
    pe.setValue(initialFont);
    DialogDescriptor dd = new DialogDescriptor(
            pe.getCustomEditor(),"Choose Font");
    Dialogdisplayer.getDefault().createDialog(dd).setVisible(true);
    if (dd.getValue() == DialogDescriptor.OK_OPTION) {
        Font f = (Font)pe.getValue();
        return f;
    }
    return initialFont;
}
项目:incubator-netbeans    文件:Valuepropertyeditor.java   
private static propertyeditor findThepropertyeditor(Class clazz) {
    propertyeditor pe;
    if (Object.class.equals(clazz)) {
        pe = null;
    } else {
        pe = propertyeditorManager.findEditor(clazz);
        if (pe == null) {
            Class sclazz = clazz.getSuperclass();
            if (sclazz != null) {
                pe = findpropertyeditor(sclazz);
            }
        }
    }
    classesWithPE.put(clazz,pe != null);
    return pe;
}
项目:incubator-netbeans    文件:Valuepropertyeditor.java   
boolean setValueWithMirror(Object value,Object valueMirror) {
    this.currentValue = value;
    Class clazz = valueMirror.getClass();
    propertyeditor propertyeditor = findpropertyeditor(clazz);
    propertyeditor = testpropertyeditorOnValue(propertyeditor,valueMirror);
    if (propertyeditor == null) {
        return false;
    }
    boolean doAttach = false;
    mirrorClass = clazz;
    delegatepropertyeditor = propertyeditor;
    if (env != null && propertyeditor instanceof Expropertyeditor) {
        doAttach = true;
    }
    delegateValue = valueMirror;
    delegatepropertyeditor.setValue(valueMirror);
    if (doAttach) {
        ((Expropertyeditor) delegatepropertyeditor).attachEnv(env);
    }
    return doAttach;
}
项目:incubator-netbeans    文件:RevisionNode.java   
@Override
public propertyeditor getpropertyeditor() {
    return new propertyeditorSupport() {
        @Override
        public void setAsText(String text) throws IllegalArgumentException {
            if (text instanceof String) {
                try {
                    entry.setMessage(!text.equals("") ? text : null);
                } catch (IOException ex) {
                    History.LOG.log(Level.WARNING,ex);
                }
                return;
            }
            throw new java.lang.IllegalArgumentException(text);
        }
        @Override
        public String getAsText() {
            return te.getdisplayValue();
        }
    };
}
项目:incubator-netbeans    文件:RendererPropertydisplayer.java   
public void seTradioButtonMax(int i) {
    if (i != radioButtonMax) {
        Dimension oldPreferredSize = null;

        if (isShowing()) {
            oldPreferredSize = getPreferredSize();
        }

        int old = radioButtonMax;
        radioButtonMax = i;

        if (oldPreferredSize != null) {
            //see if the change will affect anything
            propertyeditor ed = PropUtils.getpropertyeditor(prop);
            String[] tags = ed.getTags();

            if (tags != null) {
                if ((tags.length >= i) != (tags.length >= old)) {
                    firePropertyChange("preferredSize",oldPreferredSize,getPreferredSize()); //NOI18N
                }
            }
        }
    }
}
项目:incubator-netbeans    文件:SheetTable.java   
@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
    }
}
项目:lams    文件:JspRuntimeLibrary.java   
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()));
}
   }
项目:incubator-netbeans    文件:EditablePropertydisplayer.java   
propertyeditor getpropertyeditor() { //package private for unit tests

        propertyeditor result;

        if (editor != null) {
            return editor;
        }

        if (getInplaceEditor() != null) {
            result = getInplaceEditor().getpropertyeditor();
        } else {
            result = PropUtils.getpropertyeditor(getproperty());
        }

        editor = result;

        return result;
    }
项目:lams    文件:propertyeditorRegistrySupport.java   
private propertyeditor getpropertyeditor(Class<?> requiredType) {
    // Special case: If no required type specified,which usually only happens for
    // Collection elements,or required type is not assignable to registered type,// which usually only happens for generic properties of type Object -
    // then return propertyeditor if not registered for Collection or array type.
    // (If not registered for Collection or array,it is assumed to be intended
    // for elements.)
    if (this.registeredType == null ||
            (requiredType != null &&
            (ClassUtils.isAssignable(this.registeredType,requiredType) ||
            ClassUtils.isAssignable(requiredType,this.registeredType))) ||
            (requiredType == null &&
            (!Collection.class.isAssignableFrom(this.registeredType) && !this.registeredType.isArray()))) {
        return this.propertyeditor;
    }
    else {
        return null;
    }
}
项目:incubator-netbeans    文件:ModelProperty.java   
public propertyeditor getpropertyeditor() {
    if (mdl.getpropertyeditorClass() != null) {
        try {
            //System.err.println("ModelProperty creating a " 
            //+ mdl.getpropertyeditorClass());
            Constructor c = mdl.getpropertyeditorClass().getConstructor();
            c.setAccessible(true);

            return (propertyeditor) c.newInstance(new Object[0]);
        } catch (Exception e) {
            Exceptions.printstacktrace(e);

            return new PropUtils.NopropertyeditorEditor();
        }
    }

    return super.getpropertyeditor();
}
项目:neoscada    文件:propertyeditorRegistry.java   
/**
 * @param requiredType
 * @param propertyPath
 * @return
 */
public propertyeditor findCustomEditor ( final Class<?> requiredType,final String propertyPath )
{
    // first try to find exact match
    String key = requiredType.getCanonicalName () + ":" + propertyPath;
    propertyeditor pe = this.propertyeditors.get ( key );
    // 2nd: try to find for class only
    if ( pe == null )
    {
        key = requiredType.getCanonicalName () + ":";
        pe = this.propertyeditors.get ( key );
    }
    // 3rd: try to get internal
    if ( pe == null )
    {
        pe = propertyeditorManager.findEditor ( requiredType );
    }
    return pe;
}
项目:lazycat    文件:JspRuntimeLibrary.java   
public static Object getValueFrompropertyeditorManager(Class<?> attrClass,String attrValue)
        throws JasperException {
    try {
        propertyeditor propEditor = propertyeditorManager.findEditor(attrClass);
        if (propEditor != null) {
            propEditor.setAsText(attrValue);
            return propEditor.getValue();
        } else {
            throw new IllegalArgumentException(
                    Localizer.getMessage("jsp.error.beans.propertyeditor.notregistered"));
        }
    } catch (IllegalArgumentException ex) {
        throw new JasperException(Localizer.getMessage("jsp.error.beans.property.conversion",ex.getMessage()));
    }
}
项目:incubator-netbeans    文件:SuiteCustomizerLibraries.java   
@Override
public propertyeditor getpropertyeditor() {
    if (editor == null) {
        editor = super.getpropertyeditor();
    }
    return editor;
}
项目:incubator-netbeans    文件:BiFeatureNode.java   
@Override
public propertyeditor getpropertyeditor() {
    return new propertyeditorSupport() {
        @Override
        public java.awt.Component getCustomEditor() {
            return new CustomCodeEditor(CodePropertySupportRW.this);
        }

        @Override
        public boolean supportsCustomEditor() {
            return true;
        }
    };            
}
项目:spring-seed    文件:BeanPropertyUtil.java   
private static Object getValueFrompropertyeditorManager(Class attrClass,String attrValue) {
    propertyeditor propEditor = propertyeditorManager.findEditor(attrClass);
    if (propEditor != null) {
        propEditor.setAsText(attrValue);
        return propEditor.getValue();
    } else {
        throw new IllegalArgumentException("beans property editor not registered");
    }
}
项目:etomica    文件:PropertyText.java   
public PropertyText(propertyeditor pe) {
        super(pe.getAsText());
        editor = pe;
        addKeyListener(this);
        addFocusListener(this);
        editor.addPropertychangelistener(this);
//      setBorder(propertysheet.EMPTY_BORDER);
    }
项目:jdk8u-jdk    文件:Testpropertyeditor.java   
private static void test(Class<?> type,Class<? extends propertyeditor> expected) {
    propertyeditor actual = propertyeditorManager.findEditor(type);
    if ((actual == null) && (expected != null)) {
        throw new Error("expected editor is not found");
    }
    if ((actual != null) && !actual.getClass().equals(expected)) {
        throw new Error("found unexpected editor");
    }
}
项目:incubator-netbeans    文件:PEAnnotationProcessorTest.java   
public void testPERegistered() {
    NodeOp.registerpropertyeditors();
    propertyeditor pEditor = propertyeditorManager.findEditor(Double[].class);
    assertEquals("org.netbeans.modules.openide.nodes.Testpropertyeditor",pEditor.getClass().getName());
    pEditor = propertyeditorManager.findEditor(Integer.class);
    assertEquals("org.netbeans.modules.openide.nodes.Testpropertyeditor",pEditor.getClass().getName());
    pEditor = propertyeditorManager.findEditor(char[][].class);
    assertEquals("org.netbeans.modules.openide.nodes.Testpropertyeditor",pEditor.getClass().getName());
    pEditor = propertyeditorManager.findEditor(short.class);
    assertEquals("org.netbeans.modules.openide.nodes.Testpropertyeditor",pEditor.getClass().getName());
}
项目:incubator-netbeans    文件:ResourceSupport.java   
private static String getStringValue(FormProperty prop,Object value) {
    if (value instanceof String)
        return (String) value;

    propertyeditor prEd = prop.getCurrentEditor();
    prEd.setValue(value);
    return prEd.getAsText(); // [this does not work correctly with IconEditor...]
}
项目:lams    文件:TypeConverterDelegate.java   
/**
 * Find a default editor for the given type.
 * @param requiredType the type to find an editor for
 * @return the corresponding editor,or {@code null} if none
 */
private propertyeditor findDefaultEditor(Class<?> requiredType) {
    propertyeditor editor = null;
    if (requiredType != null) {
        // No custom editor -> check BeanWrapperImpl's default editors.
        editor = this.propertyeditorRegistry.getDefaultEditor(requiredType);
        if (editor == null && !String.class.equals(requiredType)) {
            // No BeanWrapper default editor -> check standard JavaBean editor.
            editor = BeanUtils.findEditorByConvention(requiredType);
        }
    }
    return editor;
}
项目:incubator-netbeans    文件:Valuepropertyeditor.java   
/**
 * Test if the property editor can act on the provided value. We can never be sure. :-(
 * @param propertyeditor
 * @param valueMirror
 * @return the property editor,or <code>null</code>
 */
private static propertyeditor testpropertyeditorOnValue(propertyeditor propertyeditor,Object valueMirror) {
    propertyeditor.setValue(valueMirror);
    Object value = propertyeditor.getValue();
    if (value != valueMirror && (value == null || !value.equals(valueMirror))) {
        // Returns something that we did not set. Give up.
        return null;
    }
    return propertyeditor;
}
项目:lazycat    文件:JspRuntimeLibrary.java   
public static Object getValueFromBeanInfopropertyeditor(Class<?> attrClass,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",ex.getMessage()));
    }
}
项目:lams    文件:propertyeditorRegistrySupport.java   
/**
 * Get custom editor for the given type. If no direct match found,* try custom editor for superclass (which will in any case be able
 * to render a value as String via {@code getAsText}).
 * @param requiredType the type to look for
 * @return the custom editor,or {@code null} if none found for this type
 * @see java.beans.propertyeditor#getAsText()
 */
private propertyeditor getCustomEditor(Class<?> requiredType) {
    if (requiredType == null || this.customEditors == null) {
        return null;
    }
    // Check directly registered editor for type.
    propertyeditor editor = this.customEditors.get(requiredType);
    if (editor == null) {
        // Check cached editor for type,registered for superclass or interface.
        if (this.customEditorCache != null) {
            editor = this.customEditorCache.get(requiredType);
        }
        if (editor == null) {
            // Find editor for superclass or interface.
            for (Iterator<Class<?>> it = this.customEditors.keySet().iterator(); it.hasNext() && editor == null;) {
                Class<?> key = it.next();
                if (key.isAssignableFrom(requiredType)) {
                    editor = this.customEditors.get(key);
                    // Cache editor for search type,to avoid the overhead
                    // of repeated assignable-from checks.
                    if (this.customEditorCache == null) {
                        this.customEditorCache = new HashMap<Class<?>,propertyeditor>();
                    }
                    this.customEditorCache.put(requiredType,editor);
                }
            }
        }
    }
    return editor;
}
项目:gemini.blueprint    文件:OsgipropertyeditorRegistrar.java   
public void registerCustomEditors(propertyeditorRegistry registry) {
    for (Map.Entry<Class<?>,Class<? extends propertyeditor>> entry : editors.entrySet()) {
        Class<?> type = entry.getKey();
        propertyeditor editorInstance;
        editorInstance = BeanUtils.instantiate(entry.getValue());
        registry.registerCustomEditor(type,editorInstance);
    }

    // register non-externalized types
    registry.registerCustomEditor(Dictionary.class,new CustomMapEditor(Hashtable.class));
    registry.registerCustomEditor(Properties.class,new PropertiesEditor());
    registry.registerCustomEditor(Class.class,new ClassEditor(userClassLoader));
    registry.registerCustomEditor(Class[].class,new ClassArrayEditor(userClassLoader));
}
项目:X4J    文件:DynamicParsers.java   
@Override
public Object parseImp(String input,ParserHelper helper) {
    propertyeditor editor = findEditor(helper.getRawTargetClass());
    if (editor == null) {
        return TRY_NEXT;
    }
    editor.setAsText(input);
    return editor.getValue();
}
项目:incubator-netbeans    文件:OutlineView.java   
private boolean openCustomEditor(ActionEvent e) {
    if (getSelectedRowCount() != 1 || getSelectedColumnCount() != 1) {
        return false;
    }
    int row = getSelectedRow();
    if (row < 0) return false;
    int column = getSelectedColumn();
    if (column < 0) return false;
    Object o = getValueAt(row,column);
    if (!(o instanceof Node.Property)) {
        return false;
    }
    Node.Property p = (Node.Property) o;
    if (!Boolean.TRUE.equals(p.getValue("suppressCustomEditor"))) { //NOI18N
        PropertyPanel panel = new PropertyPanel(p);
        @SuppressWarnings("deprecation")
        propertyeditor ed = panel.getpropertyeditor();

        if ((ed != null) && ed.supportsCustomEditor()) {
            Action act = panel.getActionMap().get("invokeCustomEditor"); //NOI18N

            if (act != null) {
                act.actionPerformed(null);

                return true;
            }
        }
    }
    return false;
}
项目:Pogamut3    文件:Folder.java   
/**
 * Initializes folder from the properties object.
 * @param props
 */
protected void loadFromProperties(Properties props,String prefix) throws IntrospectionException {
    Enumeration<String> keys = (Enumeration<String>) props.propertyNames();
    prefix = prefix + getName() + ".";
    // load properties in this folder
    while (keys.hasMoreElements()) {
        String key = keys.nextElement();
        if (key.startsWith(prefix)) {
            String posfix = key.replaceFirst(prefix,"");
            if (!posfix.contains(".")) {
                // the posfix represents a name of a property
                Property prop = getProperty(posfix);
                if (prop == null) {
                    continue;
                }
                // exploit the JavaBeans property editors to convert the values from text
                propertyeditor editor = propertyeditorManager.findEditor(prop.getType());
                if (editor == null) {
                    continue;
                }
                editor.setAsText(props.getProperty(key));
                prop.setValue(editor.getValue());

            }
        }
        ;
    }

    // load all subfolders
    for (Folder folder : getFolders()) {
        folder.loadFromProperties(props,prefix);
    }

}
项目:incubator-netbeans    文件:DiffNode.java   
@Override
public propertyeditor getpropertyeditor() {
    try {
        return new DiffNode.Diffpropertyeditor(getValue());
    } catch (Exception e) {
        return super.getpropertyeditor();
    }
}
项目:incubator-netbeans    文件:StringEditorTest.java   
public void testNullValueSupport() throws Exception {
    NP np = new NP();
    String defaultValue = "<null value>";
    String customValue = "Hello World!";
    np.setValue(ObjectEditor.PROP_NULL,defaultValue);

    propertyeditor p = np.getpropertyeditor();
    assertNotNull("There is some editor",p);
    assertEquals("It is StringEditor",StringEditor.class,p.getClass());
    ((StringEditor) p).readEnv(np);

    p.setValue(null);
    String value = (String)p.getValue ();
    assertNull(value);
    assertEquals(defaultValue,p.getAsText());

    p.setValue(customValue);
    value = (String)p.getValue ();
    assertEquals(customValue,value);
    assertEquals(customValue,p.getAsText());

    np.setValue(ObjectEditor.PROP_NULL,Boolean.TRUE);
    ((StringEditor) p).readEnv(np);
    p.setValue(null);
    value = (String)p.getValue ();
    assertNull(value);
    assertFalse("we've better than default 'null' string","null".equals(defaultValue));
}
项目:incubator-netbeans    文件:CustomEditordisplayer.java   
propertyeditor getpropertyeditor() { //Package private for unit tests

        if (editor == null) {
            setpropertyeditor(PropUtils.getpropertyeditor(getproperty()));
        }

        return editor;
    }
项目:openjdk-jdk10    文件:Testpropertyeditor.java   
private static void test(Class<?> type,Class<? extends propertyeditor> expected) {
    propertyeditor actual = propertyeditorManager.findEditor(type);
    if ((actual == null) && (expected != null)) {
        throw new Error("expected editor is not found");
    }
    if ((actual != null) && !actual.getClass().equals(expected)) {
        throw new Error("found unexpected editor");
    }
}
项目:incubator-netbeans    文件:EditablePropertydisplayer.java   
public boolean isValueModified() {
    boolean result = false;
    propertyeditor peditor = getpropertyeditor();

    Object enteredValue = getEnteredValue();
    Object realValue = null;

    //Get the value from the editor to make sure getAsText() does not lie
    Object editorValue = null;

    try {
        editorValue = peditor.getValue();
    } catch (ProxyNode.DifferentValuesException dve) {
        return false;
    }

    //some editors provide a single from getTags()
    //but the value is null by default
    if ((enteredValue == null) != (editorValue == null)) {
        return true;
    }

    if (realValue == null) {
        //try to check the editor value if the editor does not support
        //getAsText
        realValue = editorValue;
    }

    if ((realValue == null) != (enteredValue == null)) {
        result = true;
    } else if (realValue == enteredValue) {
        result = false;
    } else if (realValue != null) {
        result = !realValue.equals(enteredValue);
    } else {
        result = false;
    }

    return result;
}
项目:incubator-netbeans    文件:EditablePropertydisplayer.java   
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);
    }
}
项目:incubator-netbeans    文件:RendererFactory.java   
private IconPanel prepareIconPanel(propertyeditor ed,PropertyEnv env,InplaceEditor inner) {
    IconPanel icp = iconPanel();
    icp.setInplaceEditor(inner);
    icp.connect(ed,env);

    return icp;
}
项目:incubator-netbeans    文件:I18nServiceImpl.java   
/**
 * Provides a component usable as property customizer (so typically a modal
 * dialog) that allows to choose (or create) a properties bundle file within
 * the project of given form data object. The selected file should be
 * written to the given property editor (via setValue) as a resource name
 * string.
 */
@Override
public Component getBundleSelectionComponent(final propertyeditor prEd,FileObject srcFile) {
    try {
        final FileSelector fs = new FileSelector(srcFile,JavaResourceHolder.getTemplate());
        return fs.getDialog(NbBundle.getMessage(I18nServiceImpl.class,"CTL_SELECT_BUNDLE_TITLE"),// NOI18N
                            new ActionListener()
        {
            @Override
            public void actionPerformed(ActionEvent ev) {
                DataObject bundleDO = fs.getSelectedDataObject();
                if (bundleDO != null) {
                    Classpath cp = Classpath.getClasspath(bundleDO.getPrimaryFile(),Classpath.soURCE);
                    if (cp != null) {
                        String bundleName = cp.getResourceName(bundleDO.getPrimaryFile(),'/',false);
                        prEd.setValue(bundleName);
                    }
                }
            }
        });
    }
    catch (IOException ex) {
        // means that template for properties file was not found - unlikely
        ErrorManager.getDefault().notify(ErrorManager.informatIONAL,ex);
    }
    return null;
}
项目:incubator-netbeans    文件:RendererFactory.java   
private JComponent prepareCheckBox(propertyeditor editor,PropertyEnv env) {
    CheckBoxRenderer ren = checkBoxRenderer();
    ren.setUseTitle(useLabels);
    ren.clear();
    ren.setEnabled(true);
    ren.connect(editor,env);

    return ren.getComponent();
}
项目:incubator-netbeans    文件:StringCustomEditor.java   
/** Create a StringCustomEditor.
  * @param value the initial value for the string
  * @param editable whether to show the editor in read only or read-write mode
  * @param oneline whether the text component should be a single-line or multi-line component
  * @param instructions any instructions that should be displayed
  */
 StringCustomEditor (String value,boolean editable,boolean oneline,String instructions,propertyeditor editor,PropertyEnv env) {
     this.oneline = oneline;
     this.instructions = instructions;
     this.env = env;
     this.editor = editor;

     this.env.setState(PropertyEnv.STATE_NEEDS_VALIDATION);
     this.env.addPropertychangelistener(this);

     init (value,editable);
}
项目:jdk8u-jdk    文件:propertyeditorFinder.java   
public propertyeditorFinder() {
    super(propertyeditor.class,false,"Editor",DEFAULT);

    this.registry = new WeakCache<Class<?>,Class<?>>();
    this.registry.put(Byte.TYPE,ByteEditor.class);
    this.registry.put(Short.TYPE,ShortEditor.class);
    this.registry.put(Integer.TYPE,IntegerEditor.class);
    this.registry.put(Long.TYPE,LongEditor.class);
    this.registry.put(Boolean.TYPE,BooleanEditor.class);
    this.registry.put(Float.TYPE,FloatEditor.class);
    this.registry.put(Double.TYPE,DoubleEditor.class);
}

com.intellij.uiDesigner.propertyInspector.PropertyEditor的实例源码

com.intellij.uiDesigner.propertyInspector.PropertyEditor的实例源码

项目:intellij-ce-playground    文件:AbstractInsetsProperty.java   
public final propertyeditor<Insets> getEditor() {
  if (myEditor == null) {
    myEditor = new IntRegexEditor<Insets>(Insets.class,myRenderer,new int[] { 0,0 }) {
      public Insets getValue() throws Exception {
        // if a single number has been entered,interpret it as same value for all parts (IDEADEV-7330)
        try {
          int value = Integer.parseInt(myTf.getText());
          final Insets insets = new Insets(value,value,value);
          myTf.setText(myRenderer.formatText(insets));
          return insets;
        }
        catch(NumberFormatException ex) {
          return super.getValue();
        }
      }
    };
  }
  return myEditor;
}
项目:tools-idea    文件:AbstractInsetsProperty.java   
public final propertyeditor<Insets> getEditor() {
  if (myEditor == null) {
    myEditor = new IntRegexEditor<Insets>(Insets.class,value);
          myTf.setText(myRenderer.formatText(insets));
          return insets;
        }
        catch(NumberFormatException ex) {
          return super.getValue();
        }
      }
    };
  }
  return myEditor;
}
项目:consulo-ui-designer    文件:AbstractInsetsProperty.java   
public final propertyeditor<Insets> getEditor() {
  if (myEditor == null) {
    myEditor = new IntRegexEditor<Insets>(Insets.class,value);
          myTf.setText(myRenderer.formatText(insets));
          return insets;
        }
        catch(NumberFormatException ex) {
          return super.getValue();
        }
      }
    };
  }
  return myEditor;
}
项目:intellij-ce-playground    文件:Palette.java   
private void updateUI(final Property property) {
  final PropertyRenderer renderer = property.getRenderer();
  renderer.updateUI();
  final propertyeditor editor = property.getEditor();
  if (editor != null) {
    editor.updateUI();
  }
  final Property[] children = property.getChildren(null);
  for (int i = children.length - 1; i >= 0; i--) {
    updateUI(children[i]);
  }
}
项目:intellij-ce-playground    文件:IntroIntProperty.java   
public IntroIntProperty(final String name,final Method readMethod,final Method writeMethod,final PropertyRenderer<Integer> renderer,final propertyeditor<Integer> editor,final boolean storeAsClient){
  super(name,readMethod,writeMethod,storeAsClient);
  myRenderer = renderer;
  myEditor = editor;
}
项目:tools-idea    文件:Palette.java   
private void updateUI(final Property property){
  final PropertyRenderer renderer = property.getRenderer();
  renderer.updateUI();
  final propertyeditor editor = property.getEditor();
  if(editor != null){
    editor.updateUI();
  }
  final Property[] children = property.getChildren(null);
  for (int i = children.length - 1; i >= 0; i--) {
    updateUI(children[i]);
  }
}
项目:tools-idea    文件:IntroIntProperty.java   
public IntroIntProperty(final String name,storeAsClient);
  myRenderer = renderer;
  myEditor = editor;
}
项目:consulo-ui-designer    文件:Palette.java   
private void updateUI(final Property property){
  final PropertyRenderer renderer = property.getRenderer();
  renderer.updateUI();
  final propertyeditor editor = property.getEditor();
  if(editor != null){
    editor.updateUI();
  }
  final Property[] children = property.getChildren(null);
  for (int i = children.length - 1; i >= 0; i--) {
    updateUI(children[i]);
  }
}
项目:consulo-ui-designer    文件:IntroIntProperty.java   
public IntroIntProperty(final String name,storeAsClient);
  myRenderer = renderer;
  myEditor = editor;
}
项目:intellij-ce-playground    文件:BindingProperty.java   
public propertyeditor<String> getEditor(){
  return myEditor;
}
项目:intellij-ce-playground    文件:IntFieldProperty.java   
public propertyeditor<Integer> getEditor() {
  return myEditor;
}
项目:intellij-ce-playground    文件:AbstractIntProperty.java   
@Nullable public propertyeditor<Integer> getEditor() {
  return myEditor;
}
项目:intellij-ce-playground    文件:CustomCreateProperty.java   
public propertyeditor<Boolean> getEditor() {
  return myEditor;
}
项目:intellij-ce-playground    文件:BorderProperty.java   
public propertyeditor<BorderType> getEditor() {
  return null;
}
项目:intellij-ce-playground    文件:ButtonGroupProperty.java   
public propertyeditor<RadButtonGroup> getEditor() {
  return myEditor;
}
项目:intellij-ce-playground    文件:AbstractDimensionProperty.java   
public final propertyeditor<Dimension> getEditor() {
  return myEditor;
}
项目:intellij-ce-playground    文件:AbstractGridLayoutProperty.java   
public propertyeditor<Boolean> getEditor(){
  return myEditor;
}
项目:intellij-ce-playground    文件:LayoutManagerProperty.java   
public propertyeditor<String> getEditor() {
  return myEditor;
}
项目:intellij-ce-playground    文件:IntroPrimitiveTypeProperty.java   
public propertyeditor<T> getEditor(){
  if (myEditor == null) {
    myEditor = createEditor();
  }
  return myEditor;
}
项目:intellij-ce-playground    文件:IntroPrimitiveTypeProperty.java   
protected propertyeditor<T> createEditor() {
  return new PrimitiveTypeEditor<T>(myClass);
}
项目:intellij-ce-playground    文件:IntroRectangleProperty.java   
public propertyeditor<Rectangle> getEditor() {
  return myEditor;
}
项目:intellij-ce-playground    文件:IntroDimensionProperty.java   
public propertyeditor<Dimension> getEditor() {
  return myEditor;
}
项目:intellij-ce-playground    文件:IntroInsetsProperty.java   
public propertyeditor<Insets> getEditor() {
  return myEditor;
}
项目:intellij-ce-playground    文件:ClasstoBindProperty.java   
public propertyeditor<String> getEditor(){
  return myEditor;
}
项目:intellij-ce-playground    文件:IntroCharProperty.java   
protected propertyeditor<Character> createEditor() {
  return new CharEditor();
}
项目:intellij-ce-playground    文件:SizePolicyProperty.java   
public final propertyeditor<Integer> getEditor(){
  return null;
}
项目:intellij-ce-playground    文件:SizePolicyProperty.java   
public final propertyeditor<Boolean> getEditor(){
  return myEditor;
}
项目:intellij-ce-playground    文件:ClientPropertyProperty.java   
public propertyeditor getEditor() {
  return myEditor;
}
项目:intellij-ce-playground    文件:InplaceEditingLayer.java   
public void valueCommitted(final propertyeditor source,final boolean continueEditing,final boolean closeEditorOnError) {
  finishInplaceEditing();
}
项目:intellij-ce-playground    文件:InplaceEditingLayer.java   
public void editingCanceled(final propertyeditor source) {
  cancelInplaceEditing();
}
项目:intellij-ce-playground    文件:InplaceEditingLayer.java   
public void preferredSizeChanged(final propertyeditor source) {
  adjustEditorComponentSize();
}
项目:intellij-ce-playground    文件:RadGridBagLayoutManager.java   
public propertyeditor<Double> getEditor() {
  if (myEditor == null) {
    myEditor = new PrimitiveTypeEditor<Double>(Double.class);
  }
  return myEditor;
}
项目:intellij-ce-playground    文件:RadcardlayoutManager.java   
public propertyeditor<String> getEditor() {
  return myEditor;
}
项目:intellij-ce-playground    文件:RadBorderLayoutManager.java   
public propertyeditor<String> getEditor() {
  if (myEditor == null) {
    myEditor = new BorderSideEditor();
  }
  return myEditor;
}
项目:intellij-ce-playground    文件:RadContainer.java   
public propertyeditor<StringDescriptor> getEditor() {
  return myEditor;
}
项目:tools-idea    文件:BindingProperty.java   
public propertyeditor<String> getEditor(){
  return myEditor;
}
项目:tools-idea    文件:IntFieldProperty.java   
public propertyeditor<Integer> getEditor() {
  return myEditor;
}
项目:tools-idea    文件:AbstractIntProperty.java   
@Nullable public propertyeditor<Integer> getEditor() {
  return myEditor;
}
项目:tools-idea    文件:CustomCreateProperty.java   
public propertyeditor<Boolean> getEditor() {
  return myEditor;
}
项目:tools-idea    文件:BorderProperty.java   
public propertyeditor<BorderType> getEditor() {
  return null;
}

java.beans.IndexedPropertyDescriptor的实例源码

java.beans.IndexedPropertyDescriptor的实例源码

项目:incubator-netbeans    文件:BeanNodeBug21285.java   
public static void main(String[] args)throws Exception {


        BeanInfo bi = Introspector.getBeanInfo( BadBeanHidden.class );
        PropertyDescriptor[] ps = bi.getPropertyDescriptors();

        for ( int i = 0; i < ps.length; i++ ) {
            System.out.println( i + " : " + ps[i]);
            System.out.println("  Read : " + ps[i].getReadMethod() );
            System.out.println("  Write : " + ps[i].getWriteMethod() );
            System.out.println(" TYPE " + ps[i].getPropertyType() );
            if ( ps[i] instanceof IndexedPropertyDescriptor ) {
                System.out.println("  I Read : " + ((IndexedPropertyDescriptor)ps[i]).getIndexedReadMethod() );
                System.out.println("  I Write : " +((IndexedPropertyDescriptor)ps[i]).getIndexedWriteMethod() );
                System.out.println(" TYPE " + ((IndexedPropertyDescriptor)ps[i]).getIndexedPropertyType() );
            }


        }
    }
项目:myfaces-trinidad    文件:JavaIntrospector.java   
private static IndexedPropertyDescriptor _cloneIndexedPropertyDescriptor(
  IndexedPropertyDescriptor oldDescriptor
  )
{
  try
  {
    IndexedPropertyDescriptor newDescriptor = new IndexedPropertyDescriptor(
                                    oldDescriptor.getName(),oldDescriptor.getReadMethod(),oldDescriptor.getWriteMethod(),oldDescriptor.getIndexedReadMethod(),oldDescriptor.getIndexedWriteMethod());

    // copy the rest of the attributes
    _copyPropertyDescriptor(oldDescriptor,newDescriptor);

    return newDescriptor;
  }
  catch (Exception e)
  {
    _LOG.severe(e);
    return null;
  }
}
项目:lams    文件:ExtendedBeanInfo.java   
private PropertyDescriptor findExistingPropertyDescriptor(String propertyName,Class<?> propertyType) {
    for (PropertyDescriptor pd : this.propertyDescriptors) {
        final Class<?> candidateType;
        final String candidateName = pd.getName();
        if (pd instanceof IndexedPropertyDescriptor) {
            IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
            candidateType = ipd.getIndexedPropertyType();
            if (candidateName.equals(propertyName) &&
                    (candidateType.equals(propertyType) || candidateType.equals(propertyType.getComponentType()))) {
                return pd;
            }
        }
        else {
            candidateType = pd.getPropertyType();
            if (candidateName.equals(propertyName) &&
                    (candidateType.equals(propertyType) || propertyType.equals(candidateType.getComponentType()))) {
                return pd;
            }
        }
    }
    return null;
}
项目:lams    文件:ExtendedBeanInfo.java   
@Override
public boolean equals(Object obj) {
    if (this == obj) {
        return true;
    }
    if (obj != null && obj instanceof IndexedPropertyDescriptor) {
        IndexedPropertyDescriptor other = (IndexedPropertyDescriptor) obj;
        if (!compareMethods(getIndexedReadMethod(),other.getIndexedReadMethod())) {
            return false;
        }
        if (!compareMethods(getIndexedWriteMethod(),other.getIndexedWriteMethod())) {
            return false;
        }
        if (getIndexedPropertyType() != other.getIndexedPropertyType()) {
            return false;
        }
        return PropertyDescriptorUtils.equals(this,obj);
    }
    return false;
}
项目:etomica    文件:ObjectWrapper.java   
private static Property makeProperty(Object o,PropertyDescriptor propertyDescriptor) {
    Class propertyType = propertyDescriptor.getPropertyType();
    if (propertyType != null && Vector.class.isAssignableFrom(propertyType)) {
        return new VectorProperty(o,propertyDescriptor);
    }
    if (propertyType != null && IAtomList.class.isAssignableFrom(propertyType)) {
        return new AtomListProperty(o,propertyDescriptor);
    }
    if (propertyType != null && IMoleculeList.class.isAssignableFrom(propertyType)) {
        return new MoleculeListProperty(o,propertyDescriptor);
    }
    if (!(propertyDescriptor instanceof IndexedPropertyDescriptor) && propertyType.isArray() &&
            !(propertyType.getComponentType().isPrimitive() || propertyType.getComponentType().equals(String.class))) {
        return new ArrayProperty(o,propertyDescriptor);
    }
    return new InstanceProperty(o,propertyDescriptor);
}
项目:jdk8u-jdk    文件:Test4634390.java   
private static PropertyDescriptor create(PropertyDescriptor pd) {
    try {
        if (pd instanceof IndexedPropertyDescriptor) {
            IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
            return new IndexedPropertyDescriptor(
                    ipd.getName(),ipd.getReadMethod(),ipd.getWriteMethod(),ipd.getIndexedReadMethod(),ipd.getIndexedWriteMethod());
        } else {
            return new PropertyDescriptor(
                    pd.getName(),pd.getReadMethod(),pd.getWriteMethod());
        }
    }
    catch (IntrospectionException exception) {
        exception.printstacktrace();
        return null;
    }
}
项目:jdk8u-jdk    文件:Test8034164.java   
private static void test(Class<?> type,boolean read,boolean write,boolean readindexed,boolean writeIndexed) {
    PropertyDescriptor pd = BeanUtils.findPropertyDescriptor(type,"size");
    if (pd != null) {
        test(type,"read",read,null != pd.getReadMethod());
        test(type,"write",write,null != pd.getWriteMethod());
        if (pd instanceof IndexedPropertyDescriptor) {
            IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
            test(type,"indexed read",readindexed,null != ipd.getIndexedReadMethod());
            test(type,"indexed write",writeIndexed,null != ipd.getIndexedWriteMethod());
        } else if (readindexed || writeIndexed) {
            error(type,"indexed property does not exist");
        }
    } else if (read || write || readindexed || writeIndexed) {
        error(type,"property does not exist");
    }
}
项目:jdk8u-jdk    文件:Test8034085.java   
private static void test(Class<?> type,"property does not exist");
    }
}
项目:jdk8u-jdk    文件:Test6976577.java   
public static void main(String[] args) throws Exception {
    Class<?> bt = Accessor.getBeanType();
    Class<?> lt = Accessor.getListenerType();

    // test PropertyDescriptor
    PropertyDescriptor pd = new PropertyDescriptor("boolean",bt);
    test(pd.getReadMethod());
    test(pd.getWriteMethod());

    // test IndexedPropertyDescriptor
    IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor("indexed",bt);
    test(ipd.getReadMethod());
    test(ipd.getWriteMethod());
    test(ipd.getIndexedReadMethod());
    test(ipd.getIndexedWriteMethod());

    // test EventSetDescriptor
    EventSetDescriptor esd = new EventSetDescriptor(bt,"test",lt,"process");
    test(esd.getAddListenerMethod());
    test(esd.getRemoveListenerMethod());
    test(esd.getGetListenerMethod());
    test(esd.getListenerMethods());
}
项目:openjdk-jdk10    文件:Test4634390.java   
private static PropertyDescriptor create(PropertyDescriptor pd) {
    try {
        if (pd instanceof IndexedPropertyDescriptor) {
            IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
            return new IndexedPropertyDescriptor(
                    ipd.getName(),pd.getWriteMethod());
        }
    }
    catch (IntrospectionException exception) {
        exception.printstacktrace();
        return null;
    }
}
项目:openjdk-jdk10    文件:Test8034164.java   
private static void test(Class<?> type,"property does not exist");
    }
}
项目:openjdk-jdk10    文件:Test8034085.java   
private static void test(Class<?> type,"property does not exist");
    }
}
项目:openjdk-jdk10    文件:Test6976577.java   
public static void main(String[] args) throws Exception {
    Class<?> bt = Accessor.getBeanType();
    Class<?> lt = Accessor.getListenerType();

    // test PropertyDescriptor
    PropertyDescriptor pd = new PropertyDescriptor("boolean","process");
    test(esd.getAddListenerMethod());
    test(esd.getRemoveListenerMethod());
    test(esd.getGetListenerMethod());
    test(esd.getListenerMethods());
}
项目:openjdk9    文件:Test4634390.java   
private static PropertyDescriptor create(PropertyDescriptor pd) {
    try {
        if (pd instanceof IndexedPropertyDescriptor) {
            IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
            return new IndexedPropertyDescriptor(
                    ipd.getName(),pd.getWriteMethod());
        }
    }
    catch (IntrospectionException exception) {
        exception.printstacktrace();
        return null;
    }
}
项目:openjdk9    文件:Test8034164.java   
private static void test(Class<?> type,"property does not exist");
    }
}
项目:openjdk9    文件:Test8034085.java   
private static void test(Class<?> type,"property does not exist");
    }
}
项目:openjdk9    文件:Test6976577.java   
public static void main(String[] args) throws Exception {
    Class<?> bt = Accessor.getBeanType();
    Class<?> lt = Accessor.getListenerType();

    // test PropertyDescriptor
    PropertyDescriptor pd = new PropertyDescriptor("boolean","process");
    test(esd.getAddListenerMethod());
    test(esd.getRemoveListenerMethod());
    test(esd.getGetListenerMethod());
    test(esd.getListenerMethods());
}
项目:spring4-understanding    文件:ExtendedBeanInfo.java   
private PropertyDescriptor findExistingPropertyDescriptor(String propertyName,Class<?> propertyType) {
    for (PropertyDescriptor pd : this.propertyDescriptors) {
        final Class<?> candidateType;
        final String candidateName = pd.getName();
        if (pd instanceof IndexedPropertyDescriptor) {
            IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
            candidateType = ipd.getIndexedPropertyType();
            if (candidateName.equals(propertyName) &&
                    (candidateType.equals(propertyType) || candidateType.equals(propertyType.getComponentType()))) {
                return pd;
            }
        }
        else {
            candidateType = pd.getPropertyType();
            if (candidateName.equals(propertyName) &&
                    (candidateType.equals(propertyType) || propertyType.equals(candidateType.getComponentType()))) {
                return pd;
            }
        }
    }
    return null;
}
项目:jdk8u_jdk    文件:Test4634390.java   
private static PropertyDescriptor create(PropertyDescriptor pd) {
    try {
        if (pd instanceof IndexedPropertyDescriptor) {
            IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
            return new IndexedPropertyDescriptor(
                    ipd.getName(),pd.getWriteMethod());
        }
    }
    catch (IntrospectionException exception) {
        exception.printstacktrace();
        return null;
    }
}
项目:jdk8u_jdk    文件:Test8034164.java   
private static void test(Class<?> type,"property does not exist");
    }
}
项目:jdk8u_jdk    文件:Test8034085.java   
private static void test(Class<?> type,"property does not exist");
    }
}
项目:jdk8u_jdk    文件:Test6976577.java   
public static void main(String[] args) throws Exception {
    Class<?> bt = Accessor.getBeanType();
    Class<?> lt = Accessor.getListenerType();

    // test PropertyDescriptor
    PropertyDescriptor pd = new PropertyDescriptor("boolean","process");
    test(esd.getAddListenerMethod());
    test(esd.getRemoveListenerMethod());
    test(esd.getGetListenerMethod());
    test(esd.getListenerMethods());
}
项目:lookaside_java-1.8.0-openjdk    文件:Test4634390.java   
private static PropertyDescriptor create(PropertyDescriptor pd) {
    try {
        if (pd instanceof IndexedPropertyDescriptor) {
            IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
            return new IndexedPropertyDescriptor(
                    ipd.getName(),pd.getWriteMethod());
        }
    }
    catch (IntrospectionException exception) {
        exception.printstacktrace();
        return null;
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:Test8034164.java   
private static void test(Class<?> type,"property does not exist");
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:Test8034085.java   
private static void test(Class<?> type,"property does not exist");
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:Test6976577.java   
public static void main(String[] args) throws Exception {
    Class<?> bt = Accessor.getBeanType();
    Class<?> lt = Accessor.getListenerType();

    // test PropertyDescriptor
    PropertyDescriptor pd = new PropertyDescriptor("boolean","process");
    test(esd.getAddListenerMethod());
    test(esd.getRemoveListenerMethod());
    test(esd.getGetListenerMethod());
    test(esd.getListenerMethods());
}
项目:spring    文件:ExtendedBeanInfo.java   
private PropertyDescriptor findExistingPropertyDescriptor(String propertyName,Class<?> propertyType) {
    for (PropertyDescriptor pd : this.propertyDescriptors) {
        final Class<?> candidateType;
        final String candidateName = pd.getName();
        if (pd instanceof IndexedPropertyDescriptor) {
            IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
            candidateType = ipd.getIndexedPropertyType();
            if (candidateName.equals(propertyName) &&
                    (candidateType.equals(propertyType) || candidateType.equals(propertyType.getComponentType()))) {
                return pd;
            }
        }
        else {
            candidateType = pd.getPropertyType();
            if (candidateName.equals(propertyName) &&
                    (candidateType.equals(propertyType) || propertyType.equals(candidateType.getComponentType()))) {
                return pd;
            }
        }
    }
    return null;
}
项目:infobip-open-jdk-8    文件:Test4634390.java   
private static PropertyDescriptor create(PropertyDescriptor pd) {
    try {
        if (pd instanceof IndexedPropertyDescriptor) {
            IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
            return new IndexedPropertyDescriptor(
                    ipd.getName(),pd.getWriteMethod());
        }
    }
    catch (IntrospectionException exception) {
        exception.printstacktrace();
        return null;
    }
}
项目:infobip-open-jdk-8    文件:Test8034164.java   
private static void test(Class<?> type,"property does not exist");
    }
}
项目:infobip-open-jdk-8    文件:Test8034085.java   
private static void test(Class<?> type,"property does not exist");
    }
}
项目:infobip-open-jdk-8    文件:Test6976577.java   
public static void main(String[] args) throws Exception {
    Class<?> bt = Accessor.getBeanType();
    Class<?> lt = Accessor.getListenerType();

    // test PropertyDescriptor
    PropertyDescriptor pd = new PropertyDescriptor("boolean","process");
    test(esd.getAddListenerMethod());
    test(esd.getRemoveListenerMethod());
    test(esd.getGetListenerMethod());
    test(esd.getListenerMethods());
}
项目:jdk8u-dev-jdk    文件:Test4634390.java   
private static PropertyDescriptor create(PropertyDescriptor pd) {
    try {
        if (pd instanceof IndexedPropertyDescriptor) {
            IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
            return new IndexedPropertyDescriptor(
                    ipd.getName(),pd.getWriteMethod());
        }
    }
    catch (IntrospectionException exception) {
        exception.printstacktrace();
        return null;
    }
}
项目:jdk8u-dev-jdk    文件:Test8034164.java   
private static void test(Class<?> type,"property does not exist");
    }
}
项目:jdk8u-dev-jdk    文件:Test8034085.java   
private static void test(Class<?> type,"property does not exist");
    }
}
项目:jdk8u-dev-jdk    文件:Test6976577.java   
public static void main(String[] args) throws Exception {
    Class<?> bt = Accessor.getBeanType();
    Class<?> lt = Accessor.getListenerType();

    // test PropertyDescriptor
    PropertyDescriptor pd = new PropertyDescriptor("boolean","process");
    test(esd.getAddListenerMethod());
    test(esd.getRemoveListenerMethod());
    test(esd.getGetListenerMethod());
    test(esd.getListenerMethods());
}
项目:Stdlib    文件:PropertyUtils.java   
/**
 * Return the Java Class representing the property type of the specified property,or
 * <code>null</code> if there is no such property for the specified bean.  This method
 * follows the same name resolution rules used by <code>getPropertyDescriptor()</code>,* so if the last element of a name reference is indexed,the type of the property itself
 * will be returned.  If the last (or only) element has no property with the specified
 * name,<code>null</code> is returned.
 *
 * @param bean Bean for which a property descriptor is requested
 * @param name Possibly indexed and/or nested name of the property for which a property
 *             descriptor is requested
 * @throws illegalaccessexception    if the caller does not have access to the property
 *                                   accessor method
 * @throws IllegalArgumentException  if <code>bean</code> or <code>name</code> are null
 *                                   or if a nested reference to a property returns null
 * @throws InvocationTargetException if the property accessor method throws an exception
 * @throws NoSuchMethodException     if an accessor method for this property cannot be
 *                                   found
 */
public static Class getPropertyType(Object bean,String name)
   throws illegalaccessexception,InvocationTargetException,NoSuchMethodException
{

   if(bean == null) throw new IllegalArgumentException("No bean specified");
   if(name == null) throw new IllegalArgumentException("No name specified");

   PropertyDescriptor descriptor = getPropertyDescriptor(bean,name);
   if(descriptor == null) {
      return null;
   } else if(descriptor instanceof IndexedPropertyDescriptor) {
      return (((IndexedPropertyDescriptor) descriptor).getIndexedPropertyType());
   } else if(descriptor instanceof MappedPropertyDescriptor) {
      return (((MappedPropertyDescriptor) descriptor).getMappedPropertyType());
   } else {
      return descriptor.getPropertyType();
   }

}
项目:jdk7-jdk    文件:Test4634390.java   
private static PropertyDescriptor create(PropertyDescriptor pd) {
    try {
        if (pd instanceof IndexedPropertyDescriptor) {
            IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
            return new IndexedPropertyDescriptor(
                    ipd.getName(),pd.getWriteMethod());
        }
    }
    catch (IntrospectionException exception) {
        exception.printstacktrace();
        return null;
    }
}
项目:JAVA_UNIT    文件:Test4634390.java   
private static PropertyDescriptor create(PropertyDescriptor pd) {
    try {
        if (pd instanceof IndexedPropertyDescriptor) {
            IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
            return new IndexedPropertyDescriptor(
                    ipd.getName(),pd.getWriteMethod());
        }
    }
    catch (IntrospectionException exception) {
        exception.printstacktrace();
        return null;
    }
}
项目:cn1    文件:IntrospectorTest.java   
public void test_MixedBooleanSimpleClass7() throws Exception {
    BeanInfo info = Introspector
            .getBeanInfo(MixedBooleanSimpleClass7.class);
    Method getter = MixedBooleanSimpleClass7.class
            .getDeclaredMethod("isList");
    Method setter = MixedBooleanSimpleClass7.class.getDeclaredMethod(
            "setList",boolean.class);

    for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
        if (propertyName.equals(pd.getName())) {
            assertFalse(pd instanceof IndexedPropertyDescriptor);
            assertEquals(getter,pd.getReadMethod());
            assertEquals(setter,pd.getWriteMethod());
        }
    }
}
项目:cn1    文件:IndexedPropertyDescriptorTest.java   
public void testSetIndexedWriteMethod_return()
        throws IntrospectionException,NoSuchMethodException,NoSuchMethodException {
    String propertyName = "PropertyFour";
    Class<MockJavaBean> beanClass = MockJavaBean.class;

    Method readMethod = beanClass.getmethod("get" + propertyName,(Class[]) null);
    Method writeMethod = beanClass.getmethod("set" + propertyName,new Class[] { String[].class });
    Method indexedReadMethod = beanClass.getmethod("get" + propertyName,new Class[] { Integer.TYPE });

    IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
            propertyName,readMethod,writeMethod,indexedReadMethod,null);
    assertNull(ipd.getIndexedWriteMethod());
    Method badArgType = beanClass.getmethod("setPropertyFourInvalid",new Class[] { Integer.TYPE,String.class });
    ipd.setIndexedWriteMethod(badArgType);

    assertEquals(String.class,ipd.getIndexedPropertyType());
    assertEquals(String[].class,ipd.getPropertyType());
    assertEquals(Integer.TYPE,ipd.getIndexedWriteMethod().getReturnType());
}

java.beans.PropertyDescriptor的实例源码

java.beans.PropertyDescriptor的实例源码

项目:lams    文件:AbstractAutowireCapablebeanfactory.java   
/**
 * Extract a filtered set of PropertyDescriptors from the given BeanWrapper,* excluding ignored dependency types or properties defined on ignored dependency interfaces.
 * @param bw the BeanWrapper the bean was created with
 * @param cache whether to cache filtered PropertyDescriptors for the given bean Class
 * @return the filtered PropertyDescriptors
 * @see #isExcludedFromDependencyCheck
 * @see #filterPropertyDescriptorsForDependencyCheck(org.springframework.beans.BeanWrapper)
 */
protected PropertyDescriptor[] filterPropertyDescriptorsForDependencyCheck(BeanWrapper bw,boolean cache) {
    PropertyDescriptor[] filtered = this.filteredPropertyDescriptorsCache.get(bw.getWrappedClass());
    if (filtered == null) {
        if (cache) {
            synchronized (this.filteredPropertyDescriptorsCache) {
                filtered = this.filteredPropertyDescriptorsCache.get(bw.getWrappedClass());
                if (filtered == null) {
                    filtered = filterPropertyDescriptorsForDependencyCheck(bw);
                    this.filteredPropertyDescriptorsCache.put(bw.getWrappedClass(),filtered);
                }
            }
        }
        else {
            filtered = filterPropertyDescriptorsForDependencyCheck(bw);
        }
    }
    return filtered;
}
项目:reflection-util    文件:PropertyUtils.java   
public static void writeDirectly(Object destination,PropertyDescriptor propertyDescriptor,Object value) {
    try {
        Field field = findField(destination,propertyDescriptor);
        boolean accessible = field.isAccessible();
        try {
            if (!accessible) {
                field.setAccessible(true);
            }
            field.set(destination,value);
        } finally {
            if (!accessible) {
                field.setAccessible(false);
            }
        }
    } catch (NoSuchFieldException | illegalaccessexception e) {
        throw new ReflectionRuntimeException("Failed to write " + getQualifiedPropertyName(destination,propertyDescriptor),e);
    }
}
项目:convertigo-engine    文件:ClientInstructionSetCheckedBeanInfo.java   
public ClientInstructionSetCheckedBeanInfo() {
    try {
        beanClass = ClientInstructionSetChecked.class;
        additionalBeanClass = com.twinsoft.convertigo.beans.extractionrules.siteclipper.AbstractClientInstructionWithPath.class;

        iconNameC16 = "/com/twinsoft/convertigo/beans/extractionrules/siteclipper/images/rule_clientinstructionsetchecked_color_16x16.png";
        iconNameC32 = "/com/twinsoft/convertigo/beans/extractionrules/siteclipper/images/rule_clientinstructionsetchecked_color_32x32.png";

        resourceBundle = getResourceBundle("res/ClientInstructionSetChecked");

        displayName = getExternalizedString("display_name");
        shortDescription = getExternalizedString("short_description");

        properties = new PropertyDescriptor[1];

        properties[0] = new PropertyDescriptor("targetValue",beanClass,"getTargetValue","setTargetValue");
        properties[0].setdisplayName(getExternalizedString("property.targetvalue.display_name"));
        properties[0].setShortDescription(getExternalizedString("property.targetvalue.short_description"));
        properties[0].setValue("scriptable",Boolean.TRUE);
    }
    catch(Exception e) {
        com.twinsoft.convertigo.engine.Engine.logBeans.error("Exception with bean info; beanpanel-heading">
            项目:zooadmin   
            文件:BeanMapUtil.java    
          
public static Object convertMap2Bean(Class type,Map map)
        throws IntrospectionException,illegalaccessexception,InstantiationException,InvocationTargetException {
    BeanInfo beanInfo = Introspector.getBeanInfo(type);
    Object obj = type.newInstance();
    PropertyDescriptor[] propertyDescriptors = beanInfo
            .getPropertyDescriptors();
    for (PropertyDescriptor pro : propertyDescriptors) {
        String propertyName = pro.getName();
        if (pro.getPropertyType().getName().equals("java.lang.class")) {
            continue;
        }
        if (map.containsKey(propertyName)) {
            Object value = map.get(propertyName);
            Method setter = pro.getWriteMethod();
            setter.invoke(obj,value);
        }
    }
    return obj;
}
项目:xmanager    文件:BeanUtils.java   
/**
 * 获取Bean的属性
 * @param bean bean
 * @param propertyName 属性名
 * @return 属性值
 */
public static Object getProperty(Object bean,String propertyName) {
    PropertyDescriptor pd = getPropertyDescriptor(bean.getClass(),propertyName);
    if (pd == null) {
        throw new RuntimeException("Could not read property '" + propertyName + "' from bean PropertyDescriptor is null");
    }
    Method readMethod = pd.getReadMethod();
    if (readMethod == null) {
        throw new RuntimeException("Could not read property '" + propertyName + "' from bean readMethod is null");
    }
    if (!readMethod.isAccessible()) {
        readMethod.setAccessible(true);
    }
    try {
        return readMethod.invoke(bean);
    } catch (Throwable ex) {
        throw new RuntimeException("Could not read property '" + propertyName + "' from bean",ex);
    }
}
项目:convertigo-engine    文件:UIStyleBeanInfo.java   
public UIStyleBeanInfo() {
    try {
        beanClass = UIStyle.class;
        additionalBeanClass = com.twinsoft.convertigo.beans.mobile.components.UIComponent.class;

        iconNameC16 = "/com/twinsoft/convertigo/beans/mobile/components/images/uistyle_color_16x16.png";
        iconNameC32 = "/com/twinsoft/convertigo/beans/mobile/components/images/uistyle_color_32x32.png";

        resourceBundle = getResourceBundle("res/UIStyle");

        displayName = resourceBundle.getString("display_name");
        shortDescription = resourceBundle.getString("short_description");

        properties = new PropertyDescriptor[1];

        properties[0] = new PropertyDescriptor("styleContent","getStyleContent","setStyleContent");
        properties[0].setdisplayName(getExternalizedString("property.styleContent.display_name"));
        properties[0].setShortDescription(getExternalizedString("property.styleContent.short_description"));
        properties[0].setHidden(true);
    }
    catch(Exception e) {
        com.twinsoft.convertigo.engine.Engine.logBeans.error("Exception with bean info; beanpanel-heading">
            项目:ureport   
            文件:DatasourceServletAction.java    
          
public void buildClass(HttpServletRequest req,HttpServletResponse resp) throws servletexception,IOException {
    String clazz=req.getParameter("clazz");
    List<Field> result=new ArrayList<Field>();
    try{
        Class<?> targetClass=Class.forName(clazz);
        PropertyDescriptor[] propertyDescriptors=PropertyUtils.getPropertyDescriptors(targetClass);
        for(PropertyDescriptor pd:propertyDescriptors){
            String name=pd.getName();
            if("class".equals(name)){
                continue;
            }
            result.add(new Field(name));
        }
        writeObjectToJson(resp,result);
    }catch(Exception ex){
        throw new ReportDesignException(ex);
    }
}
项目:convertigo-engine    文件:SerialStepBeanInfo.java   
public SerialStepBeanInfo() {
    try {
        beanClass = SerialStep.class;
        additionalBeanClass = com.twinsoft.convertigo.beans.steps.BranchStep.class;

        iconNameC16 = "/com/twinsoft/convertigo/beans/steps/images/serial_16x16.png";
        iconNameC32 = "/com/twinsoft/convertigo/beans/steps/images/serial_32x32.png";

        resourceBundle = getResourceBundle("res/SerialStep");

        displayName = resourceBundle.getString("display_name");
        shortDescription = resourceBundle.getString("short_description");

        PropertyDescriptor property = getPropertyDescriptor("maxnumberOfThreads");
           property.setHidden(true) ;

    }
    catch(Exception e) {
        com.twinsoft.convertigo.engine.Engine.logBeans.error("Exception with bean info; beanpanel-heading">
            项目:incubator-netbeans   
            文件:DefaultPropertyModelTest.java    
          
public void testUsageOfExplicitPropertyDescriptor() throws Exception {
    PropertyDescriptor pd = new PropertyDescriptor(
            "myProp",this.getClass(),"getterUsageOfExplicitPropertyDescriptor","setterUsageOfExplicitPropertyDescriptor"
            );

    DefaultPropertyModel model = new DefaultPropertyModel(this,pd);

    assertEquals("Getter returns this",model.getValue(),this);

    String msgToThrow = "msgToThrow";
    try {
        model.setValue(msgToThrow);
        fail("Setter should throw an exception");
    } catch (InvocationTargetException ex) {
        // when an exception occurs it should throw InvocationTargetException
        assertEquals("The right message",msgToThrow,ex.getTargetException().getMessage());
    }
}
项目:convertigo-engine    文件:XMLHttpHeadersBeanInfo.java   
public XMLHttpHeadersBeanInfo() {
    try {
        beanClass = XMLHttpHeaders.class;
        additionalBeanClass = com.twinsoft.convertigo.beans.extractionrules.HtmlExtractionRule.class;

        iconNameC16 = "/com/twinsoft/convertigo/beans/common/images/xmlhttpheaders_color_16x16.png";
        iconNameC32 = "/com/twinsoft/convertigo/beans/common/images/xmlhttpheaders_color_32x32.png";

        resourceBundle = getResourceBundle("res/XMLHttpHeaders");

        displayName = getExternalizedString("display_name");
        shortDescription = getExternalizedString("short_description");

        PropertyDescriptor property = getPropertyDescriptor("xpath");
        property.setHidden(true);
    }
    catch(Exception e) {
        com.twinsoft.convertigo.engine.Engine.logBeans.error("Exception with bean info; beanpanel-heading">
            项目:FCat   
            文件:ObjectUtil.java    
          
/**
 * 对象到map
 * @param obj
 * @return
 */
public static Map<String,Object> objectToMap(Object obj) { 
    Map<String,Object> map = new HashMap<String,Object>();
    if(obj == null) {
        return map;      
    }
    try{
     BeanInfo beanInfo = Introspector.getBeanInfo(obj.getClass());    
     PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();    
     for (PropertyDescriptor property : propertyDescriptors) {    
         String key = property.getName();    
         if (key.comparetoIgnoreCase("class") == 0) {   
             continue;  
         }  
         Method getter = property.getReadMethod();  
         Object value = getter!=null ? getter.invoke(obj) : null;  
         map.put(key,value);  
     }    
    }catch(Exception e) {
        logger.error(e.getMessage());
    }
    return map;
}
项目:Dude    文件:Enums.java   
/**
 * 获取枚举中指定属性的值
 *
 * @param enumCls 枚举类型
 * @param prop    Bean属性名
 * @return (枚举值,指定属性的值)
 */
public static Map<Enum<?>,Object> getEnumAndValue(Class<?> enumCls,String prop) {

    Object[] enumValues = enumCls.getEnumConstants();
    if (isEmpty(enumValues)) {
        return newLinkedHashMap();
    }
    Map<Enum<?>,Object> result = newLinkedHashMapWithExpectedSize(enumValues.length * 2);
    try {
        for (Object enumValue : enumValues) {
            PropertyDescriptor pd = getPropertyDescriptor(enumValue,prop);
            if (pd == null || pd.getReadMethod() == null) {
                continue;
            }
            result.put((Enum<?>) enumValue,pd.getReadMethod().invoke(enumValue));
        }
    } catch (Exception e) {
        // ignore
    }
    return result;
}
项目:lams    文件:MetadataMBeanInfoAssembler.java   
/**
 * Retrieves the description for the supplied {@code Method} from the
 * Metadata. Uses the method name is no description is present in the Metadata.
 */
@Override
protected String getoperationDescription(Method method,String beanKey) {
    PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method);
    if (pd != null) {
        ManagedAttribute ma = this.attributeSource.getManagedAttribute(method);
        if (ma != null && StringUtils.hasText(ma.getDescription())) {
            return ma.getDescription();
        }
        ManagedMetric metric = this.attributeSource.getManagedMetric(method);
        if (metric != null && StringUtils.hasText(metric.getDescription())) {
            return metric.getDescription();
        }
        return method.getName();
    }
    else {
        ManagedOperation mo = this.attributeSource.getManagedOperation(method);
        if (mo != null && StringUtils.hasText(mo.getDescription())) {
            return mo.getDescription();
        }
        return method.getName();
    }
}
项目:spring-rest-commons-options    文件:ReflectionUtils.java   
private static void collectParameters(Collection<Parameters> parameters,Parameter parameter,Annotation a,boolean isPathVariable) {
    if (a != null) {
        String typestr = parameter.getType().getSimpleName();
        Type type = parameter.getParameterizedType();
        if (type instanceof ParameterizedType) {
            typestr = ((Class<?>) ((ParameterizedType) type).getActualTypeArguments()[0]).getSimpleName();
        }
        parameters.add(new Parameters((boolean) AnnotationUtils.getValue(a,"required"),(String) (AnnotationUtils.getValue(a).equals("") ? parameter.getName()
                        : AnnotationUtils.getValue(a)),typestr));
    } else if (Pageable.class.isAssignableFrom(parameter.getType()) && !isPathVariable) {
        try {
            for (PropertyDescriptor propertyDescriptor : Introspector.getBeanInfo(parameter.getType())
                    .getPropertyDescriptors()) {
                parameters.add(new Parameters(false,propertyDescriptor.getName(),propertyDescriptor.getPropertyType().getSimpleName()));
            }
        } catch (IntrospectionException e) {
            LOGGER.error("Problemas al obtener el Pageable: {}",parameter,e);
        }
    }
}
项目:convertigo-engine    文件:InjectorBeanInfo.java   
public InjectorBeanInfo() {
    try {
        beanClass = Injector.class;
        additionalBeanClass = com.twinsoft.convertigo.beans.extractionrules.siteclipper.BaseRule.class;

        resourceBundle = getResourceBundle("res/Injector");

        properties = new PropertyDescriptor[2];

        properties[0] = new PropertyDescriptor("location","getLocation","setLocation");
        properties[0].setdisplayName(getExternalizedString("property.location.display_name"));
        properties[0].setShortDescription(getExternalizedString("property.location.short_description"));
        properties[0].setpropertyeditorClass(HtmlLocation.class);

        properties[1] = new PropertyDescriptor("customregexp","getCustomregexp","setCustomregexp");
        properties[1].setdisplayName(getExternalizedString("property.customregexp.display_name"));
        properties[1].setShortDescription(getExternalizedString("property.customregexp.short_description"));
        properties[1].setExpert(true);
    }
    catch(Exception e) {
        com.twinsoft.convertigo.engine.Engine.logBeans.error("Exception with bean info; beanpanel-heading">
            项目:spring-rest-commons-options   
            文件:ModelStrategy.java    
          
private List<DetailField> createDetail(Class<?> c,boolean isRequest) {
    List<DetailField> detailFields = new ArrayList<>();
    ReflectionUtils.getGenericclass(c).ifPresent(clazz -> {
        try {
            for (PropertyDescriptor propertyDescriptor : Introspector.getBeanInfo(clazz,Object.class)
                    .getPropertyDescriptors()) {
                if (!propertyDescriptor.getReadMethod().getDeclaringClass().equals(Object.class)) {
                    Optional<Field> field = getField(clazz,propertyDescriptor);
                    if (checkIfAddField(field,propertyDescriptor,isRequest)) {
                        Optional<DetailField> detail = super.createDetail(propertyDescriptor,field,isRequest);
                        detail.ifPresent(detailFields::add);
                    }
                }
            }
        } catch (Exception e) {
            LOGGER.error("Error al inspeccionar la clase {}",clazz,e);
        }
    });
    return detailFields;
}
项目:convertigo-engine    文件:CriteriaWithRegexBeanInfo.java   
public CriteriaWithRegexBeanInfo() {
    try {
        beanClass = CriteriaWithRegex.class;
        additionalBeanClass = com.twinsoft.convertigo.beans.criteria.siteclipper.BaseCriteria.class;

        resourceBundle = getResourceBundle("res/CriteriaWithRegex");

        properties = new PropertyDescriptor[1];

        properties[0] = new PropertyDescriptor("regexp","getRegexp","setRegexp");
        properties[0].setdisplayName(getExternalizedString("property.regexp.display_name"));
        properties[0].setShortDescription(getExternalizedString("property.regexp.short_description"));  

    }
    catch(Exception e) {
        com.twinsoft.convertigo.engine.Engine.logBeans.error("Exception with bean info; beanpanel-heading">
            项目:lams   
            文件:ExtendedBeanInfo.java    
          
public static void copyNonMethodProperties(PropertyDescriptor source,PropertyDescriptor target)
        throws IntrospectionException {

    target.setExpert(source.isExpert());
    target.setHidden(source.isHidden());
    target.setPreferred(source.isPreferred());
    target.setName(source.getName());
    target.setShortDescription(source.getShortDescription());
    target.setdisplayName(source.getdisplayName());

    // copy all attributes (emulating behavior of private FeatureDescriptor#addTable)
    Enumeration<String> keys = source.attributeNames();
    while (keys.hasMoreElements()) {
        String key = keys.nextElement();
        target.setValue(key,source.getValue(key));
    }

    // See java.beans.PropertyDescriptor#PropertyDescriptor(PropertyDescriptor)
    target.setpropertyeditorClass(source.getpropertyeditorClass());
    target.setBound(source.isBound());
    target.setConstrained(source.isConstrained());
}
项目:convertigo-engine    文件:UIPageEventBeanInfo.java   
public UIPageEventBeanInfo() {
    try {
        beanClass = UIPageEvent.class;
        additionalBeanClass = com.twinsoft.convertigo.beans.mobile.components.UIComponent.class;

        iconNameC16 = "/com/twinsoft/convertigo/beans/mobile/components/images/uipageevent_color_16x16.png";
        iconNameC32 = "/com/twinsoft/convertigo/beans/mobile/components/images/uipageevent_color_32x32.png";

        resourceBundle = getResourceBundle("res/UIPageEvent");

        displayName = resourceBundle.getString("display_name");
        shortDescription = resourceBundle.getString("short_description");

        properties = new PropertyDescriptor[1];

        properties[0] = new PropertyDescriptor("viewEvent","getViewEvent","setViewEvent");
        properties[0].setdisplayName(getExternalizedString("property.viewEvent.display_name"));
        properties[0].setShortDescription(getExternalizedString("property.viewEvent.short_description"));
        properties[0].setpropertyeditorClass(getEditorClass("StringComboBoxPropertyDescriptor"));
    }
    catch(Exception e) {
        com.twinsoft.convertigo.engine.Engine.logBeans.error("Exception with bean info; beanpanel-heading">
            项目:convertigo-engine   
            文件:InputHtmlSetFileStatementBeanInfo.java    
          
public InputHtmlSetFileStatementBeanInfo() {
    try {
        beanClass = InputHtmlSetFileStatement.class;
        additionalBeanClass = com.twinsoft.convertigo.beans.statements.AbstractEventStatement.class;

        iconNameC16 = "/com/twinsoft/convertigo/beans/statements/images/inputhtmlsetfile_16x16.png";
        iconNameC32 = "/com/twinsoft/convertigo/beans/statements/images/inputhtmlsetfile_32x32.png";

        resourceBundle = getResourceBundle("res/InputHtmlSetFileStatement");

        displayName = resourceBundle.getString("display_name");
        shortDescription = resourceBundle.getString("short_description");

        properties = new PropertyDescriptor[1];

        properties[0] = new PropertyDescriptor("filename","getFilename","setFilename");
        properties[0].setdisplayName(getExternalizedString("property.filename.display_name"));
        properties[0].setShortDescription(getExternalizedString("property.filename.short_description"));
           properties[0].setValue("scriptable",e);
    }
}
项目:aws-sdk-java-v2    文件:DefaultClientBuilderTest.java   
@Test
public void clientBuilderFieldsHaveBeanEquivalents() throws Exception {
    ClientBuilder<TestClientBuilder,TestClient> builder = testClientBuilder();

    BeanInfo beanInfo = Introspector.getBeanInfo(builder.getClass());
    Method[] clientBuilderMethods = ClientBuilder.class.getDeclaredMethods();

    Arrays.stream(clientBuilderMethods).filter(m -> !m.isSynthetic()).forEach(builderMethod -> {
        String propertyName = builderMethod.getName();

        Optional<PropertyDescriptor> propertyForMethod =
                Arrays.stream(beanInfo.getPropertyDescriptors())
                      .filter(property -> property.getName().equals(propertyName))
                      .findFirst();

        assertthat(propertyForMethod).as(propertyName + " property").hasValueSatisfying(property -> {
            assertthat(property.getReadMethod()).as(propertyName + " getter").isNull();
            assertthat(property.getWriteMethod()).as(propertyName + " setter").isNotNull();
        });
    });

}
项目:convertigo-engine    文件:AbstractComplexeEventStatementBeanInfo.java   
public AbstractComplexeEventStatementBeanInfo() {
    try {
        beanClass = AbstractComplexeEventStatement.class;
        additionalBeanClass = com.twinsoft.convertigo.beans.statements.AbstractEventStatement.class;

        resourceBundle = getResourceBundle("res/AbstractComplexeEventStatement");

        properties = new PropertyDescriptor[1];

           properties[0] = new PropertyDescriptor("uiEvent","getUiEvent","setUiEvent");
           properties[0].setdisplayName(getExternalizedString("property.uievent.display_name"));
           properties[0].setShortDescription(getExternalizedString("property.uievent.short_description"));    
    }
    catch(Exception e) {
        com.twinsoft.convertigo.engine.Engine.logBeans.error("Exception with bean info; beanpanel-heading">
            项目:iBase4J-Common   
            文件:InstanceUtil.java    
          
public static <T> T transMap2Bean(Map<String,Object> map,Class<T> clazz) {
    T bean = null;
    try {
        bean = clazz.newInstance();
        BeanInfo beanInfo = Introspector.getBeanInfo(clazz);
        PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
        for (PropertyDescriptor property : propertyDescriptors) {
            String key = property.getName();
            if (map.containsKey(key)) {
                Object value = map.get(key);
                // 得到property对应的setter方法
                Method setter = property.getWriteMethod();
                setter.invoke(bean,TypeParseUtil.convert(value,property.getPropertyType(),null));
            }
        }
    } catch (Exception e) {
        logger.error("transMap2Bean Error ",e);
    }
    return bean;
}
项目:neoscada    文件:AbstractObjectExporter.java   
/**
 * create data items from the properties
 */
protected void createDataItems ( final Class<?> targetClazz )
{
    try
    {
        final BeanInfo bi = Introspector.getBeanInfo ( targetClazz );
        for ( final PropertyDescriptor pd : bi.getPropertyDescriptors () )
        {
            final DataItem item = createItem ( pd,targetClazz );
            this.items.put ( pd.getName (),item );

            final Map<String,Variant> itemAttributes = new HashMap<String,Variant> ();
            fillAttributes ( pd,itemAttributes );
            this.attributes.put ( pd.getName (),itemAttributes );

            initAttribute ( pd );
        }
    }
    catch ( final IntrospectionException e )
    {
        logger.info ( "Failed to read initial item",e );
    }
}
项目:jaffa-framework    文件:BeanMoulder.java   
private static void setProperty (PropertyDescriptor pd,Object value,Object source)
throws illegalaccessexception,InvocationTargetException,MouldException {
    if(pd!=null && pd.getWriteMethod()!=null) {
        Method m = pd.getWriteMethod();
        if(!m.isAccessible()) m.setAccessible(true);
        Class tClass = m.getParameterTypes()[0];
        if(value==null || tClass.isAssignableFrom(value.getClass())) {
            m.invoke(source,new Object[] {value});
            log.debug("Set property '" + pd.getName() + "=" + value + "' on object '" + source.getClass().getName() + "'");
        } else if(DataTypeMapper.instance().isMappable(value.getClass(),tClass)) {
            // See if there is a datatype mapper for these classes
            value = DataTypeMapper.instance().map(value,tClass);
            m.invoke(source,new Object[] {value});
            log.debug("Translate+Set property '" + pd.getName() + "=" + value + "' on object '" + source.getClass().getName() + "'");
        } else {
            // Data type mismatch
            throw new MouldException(MouldException.DATATYPE_MISMATCH,source.getClass().getName() + "." + m.getName(),tClass.getName(),value.getClass().getName());
        }
    } else {
        MouldException me = new MouldException(MouldException.NO_SETTER,null,pd==null?"???":pd.getName(),source.getClass().getName());
        log.error(me.getLocalizedMessage());
        throw me;
    }
}
项目:convertigo-engine    文件:JavaScriptBeanInfo.java   
public JavaScriptBeanInfo() {
    try {
        beanClass = JavaScript.class;
        additionalBeanClass = BaseRule.class;

        resourceBundle = getResourceBundle("res/JavaScript");

        properties = new PropertyDescriptor[1];

        properties[0] = new PropertyDescriptor("expression","getExpression","setExpression" );
        properties[0].setdisplayName(getExternalizedString("property.expression.display_name") );
        properties[0].setShortDescription(getExternalizedString("property.expression.short_description") );
           properties[0].setpropertyeditorClass(getEditorClass("JavascriptTextEditor"));
           properties[0].setValue("scriptable",e);
    }
}
项目:lams    文件:MetadataMBeanInfoAssembler.java   
/**
 * Creates a description for the attribute corresponding to this property
 * descriptor. Attempts to create the description using Metadata from either
 * the getter or setter attributes,otherwise uses the property name.
 */
@Override
protected String getAttributeDescription(PropertyDescriptor propertyDescriptor,String beanKey) {
    Method readMethod = propertyDescriptor.getReadMethod();
    Method writeMethod = propertyDescriptor.getWriteMethod();

    ManagedAttribute getter =
            (readMethod != null ? this.attributeSource.getManagedAttribute(readMethod) : null);
    ManagedAttribute setter =
            (writeMethod != null ? this.attributeSource.getManagedAttribute(writeMethod) : null);

    if (getter != null && StringUtils.hasText(getter.getDescription())) {
        return getter.getDescription();
    }
    else if (setter != null && StringUtils.hasText(setter.getDescription())) {
        return setter.getDescription();
    }

    ManagedMetric metric = (readMethod != null ? this.attributeSource.getManagedMetric(readMethod) : null);
    if (metric != null && StringUtils.hasText(metric.getDescription())) {
        return metric.getDescription();
    }

    return propertyDescriptor.getdisplayName();
}
项目:lams    文件:requiredAnnotationBeanPostProcessor.java   
@Override
public PropertyValues postProcesspropertyValues(
        PropertyValues pvs,PropertyDescriptor[] pds,Object bean,String beanName)
        throws BeansException {

    if (!this.validatedBeanNames.contains(beanName)) {
        if (!shouldSkip(this.beanfactory,beanName)) {
            List<String> invalidProperties = new ArrayList<String>();
            for (PropertyDescriptor pd : pds) {
                if (isrequiredProperty(pd) && !pvs.contains(pd.getName())) {
                    invalidProperties.add(pd.getName());
                }
            }
            if (!invalidProperties.isEmpty()) {
                throw new BeanInitializationException(buildExceptionMessage(invalidProperties,beanName));
            }
        }
        this.validatedBeanNames.add(beanName);
    }
    return pvs;
}
项目:mycat-src-1.6.1-RELEASE    文件:ParameterMapping.java   
/**
 * 用于导出clazz这个JavaBean的所有属性的PropertyDescriptor
 * @param clazz
 * @return
 */
private static PropertyDescriptor[] getDescriptors(Class<?> clazz) {
    //PropertyDescriptor类表示JavaBean类通过存储器导出一个属性
    PropertyDescriptor[] pds;
    List<PropertyDescriptor> list;
    PropertyDescriptor[] pds2 = descriptors.get(clazz);
    //该clazz是否第一次加载
    if (null == pds2) {
        try {
            BeanInfo beanInfo = Introspector.getBeanInfo(clazz);
            pds = beanInfo.getPropertyDescriptors();
            list = new ArrayList<PropertyDescriptor>();
            //加载每一个类型不为空的property
            for (int i = 0; i < pds.length; i++) {
                if (null != pds[i].getPropertyType()) {
                    list.add(pds[i]);
                }
            }
            pds2 = new PropertyDescriptor[list.size()];
            list.toArray(pds2);
        } catch (IntrospectionException ie) {
            LOGGER.error("ParameterMappingError",ie);
            pds2 = new PropertyDescriptor[0];
        }
    }
    descriptors.put(clazz,pds2);
    return (pds2);
}
项目:convertigo-engine    文件:UrlMappingResponseBeanInfo.java   
public UrlMappingResponseBeanInfo() {
    try {
        beanClass = UrlMappingResponse.class;
        additionalBeanClass = com.twinsoft.convertigo.beans.core.DatabaSEObject.class;

        iconNameC16 = "/com/twinsoft/convertigo/beans/core/images/urlmappingresponse_color_16x16.png";
        iconNameC32 = "/com/twinsoft/convertigo/beans/core/images/urlmappingresponse_color_32x32.png";

        resourceBundle = getResourceBundle("res/UrlMappingResponse");

        displayName = resourceBundle.getString("display_name");
        shortDescription = resourceBundle.getString("short_description");

        properties = new PropertyDescriptor[0];
    }
    catch(Exception e) {
        com.twinsoft.convertigo.engine.Engine.logBeans.error("Exception with bean info; beanpanel-heading">
            项目:tk-mybatis   
            文件:FieldHelper.java    
          
/**
 * 通过方法获取属性
 *
 * @param entityClass
 * @return
 */
public List<EntityField> getProperties(Class<?> entityClass) {
    Map<String,Class<?>> genericMap = _getGenericTypeMap(entityClass);
    List<EntityField> entityFields = new ArrayList<EntityField>();
    BeanInfo beanInfo;
    try {
        beanInfo = Introspector.getBeanInfo(entityClass);
    } catch (IntrospectionException e) {
        throw new MapperException(e);
    }
    PropertyDescriptor[] descriptors = beanInfo.getPropertyDescriptors();
    for (PropertyDescriptor desc : descriptors) {
        if (desc != null && !"class".equals(desc.getName())) {
            EntityField entityField = new EntityField(null,desc);
            if (desc.getReadMethod() != null
                    && desc.getReadMethod().getGenericReturnType() != null
                    && desc.getReadMethod().getGenericReturnType() instanceof TypeVariable) {
                entityField.setJavaType(genericMap.get(((TypeVariable) desc.getReadMethod().getGenericReturnType()).getName()));
            } else if (desc.getWriteMethod() != null
                    && desc.getWriteMethod().getGenericParameterTypes() != null
                    && desc.getWriteMethod().getGenericParameterTypes().length == 1
                    && desc.getWriteMethod().getGenericParameterTypes()[0] instanceof TypeVariable) {
                entityField.setJavaType(genericMap.get(((TypeVariable) desc.getWriteMethod().getGenericParameterTypes()[0]).getName()));
            }
            entityFields.add(entityField);
        }
    }
    return entityFields;
}
项目:convertigo-engine    文件:DeleteDocumentAttachmentTransactionBeanInfo.java   
public DeleteDocumentAttachmentTransactionBeanInfo() {
    try {
        beanClass = DeleteDocumentAttachmentTransaction.class;
        additionalBeanClass = AbstractDocumentTransaction.class;

        resourceBundle = getResourceBundle("res/DeleteDocumentAttachmentTransaction");

        displayName = getExternalizedString("display_name");
        shortDescription = getExternalizedString("short_description");

        iconNameC16 = "/com/twinsoft/convertigo/beans/transactions/couchdb/images/deletedocumentattachment_color_16x16.png";
        iconNameC32 = "/com/twinsoft/convertigo/beans/transactions/couchdb/images/deletedocumentattachment_color_32x32.png";

        properties = new PropertyDescriptor[3];

        properties[0] = new PropertyDescriptor("q_rev","getQ_rev","setQ_rev");
        properties[0].setdisplayName(getExternalizedString("property.q_rev.display_name"));
        properties[0].setShortDescription(getExternalizedString("property.q_rev.short_description"));

        properties[1] = new PropertyDescriptor("q_batch","getQ_batch","setQ_batch");
        properties[1].setdisplayName(getExternalizedString("property.q_batch.display_name"));
        properties[1].setShortDescription(getExternalizedString("property.q_batch.short_description"));

        properties[2] = new PropertyDescriptor("p_attname","getP_attname","setP_attname");
        properties[2].setdisplayName(getExternalizedString("property.p_attname.display_name"));
        properties[2].setShortDescription(getExternalizedString("property.p_attname.short_description"));

    }
    catch(Exception e) {
        com.twinsoft.convertigo.engine.Engine.logBeans.error("Exception with bean info; beanpanel-heading">
            项目:convertigo-engine   
            文件:MouseStatementBeanInfo.java    
          
public MouseStatementBeanInfo() {
    try {
        beanClass = MouseStatement.class;
        additionalBeanClass = com.twinsoft.convertigo.beans.statements.SimpleEventStatement.class;

        iconNameC16 = "/com/twinsoft/convertigo/beans/statements/images/mouse_16x16.png";
        iconNameC32 = "/com/twinsoft/convertigo/beans/statements/images/mouse_32x32.png";

        resourceBundle = getResourceBundle("res/MouseStatement");

        displayName = resourceBundle.getString("display_name");
        shortDescription = resourceBundle.getString("short_description");

        properties = new PropertyDescriptor[0];
    }
    catch(Exception e) {
        com.twinsoft.convertigo.engine.Engine.logBeans.error("Exception with bean info; beanpanel-heading">
            项目:convertigo-engine   
            文件:WriteXMLStepBeanInfo.java    
          
public WriteXMLStepBeanInfo() {
    try {
        beanClass = WriteXMLStep.class;
        additionalBeanClass = com.twinsoft.convertigo.beans.steps.WriteFileStep.class;

        iconNameC16 = "/com/twinsoft/convertigo/beans/steps/images/xmlW_16x16.png";
        iconNameC32 = "/com/twinsoft/convertigo/beans/steps/images/xmlW_32x32.png";

        resourceBundle = getResourceBundle("res/WriteXMLStep");

        displayName = resourceBundle.getString("display_name");
        shortDescription = resourceBundle.getString("short_description");             

        properties = new PropertyDescriptor[1];

        properties[0] = new PropertyDescriptor("defaultRoottagname","getDefaultRoottagname","setDefaultRoottagname");
        properties[0].setdisplayName(getExternalizedString("property.defaultroottagname.display_name"));
        properties[0].setShortDescription(getExternalizedString("property.defaultroottagname.short_description"));
        properties[0].setValue(DatabaSEObject.PROPERTY_XMLNAME,e);
    }
}
项目:openjdk-jdk10    文件:TestMethodorderDependence.java   
public static void main(final String[] args) throws Exception {
    final BeanInfo beanInfo = Introspector.getBeanInfo(Sub.class);
    final PropertyDescriptor[] pds = beanInfo.getPropertyDescriptors();
    for (final PropertyDescriptor pd : pds) {
        System.err.println("pd = " + pd);
        final Class<?> type = pd.getPropertyType();
        if (type != Class.class && type != Long[].class
                && type != Integer.class && type != Enum.class) {
            throw new RuntimeException(Arrays.toString(pds));
        }
    }
}
项目:convertigo-engine    文件:ContextGetStatementBeanInfo.java   
public ContextGetStatementBeanInfo() {
    try {
        beanClass = ContextGetStatement.class;
        additionalBeanClass = com.twinsoft.convertigo.beans.core.Statement.class;

        iconNameC16 = "/com/twinsoft/convertigo/beans/statements/images/contextget_16x16.png";
        iconNameC32 = "/com/twinsoft/convertigo/beans/statements/images/contextget_32x32.png";

        resourceBundle = getResourceBundle("res/ContextGetStatement");

        displayName = resourceBundle.getString("display_name");
        shortDescription = resourceBundle.getString("short_description");

        properties = new PropertyDescriptor[2];

           properties[0] = new PropertyDescriptor("key","getKey","setKey");
           properties[0].setdisplayName(getExternalizedString("property.key.display_name"));
           properties[0].setShortDescription(getExternalizedString("property.key.short_description"));

           properties[1] = new PropertyDescriptor("variable","getvariable","setvariable");
           properties[1].setdisplayName(getExternalizedString("property.variable.display_name"));
           properties[1].setShortDescription(getExternalizedString("property.variable.short_description"));
    }
    catch(Exception e) {
        com.twinsoft.convertigo.engine.Engine.logBeans.error("Exception with bean info; beanpanel-heading">
            项目:reflection-util   
            文件:PropertyUtilsTest.java    
          
@Test
public void testReadDirectly_PropertyWithoutField() throws Exception {
    TestEntity testEntity = new TestEntity();
    PropertyDescriptor property = PropertyUtils.getPropertyDescriptor(TestEntity.class,TestEntity::getPropertyWithoutField);
    try {
        PropertyUtils.readDirectly(testEntity,property);
        fail("ReflectionRuntimeException expected");
    } catch (ReflectionRuntimeException e) {
        assertEquals("Failed to read TestEntity.propertyWithoutField",e.getMessage());
    }
}
项目:convertigo-engine    文件:CreateDirectoryStepBeanInfo.java   
public CreateDirectoryStepBeanInfo() {
    try {
        beanClass = CreateDirectoryStep.class;
        additionalBeanClass = com.twinsoft.convertigo.beans.core.Step.class;

        iconNameC16 = "/com/twinsoft/convertigo/beans/steps/images/createDirectory_16x16.png";
        iconNameC32 = "/com/twinsoft/convertigo/beans/steps/images/createDirectory_32x32.png";

        resourceBundle = getResourceBundle("res/CreateDirectoryStep");

        displayName = resourceBundle.getString("display_name");
        shortDescription = resourceBundle.getString("short_description");             

        properties = new PropertyDescriptor[2];

        properties[0] = new PropertyDescriptor("destinationPath","getDestinationPath","setDestinationPath");
        properties[0].setExpert(true);
        properties[0].setdisplayName(getExternalizedString("property.destinationPath.display_name"));
        properties[0].setShortDescription(getExternalizedString("property.destinationPath.short_description"));    
        properties[0].setValue("scriptable",Boolean.TRUE);

        properties[1] = new PropertyDescriptor("createNonExistentParentDirectories","isCreateNonExistentParentDirectories","setCreateNonExistentParentDirectories");
        properties[1].setdisplayName(getExternalizedString("property.createNonExistentParentDirectories.display_name"));
        properties[1].setShortDescription(getExternalizedString("property.createNonExistentParentDirectories.short_description"));
        properties[1].setExpert(true);

    }
    catch(Exception e) {
        com.twinsoft.convertigo.engine.Engine.logBeans.error("Exception with bean info; beanpanel-heading">
            项目:convertigo-engine   
            文件:GetServerUuidsTransactionBeanInfo.java    
          
public GetServerUuidsTransactionBeanInfo() {
    try {
        beanClass = GetServerUuidsTransaction.class;
        additionalBeanClass = AbstractCouchDbTransaction.class;

        resourceBundle = getResourceBundle("res/GetServerUuidsTransaction");

        displayName = getExternalizedString("display_name");
        shortDescription = getExternalizedString("short_description");

        iconNameC16 = "/com/twinsoft/convertigo/beans/transactions/couchdb/images/getserveruuids_color_16x16.png";
        iconNameC32 = "/com/twinsoft/convertigo/beans/transactions/couchdb/images/getserveruuids_color_32x32.png";

        properties = new PropertyDescriptor[1];

        properties[0] = new PropertyDescriptor("q_count","getQ_count","setQ_count");
        properties[0].setdisplayName(getExternalizedString("property.q_count.display_name"));
        properties[0].setShortDescription(getExternalizedString("property.q_count.short_description"));
    }
    catch(Exception e) {
        com.twinsoft.convertigo.engine.Engine.logBeans.error("Exception with bean info; beanpanel-heading">
            项目:GitHub   
            文件:IncludeJSR303AnnotationsIT.java    
          
private static Object createInstanceWithPropertyValue(Class type,String propertyName,Object propertyValue) {
    try {
        Object instance = type.newInstance();
        PropertyDescriptor propertyDescriptor = new PropertyDescriptor(propertyName,type);
        propertyDescriptor.getWriteMethod().invoke(instance,propertyValue);

        return instance;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

java.beans.PropertyEditorManager的实例源码

java.beans.PropertyEditorManager的实例源码

项目:incubator-netbeans    文件:Valuepropertyeditor.java   
private static propertyeditor findThepropertyeditor(Class clazz) {
    propertyeditor pe;
    if (Object.class.equals(clazz)) {
        pe = null;
    } else {
        pe = propertyeditorManager.findEditor(clazz);
        if (pe == null) {
            Class sclazz = clazz.getSuperclass();
            if (sclazz != null) {
                pe = findpropertyeditor(sclazz);
            }
        }
    }
    classesWithPE.put(clazz,pe != null);
    return pe;
}
项目:incubator-netbeans    文件:TermOptionsPanel.java   
private void fontButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FirsT:event_fontButtonActionPerformed
propertyeditor pe = propertyeditorManager.findEditor(Font.class);
if (pe != null) {
    pe.setValue(termOptions.getFont());
    DialogDescriptor dd = new DialogDescriptor(pe.getCustomEditor(),FontChooser_title());

    String defaultFontString = FontChooser_defaultFont_label();
    dd.setoptions(new Object[]{DialogDescriptor.OK_OPTION,defaultFontString,DialogDescriptor.CANCEL_OPTION});  //NOI18N
    Dialogdisplayer.getDefault().createDialog(dd).setVisible(true);
    if (dd.getValue() == DialogDescriptor.OK_OPTION) {
    Font f = (Font) pe.getValue();
    termOptions.setFont(f);
    applyTermOptions();
    } else if (dd.getValue() == defaultFontString) {
    Font controlFont = UIManager.getFont("controlFont");            //NOI18N
    int fontSize = (controlFont == null) ? 12 : controlFont.getSize();
    termOptions.setFont(new Font("monospaced",Font.PLAIN,fontSize));  //NOI18N
    }
}
   }
项目:incubator-netbeans    文件:PELookupTest.java   
public void testPackageUnregistering() {
    MockLookup.setInstances(new NodesRegistrationSupport.PEPackageRegistration("test1.pkg"));
    NodeOp.registerpropertyeditors();
    MockLookup.setInstances(new NodesRegistrationSupport.PEPackageRegistration("test2.pkg"));

    String[] editorSearchPath = propertyeditorManager.getEditorSearchPath();
    int count = 0;
    for (int i = 0; i < editorSearchPath.length; i++) {
        assertNotSame("test1.pkg",editorSearchPath[i]);
        if ("test2.pkg".equals(editorSearchPath[i])) {
            count++;
        }
    }
    assertEquals(1,count);

}
项目:incubator-netbeans    文件:OutputSettingsPanel.java   
private void btnSelectFontActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FirsT:event_btnSelectFontActionPerformed
    propertyeditor pe = propertyeditorManager.findEditor(Font.class);
    if (pe != null) {
        pe.setValue(outputoptions.getFont());
        DialogDescriptor dd = new DialogDescriptor(pe.getCustomEditor(),NbBundle.getMessage(Controller.class,"LBL_Font_Chooser_Title"));                         //NOI18N
        String defaultFont = NbBundle.getMessage(Controller.class,"BTN_Defaul_Font");                                 //NOI18N
        dd.setoptions(new Object[]{DialogDescriptor.OK_OPTION,defaultFont,DialogDescriptor.CANCEL_OPTION});  //NOI18N
        Dialogdisplayer.getDefault().createDialog(dd).setVisible(true);
        if (dd.getValue() == DialogDescriptor.OK_OPTION) {
            Font f = (Font) pe.getValue();
            outputoptions.setFont(f);
        } else if (dd.getValue() == defaultFont) {
            outputoptions.setFont(null);
        }
        updateFontField();
    }
}
项目:Pogamut3    文件:Introspector.java   
public static Property getProperty(Field field,Object object) {
    // access also protected and private fields
    field.setAccessible(true);

    // Properties are only primitive types marked by Prop annotation
    if (field.isAnnotationPresent(JProp.class)) {
        // We require that class of the field to be loaded,because we often specify
        // the propertyeditor there in static block.
        forceInitialization(field.getType());

        //Todo this condition should be used on client when deciding whether to show an editor for it
        if (propertyeditorManager.findEditor(field.getType()) != null) {
            // add the property
            return new JavaProperty(object,field);
        }
    }
    return null;
}
项目:neoscada    文件:propertyeditorRegistry.java   
/**
 * @param requiredType
 * @param propertyPath
 * @return
 */
public propertyeditor findCustomEditor ( final Class<?> requiredType,final String propertyPath )
{
    // first try to find exact match
    String key = requiredType.getCanonicalName () + ":" + propertyPath;
    propertyeditor pe = this.propertyeditors.get ( key );
    // 2nd: try to find for class only
    if ( pe == null )
    {
        key = requiredType.getCanonicalName () + ":";
        pe = this.propertyeditors.get ( key );
    }
    // 3rd: try to get internal
    if ( pe == null )
    {
        pe = propertyeditorManager.findEditor ( requiredType );
    }
    return pe;
}
项目:tomcat7    文件:JspRuntimeLibrary.java   
public static Object getValueFrompropertyeditorManager(
                 Class<?> attrClass,String attrName,String attrValue) 
    throws JasperException 
{
    try {
        propertyeditor propEditor = 
            propertyeditorManager.findEditor(attrClass);
        if (propEditor != null) {
            propEditor.setAsText(attrValue);
            return propEditor.getValue();
        } else {
            throw new IllegalArgumentException(
                Localizer.getMessage("jsp.error.beans.propertyeditor.notregistered"));
        }
    } catch (IllegalArgumentException ex) {
        throw new JasperException(
            Localizer.getMessage("jsp.error.beans.property.conversion",attrValue,attrClass.getName(),attrName,ex.getMessage()));
    }
}
项目:lams    文件:JspRuntimeLibrary.java   
public static Object getValueFrompropertyeditorManager(
             Class attrClass,String attrValue) 
throws JasperException 
   {
try {
    propertyeditor propEditor = 
    propertyeditorManager.findEditor(attrClass);
    if (propEditor != null) {
    propEditor.setAsText(attrValue);
    return propEditor.getValue();
    } else {
    throw new IllegalArgumentException(
                   Localizer.getMessage("jsp.error.beans.propertyeditor.notregistered"));
    }
} catch (IllegalArgumentException ex) {
    throw new JasperException(
               Localizer.getMessage("jsp.error.beans.property.conversion",ex.getMessage()));
}
   }
项目:apache-tomcat-7.0.73-with-comment    文件:JspRuntimeLibrary.java   
public static Object getValueFrompropertyeditorManager(
                 Class<?> attrClass,ex.getMessage()));
    }
}
项目:MaxSim    文件:FontChooserDialog.java   
public static Font show(Font initialFont) {
    propertyeditor pe = propertyeditorManager.findEditor(Font.class);
    if (pe == null) {
        throw new RuntimeException("Could not find font editor component.");
    }
    pe.setValue(initialFont);
    DialogDescriptor dd = new DialogDescriptor(
            pe.getCustomEditor(),"Choose Font");
    Dialogdisplayer.getDefault().createDialog(dd).setVisible(true);
    if (dd.getValue() == DialogDescriptor.OK_OPTION) {
        Font f = (Font)pe.getValue();
        return f;
    }
    return initialFont;
}
项目:jdk8u-jdk    文件:Test6963811.java   
public void run() {
    try {
        Thread.sleep(this.time); // increase the chance of the deadlock
        if (this.sync) {
            synchronized (Test6963811.class) {
                propertyeditorManager.findEditor(Super.class);
            }
        }
        else {
            propertyeditorManager.findEditor(Sub.class);
        }
    }
    catch (Exception exception) {
        exception.printstacktrace();
    }
}
项目:openjdk-jdk10    文件:Test6963811.java   
public void run() {
    try {
        Thread.sleep(this.time); // increase the chance of the deadlock
        if (this.sync) {
            synchronized (Test6963811.class) {
                propertyeditorManager.findEditor(Super.class);
            }
        }
        else {
            propertyeditorManager.findEditor(Sub.class);
        }
    }
    catch (Exception exception) {
        exception.printstacktrace();
    }
}
项目:lazycat    文件:JspRuntimeLibrary.java   
public static Object getValueFrompropertyeditorManager(Class<?> attrClass,String attrValue)
        throws JasperException {
    try {
        propertyeditor propEditor = propertyeditorManager.findEditor(attrClass);
        if (propEditor != null) {
            propEditor.setAsText(attrValue);
            return propEditor.getValue();
        } else {
            throw new IllegalArgumentException(
                    Localizer.getMessage("jsp.error.beans.propertyeditor.notregistered"));
        }
    } catch (IllegalArgumentException ex) {
        throw new JasperException(Localizer.getMessage("jsp.error.beans.property.conversion",ex.getMessage()));
    }
}
项目:openjdk9    文件:Test6963811.java   
public void run() {
    try {
        Thread.sleep(this.time); // increase the chance of the deadlock
        if (this.sync) {
            synchronized (Test6963811.class) {
                propertyeditorManager.findEditor(Super.class);
            }
        }
        else {
            propertyeditorManager.findEditor(Sub.class);
        }
    }
    catch (Exception exception) {
        exception.printstacktrace();
    }
}
项目:beyondj    文件:JspRuntimeLibrary.java   
public static Object getValueFrompropertyeditorManager(
                 Class<?> attrClass,String attrValue)
    throws JasperException
{
    try {
        propertyeditor propEditor =
            propertyeditorManager.findEditor(attrClass);
        if (propEditor != null) {
            propEditor.setAsText(attrValue);
            return propEditor.getValue();
        } else {
            throw new IllegalArgumentException(
                Localizer.getMessage("jsp.error.beans.propertyeditor.notregistered"));
        }
    } catch (IllegalArgumentException ex) {
        throw new JasperException(
            Localizer.getMessage("jsp.error.beans.property.conversion",ex.getMessage()));
    }
}
项目:eva2    文件:propertyeditorProvider.java   
/**
 * Retrieve an editor object for a given class.
 * This method seems unable to retrieve a primitive editor for obscure reasons.
 * So better use the one based on PropertyDescriptor if possible.
 */
public static propertyeditor findEditor(Class<?> cls) {
    propertyeditor editor = propertyeditorManager.findEditor(cls);

    // Try to unwrap primitives
    if (editor == null && Primitives.isWrapperType(cls)) {
        editor = propertyeditorManager.findEditor(Primitives.unwrap(cls));
    }

    if ((editor == null) && useDefaultGOE) {
        if (cls.isArray()) {
            Class<?> unwrapped = Primitives.isWrapperType(cls.getComponentType()) ? Primitives.unwrap(cls.getComponentType()) : cls;
            if (unwrapped.isPrimitive()) {
                editor = new ArrayEditor();
            } else {
                editor = new ObjectArrayEditor<>(unwrapped.getComponentType());
            }
        } else if (cls.isEnum()) {
            editor = new EnumEditor();
        } else {
            editor = new GenericObjectEditor();
            ((GenericObjectEditor)editor).setClasstype(cls);
        }
    }
    return editor;
}
项目:netbeansplugins    文件:LocalenbPanel.java   
/**
 * Load values from the LocaleOption
 */
void load() {
    final LocaleOption localeOption = LocaleOption.getDefault();

    final String[] datePatternsList = localeOption.getDatePatternList();
    this.datePatternsPE = propertyeditorManager.findEditor(String[].class);
    this.datePatternsPE.setValue( datePatternsList );

    final String[] messagePatternsList = localeOption.getMessagePatternList();
    this.messagePatternsPE = propertyeditorManager.findEditor(String[].class);
    this.messagePatternsPE.setValue( messagePatternsList );

    final String[] numberPatternsList = localeOption.getNumberPatternList();
    this.numberPatternsPE = propertyeditorManager.findEditor(String[].class);
    this.numberPatternsPE.setValue( numberPatternsList );

    //---
    this.datePatternsTextField.setText( this.datePatternsPE.getAsText() );
    this.messagePatternsTextField.setText( this.messagePatternsPE.getAsText() );
    this.numberPatternsTextField.setText( this.numberPatternsPE.getAsText() );


    this.dateParseFormattedTextField.setValue( localeOption.getMessageArgDatePattern() );
    this.numberParseFormattedTextField.setValue( localeOption.getMessageArgNumberPattern() );
}
项目:jdk8u_jdk    文件:Test6963811.java   
public void run() {
    try {
        Thread.sleep(this.time); // increase the chance of the deadlock
        if (this.sync) {
            synchronized (Test6963811.class) {
                propertyeditorManager.findEditor(Super.class);
            }
        }
        else {
            propertyeditorManager.findEditor(Sub.class);
        }
    }
    catch (Exception exception) {
        exception.printstacktrace();
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:Test6963811.java   
public void run() {
    try {
        Thread.sleep(this.time); // increase the chance of the deadlock
        if (this.sync) {
            synchronized (Test6963811.class) {
                propertyeditorManager.findEditor(Super.class);
            }
        }
        else {
            propertyeditorManager.findEditor(Sub.class);
        }
    }
    catch (Exception exception) {
        exception.printstacktrace();
    }
}
项目:aries-rsa    文件:IntrospectionSupport.java   
private static Object convert(Object value,Class<?> type) {
    if( type.isArray() ) {
        if( value.getClass().isArray() ) {
            int length = Array.getLength(value);
            Class<?> componentType = type.getComponentType();
            Object rc = Array.newInstance(componentType,length);
            for (int i = 0; i < length; i++) {
                Object o = Array.get(value,i);
                Array.set(rc,i,convert(o,componentType));
            }
            return rc;
        }
    }
    propertyeditor editor = propertyeditorManager.findEditor(type);
    if (editor != null) {
        editor.setAsText(value.toString());
        return editor.getValue();
    }
    return null;
}
项目:repo.kmeanspp.silhouette_score    文件:GenericObjectEditor.java   
public static void registerEditor(String name,String value) {
  Class<?> baseCls;
  Class<?> cls;

  try {
    // array class?
    if (name.endsWith("[]")) {
      baseCls = Class.forName(name.substring(0,name.indexOf("[]")));
      cls = Array.newInstance(baseCls,1).getClass();
    } else {
      cls = Class.forName(name);
    }
    // register
    propertyeditorManager.registerEditor(cls,Class.forName(value));
  } catch (Exception e) {
    Logger.log(weka.core.logging.Logger.Level.WARNING,"Problem registering "
      + name + "/" + value + ": " + e);
  }
}
项目:Camel    文件:IntrospectionSupport.java   
private static Object convert(TypeConverter typeConverter,Class<?> type,Object value)
    throws URISyntaxException,NoTypeConversionAvailableException {
    if (typeConverter != null) {
        return typeConverter.mandatoryConvertTo(type,value);
    }
    if (type == URI.class) {
        return new URI(value.toString());
    }
    propertyeditor editor = propertyeditorManager.findEditor(type);
    if (editor != null) {
        // property editor is not thread safe,so we need to lock
        Object answer;
        synchronized (LOCK) {
            editor.setAsText(value.toString());
            answer = editor.getValue();
        }
        return answer;
    }
    return null;
}
项目:kc-rice    文件:ObjectPropertyUtils.java   
/**
 * Get a property editor given a property type.
 *
 * @param propertyType The property type to look up an editor for.
 * @param path The property path,if applicable.
 * @return property editor
 */
public static propertyeditor getpropertyeditor(Class<?> propertyType) {
    propertyeditorRegistry registry = getpropertyeditorRegistry();
    propertyeditor editor = null;

    if (registry != null) {
        editor = registry.findCustomEditor(propertyType,null);
    } else {

        DataDictionaryService dataDictionaryService = KRADServiceLocatorWeb.getDataDictionaryService();
        Map<Class<?>,String> editorMap = dataDictionaryService.getpropertyeditorMap();
        String editorPrototypeName = editorMap == null ? null : editorMap.get(propertyType);

        if (editorPrototypeName != null) {
            editor = (propertyeditor) dataDictionaryService.getDataDictionary().getDictionaryPrototype(editorPrototypeName);
        }
    }

    if (editor == null && propertyType != null) {
        // Fall back to default beans lookup
        editor = propertyeditorManager.findEditor(propertyType);
    }

    return editor;
}
项目:packagedrone    文件:JspRuntimeLibrary.java   
public static Object getValueFrompropertyeditorManager(
             Class attrClass,ex.getMessage()));
}
   }
项目:netbeans-mmd-plugin    文件:MMDCfgPanel.java   
private void buttonFontActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FirsT:event_buttonFontActionPerformed
  final propertyeditor editor = propertyeditorManager.findEditor(Font.class);
  if (editor == null) {
    LOGGER.error("Can't find any font editor");
    NbUtils.msgError(null,"Can't find editor! Unexpected state! Contact developer!");
    return;
  }
  editor.setValue(this.config.getFont());

  final DialogDescriptor descriptor = new DialogDescriptor(
      editor.getCustomEditor(),"Mind map font"
  );

  Dialogdisplayer.getDefault().createDialog(descriptor).setVisible(true);
  if (descriptor.getValue() == DialogDescriptor.OK_OPTION) {
    this.config.setFont((Font) editor.getValue());
    updateFontButton(this.config);
    if (changeNotificationAllowed) {
      this.controller.changed();
    }
  }
}
项目:autoweka    文件:GenericObjectEditor.java   
public static void registerEditor(String name,String value) {
  Class              baseCls;
  Class               cls;

  try {
    // array class?
    if (name.endsWith("[]")) {
      baseCls = Class.forName(name.substring(0,1).getClass();
    }
    else {
      cls = Class.forName(name);
    }
    // register
    propertyeditorManager.registerEditor(cls,Class.forName(value));
  }
  catch (Exception e) {
    System.err.println("Problem registering " + name + "/" + value + ": " + e);
  }
}
项目:umple    文件:GenericObjectEditor.java   
public static void registerEditor(String name,"Problem registering "
      + name + "/" + value + ": " + e);
  }
}
项目:daq-eclipse    文件:IntrospectionSupport.java   
private static boolean isSettableType(Class clazz) {
    if (propertyeditorManager.findEditor(clazz) != null) {
        return true;
    }
    if (clazz == URI.class) {
        return true;
    }
    if (clazz == File.class) {
        return true;
    }
    if (clazz == File[].class) {
        return true;
    }
    if (clazz == Boolean.class) {
        return true;
    }
    return false;
}
项目:infobip-open-jdk-8    文件:Test6963811.java   
public void run() {
    try {
        Thread.sleep(this.time); // increase the chance of the deadlock
        if (this.sync) {
            synchronized (Test6963811.class) {
                propertyeditorManager.findEditor(Super.class);
            }
        }
        else {
            propertyeditorManager.findEditor(Sub.class);
        }
    }
    catch (Exception exception) {
        exception.printstacktrace();
    }
}
项目:jdk8u-dev-jdk    文件:Test6963811.java   
public void run() {
    try {
        Thread.sleep(this.time); // increase the chance of the deadlock
        if (this.sync) {
            synchronized (Test6963811.class) {
                propertyeditorManager.findEditor(Super.class);
            }
        }
        else {
            propertyeditorManager.findEditor(Sub.class);
        }
    }
    catch (Exception exception) {
        exception.printstacktrace();
    }
}
项目:mocha-mvc    文件:StringPEConverter.java   
@Override
public Object convertOne(Class<?> type,InvokeContext ctx,Object from) {
    if (from != null && !(from instanceof String)) {
        return NOT_CONVERTABLE;
    }
    propertyeditor pe = propertyeditorManager.findEditor(type);
    if (pe == null) {
        return NOT_CONVERTABLE;
    }
    if (from == null) {
        return null;
    } else {
        try {
            pe.setAsText((String) from);
            return pe.getValue();
        } catch (Exception e) {
            log.warn("Can't convert parameter to {}",type.getName(),e);
            return NOT_CONVERTABLE;
        }
    }
}
项目:jdk7-jdk    文件:Test6963811.java   
public void run() {
    try {
        Thread.sleep(this.time); // increase the chance of the deadlock
        if (this.sync) {
            synchronized (Test6963811.class) {
                propertyeditorManager.findEditor(Super.class);
            }
        }
        else {
            propertyeditorManager.findEditor(Sub.class);
        }
    }
    catch (Exception exception) {
        exception.printstacktrace();
    }
}
项目:openjdk-source-code-learn    文件:Test6963811.java   
public void run() {
    try {
        Thread.sleep(this.time); // increase the chance of the deadlock
        if (this.sync) {
            synchronized (Test6963811.class) {
                propertyeditorManager.findEditor(Super.class);
            }
        }
        else {
            propertyeditorManager.findEditor(Sub.class);
        }
    }
    catch (Exception exception) {
        exception.printstacktrace();
    }
}
项目:class-guard    文件:JspRuntimeLibrary.java   
public static Object getValueFrompropertyeditorManager(
                 Class<?> attrClass,ex.getMessage()));
    }
}
项目:OLD-OpenJDK8    文件:Test6963811.java   
public void run() {
    try {
        Thread.sleep(this.time); // increase the chance of the deadlock
        if (this.sync) {
            synchronized (Test6963811.class) {
                propertyeditorManager.findEditor(Super.class);
            }
        }
        else {
            propertyeditorManager.findEditor(Sub.class);
        }
    }
    catch (Exception exception) {
        exception.printstacktrace();
    }
}
项目:rice    文件:ObjectPropertyUtils.java   
/**
 * Get a property editor given a property type.
 *
 * @param propertyType The property type to look up an editor for.
 * @param path The property path,String> editorMap = dataDictionaryService.getpropertyeditorMap();
        String editorPrototypeName = editorMap == null ? null : editorMap.get(propertyType);

        if (editorPrototypeName != null) {
            editor = (propertyeditor) dataDictionaryService.getDataDictionary().getDictionaryPrototype(editorPrototypeName);
        }
    }

    if (editor == null && propertyType != null) {
        // Fall back to default beans lookup
        editor = propertyeditorManager.findEditor(propertyType);
    }

    return editor;
}
项目:cn1    文件:propertyeditorManagerTest.java   
public void testStringEditor_SetAsText_Null() {
    propertyeditor editor = propertyeditorManager.findEditor(String.class);

    editor.setAsText("null");
    assertEquals("null",editor.getAsText());
    assertEquals("\"null\"",editor.getJavaInitializationString());
    assertEquals("null",editor.getValue());

    editor.setAsText("");
    assertEquals("",editor.getAsText());
    assertEquals("\"\"",editor.getJavaInitializationString());

    editor.setAsText(null);
    assertEquals("null",editor.getJavaInitializationString());
    assertNull(editor.getValue());
}
项目:cn1    文件:propertyeditorManagerRegressionTest.java   
public void testFindEditorAccordingPath_2() throws Exception {
    // Regression Harmony-1205
    String newPath[] = new String[origPath.length + 1];
    newPath[origPath.length] = "org.apache.harmony.beans.tests.support";
    for (int i = 0; i < origPath.length; i++) {
        newPath[i] = origPath[i];
    }

    propertyeditorManager.setEditorSearchPath(newPath);

    propertyeditor editor = propertyeditorManager.findEditor(Class
            .forName("java.lang.String"));

    assertEquals(org.apache.harmony.beans.editors.StringEditor.class,editor.getClass());
}
项目:apache-tomcat-7.0.57    文件:JspRuntimeLibrary.java   
public static Object getValueFrompropertyeditorManager(
                 Class<?> attrClass,ex.getMessage()));
    }
}

关于java.beans.PropertyEditor的实例源码java.beans.introspection的介绍已经告一段落,感谢您的耐心阅读,如果想了解更多关于com.intellij.uiDesigner.propertyInspector.PropertyEditor的实例源码、java.beans.IndexedPropertyDescriptor的实例源码、java.beans.PropertyDescriptor的实例源码、java.beans.PropertyEditorManager的实例源码的相关信息,请在本站寻找。

本文标签: