1 9 package de.loskutov.bco.ui.actions; 10 11 import org.eclipse.jface.action.Action; 12 import org.eclipse.jface.preference.IPreferenceStore; 13 import org.eclipse.jface.util.IPropertyChangeListener; 14 import org.eclipse.ui.plugin.AbstractUIPlugin; 15 16 import de.loskutov.bco.BytecodeOutlinePlugin; 17 18 19 26 public class DefaultToggleAction extends Action { 27 28 private static final String ACTION = "action"; 29 private boolean isChecked; 30 31 public DefaultToggleAction(String id, IPropertyChangeListener listener) { 32 super(); 33 setId(id); 34 init(); 35 36 IPreferenceStore store = BytecodeOutlinePlugin.getDefault().getPreferenceStore(); 37 38 isChecked = store.getBoolean(id); 39 setChecked(isChecked); 40 addPropertyChangeListener(listener); 43 } 44 45 private void init(){ 46 setImageDescriptor(AbstractUIPlugin 47 .imageDescriptorFromPlugin( 48 BytecodeOutlinePlugin.getDefault().getBundle() 49 .getSymbolicName(), 50 BytecodeOutlinePlugin 51 .getResourceString(ACTION + "." + getId() + "." + IMAGE))); 52 53 setText(BytecodeOutlinePlugin 54 .getResourceString(ACTION + "." + getId() + "." + TEXT)); 55 setToolTipText(BytecodeOutlinePlugin 56 .getResourceString(ACTION + "." + getId() + "." + TOOL_TIP_TEXT)); 57 } 58 59 62 public void run() { 63 isChecked = !isChecked; 64 setChecked(isChecked); 65 } 66 } 67 | Popular Tags |