sameshellprovider.java

来自「jfa2ce 源码帮助开发人员更好的理解运用」· Java 代码 · 共 50 行

JAVA
50
字号
/******************************************************************************* * Copyright (c) 2000, 2005 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: *     IBM Corporation - initial API and implementation *******************************************************************************/package org.eclipse.jface.window;import org.eclipse.swt.widgets.Control;import org.eclipse.swt.widgets.Shell;/** * Standard shell provider that always returns the shell containing the given * control. This will always return the correct shell for the control, even if * the control is reparented. *  * @since 3.1 */public class SameShellProvider implements IShellProvider {    private Control targetControl;        /**     * Returns a shell provider that always returns the current     * shell for the given control.     *      * @param targetControl control whose shell will be tracked, or null if getShell() should always     * return null     */    public SameShellProvider(Control targetControl) {        this.targetControl = targetControl;    }        /* (non-javadoc)     * @see IShellProvider#getShell()     */    public Shell getShell() {        if (targetControl instanceof Shell) {            return (Shell)targetControl;        }                return targetControl == null? null :targetControl.getShell();    }}

⌨️ 快捷键说明

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