/** * Save the checked state of the specified action in the Debug UI plugin's * preference store. The specified action is expected to be enabled and * support the style <code>IAction.AS_CHECK_BOX</code>. * * @param action the enabled, toggle action whose checked state will be * saved in preferences * @since 2.1 */ protected void saveCheckedActionState(IAction action) { String prefKey = generatePreferenceKey(action); IPreferenceStore prefStore = getPreferenceStore(); prefStore.setValue(prefKey, action.isChecked()); }
/** * Restores the persisted checked state of the specified action that was * stored in preferences. If the action is disabled, its persisted state * is not restored (because a disabled action cannot be run). * * @param action the action whose checked state will be restored * @since 2.1 */ protected void initActionState(IAction action) { String id = action.getId(); if (id != null && action.isEnabled()) { String prefKey = generatePreferenceKey(action); boolean checked = getPreferenceStore().getBoolean(prefKey); action.setChecked(checked); } }