1 19 20 package org.netbeans.modules.editor.options; 21 22 import java.awt.*; 23 import java.beans.*; 24 import java.util.HashMap ; 25 import javax.swing.event.*; 26 27 import org.netbeans.editor.Coloring; 28 import org.openide.explorer.propertysheet.PropertyPanel; 30 import org.openide.util.HelpCtx; 31 import org.openide.util.NbBundle; 32 33 41 42 public class ColoringArrayEditor extends PropertyEditorSupport { 43 44 private ColoringArrayEditorPanel editor; 45 46 private static final String HELP_ID = "editing.fontsandcolors"; 48 public boolean supportsCustomEditor() { 49 return true; 50 } 51 52 public String getAsText() { 53 return NbBundle.getMessage( ColoringArrayEditor.class, "PROP_Coloring" ); } 55 56 public java.awt.Component getCustomEditor() { 57 if( editor == null ) { 58 editor = new ColoringArrayEditorPanel(); 59 HelpCtx.setHelpIDString( editor, getHelpCtx().getHelpID() ); 60 refreshEditor(); 61 editor.addPropertyChangeListener( new PropertyChangeListener() { 62 public void propertyChange( PropertyChangeEvent evt ) { 63 if( "value".equals( evt.getPropertyName() ) ) setValue( editor.getValue() ); } 65 }); 66 } 67 return editor; 68 } 69 70 protected HelpCtx getHelpCtx () { 71 return new HelpCtx (HELP_ID); 72 } 73 74 public void setAsText( String s ) { 75 return; 76 } 77 78 public void setValue( Object obj ) { 79 Object oldValue = getValue(); 80 if( (obj != null) && (! obj.equals( oldValue ) ) ) { 81 super.setValue( obj ); 82 if( ( editor != null ) && (! editor.getValue().equals( getValue() ) ) ) { 83 refreshEditor(); 84 } 85 } 86 } 87 88 private void refreshEditor() { 89 if( editor != null ) { 90 editor.setValue( (HashMap )getValue() ); 91 } 92 } 93 } 94 | Popular Tags |