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

📄 defaultdeviceeditoractiondelegate.java

📁 eclipseme的最新版本的source,欢迎j2me程序员使用
💻 JAVA
字号:
/**
 * Copyright (c) 2003-2006 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;

import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IActionDelegate;
import org.eclipse.ui.PlatformUI;

import eclipseme.core.model.impl.AbstractDevice;
import eclipseme.ui.internal.device.editor.DeviceEditorDialog;

/**
 * An action delegate implementation that opens the default
 * device editor implementation.
 * <p />
 * Copyright (c) 2003-2006 Craig Setera<br>
 * All Rights Reserved.<br>
 * Licensed under the Eclipse Public License - v 1.0<p/>
 * <br>
 * $Revision: 1.1 $
 * <br>
 * $Date: 2006/02/25 01:55:03 $
 * <br>
 * @author Craig Setera
 */
public class DefaultDeviceEditorActionDelegate implements IActionDelegate {
	private AbstractDevice device;
	
	/**
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
	 */
	public void run(IAction action) {
		Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
		
		DeviceEditorDialog dialog = getDeviceEditorDialog(shell);
		dialog.setDevice(device);
		dialog.open();
	}

	/**
	 * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
	 */
	public void selectionChanged(IAction action, ISelection selection) {
		device = null;
		
		if (selection instanceof IStructuredSelection) {
			IStructuredSelection ss = (IStructuredSelection) selection;
			if (ss.size() == 1) {
				Object obj = ss.getFirstElement();
				if (obj instanceof AbstractDevice) {
					device = (AbstractDevice) obj;
				}
			}
		}
		
		action.setEnabled(device != null);
	}
	
	/**
	 * Return the dialog to be used for editing the dialog.
	 * @param shell
	 * @return
	 */
	protected DeviceEditorDialog getDeviceEditorDialog(Shell shell) {
		return new DeviceEditorDialog(shell);
	}
}

⌨️ 快捷键说明

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