|
What this is
Other links
The source code/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun * Microsystems, Inc. All Rights Reserved. */ /* * InplaceEditorFactory.java * * Created on January 4, 2003, 4:52 PM */ package org.openide.explorer.propertysheet; import org.openide.explorer.propertysheet.editors.EnhancedPropertyEditor; import org.openide.nodes.Node.Property; import java.beans.PropertyEditor; import javax.swing.BorderFactory; import javax.swing.JComponent; /** Factory providing inplace editor implementations. Provides appropriate * InplaceEditor implementations, depending on the type of the property, the * results of PropertyEditor.getTags(), or any hinting provided by the property * editor or PropertyEnv to use a custom inplace editor implementation. * Configures the editor returned and attaches it to the property in question. * @author Tim Boudreau */ final class InplaceEditorFactory { private InplaceEditor checkbox=null; private InplaceEditor text=null; private InplaceEditor combo=null; private InplaceEditor radio=null; private ReusablePropertyEnv reusableEnv; private boolean tableUI; InplaceEditorFactory(boolean tableUI, ReusablePropertyEnv env) { this.tableUI=tableUI; this.reusableEnv = env; } int radioButtonMax = -1; /** Set a threshold number of tags below which a radio button, not a * combo box editor should be used */ void setRadioButtonMax (int i) { radioButtonMax = i; } private boolean useLabels=false; /** Set whether or not radio and checkbox editors should show the property * name */ void setUseLabels(boolean val) { useLabels = val; } private boolean useRadioBoolean = PropUtils.forceRadioButtons; void setUseRadioBoolean(boolean val) { useRadioBoolean = val; } /**Lazily create (or create a new instance of) the radio button editor */ private InplaceEditor getRadioEditor(boolean newInstance) { RadioInplaceEditor result; if (newInstance) { result = new RadioInplaceEditor(tableUI); } else { if (radio == null) { radio = new RadioInplaceEditor(tableUI); //Mainly for debugging ((JComponent) radio).setName("RadioEditor for " + getClass().getName() + "@" + System.identityHashCode(this)); //NOI18N } result = (RadioInplaceEditor) radio; } result.setUseTitle(useLabels); return result; } /**Lazily create (or create a new instance of) the combo box editor */ private InplaceEditor getComboBoxEditor(boolean newInstance) { if (newInstance) return new ComboInplaceEditor(tableUI); if (combo == null) { combo = new ComboInplaceEditor(tableUI); //Mainly for debugging ((JComponent) combo).setName("ComboInplaceEditor for " + getClass().getName() + "@" + System.identityHashCode(this)); //NOI18N } return combo; } /**Lazily create (or create a new instance of) the string editor */ private InplaceEditor getStringEditor(boolean newInstance) { if (newInstance) return new StringInplaceEditor(); if (text == null) { text = new StringInplaceEditor(); //Mainly for debugging ((JComponent) text).setName("StringEditor for " + getClass().getName() + "@" + System.identityHashCode(this)); //NOI18N } return text; } /**Lazily create (or create a new instance of) the checkbox editor */ private InplaceEditor getCheckboxEditor(boolean newInstance) { CheckboxInplaceEditor result; if (newInstance) { result = new CheckboxInplaceEditor(); } else { if (checkbox == null) { checkbox = new CheckboxInplaceEditor(); //Mainly for debugging ((JComponent) checkbox).setName("CheckboxEditor for " + getClass().getName() + "@" + System.identityHashCode(this)); //NOI18N } result = (CheckboxInplaceEditor) checkbox; } result.setUseTitle(useLabels); return (InplaceEditor) result; } /** Factory method that returns an appropriate inplace * editor for an object. Special handling is provided for * instances of Node.Property which can provide hints or * even their own legacy inplace editor implementation. * |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.