spellcheckconfiguration.java

来自「Eclipse 3高级编程一书源码」· Java 代码 · 共 69 行

JAVA
69
字号
/*******************************************************************************
 * Copyright (c) 2003 Berthold Daum. All rights reserved. This program and the
 * accompanying materials are made available under the terms of the Common
 * Public License v1.0 which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/cpl-v10.html
 * 
 * Contributors: Berthold Daum
 ******************************************************************************/
package com.bdaum.SpellChecker;

import org.eclipse.core.runtime.Preferences;

import com.bdaum.SpellChecker.preferences.SpellCheckerPreferences;
import com.swabunga.spell.engine.Configuration;

public class SpellCheckConfiguration extends Configuration {

	private static final String TRUE = "true";

	/**
	 * Fetch integer value from Preferences
	 * 
	 * @param key -
	 *            identification of value
	 * @return - value belonging to the key
	 */
	public int getInteger(String key) {
		try {
			return Integer.parseInt(getString(key));
		} catch (NumberFormatException e) {
			return 0;
		}
	}

	/**
	 * Fetch Boolean value from Preferences
	 * 
	 * @param key -
	 *            identification of value
	 * @return - value belonging to the key
	 */
	public boolean getBoolean(String key) {
		return TRUE.equals(getString(key));
	}

	/**
	 * Fetch string value from Properties or Preferences
	 * 
	 * @param key -
	 *            identification of value
	 * @return - value belonging to the key
	 */
	public String getString(String key) {
		SpellCheckerPreferences preferences = SpellCheckerPlugin.getManager()
				.getPreferences();
		Preferences prefs = preferences.getPluginPreferences();
		return prefs.getString(key);
	}

	/**
	 * All preferences are set via the PreferencePages. Therefore, the setXXX()
	 * implementation do nothing here.
	 */
	public void setInteger(String key, int value) {
	}

	public void setBoolean(String key, boolean value) {
	}
}

⌨️ 快捷键说明

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