public JComponent createEmbeddedPropertyGUI ( String prefix , Properties props , Properties info ) { if ( Debug . debugging ( "inspectordetail" ) ) { Debug . output ( "Inspector creating GUI for " + prefix + "\nPROPERTIES " + props + "\nPROP INFO " + info ) ; } String propertyList = info . getProperty ( PropertyConsumer . initPropertiesProperty ) ; Vector < String > sortedKeys ; if ( propertyList != null ) { Vector < String > propertiesToShow = PropUtils . parseSpacedMarkers ( propertyList ) ; for ( int i = 0 ; i < propertiesToShow . size ( ) ; i ++ ) { propertiesToShow . set ( i , prefix + "." + propertiesToShow . get ( i ) ) ; } sortedKeys = propertiesToShow ; } else { sortedKeys = sortKeys ( props . keySet ( ) ) ; } editors = new Hashtable < String , PropertyEditor > ( sortedKeys . size ( ) ) ; JPanel component = new JPanel ( ) ; component . setLayout ( new BorderLayout ( ) ) ; JPanel propertyPanel = new JPanel ( ) ; GridBagLayout gridbag = new GridBagLayout ( ) ; GridBagConstraints c = new GridBagConstraints ( ) ; c . insets = new Insets ( 2 , 10 , 2 , 10 ) ; propertyPanel . setLayout ( gridbag ) ; int i = 0 ; for ( String prop : sortedKeys ) { String marker = prop ; if ( prefix != null && prop . startsWith ( prefix ) ) { marker = prop . substring ( prefix . length ( ) + 1 ) ; } if ( marker . startsWith ( "." ) ) { marker = marker . substring ( 1 ) ; } String editorMarker = marker + PropertyConsumer . ScopedEditorProperty ; String editorClass = info . getProperty ( editorMarker ) ; if ( editorClass == null ) { editorClass = defaultEditorClass ; } Class < ? > propertyEditorClass = null ; PropertyEditor editor = null ; try { propertyEditorClass = Class . forName ( editorClass ) ; editor = ( PropertyEditor ) propertyEditorClass . newInstance ( ) ; if ( editor instanceof PropertyConsumer ) { ( ( PropertyConsumer ) editor ) . setProperties ( marker , info ) ; } editors . put ( prop , editor ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; editorClass = null ; } Component editorFace = null ; if ( editor != null && editor . supportsCustomEditor ( ) ) { editorFace = editor . getCustomEditor ( ) ; } else { editorFace = new JLabel ( i18n . get ( Inspector . class , "Does_not_support_custom_editor" , "Does not support custom editor" ) ) ; } if ( editor != null ) { Object propVal = props . get ( prop ) ; if ( Debug . debugging ( "inspector" ) ) { Debug . output ( "Inspector loading " + prop + "(" + propVal + ")" ) ; } editor . setValue ( propVal ) ; } String labelMarker = marker + PropertyConsumer . LabelEditorProperty ; String labelText = info . getProperty ( labelMarker ) ; if ( labelText == null ) { labelText = marker ; } JLabel label = new JLabel ( labelText + ":" ) ; label . setHorizontalAlignment ( SwingConstants . RIGHT ) ; c . gridx = 0 ; c . gridy = i ++ ; c . weightx = 0 ; c . fill = GridBagConstraints . NONE ; c . anchor = GridBagConstraints . EAST ; gridbag . setConstraints ( label , c ) ; propertyPanel . add ( label ) ; c . gridx = 1 ; c . anchor = GridBagConstraints . WEST ; c . fill = GridBagConstraints . HORIZONTAL ; c . weightx = 1f ; gridbag . setConstraints ( editorFace , c ) ; propertyPanel . add ( editorFace ) ; String toolTip = ( String ) info . get ( marker ) ; label . setToolTipText ( toolTip == null ? i18n . get ( Inspector . class , "No_further_information_available" , "No further information available." ) : toolTip ) ; } JScrollPane scrollPane = new JScrollPane ( propertyPanel , ScrollPaneConstants . VERTICAL_SCROLLBAR_AS_NEEDED , ScrollPaneConstants . HORIZONTAL_SCROLLBAR_NEVER ) ; scrollPane . setBorder ( null ) ; scrollPane . setAlignmentY ( Component . TOP_ALIGNMENT ) ; component . add ( scrollPane , BorderLayout . CENTER ) ; return component ; }
Creates a JComponent with the properties to be changed . This component is suitable for inclusion into a GUI . Do n't use this method directly ! Use the createPropertyGUI ( PropertyConsumer ) instead . You will get a NullPointerException if you use this method without setting the PropertyConsumer in the Inspector .