⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 togglestate.java

📁 jfa2ce 源码帮助开发人员更好的理解运用
💻 JAVA
字号:
/******************************************************************************* * Copyright (c) 2005, 2006 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: *     IBM Corporation - initial API and implementation *******************************************************************************/package org.eclipse.jface.commands;import org.eclipse.jface.menus.IMenuStateIds;import org.eclipse.jface.preference.IPreferenceStore;/** * <p> * A piece of state storing a {@link Boolean}. * </p> * <p> * If this state is registered using {@link IMenuStateIds#STYLE}, then it will * control the presentation of the command if displayed in the menus, tool bars * or status line. * </p> * <p> * Clients may instantiate this class, but must not extend. * </p> *  * @since 3.2 */public class ToggleState extends PersistentState {	/**	 * Constructs a new <code>ToggleState</code>. By default, the toggle is	 * off (e.g., <code>false</code>).	 */	public ToggleState() {		setValue(Boolean.FALSE);	}	public final void load(final IPreferenceStore store,			final String preferenceKey) {		final boolean currentValue = ((Boolean) getValue()).booleanValue(); 		store.setDefault(preferenceKey, currentValue);		if (shouldPersist() && (store.contains(preferenceKey))) {			final boolean value = store.getBoolean(preferenceKey);			setValue(value ? Boolean.TRUE : Boolean.FALSE);		}	}	public final void save(final IPreferenceStore store,			final String preferenceKey) {		if (shouldPersist()) {			final Object value = getValue();			if (value instanceof Boolean) {				store.setValue(preferenceKey, ((Boolean) value).booleanValue());			}		}	}	public void setValue(final Object value) {		if (!(value instanceof Boolean)) {			throw new IllegalArgumentException(					"ToggleState takes a Boolean as a value"); //$NON-NLS-1$		}		super.setValue(value);	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -