annotate org.eclipse.jface/src/org/eclipse/jface/window/SameShellProvider.d @ 12:bc29606a740c

Added dwt-addons in original directory structure of eclipse.org
author Frank Benoit <benoit@tionex.de>
date Sat, 14 Mar 2009 18:23:29 +0100
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
1 /*******************************************************************************
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
2 * Copyright (c) 2000, 2005 IBM Corporation and others.
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
3 * All rights reserved. This program and the accompanying materials
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
4 * are made available under the terms of the Eclipse Public License v1.0
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
5 * which accompanies this distribution, and is available at
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
6 * http://www.eclipse.org/legal/epl-v10.html
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
7 *
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
8 * Contributors:
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
9 * IBM Corporation - initial API and implementation
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
10 * Port to the D programming language:
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
11 * Frank Benoit <benoit@tionex.de>
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
12 *******************************************************************************/
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
13 module org.eclipse.jface.window.SameShellProvider;
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
14
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
15 import org.eclipse.swt.widgets.Control;
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
16 import org.eclipse.swt.widgets.Shell;
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
17
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
18 import org.eclipse.jface.window.IShellProvider;
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
19
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
20 import java.lang.all;
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
21
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
22 /**
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
23 * Standard shell provider that always returns the shell containing the given
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
24 * control. This will always return the correct shell for the control, even if
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
25 * the control is reparented.
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
26 *
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
27 * @since 3.1
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
28 */
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
29 public class SameShellProvider : IShellProvider {
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
30
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
31 private Control targetControl;
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
32
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
33 /**
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
34 * Returns a shell provider that always returns the current
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
35 * shell for the given control.
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
36 *
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
37 * @param targetControl control whose shell will be tracked, or null if getShell() should always
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
38 * return null
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
39 */
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
40 public this(Control targetControl) {
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
41 this.targetControl = targetControl;
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
42 }
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
43
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
44 /* (non-javadoc)
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
45 * @see IShellProvider#getShell()
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
46 */
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
47 public Shell getShell() {
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
48 if ( auto res = cast(Shell)targetControl ) {
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
49 return res;
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
50 }
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
51
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
52 return targetControl is null? null :targetControl.getShell();
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
53 }
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
54
bc29606a740c Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
55 }