1 19 20 package org.netbeans.modules.subversion.ui.status; 21 22 import org.openide.util.NbBundle; 23 import org.openide.util.HelpCtx; 24 import org.openide.util.actions.SystemAction; 25 import org.openide.awt.DynamicMenuContent; 26 import org.openide.awt.Mnemonics; 27 import org.netbeans.modules.subversion.SvnModuleConfig; 28 29 import javax.swing.*; 30 import java.awt.event.ActionEvent ; 31 import java.util.prefs.Preferences ; 32 33 38 public class ShowTextAnnotationsAction extends SystemAction implements DynamicMenuContent { 39 40 private JCheckBoxMenuItem [] menuItems; 41 42 public JComponent[] getMenuPresenters() { 43 createItems(); 44 updateState(); 45 return menuItems; 46 } 47 48 public JComponent[] synchMenuPresenters(JComponent[] items) { 49 updateState(); 50 return items; 51 } 52 53 private void updateState() { 54 String taf = SvnModuleConfig.getDefault().getPreferences().get(SvnModuleConfig.PROP_TEXT_ANNOTATIONS_FORMAT, null); 55 menuItems[0].setSelected(taf != null); 56 } 57 58 private void createItems() { 59 if (menuItems == null) { 60 menuItems = new JCheckBoxMenuItem[1]; 61 menuItems[0] = new JCheckBoxMenuItem(this); 62 menuItems[0].setIcon(null); 63 Mnemonics.setLocalizedText(menuItems[0], NbBundle.getMessage(ShowTextAnnotationsAction.class, "CTL_MenuItem_ShowTextAnnotations")); 64 } 65 } 66 67 public String getName() { 68 return NbBundle.getMessage(ShowTextAnnotationsAction.class, "CTL_MenuItem_ShowTextAnnotations"); 69 } 70 71 public boolean isEnabled() { 72 return true; 73 } 74 75 public HelpCtx getHelpCtx() { 76 return new HelpCtx(ShowTextAnnotationsAction.class); 77 } 78 79 public void actionPerformed(ActionEvent e) { 80 Preferences prefs = SvnModuleConfig.getDefault().getPreferences(); 81 String taf = prefs.get(SvnModuleConfig.PROP_TEXT_ANNOTATIONS_FORMAT, null); 82 if (taf == null) { 83 prefs.put(SvnModuleConfig.PROP_TEXT_ANNOTATIONS_FORMAT, SvnModuleConfig.TEXT_ANNOTATIONS_FORMAT_DEFAULT); 84 } else { 85 prefs.remove(SvnModuleConfig.PROP_TEXT_ANNOTATIONS_FORMAT); 86 } 87 } 88 } 89 | Popular Tags |