當前位置: 首頁>>代碼示例>>Java>>正文


Java PropertyEditor.getAsText方法代碼示例

本文整理匯總了Java中java.beans.PropertyEditor.getAsText方法的典型用法代碼示例。如果您正苦於以下問題:Java PropertyEditor.getAsText方法的具體用法?Java PropertyEditor.getAsText怎麽用?Java PropertyEditor.getAsText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.beans.PropertyEditor的用法示例。


在下文中一共展示了PropertyEditor.getAsText方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getEnteredValue

import java.beans.PropertyEditor; //導入方法依賴的package包/類
public Object getEnteredValue() {
    Object result;

    if (getInplaceEditor() != null) {
        result = getInplaceEditor().getValue();
    } else {
        if (cachedInitialValue != NO_VALUE) {
            result = cachedInitialValue;
        } else {
            PropertyEditor ed = PropUtils.getPropertyEditor(getProperty());

            try {
                result = ed.getAsText();
            } catch (ProxyNode.DifferentValuesException dve) {
                result = null;
            }
        }
    }

    return result;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:22,代碼來源:EditablePropertyDisplayer.java

示例2: formatFieldValue

import java.beans.PropertyEditor; //導入方法依賴的package包/類
/**
 * Formats the field value based on registered PropertyEditors.
 * @see #getCustomEditor
 */
@Override
protected Object formatFieldValue(String field, Object value) {
	String fixedField = fixedField(field);
	// Try custom editor...
	PropertyEditor customEditor = getCustomEditor(fixedField);
	if (customEditor != null) {
		customEditor.setValue(value);
		String textValue = customEditor.getAsText();
		// If the PropertyEditor returned null, there is no appropriate
		// text representation for this value: only use it if non-null.
		if (textValue != null) {
			return textValue;
		}
	}
	if (this.conversionService != null) {
		// Try custom converter...
		TypeDescriptor fieldDesc = getPropertyAccessor().getPropertyTypeDescriptor(fixedField);
		TypeDescriptor strDesc = TypeDescriptor.valueOf(String.class);
		if (fieldDesc != null && this.conversionService.canConvert(fieldDesc, strDesc)) {
			return this.conversionService.convert(value, fieldDesc, strDesc);
		}
	}
	return value;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:29,代碼來源:AbstractPropertyBindingResult.java

示例3: getStringValue

import java.beans.PropertyEditor; //導入方法依賴的package包/類
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...]
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:9,代碼來源:ResourceSupport.java

示例4: connect

import java.beans.PropertyEditor; //導入方法依賴的package包/類
@Override
public void connect(PropertyEditor p, PropertyEnv env) {
    setActionCommand(COMMAND_SUCCESS);
    this.env = env;
    
    if(PropUtils.supportsValueIncrement( env ) ) {
        PropUtils.wrapUpDownArrowActions( this, this );
    }

    if (editor == p) {
        return;
    }

    editor = p;

    boolean editable = PropUtils.checkEnabled(this, p, env);
    setEnabled(editable);

    //Undocumented, but in NB 3.5 and earlier, getAsText() returning null for
    //paintable editors was yet another way to disable a property editor
    if ((p.getTags() == null) && (p.getAsText() == null) && p.isPaintable()) {
        editable = false;
    }

    setEditable(editable);
    reset();
    added = false;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:29,代碼來源:StringInplaceEditor.java

示例5: getAsText

import java.beans.PropertyEditor; //導入方法依賴的package包/類
public String getAsText(final Object object) {
    final PropertyEditor editor = fetchFromPool();
    try {
        editor.setValue(object);
        return editor.getAsText();
    } finally {
        pool.putInPool(editor);
    }
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:10,代碼來源:ThreadSafePropertyEditor.java

示例6: PropertyText

import java.beans.PropertyEditor; //導入方法依賴的package包/類
public PropertyText(PropertyEditor pe) {
	    super(pe.getAsText());
	    editor = pe;
	    addKeyListener(this);
	    addFocusListener(this);
	    editor.addPropertyChangeListener(this);
//    	setBorder(PropertySheet.EMPTY_BORDER);
    }
 
開發者ID:etomica,項目名稱:etomica,代碼行數:9,代碼來源:PropertyText.java

示例7: onCustomEditorButton

import java.beans.PropertyEditor; //導入方法依賴的package包/類
/**  Returns true if a mouse event occured over the custom editor button.
 *   This is used to supply button specific tooltips and launch the custom
 *   editor without needing to instantiate a real button */
private boolean onCustomEditorButton(MouseEvent e) {
    //see if we're in the approximate bounds of the custom editor button
    Point pt = e.getPoint();
    int row = rowAtPoint(pt);
    int col = columnAtPoint(pt);
    FeatureDescriptor fd = getSheetModel().getPropertySetModel().getFeatureDescriptor(row);
    if( null == fd ) {
        //prevent NPE when the activated Node has been destroyed and a new one hasn't been set yet
        return false;
    }

    //see if the event happened over the custom editor button
    boolean success;

    if (PropUtils.noCustomButtons) {
        //#41412 - impossible to invoke custom editor on props w/ no inline
        //edit mode if the no custom buttons switch is set
        success = false;
    } else {
        success = e.getX() > (getWidth() - PropUtils.getCustomButtonWidth());
    }

    //if it's a mouse button event, then we're not showing a tooltip, we're
    //deciding if we should display a custom editor.  For read-only props that
    //support one, we should return true, since clicking the non-editable cell
    //is not terribly useful.
    if (
        (e.getID() == MouseEvent.MOUSE_PRESSED) || (e.getID() == MouseEvent.MOUSE_RELEASED) ||
            (e.getID() == MouseEvent.MOUSE_CLICKED)
    ) {
        //We will show the custom editor for any click on the text value
        //of a property that looks editable but sets canEditAsText to false -
        //the click means the user is trying to edit something, so to just
        //swallow the gesture is confusing
        success |= Boolean.FALSE.equals(fd.getValue("canEditAsText"));

        if (!success && fd instanceof Property) {
            PropertyEditor pe = PropUtils.getPropertyEditor((Property) fd);

            if ((pe != null) && pe.supportsCustomEditor()) {
                //Undocumented but used in Studio - in NB 3.5 and earlier, returning null from getAsText()
                //was a way to make a property non-editable
                success |= (pe.isPaintable() && (pe.getAsText() == null) && (pe.getTags() == null));
            }
        }
    }

    try {
        if (success) { //NOI18N

            if (fd instanceof Property && (col == 1)) {
                boolean supp = PropUtils.getPropertyEditor((Property) fd).supportsCustomEditor();

                return (supp);
            }
        }
    } catch (IllegalStateException ise) {
        //See bugtraq 4941073 - if a property accessed via Reflection throws
        //an unexpected exception (try customize bean on a vanilla GenericServlet
        //to produce this) when the getter is accessed, then we are already
        //displaying "Error fetching property value" in the value area of
        //the propertysheet.  No point in distracting the user with a 
        //stack trace - it's not our bug.
        Logger.getLogger(SheetTable.class.getName()).log(Level.WARNING, null, ise);
    }

    return false;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:72,代碼來源:SheetTable.java


注:本文中的java.beans.PropertyEditor.getAsText方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。