KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > swt > IFocusService


1 /*******************************************************************************
2  * Copyright (c) 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  ******************************************************************************/

11
12 package org.eclipse.ui.swt;
13
14 import org.eclipse.swt.widgets.Control;
15
16 /**
17  * Tracks focusGained and focusLost events for a Control registered with this
18  * service, and provides the control and its registered ID as variables to the
19  * application evaluation context for evaluation be the various services.
20  * <p>
21  * This service provides 2 variables, activeFocusControl (a Control) and
22  * activeFocusControlId (the ID registered with the service).
23  * </p>
24  * <p>
25  * You can use this service to provide default cut/copy/paste/selectAll for
26  * specific text controls outside of the normal workbench part lifecycle, like a
27  * control contributed to the trim. For example:
28  * </p>
29  * <p>
30  *
31  * <pre>
32  * &lt;handler
33  * class=&quot;org.eclipse.ui.internal.handlers.WidgetMethodHandler:paste&quot;
34  * commandId=&quot;org.eclipse.ui.edit.paste&quot;&gt;
35  * &lt;activeWhen&gt;
36  * &lt;with variable=&quot;activeFocusControlId&quot;&gt;
37  * &lt;equals value=&quot;org.eclipse.ui.tests.focusText&quot;/&gt;
38  * &lt;/with&gt;
39  * &lt;/activeWhen&gt;
40  * &lt;/handler&gt;
41  * </pre>
42  *
43  * </p>
44  *
45  * @see org.eclipse.ui.ISources
46  * @since 3.3
47  */

48 public interface IFocusService {
49     /**
50      * Use the value to provide default copy behaviour in a handler element
51      * class attribute.
52      */

53     public static final String JavaDoc COPY_HANDLER = "org.eclipse.ui.internal.handlers.WidgetMethodHandler:copy"; //$NON-NLS-1$
54

55     /**
56      * Use the value to provide default paste behaviour in a handler element
57      * class attribute.
58      */

59     public static final String JavaDoc PASTE_HANDLER = "org.eclipse.ui.internal.handlers.WidgetMethodHandler:paste"; //$NON-NLS-1$
60

61     /**
62      * Use the value to provide default cut behaviour in a handler element class
63      * attribute.
64      */

65     public static final String JavaDoc CUT_HANDLER = "org.eclipse.ui.internal.handlers.WidgetMethodHandler:cut"; //$NON-NLS-1$
66

67     /**
68      * Use the value to provide default select all behaviour in a handler
69      * element class attribute.
70      */

71     public static final String JavaDoc SELECT_ALL_HANDLER = "org.eclipse.ui.internal.handlers.SelectAllHandler"; //$NON-NLS-1$
72

73     /**
74      * A Control for which the service will track focus. When in focus, this
75      * Control and its ID will be provided as variables to core expressions for
76      * the various services, as activeFocusControl and activeFocusControlId
77      * respectively.
78      * <p>
79      * A control must only be registered once, but different controls can be
80      * registered with the same ID. Expressions evaluated against the
81      * activeFocusControlId would then be true for all of the controls thus
82      * registered.
83      * </p>
84      * <p>
85      * We will remove ourselves as a listener when the Control is disposed.
86      * </p>
87      *
88      * @param control
89      * the control. Must not be <code>null</code>. If the control
90      * is already registered with this service this call is a no-op.
91      * @param id
92      * an ID for this control. Must not be <code>null</code>.
93      */

94     public void addFocusTracker(Control control, String JavaDoc id);
95
96     /**
97      * No longer track focus events for this control. Use this method when the
98      * control should no longer be tracked, but is not disposed.
99      *
100      * @param control
101      * the control registered with the service. Must not be
102      * <code>null</code>.
103      */

104     public void removeFocusTracker(Control control);
105 }
106
Popular Tags