1 19 20 package org.netbeans.modules.options.advanced; 21 22 import java.awt.BorderLayout ; 23 import java.awt.Dimension ; 24 import java.awt.event.ActionEvent ; 25 import java.awt.event.ActionListener ; 26 import java.util.Iterator ; 27 import javax.swing.JComponent ; 28 import javax.swing.JPanel ; 29 import javax.swing.JScrollPane ; 30 31 import org.netbeans.modules.options.ui.TabbedPanel; 32 import org.netbeans.spi.options.OptionsPanelController; 33 import org.openide.util.HelpCtx; 34 import org.openide.util.Lookup; 35 import org.openide.util.NbBundle; 36 import org.netbeans.modules.options.*; 37 38 39 44 public final class AdvancedPanel extends JPanel { 45 46 47 TabbedPanel tabbedPanel; 48 private final Model model = new Model (); 49 50 51 AdvancedPanel () {} 52 53 public void update () { 54 model.update (); 55 } 56 57 public void applyChanges () { 58 model.applyChanges (); 59 } 60 61 public void cancel () { 62 model.cancel (); 63 } 64 65 public HelpCtx getHelpCtx () { 66 return model.getHelpCtx (tabbedPanel.getSelectedComponent ()); 67 } 68 69 public boolean dataValid () { 70 return model.isValid (); 71 } 72 73 public boolean isChanged () { 74 return model.isChanged (); 75 } 76 77 public Lookup getLookup () { 78 return model.getLookup (); 79 } 80 81 void init (Lookup masterLookup) { 82 tabbedPanel = new WhiteTabbedPanel (model, TabbedPanel.EXPAND_SOME); tabbedPanel.setBorder (null); 85 tabbedPanel.addActionListener (new ActionListener () { 86 public void actionPerformed (ActionEvent e) { 87 firePropertyChange (OptionsPanelController.PROP_HELP_CTX, null, null); 88 } 89 }); 90 JScrollPane scrollPane = new JScrollPane (tabbedPanel); 91 scrollPane.getVerticalScrollBar ().setUnitIncrement (20); 92 93 setLayout (new BorderLayout ()); 95 add (scrollPane, BorderLayout.CENTER); 96 97 int preferredWith = 0; 98 Iterator it = model.getCategories ().iterator (); 99 while (it.hasNext ()) { 100 String category = (String ) it.next (); 101 JComponent component = model.getPanel (category); 102 preferredWith = Math.max ( 103 preferredWith, 104 component.getPreferredSize ().width + 22 105 ); 106 } 107 setPreferredSize (new Dimension (preferredWith, 100)); 108 model.setLoookup (masterLookup); 109 } 110 } 111 | Popular Tags |