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

📄 signaturepasswordhandler.java

📁 eclipseme的最新版本的source,欢迎j2me程序员使用
💻 JAVA
字号:
/*
 ********************************************************************
 *
 *	Filename    :   SignaturePasswordHandler.java
 *  Package		:	eclipseme.ui.internal.statusHandlers
 *	System      :   eclipseme.ui
 *	Author      :   Kevin Hunter
 *	Description :   "Status handler" designed to prompt the user
 *					for passwords for signing.
 *	                
 *
 * Copyright (c) 2004 Kevin Hunter
 * All Rights Reserved.
 * Licensed under the Eclipse Public License - v 1.0
 * For more information see http://www.eclipse.org/legal/epl-v10.html
 *
 *	CVS
 *	$$Source: /cvsroot/eclipseme/eclipseme.ui/src/eclipseme/ui/internal/statusHandlers/SignaturePasswordHandler.java,v $$
 *	$$Author: setera $$
 *	$$Date: 2005/10/29 15:39:34 $$
 *	$$Revision: 1.2 $$
 *
 ********************************************************************
 */

package eclipseme.ui.internal.statusHandlers;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.debug.core.IStatusHandler;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

import eclipseme.core.signing.SignaturePasswords;
import eclipseme.ui.internal.dialog.SigningPasswordsDialog;

/**
 * This class is a bit of a hack.  Status handlers normally are used to
 * report status back to the user.  This one is used to actually prompt
 * the user for passwords as required.  The 
 * eclipseme.core.internal.signing.SignatureUtils class calls this
 * through the status handler mechanism when it needs to obtain passwords
 * from the user.
 * 
 */
public class SignaturePasswordHandler implements IStatusHandler
{
	/**
	 * @see org.eclipse.debug.core.IStatusHandler#handleStatus(org.eclipse.core.runtime.IStatus, java.lang.Object)
	 */
	public Object handleStatus(final IStatus status, Object source)
	{
		Display display = Display.getCurrent();
		
		DialogRunner runner = new DialogRunner((IProject)source);
		
		display.syncExec(runner);
		
		return(runner.getPasswords());
	}
	
	private class DialogRunner implements Runnable
	{
		IProject 			project;
		SignaturePasswords	passwords;
		
		public DialogRunner(IProject project)
		{
			this.project = project;
		}
		
		public void run()
		{
			Display display = Display.getCurrent();
			Shell shell = display.getActiveShell();
			if (shell == null)
			{
				shell = new Shell(display, SWT.NONE);
			}
			
			SigningPasswordsDialog dlg = new SigningPasswordsDialog(shell, project);
			if (dlg.open() != IDialogConstants.OK_ID)
			{
				passwords = null;
			}
			else
			{
				passwords = new SignaturePasswords();
				passwords.setKeystorePassword(dlg.getKeystorePassword());
				passwords.setKeyPassword(dlg.getKeyPassword());
			}
		}
		
		public SignaturePasswords getPasswords()
		{
			return(passwords);
		}
	}
}

/*
 ********************************************************************
 *	CVS History:
 *	$$Log: SignaturePasswordHandler.java,v $
 *	$Revision 1.2  2005/10/29 15:39:34  setera
 *	$Refactor packaging and signing functionality into their own packages
 *	$Warn user while trying to package a project with an invalid platform definition (Bug 1304273)
 *	$
 *	$Revision 1.1  2004/11/27 21:35:05  kdhunter
 *	$Signature handler to prompt for passwords
 *	$$
 *
 ********************************************************************
 */

⌨️ 快捷键说明

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