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

📄 jarselectionvalidator.java

📁 eclipseme的最新版本的source,欢迎j2me程序员使用
💻 JAVA
字号:
/**
 * Copyright (c) 2003-2005 Craig Setera
 * All Rights Reserved.
 * Licensed under the Eclipse Public License - v 1.0
 * For more information see http://www.eclipse.org/legal/epl-v10.html
 */
package eclipseme.ui.internal.utils;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.ui.dialogs.ISelectionStatusValidator;

import eclipseme.ui.IEclipseMEUIConstants;

/**
 * Viewer selection validator for jar/zip files.
 * <p />
 * Copyright (c) 2003-2005 Craig Setera<br>
 * All Rights Reserved.<br>
 * Licensed under the Eclipse Public License - v 1.0<p/>
 * <br>
 * $Revision: 1.2 $
 * <br>
 * $Date: 2005/07/07 02:36:26 $
 * <br>
 * @author Craig Setera
 */
/**
 * The selection validator for the jar file dialog.
 */
public class JARSelectionValidator implements ISelectionStatusValidator {
	private IStatus okStatus = new Status(
		IStatus.OK, 
		IEclipseMEUIConstants.PLUGIN_ID,
		0,
		"",
		null);
		
	private IStatus errorStatus = new Status(
		IStatus.ERROR, 
		IEclipseMEUIConstants.PLUGIN_ID,
		0,
		"",
		null);
		
	/**
	 * @see org.eclipse.ui.dialogs.ISelectionStatusValidator#validate(java.lang.Object[])
	 */
	public IStatus validate(Object[] selection) {
		return isValid(selection) ? okStatus : errorStatus;
	}

	/**
	 * Return a booelan indicating whether the specified selection is valid.
	 * 
	 * @param selection
	 * @return
	 */
	protected boolean isValid(Object[] selection) {
		boolean valid = true;
		
		if (selection.length > 0) {
			for (int i = 0; i < selection.length; i++) {
				Object object = selection[i];
				if (!IFile.class.isInstance(object)) {
					valid = false;
					break;
				}
			}
		} else {
			valid = false;
		}
		
		return valid;
	}
}

⌨️ 快捷键说明

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