本文整理汇总了Java中org.openide.nodes.Node.Property.getValueType方法的典型用法代码示例。如果您正苦于以下问题:Java Property.getValueType方法的具体用法?Java Property.getValueType怎么用?Java Property.getValueType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openide.nodes.Node.Property
的用法示例。
在下文中一共展示了Property.getValueType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getInplaceEditor
import org.openide.nodes.Node.Property; //导入方法依赖的package包/类
InplaceEditor getInplaceEditor(Property p, PropertyEnv env, boolean newInstance) {
PropertyEditor ped = PropUtils.getPropertyEditor(p);
InplaceEditor result = (InplaceEditor) p.getValue("inplaceEditor"); //NOI18N
env.setFeatureDescriptor(p);
env.setEditable(p.canWrite());
if (ped instanceof ExPropertyEditor) {
ExPropertyEditor epe = (ExPropertyEditor) ped;
//configure the editor/propertyenv
epe.attachEnv(env);
if (result == null) {
result = env.getInplaceEditor();
}
} else if (ped instanceof EnhancedPropertyEditor) {
//handle legacy inplace custom editors
EnhancedPropertyEditor enh = (EnhancedPropertyEditor) ped;
if (enh.hasInPlaceCustomEditor()) {
//Use our wrapper component to handle this
result = new WrapperInplaceEditor(enh);
}
}
//Okay, the result is null, provide one of the standard inplace editors
if (result == null) {
Class c = p.getValueType();
String[] tags;
if ((c == Boolean.class) || (c == Boolean.TYPE)) {
if (ped instanceof PropUtils.NoPropertyEditorEditor) {
//platform case
result = getStringEditor(newInstance);
} else {
boolean useRadioButtons = useRadioBoolean || (p.getValue("stringValues") != null); //NOI18N
result = useRadioButtons ? getRadioEditor(newInstance) : getCheckboxEditor(newInstance);
}
} else if ((tags = ped.getTags()) != null) {
if (tags.length <= radioButtonMax) {
result = getRadioEditor(newInstance);
} else {
result = getComboBoxEditor(newInstance);
}
} else {
result = getStringEditor(newInstance);
}
}
if (!tableUI && Boolean.FALSE.equals(p.getValue("canEditAsText"))) { //NOI18N
result.getComponent().setEnabled(false);
}
result.clear(); //XXX shouldn't need to do this!
result.setPropertyModel(new NodePropertyModel(p, env.getBeans()));
result.connect(ped, env);
//XXX?
if (tableUI) {
if( result instanceof JTextField )
result.getComponent().setBorder(BorderFactory.createEmptyBorder(0,3,0,0));
else
result.getComponent().setBorder(BorderFactory.createEmptyBorder());
}
return result;
}
示例2: getPropertyEditor
import org.openide.nodes.Node.Property; //导入方法依赖的package包/类
/** 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;
}
示例3: checkEditBoolean
import org.openide.nodes.Node.Property; //导入方法依赖的package包/类
/** 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;
}
示例4: getDescriptionFor
import org.openide.nodes.Node.Property; //导入方法依赖的package包/类
/** Utility method that returns the short description
* of the property in question,
* used by the table to supply tooltips. */
public String getDescriptionFor(int row, int column) {
if ((row == -1) || (column == -1)) {
return ""; //NOI18N
}
FeatureDescriptor fd = model.getFeatureDescriptor(row);
Property p = (fd instanceof Property) ? (Property) fd : null;
String result = null;
if (p != null) {
try {
//try to get the short description, fall back to the value
if (column == 0) {
result = p.getShortDescription();
} else {
PropertyEditor ped = PropUtils.getPropertyEditor (p);
if (ped != null) {
result = ped.getAsText();
} else {
//IZ 44152, Debugger can produce > 512K strings, so add
//some special handling for very long strings
if (p.getValueType() == String.class) {
String s = (String) p.getValue();
if (s != null && s.length() > 2048) {
return "";
} else {
return s;
}
}
}
}
} catch (Exception e) {
//Suppress the exception, this is a tooltip
result = (column == 0) ? p.getShortDescription() : e.toString();
}
} else {
PropertySet ps = (PropertySet) fd;
result = ps.getShortDescription();
}
if (result == null) {
result = ""; //NOI18N
}
return result;
}