1 19 20 package org.netbeans.modules.options.editor; 21 22 import java.beans.PropertyChangeListener ; 23 import javax.swing.JComponent ; 24 import org.netbeans.modules.options.codetemplates.CodeTemplatesPanelController; 25 import org.netbeans.modules.options.generaleditor.GeneralEditorPanelController; 26 import org.netbeans.modules.options.indentation.IndentationPanelController; 27 import org.netbeans.modules.options.macros.MacrosPanelController; 28 import org.netbeans.spi.options.OptionsPanelController; 29 import org.openide.util.HelpCtx; 30 import org.openide.util.Lookup; 31 32 33 38 public final class EditorPanelController extends OptionsPanelController { 39 40 private GeneralEditorPanelController general = new GeneralEditorPanelController (); 41 private IndentationPanelController indentation = new IndentationPanelController (); 42 private CodeTemplatesPanelController codeTemplates = new CodeTemplatesPanelController (); 43 private MacrosPanelController macros = new MacrosPanelController (); 44 45 46 public void update () { 47 general.update (); 48 indentation.update (); 49 codeTemplates.update (); 50 macros.update (); 51 } 52 53 public void applyChanges () { 54 general.applyChanges (); 55 indentation.applyChanges (); 56 codeTemplates.applyChanges (); 57 macros.applyChanges (); 58 } 59 60 public void cancel () { 61 general.cancel (); 62 indentation.cancel (); 63 codeTemplates.cancel (); 64 macros.cancel (); 65 } 66 67 public boolean isValid () { 68 if (!general.isValid ()) return false; 69 if (!indentation.isValid ()) return false; 70 if (!codeTemplates.isValid ()) return false; 71 if (!macros.isValid ()) return false; 72 return true; 73 } 74 75 public boolean isChanged () { 76 if (general.isChanged ()) return true; 77 if (indentation.isChanged ()) return true; 78 if (codeTemplates.isChanged ()) return true; 79 if (macros.isChanged ()) return true; 80 return false; 81 } 82 83 public HelpCtx getHelpCtx () { 84 return new HelpCtx ("netbeans.optionsDialog.editor"); 85 } 86 87 private EditorPanel editorPanel; 88 public JComponent getComponent (Lookup masterLookup) { 89 if (editorPanel == null) 90 editorPanel = new EditorPanel ( 91 general.getComponent (masterLookup), 92 indentation.getComponent (masterLookup), 93 codeTemplates.getComponent (masterLookup), 94 macros.getComponent (masterLookup) 95 ); 96 return editorPanel; 97 } 98 99 public void addPropertyChangeListener (PropertyChangeListener l) { 100 general.addPropertyChangeListener (l); 101 indentation.addPropertyChangeListener (l); 102 codeTemplates.addPropertyChangeListener (l); 103 macros.addPropertyChangeListener (l); 104 } 105 106 public void removePropertyChangeListener (PropertyChangeListener l) { 107 general.removePropertyChangeListener (l); 108 indentation.removePropertyChangeListener (l); 109 codeTemplates.removePropertyChangeListener (l); 110 macros.removePropertyChangeListener (l); 111 } 112 } 113 | Popular Tags |