Java Code Examples for java.beans.FeatureDescriptor#getValue()

The following examples show how to use java.beans.FeatureDescriptor#getValue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ModelProperty.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Creates a new instance of ModelProperty */
private ModelProperty(PropertyModel pm) {
    super(pm.getPropertyType());
    this.mdl = pm;

    if (mdl instanceof ExPropertyModel) {
        FeatureDescriptor fd = ((ExPropertyModel) mdl).getFeatureDescriptor();
        Boolean result = (Boolean) fd.getValue("canEditAsText"); // NOI18N

        if (result != null) {
            this.setValue("canEditAsText", result);
        }
    }

    //System.err.println(
    //"Created ModelProperty wrapper for mystery PropertyModel " + pm);
}
 
Example 2
Source File: StringEditor.java    From netbeans with Apache License 2.0 6 votes vote down vote up
void readEnv (FeatureDescriptor desc) {
    if (desc instanceof Node.Property){
        Node.Property prop = (Node.Property)desc;
        editable = prop.canWrite();
        //enh 29294 - support one-line editor & suppression of custom
        //editor
        instructions = (String) prop.getValue ("instructions"); //NOI18N
        oneline = Boolean.TRUE.equals (prop.getValue ("oneline")); //NOI18N
        customEd = !Boolean.TRUE.equals (prop.getValue
            ("suppressCustomEditor")); //NOI18N
    }
    Object obj = desc.getValue(ObjectEditor.PROP_NULL);
    if (Boolean.TRUE.equals(obj)) {
        nullValue = NbBundle.getMessage(StringEditor.class, "CTL_NullValue");
    } else {
        if (obj instanceof String) {
            nullValue = (String)obj;
        } else {
            nullValue = null;
        }
    }
}
 
Example 3
Source File: SheetTable.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private TableCellEditor getCustomEditor( int row ) {
    FeatureDescriptor fd = getPropertySetModel().getFeatureDescriptor(row);

    if (fd instanceof PropertySet)
        return null;

    Object res = fd.getValue( "custom.cell.editor"); //NOI18N
    if( res instanceof TableCellEditor ) {
        prepareCustomEditor( res );
        return ( TableCellEditor ) res;
    }
    return null;
}
 
Example 4
Source File: Test4058433.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static void print(FeatureDescriptor descriptor) {
    String name = descriptor.getName();
    String display = descriptor.getDisplayName();
    String description = descriptor.getShortDescription();
    System.out.println("name: " + name);
    if (!Objects.equals(name, display)) {
        System.out.println("display name: " + display);
    }
    if (!Objects.equals(display, description)) {
        System.out.println("description: " + description.trim());
    }
    print("expert", descriptor.isExpert());
    print("hidden", descriptor.isHidden());
    print("preferred", descriptor.isPreferred());
    TreeMap<String,Object> map = new TreeMap<>();
    Enumeration<String> enumeration = descriptor.attributeNames();
    while (enumeration.hasMoreElements()) {
        String id = enumeration.nextElement();
        Object value = descriptor.getValue(id);
        if (value.getClass().isArray()) {
            TreeSet<String> set = new TreeSet<>();
            int index = 0;
            int length = Array.getLength(value);
            while (index < length) {
                set.add(Array.get(value, index++) + ", " +
                        Array.get(value, index++) + ", " +
                        Array.get(value, index++));
            }
            value = set.toString();
        }
        map.put(id, value);
    }
    for (Entry<String,Object> entry : map.entrySet()) {
        System.out.println(entry.getKey() + ": " + entry.getValue());
    }
}
 
Example 5
Source File: ListImageEditor.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void attachEnv (PropertyEnv env) {
    FeatureDescriptor d = env.getFeatureDescriptor ();
    if (d instanceof Node.Property) {
        canWrite = ((Node.Property)d).canWrite ();
    }
    
    Object o;
    Image imgs [] = null;
    Integer vals [] = null;
    String descs [] = null;
    
    o = d.getValue (PROP_IMAGES);
    if (o instanceof Image []) {
        imgs = (Image [])o;
    }
    o = d.getValue (PROP_VALUES);
    if (o instanceof Integer []) {
        vals = (Integer [])o;
    }
    o = d.getValue (PROP_DESCRIPTIONS);
    if (o instanceof String []) {
        descs = (String [])o;
    }
    
    if (imgs != null && vals != null) {
        int length = length = imgs.length;

        if(vals.length < length)  {
            length = vals.length;
        }

        if (descs != null && descs.length < length) {
            length = descs.length;
        }

        images = new Image [length];
        values = new Integer [length];
        descriptions = new String [length];

        for (int i = 0; i < length; i++) {
            images [i] = imgs [i];
            values [i] = vals [i];
            descriptions [i] = descs == null ? vals [i].toString () : descs [i];
        }
    }
}
 
Example 6
Source File: Test4935607.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
private static void test(Object expected, FeatureDescriptor fd) {
    System.out.println(fd.getName());
    Object actual = fd.getValue("transient"); // NON-NLS: the attribute name
    if ((actual == null) ? (expected != null) : !actual.equals(expected))
        throw new Error("expected " + expected + " value, but actual value is " + actual);
}
 
Example 7
Source File: Test4935607.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
private static void test(Object expected, FeatureDescriptor fd) {
    System.out.println(fd.getName());
    Object actual = fd.getValue("transient"); // NON-NLS: the attribute name
    if ((actual == null) ? (expected != null) : !actual.equals(expected))
        throw new Error("expected " + expected + " value, but actual value is " + actual);
}
 
Example 8
Source File: Test4935607.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
private static void test(Object expected, FeatureDescriptor fd) {
    System.out.println(fd.getName());
    Object actual = fd.getValue("transient"); // NON-NLS: the attribute name
    if ((actual == null) ? (expected != null) : !actual.equals(expected))
        throw new Error("expected " + expected + " value, but actual value is " + actual);
}
 
Example 9
Source File: Test4935607.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
private static void test(Object expected, FeatureDescriptor fd) {
    System.out.println(fd.getName());
    Object actual = fd.getValue("transient"); // NON-NLS: the attribute name
    if ((actual == null) ? (expected != null) : !actual.equals(expected))
        throw new Error("expected " + expected + " value, but actual value is " + actual);
}
 
Example 10
Source File: Test4935607.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
private static void test(Object expected, FeatureDescriptor fd) {
    System.out.println(fd.getName());
    Object actual = fd.getValue("transient"); // NON-NLS: the attribute name
    if ((actual == null) ? (expected != null) : !actual.equals(expected))
        throw new Error("expected " + expected + " value, but actual value is " + actual);
}
 
Example 11
Source File: Test4935607.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
private static void test(Object expected, FeatureDescriptor fd) {
    System.out.println(fd.getName());
    Object actual = fd.getValue("transient"); // NON-NLS: the attribute name
    if ((actual == null) ? (expected != null) : !actual.equals(expected))
        throw new Error("expected " + expected + " value, but actual value is " + actual);
}
 
Example 12
Source File: Test4935607.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
private static void test(Object expected, FeatureDescriptor fd) {
    System.out.println(fd.getName());
    Object actual = fd.getValue("transient"); // NON-NLS: the attribute name
    if ((actual == null) ? (expected != null) : !actual.equals(expected))
        throw new Error("expected " + expected + " value, but actual value is " + actual);
}
 
Example 13
Source File: Test4935607.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
private static void test(Object expected, FeatureDescriptor fd) {
    System.out.println(fd.getName());
    Object actual = fd.getValue("transient"); // NON-NLS: the attribute name
    if ((actual == null) ? (expected != null) : !actual.equals(expected))
        throw new Error("expected " + expected + " value, but actual value is " + actual);
}
 
Example 14
Source File: Test4935607.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
private static void test(Object expected, FeatureDescriptor fd) {
    System.out.println(fd.getName());
    Object actual = fd.getValue("transient"); // NON-NLS: the attribute name
    if ((actual == null) ? (expected != null) : !actual.equals(expected))
        throw new Error("expected " + expected + " value, but actual value is " + actual);
}
 
Example 15
Source File: SheetCellRenderer.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public Component getTableCellRendererComponent(
    JTable table, Object value, boolean selected, boolean hasFocus, int row, int column
) {
    FeatureDescriptor fd = (FeatureDescriptor) value;
    Component result;

    //Use selection color for both columns
    selected |= (hasFocus && (table.getSelectedRow() == row));

    if (fd == null || fd instanceof PropertySet) {
        //#118372 - don't return null, SynthLaF asks for some properties from 
        //the renderer component under JDK1.6_05
        return new JLabel();
    } else {
        if (column == 0) {
            String txt = ((Property) fd).getHtmlDisplayName();
            boolean isHtml = txt != null;

            if (!isHtml) {
                txt = fd.getDisplayName();
            }

            JLabel lbl = htmlLabel;

            HtmlRenderer.Renderer ren = (HtmlRenderer.Renderer) lbl;

            ren.setHtml(isHtml);

            lbl.setText(txt);

            if (selected) {
                lbl.setBackground(table.getSelectionBackground());
                lbl.setForeground(table.getSelectionForeground());
            } else {
                lbl.setBackground(table.getBackground());
                lbl.setForeground(table.getForeground());
            }

            lbl.setOpaque(selected);

            if (includeMargin) {
                lbl.setBorder(
                    BorderFactory.createMatteBorder(0, PropUtils.getMarginWidth() + 2, 0, 0, lbl.getBackground())
                );
            } else {
                lbl.setBorder(
                    BorderFactory.createMatteBorder(0, PropUtils.getTextMargin(), 0, 0, lbl.getBackground())
                );
            }

            //Support for name marking with icon requested by form editor
            Object o = fd.getValue("nameIcon"); //NOI18N

            if (o instanceof Icon) {
                lbl.setIcon((Icon) o);
            } else if (o instanceof Image) {
                lbl.setIcon(new ImageIcon((Image) o));
            } else {
                lbl.setIcon(null);
            }

            result = lbl;
        } else {
            result = factory().getRenderer((Property) fd);

            if (selected) {
                result.setBackground(table.getSelectionBackground());
                result.setForeground(table.getSelectionForeground());
            } else {
                result.setBackground(table.getBackground());
                result.setForeground(table.getForeground());
            }

            ((JComponent) result).setOpaque(selected);
        }
    }

    return result;
}
 
Example 16
Source File: SheetTable.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/** In the case that an edit request is made on a boolean checkbox property, an
 *  edit request should simply toggle its state without instantiating a custom
 *  editor component.  Returns true if the state was toggled, in which case the
 *  editor instantiation portion of editCellAt() should be aborted  */
boolean checkEditBoolean(int row) {
    FeatureDescriptor fd = getSheetModel().getPropertySetModel().getFeatureDescriptor(row);

    if (fd != null && fd.getValue("stringValues") != null) {
        return false; //NOI18N
    }

    Property p = (fd instanceof Property) ? (Property) fd : null;

    if (p != null) {
        Class c = p.getValueType();

        //only do this if the property is supplying no special values for
        //the tags - if it is, we are using the radio button renderer
        if ((c == Boolean.class) || (c == boolean.class)) {
            if (!isCellEditable(row, 1)) {
                return true;
            }

            //Okay, try to toggle it
            try {
                Boolean b = null;

                //get the current value
                try {
                    Object value = p.getValue();
                    if( value instanceof Boolean ) {
                        b = (Boolean) value;
                    } else {
                        //150048 - somebody has sneaked in a wrong value
                        return false;
                    }
                } catch (ProxyNode.DifferentValuesException dve) {
                    //If we're represeting conflicting multi-selected 
                    //properties, we'll make them both true when we toggle
                    b = Boolean.FALSE;
                }

                if (isEditing()) {
                    removeEditor();
                }

                changeSelection(row, 1, false, false);

                //Toggle the value
                Boolean newValue = ((b == null) || Boolean.FALSE.equals(b)) ? Boolean.TRUE : Boolean.FALSE;
                p.setValue(newValue);

                //Force an event so we'll repaint
                /*
                tableChanged(new TableModelEvent (getSheetModel(), row,
                    row, 1, TableModelEvent.UPDATE));
                 */
                paintRow(row);

                return true;
            } catch (Exception ex) {
                //Something wrong, log it
                Exceptions.printStackTrace(ex);
            }
        }
    }

    return false;
}
 
Example 17
Source File: Test4935607.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
private static void test(Object expected, FeatureDescriptor fd) {
    System.out.println(fd.getName());
    Object actual = fd.getValue("transient"); // NON-NLS: the attribute name
    if ((actual == null) ? (expected != null) : !actual.equals(expected))
        throw new Error("expected " + expected + " value, but actual value is " + actual);
}
 
Example 18
Source File: Test4935607.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
private static void test(Object expected, FeatureDescriptor fd) {
    System.out.println(fd.getName());
    Object actual = fd.getValue("transient"); // NON-NLS: the attribute name
    if ((actual == null) ? (expected != null) : !actual.equals(expected))
        throw new Error("expected " + expected + " value, but actual value is " + actual);
}
 
Example 19
Source File: Test4935607.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
private static void test(Object expected, FeatureDescriptor fd) {
    System.out.println(fd.getName());
    Object actual = fd.getValue("transient"); // NON-NLS: the attribute name
    if ((actual == null) ? (expected != null) : !actual.equals(expected))
        throw new Error("expected " + expected + " value, but actual value is " + actual);
}
 
Example 20
Source File: Test4935607.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
private static void test(Object expected, FeatureDescriptor fd) {
    System.out.println(fd.getName());
    Object actual = fd.getValue("transient"); // NON-NLS: the attribute name
    if ((actual == null) ? (expected != null) : !actual.equals(expected))
        throw new Error("expected " + expected + " value, but actual value is " + actual);
}