当前位置: 首页>>代码示例>>Java>>正文


Java PropertyEditor.supportsCustomEditor方法代码示例

本文整理汇总了Java中java.beans.PropertyEditor.supportsCustomEditor方法的典型用法代码示例。如果您正苦于以下问题:Java PropertyEditor.supportsCustomEditor方法的具体用法?Java PropertyEditor.supportsCustomEditor怎么用?Java PropertyEditor.supportsCustomEditor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.beans.PropertyEditor的用法示例。


在下文中一共展示了PropertyEditor.supportsCustomEditor方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: openCustomEditor

import java.beans.PropertyEditor; //导入方法依赖的package包/类
private boolean openCustomEditor(ActionEvent e) {
    if (getSelectedRowCount() != 1 || getSelectedColumnCount() != 1) {
        return false;
    }
    int row = getSelectedRow();
    if (row < 0) return false;
    int column = getSelectedColumn();
    if (column < 0) return false;
    Object o = getValueAt(row, column);
    if (!(o instanceof Node.Property)) {
        return false;
    }
    Node.Property p = (Node.Property) o;
    if (!Boolean.TRUE.equals(p.getValue("suppressCustomEditor"))) { //NOI18N
        PropertyPanel panel = new PropertyPanel(p);
        @SuppressWarnings("deprecation")
        PropertyEditor ed = panel.getPropertyEditor();

        if ((ed != null) && ed.supportsCustomEditor()) {
            Action act = panel.getActionMap().get("invokeCustomEditor"); //NOI18N

            if (act != null) {
                act.actionPerformed(null);

                return true;
            }
        }
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:OutlineView.java

示例2: 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

示例3: setPropertyEditor

import java.beans.PropertyEditor; //导入方法依赖的package包/类
private void setPropertyEditor(PropertyEditor editor) {
    if (this.editor != null) {
        detachFromPropertyEditor(this.editor);

        //set ignore changes even so - we may get the same property editor
        //again, in which case we're still listening to it
        ignoreChanges = true;
    }

    this.editor = editor;

    try {
        if (editor != null) {
            if (!editor.supportsCustomEditor()) {
                Class<?> type = prop.getValueType();
                throw new IllegalArgumentException(
                    "#177688: property editor " + editor + " for property " + prop +
                    " does not support a custom editor; valueType=" + type.getName() +
                    "; PropertyEditorManager says: " + PropertyEditorManager.findEditor(type) +
                    "; search path is: " + Arrays.toString(PropertyEditorManager.getEditorSearchPath()) +
                    "; CCL: " + Thread.currentThread().getContextClassLoader()
                );
            }

            try {
                originalValue = editor.getValue();
            } catch (Exception e) {
                //dve or other, don't worry
            }

            //Issue 39437 - PropertyPanel in custom editor mode
            //expects a PropertyEnv even if the editor is not
            //an ExPropertyEditor.
            PropertyEnv env = new PropertyEnv();

            //Use the hack to access the real underlying FD, for, e.g.,
            //core.projects.FileStateEditor
            env.setFeatureDescriptor(EditorPropertyDisplayer.findFeatureDescriptor(this));
            setPropertyEnv(env);

            if (editor instanceof ExPropertyEditor) {
                ((ExPropertyEditor) editor).attachEnv(env);
            }

            attachToPropertyEditor(editor);
        }
    } finally {
        ignoreChanges = false;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:51,代码来源:CustomEditorDisplayer.java

示例4: getRenderer

import java.beans.PropertyEditor; //导入方法依赖的package包/类
/** Get a renderer component appropriate to a given property */
public JComponent getRenderer(Property prop) {
    mdl.setProperty(prop);
    env.reset();

    PropertyEditor editor = preparePropertyEditor(mdl, env);

    if (editor instanceof ExceptionPropertyEditor) {
        return getExceptionRenderer((Exception) editor.getValue());
    }

    JComponent result = null;

    try {
        if (editor.isPaintable()) {
            result = prepareString(editor, env);
        } else {
            Class c = mdl.getPropertyType();

            if ((c == Boolean.class) || (c == boolean.class)) {
                //Special handling for hinting for org.netbeans.beaninfo.BoolEditor
                boolean useRadioRenderer = useRadioBoolean ||
                    (env.getFeatureDescriptor().getValue("stringValues") != null); //NOI18N

                if (useRadioRenderer) {
                    result = prepareRadioButtons(editor, env);
                } else {
                    result = prepareCheckbox(editor, env);
                }
            } else if (editor.getTags() != null) {
                String[] s = editor.getTags();
                boolean editAsText = Boolean.TRUE.equals(prop.getValue("canEditAsText"));

                if ((s.length <= radioButtonMax) && !editAsText) {
                    result = prepareRadioButtons(editor, env);
                } else {
                    result = prepareCombobox(editor, env);
                }
            } else {
                result = prepareString(editor, env);
            }
        }

        if ((result != radioRenderer) && (result != textFieldRenderer)) {
            if ((result != checkboxRenderer) && tableUI && !(result instanceof JComboBox)) {
                result.setBorder(BorderFactory.createEmptyBorder(0, 3, 0, 0));
            } else if ((result instanceof JComboBox) && tableUI) {
                result.setBorder(BorderFactory.createEmptyBorder());
            } else if (!(result instanceof JComboBox) && (!(result instanceof JCheckBox))) {
                result.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 0));
            }
        }
    } catch (Exception e) {
        result = getExceptionRenderer(e);
        Logger.getLogger(RendererFactory.class.getName()).log(Level.WARNING, null, e);
    }

    result.setEnabled(prop.canWrite());

    boolean propRequestsSuppressButton = Boolean.TRUE.equals(prop.getValue("suppressCustomEditor")); //NOI18N

    if (
        !(result instanceof JLabel) &&
            ((env.getState() == env.STATE_INVALID) || (prop.getValue("valueIcon") != null))
    ) { //NOI18N
        result = prepareIconPanel(editor, env, (InplaceEditor) result);
    }

    /* If we need a custom editor button, embed the resulting component in
     an instance of ButtonPanel and return that */
    if (
        editor.supportsCustomEditor() && !PropUtils.noCustomButtons && !suppressButton &&
            !propRequestsSuppressButton
    ) {
        ButtonPanel bp = buttonPanel();
        bp.setInplaceEditor((InplaceEditor) result);
        result = bp;
    }

    return result;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:82,代码来源:RendererFactory.java


注:本文中的java.beans.PropertyEditor.supportsCustomEditor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。