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

📄 spellcheckerimages.java

📁 Eclipse高级编程3源码(书本源码)
💻 JAVA
字号:
/*******************************************************************************
 * 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 java.net.MalformedURLException;
import java.net.URL;

import org.eclipse.jface.action.IAction;
import org.eclipse.jface.resource.ImageDescriptor;

/**
 * Compilation of the images used in com.bdaum.SpellChecker plug-in.
 */
public class SpellCheckerImages {

	// Get URL for icon folder
	private static URL fgIconBaseURL = SpellCheckerPlugin.getDefault()
			.getBundle().getEntry("icons/");

	/**
	 * Filenames for the images in this registry
	 */

	public static final String IMG_IGNORE = "ignore.gif";

	public static final String IMG_IGNOREALL = "ignoreAll.gif";

	public static final String IMG_CANCEL = "cancel.gif";

	public static final String IMG_REPLACE = "replace.gif";

	public static final String IMG_REPLACEALL = "replaceAll.gif";

	public static final String IMG_ADDTODICTIONARY = "addToDictionary.gif";

	public static final String IMG_CHECK = "check.gif";

	/**
	 * Supply action with icons
	 * 
	 * @param action -
	 *            Action to be decorated
	 * @param type -
	 *            icon type
	 * @param relPath -
	 *            relative path of icon
	 */
	public static void setImageDescriptors(IAction action, String type,
			String relPath) {
		try {
			ImageDescriptor id = ImageDescriptor.createFromURL(makeIconFileURL(
					"full/d" + type, relPath));
			if (id != null)
				action.setDisabledImageDescriptor(id);
		} catch (MalformedURLException e) {
			SpellCheckerPlugin
					.logError(
							8,
							Messages
									.getString("SpellCheckerImages.Bad_URL_when_loading_disabled_image"),
							e);
		}
		try {
			ImageDescriptor id = ImageDescriptor.createFromURL(makeIconFileURL(
					"full/c" + type, relPath));
			if (id != null)
				action.setHoverImageDescriptor(id);
		} catch (MalformedURLException e) {
			SpellCheckerPlugin
					.logError(
							9,
							Messages
									.getString("SpellCheckerImages.Bad_URL_when_loading_hover_image"),
							e);
			action.setImageDescriptor(ImageDescriptor
					.getMissingImageDescriptor());
		}
	}

	// Construct URL for icon file
	private static URL makeIconFileURL(String prefix, String name)
			throws MalformedURLException {
		if (fgIconBaseURL == null)
			throw new MalformedURLException();
		return new URL(fgIconBaseURL, prefix + "/" + name);
	}
}

⌨️ 快捷键说明

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