Examples of PropertyEditor


Examples of java.beans.PropertyEditor

                       catch (ClassNotFoundException e) {
                          throw new Exception("Class not found for attribute '" + name +
                                              "' of type '" + type + "'");
                       }

                       PropertyEditor peditor = PropertyEditorManager.findEditor(clazz);

                      if (peditor != null) {
                      
                         // (d) use a PropertyEditor - extract the value
                        
                         String value = getElementContent(element);
                         peditor.setAsText(value);
                        
                         attrs.add(new Attribute(name, peditor.getValue()));
                      }
                      else {
                         throw new Exception("Cannot find a way to load attribute '" + name +
                                             "' of type '" + type + "'");
                      }
View Full Code Here

Examples of java.beans.PropertyEditor

         typeInfo = info;
      if (typeInfo == null)
         throw new IllegalArgumentException("Unable to determine type for value: " + value);
        
      Class clazz = typeInfo.getType();
      PropertyEditor editor = PropertyEditorManager.findEditor(clazz);
      if (editor != null)
      {
         editor.setAsText((String) value);
         return editor.getValue();
      }
      else
      {
         // TODO improve <init>(String) might not be relevent?
         Constructor constructor = clazz.getConstructor(new Class[] { String.class });
View Full Code Here

Examples of java.beans.PropertyEditor

        }
    }

    private void writeParameter(XMLStreamWriter writer, int index, FilterProperty property) {
        try {
            PropertyEditor editor = property.getPropertyEditor();
            if (editor == null) {
                editor = PropertyEditorManager.findEditor(property.getValueType());
            }
            if (editor == null) {
                return;
            }
            Object val = property.getValue();
            editor.setValue(val);
            writer.writeStartElement("parameter");
            writer.writeAttribute("index", String.valueOf(index));
            writer.writeCharacters(editor.getAsText());
            writer.writeEndElement();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
View Full Code Here

Examples of java.beans.PropertyEditor

                        int index = Integer.parseInt(reader.getAttributeValue(null, "index"));
                        property = query.getFilter().getProperties()[index];
                    }
                } else if (eventType.equals(XMLStreamReader.CHARACTERS) && property != null) {
                    try {
                        PropertyEditor editor = property.getPropertyEditor();
                        if (editor == null) {
                            editor = PropertyEditorManager.findEditor(property.getValueType());
                        }
                        if (editor != null) {
                            String textValue = reader.getText();
                            editor.setAsText(textValue);
                            property.setValue(editor.getValue());
                            model.updateParameters(query);
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
View Full Code Here

Examples of java.beans.PropertyEditor

                log.debug("No editor for property " + name);
                editors[i] = null;
                continue;
            }

            PropertyEditor propertyEditor;
            Class<?> editorClass = descriptors[i].getPropertyEditorClass();

            if (log.isDebugEnabled()) {
                log.debug("Property " + name + " has editor class " + editorClass);
            }

            if (editorClass != null) {
                try {
                    propertyEditor = (PropertyEditor) editorClass.newInstance();
                } catch (InstantiationException e) {
                    log.error("Can't create property editor.", e);
                    throw new Error(e.toString());
                } catch (IllegalAccessException e) {
                    log.error("Can't create property editor.", e);
                    throw new Error(e.toString());
                }
            } else {
                Class<?> c = descriptors[i].getPropertyType();
                propertyEditor = PropertyEditorManager.findEditor(c);
            }

            if (log.isDebugEnabled()) {
                log.debug("Property " + name + " has property editor " + propertyEditor);
            }

            if (propertyEditor == null) {
                log.debug("No editor for property " + name);
                editors[i] = null;
                continue;
            }

            if (!propertyEditor.supportsCustomEditor()) {
                propertyEditor = createWrapperEditor(propertyEditor, descriptors[i]);

                if (log.isDebugEnabled()) {
                    log.debug("Editor for property " + name + " is wrapped in " + propertyEditor);
                }
            }
            if(propertyEditor instanceof TestBeanPropertyEditor)
            {
                ((TestBeanPropertyEditor)propertyEditor).setDescriptor(descriptors[i]);
            }
            if (propertyEditor.getCustomEditor() instanceof JScrollPane) {
                scrollerCount++;
            }

            editors[i] = propertyEditor;
View Full Code Here

Examples of java.beans.PropertyEditor

        boolean notNull = Boolean.TRUE.equals(descriptor.getValue(NOT_UNDEFINED));
        boolean notExpression = Boolean.TRUE.equals(descriptor.getValue(NOT_EXPRESSION));
        boolean notOther = Boolean.TRUE.equals(descriptor.getValue(NOT_OTHER));

        PropertyEditor guiEditor;
        if (notNull && tags == null) {
            guiEditor = new FieldStringEditor();
        } else {
            ComboStringEditor e = new ComboStringEditor();
            e.setNoUndefined(notNull);
View Full Code Here

Examples of java.beans.PropertyEditor

    /**
     * Save values from the GUI fields into the property map
     */
    void saveGuiFields() {
        for (int i = 0; i < editors.length; i++) {
            PropertyEditor propertyEditor=editors[i]; // might be null (e.g. in testing)
            if (propertyEditor != null) {
                Object value = propertyEditor.getValue();
                String name = descriptors[i].getName();
                if (value == null) {
                    propertyMap.remove(name);
                    if (log.isDebugEnabled()) {
                        log.debug("Unset " + name);
View Full Code Here

Examples of java.beans.PropertyEditor

        }
    }

    void clearGuiFields() {
        for (int i = 0; i < editors.length; i++) {
            PropertyEditor propertyEditor=editors[i]; // might be null (e.g. in testing)
            if (propertyEditor != null) {
                try {
                if (propertyEditor instanceof WrapperEditor){
                    WrapperEditor we = (WrapperEditor) propertyEditor;
                    String tags[]=we.getTags();
                    if (tags != null && tags.length > 0) {
                        we.setAsText(tags[0]);
                    } else {
                        we.setValue("");
                    }
                } else if (propertyEditor instanceof ComboStringEditor) {
                    ComboStringEditor cse = (ComboStringEditor) propertyEditor;
                    cse.setAsText(cse.getInitialEditValue());
                } else {
                    propertyEditor.setAsText("");
                }
                } catch (IllegalArgumentException ex){
                    log.error("Failed to set field "+descriptors[i].getName(),ex);
                }
            }
View Full Code Here

Examples of java.beans.PropertyEditor

            throwMBeanException(new IllegalArgumentException(
                    "Unknown attribute: " + aname));
        }
       
        try {
            PropertyEditor e = getPropertyEditor(
                    getParent(aname).getClass(),
                    pdesc.getName(), pdesc.getPropertyType());
            e.setAsText((String) avalue);
            OgnlContext ctx = (OgnlContext) Ognl.createDefaultContext(source);
            ctx.setTypeConverter(typeConverter);
            Ognl.setValue(aname, ctx, source, e.getValue());
        } catch (Throwable e) {
            throwMBeanException(e);
        }
    }
View Full Code Here

Examples of net.sourceforge.marathon.util.PropertyEditor

    public int getTabSize() {
        return tabSize;
    }

    public void changeEditorSettings(JFrame parent) {
        PropertyEditor ped = new PropertyEditor(parent, RSTAEditorProvider.class,
                RSTAEditorProvider.class.getResource("rsyntaxtextarea.props"), "Editor Settings");
        ped.setVisible(true);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.