Java Code Examples for org.openide.nodes.Node.Property#setValue()

The following examples show how to use org.openide.nodes.Node.Property#setValue() . 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: SheetTableModel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
    if (columnIndex == 0) {
        throw new IllegalArgumentException("Cannot set property names.");
    }

    try {
        FeatureDescriptor fd = model.getFeatureDescriptor(rowIndex);

        if (fd instanceof Property) {
            Property p = (Property) fd;
            p.setValue(aValue);
        } else {
            throw new IllegalArgumentException(
                "Index " + Integer.toString(rowIndex) + Integer.toString(columnIndex) +
                " does not represent a property. "
            ); //NOI18N
        }
    } catch (IllegalAccessException iae) {
        Logger.getLogger(SheetTableModel.class.getName()).log(Level.WARNING, null, iae);
    } catch (java.lang.reflect.InvocationTargetException ite) {
        Logger.getLogger(SheetTableModel.class.getName()).log(Level.WARNING, null, ite);
    }
}
 
Example 2
Source File: OutlineView.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Set an attribute value for the property column
 * representing properties that have the passed programmatic (not display)
 * name.
 *
 * @param columnName The programmatic name (Property.getName()) of the
 * column
 * @param attributeName The name of the attribute that is to be set
 * @param value The value of the attribute
 * @throws IllegalArgumentException if the column name is not found.
 * @since 6.44
 */
public final void setPropertyColumnAttribute(String columnName, String attributeName, Object value)
                  throws IllegalArgumentException {
    Property[] props = rowModel.getProperties();
    boolean found = false;
    for (Property p : props) {
        if (columnName.equals(p.getName())) {
            p.setValue(attributeName, value);
            found = true;
        }
    }
    if (!found) {
        throw new IllegalArgumentException("Unknown column "+columnName);
    }
}
 
Example 3
Source File: NodeTableModel.java    From netbeans with Apache License 2.0 4 votes vote down vote up
void setSortOrderDescending(boolean descending) {
    if (sortColumn != -1) {
        Property p = allPropertyColumns[sortColumn].getProperty();
        p.setValue(ATTR_DESCENDING_ORDER, descending ? Boolean.TRUE : Boolean.FALSE);
    }
}
 
Example 4
Source File: NodeTableModel.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/** Set column representing a property to be visible
 */
private void setVisible(Property p, boolean visible) {
    p.setValue(ATTR_INVISIBLE, (!visible) ? Boolean.TRUE : Boolean.FALSE);
}
 
Example 5
Source File: PropUtils.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/** Gets a property editor appropriate to the property.
 *  This method centralizes all code for fetching property editors
 *  used by the property sheet, such that future alternative
 *  registration systems for property editors may be easily
 *  implemented.
 *  <P><strong>Note:</strong>  This method will return a property
 *  editor with the value of the property already assigned.  Client
 *  code need not set the value in the property editor unless it
 *  should be changed, as this can result in unnecessary event
 *  firing.
 */
static PropertyEditor getPropertyEditor(Property p, boolean updateEditor) {
    PropertyEditor result = p.getPropertyEditor();

    //XXX Next few lines replicate a hack in the original property sheet.
    //Correct solution is to move IndexedPropertyEditor & custom editor
    //to the Nodes package and just return an instance from
    //IndexedProperty.getPropertyEditor.  Appears to be here due to some
    //kind of dependancy avoidance.
    if (p instanceof Node.IndexedProperty && (result == null)) {
        result = new IndexedPropertyEditor();

        // indexed property editor does not want to fire immediately
        p.setValue(PropertyEnv.PROP_CHANGE_IMMEDIATE, Boolean.FALSE);
    }

    if (result == null) {
        result = getPropertyEditor(p.getValueType()); //XXX is this agood idea?
    }

    //handle a type with no registered property editor here
    if (result == null) {
        java.util.List<String> missing = getMissing();
        String type = p.getValueType().getName();

        if (!(missing.contains(type))) {
            Logger.getAnonymousLogger().fine(
                "No property editor registered for type " + type
            ); //NOI18N
            missing.add(type);
        }

        result = new NoPropertyEditorEditor();
    } else if (p.canRead()) {
        try {
            try {
                try {
                    if (
                        ((p.getValueType() == Boolean.class) || (p.getValueType() == Boolean.TYPE)) &&
                            (p.getValue() == null)
                    ) {
                        // Allows Module folder nodes that use null to
                        // indicate indeterminate state to work
                        result = new Boolean3WayEditor();
                    }

                    if (updateEditor || null == result.getValue()) {
                        updateEdFromProp(p, result, p.getDisplayName());
                    }
                } catch (ProxyNode.DifferentValuesException dve) {
                    if ((p.getValueType() == Boolean.class) || (p.getValueType() == Boolean.TYPE)) {
                        result = new Boolean3WayEditor();
                    } else {
                         if(result instanceof ExPropertyEditor)
                             result = new ExDifferentValuesEditor(result);
                         else
                             result = new DifferentValuesEditor(result);
                    }
                }
            } catch (IllegalAccessException iae) {
                throw (IllegalStateException) new IllegalStateException("Error getting property value").initCause(iae);
            }
        } catch (InvocationTargetException ite) {
            throw (IllegalStateException) new IllegalStateException("Error getting property value").initCause(ite);
        }
    }

    return result;
}
 
Example 6
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 7
Source File: OutlineView152857Test.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
protected Sheet createSheet () {
    Sheet s = super.createSheet ();
    Sheet.Set ss = s.get (Sheet.PROPERTIES);
    if (ss == null) {
        ss = Sheet.createPropertiesSet ();
        s.put (ss);
    }
    Property [] props = new Property [2];

    DummyProperty dp = new DummyProperty (getName ());
    dp.setValue ("ComparableColumnTTV", Boolean.TRUE);
    props [0] = dp;

    Property p_tree = new Node.Property<Boolean> (Boolean.class) {

        @Override
        public boolean canRead () {
            return true;
        }

        @Override
        public Boolean getValue () throws IllegalAccessException, InvocationTargetException {
            return Boolean.TRUE;
        }

        @Override
        public boolean canWrite () {
            return false;
        }

        @Override
        public void setValue (Boolean val) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
            throw new UnsupportedOperationException ("Not supported yet.");
        }
    };

    p_tree.setValue ("TreeColumnTTV", Boolean.TRUE);
    p_tree.setValue ("ComparableColumnTTV", Boolean.TRUE);
    p_tree.setValue ("SortingColumnTTV", Boolean.TRUE);
    props [1] = p_tree;

    ss.put (props);

    return s;
}
 
Example 8
Source File: NodeTableModel.java    From netbeans with Apache License 2.0 4 votes vote down vote up
void setSortOrderDescending(boolean descending) {
    if (sortColumn != -1) {
        Property p = allPropertyColumns[sortColumn].getProperty();
        p.setValue(ATTR_DESCENDING_ORDER, descending ? Boolean.TRUE : Boolean.FALSE);
    }
}