1 11 package org.eclipse.ui.internal.texteditor; 12 13 import java.util.ResourceBundle ; 14 15 import org.eclipse.core.runtime.Assert; 16 17 import org.eclipse.jface.preference.IPreferenceStore; 18 import org.eclipse.ui.texteditor.IUpdate; 19 import org.eclipse.ui.texteditor.ResourceAction; 20 21 25 public class BooleanPreferenceToggleAction extends ResourceAction implements IUpdate { 26 27 private final String fKey; 28 private final IPreferenceStore fPreferences; 29 30 public BooleanPreferenceToggleAction(ResourceBundle bundle, String prefix, int style, IPreferenceStore preferences, String key) { 31 super(bundle, prefix, style); 32 Assert.isLegal(preferences != null); 33 Assert.isLegal(key != null); 34 fPreferences= preferences; 35 fKey= key; 36 37 update(); 38 } 39 40 43 public void update() { 44 setChecked(fPreferences.getBoolean(fKey)); 45 } 46 47 50 public void run() { 51 boolean state= fPreferences.getBoolean(fKey); 52 fPreferences.setValue(fKey, !state); 53 } 54 } 55 | Popular Tags |