KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > ISelectionService


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 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 package org.eclipse.ui;
12
13 import org.eclipse.jface.viewers.ISelection;
14
15 /**
16  * A selection service tracks the selection within an object.
17  * <p>
18  * A listener that wants to be notified when the selection becomes
19  * <code>null</code> must implement the <code>INullSelectionListener</code>
20  * interface.
21  * </p>
22  * <p>
23  * This interface is not intended to be implemented by clients.
24  * </p>
25  * @see org.eclipse.ui.ISelectionListener
26  * @see org.eclipse.ui.INullSelectionListener
27  */

28 public interface ISelectionService {
29     /**
30      * Adds the given selection listener.
31      * Has no effect if an identical listener is already registered.
32      *
33      * @param listener a selection listener
34      */

35     public void addSelectionListener(ISelectionListener listener);
36
37     /**
38      * Adds a part-specific selection listener which is notified when selection changes
39      * in the part with the given id. This is independent of part activation - the part
40      * need not be active for notification to be sent.
41      * <p>
42      * When the part is created, the listener is passed the part's initial selection.
43      * When the part is disposed, the listener is passed a <code>null</code> selection,
44      * but only if the listener implements <code>INullSelectionListener</code>.
45      * </p>
46      * <p>
47      * Note: This will not correctly track editor parts as each editor does
48      * not have a unique partId.
49      * </p>
50      *
51      * @param partId the id of the part to track
52      * @param listener a selection listener
53      * @since 2.0
54      */

55     public void addSelectionListener(String JavaDoc partId, ISelectionListener listener);
56
57     /**
58      * Adds the given post selection listener.It is equivalent to selection
59      * changed if the selection was triggered by the mouse but it has a
60      * delay if the selection is triggered by the keyboard arrows.
61      * Has no effect if an identical listener is already registered.
62      *
63      * Note: Works only for StructuredViewer(s).
64      *
65      * @param listener a selection listener
66      */

67     public void addPostSelectionListener(ISelectionListener listener);
68
69     /**
70      * Adds a part-specific selection listener which is notified when selection changes
71      * in the part with the given id. This is independent of part activation - the part
72      * need not be active for notification to be sent.
73      * <p>
74      * When the part is created, the listener is passed the part's initial selection.
75      * When the part is disposed, the listener is passed a <code>null</code> selection,
76      * but only if the listener implements <code>INullSelectionListener</code>.
77      * </p>
78      * <p>
79      * Note: This will not correctly track editor parts as each editor does
80      * not have a unique partId.
81      * </p>
82      *
83      * @param partId the id of the part to track
84      * @param listener a selection listener
85      * @since 2.0
86      */

87     public void addPostSelectionListener(String JavaDoc partId,
88             ISelectionListener listener);
89
90     /**
91      * Returns the current selection in the active part. If the selection in the
92      * active part is <em>undefined</em> (the active part has no selection provider)
93      * the result will be <code>null</code>.
94      *
95      * @return the current selection, or <code>null</code> if undefined
96      */

97     public ISelection getSelection();
98
99     /**
100      * Returns the current selection in the part with the given id. If the part is not open,
101      * or if the selection in the active part is <em>undefined</em> (the active part has no selection provider)
102      * the result will be <code>null</code>.
103      *
104      * @param partId the id of the part
105      * @return the current selection, or <code>null</code> if undefined
106      * @since 2.0
107      */

108     public ISelection getSelection(String JavaDoc partId);
109
110     /**
111      * Removes the given selection listener.
112      * Has no effect if an identical listener is not registered.
113      *
114      * @param listener a selection listener
115      */

116     public void removeSelectionListener(ISelectionListener listener);
117
118     /**
119      * Removes the given part-specific selection listener.
120      * Has no effect if an identical listener is not registered for the given part id.
121      *
122      * @param partId the id of the part to track
123      * @param listener a selection listener
124      * @since 2.0
125      */

126     public void removeSelectionListener(String JavaDoc partId,
127             ISelectionListener listener);
128
129     /**
130      * Removes the given post selection listener.
131      * Has no effect if an identical listener is not registered.
132      *
133      * @param listener a selection listener
134      */

135     public void removePostSelectionListener(ISelectionListener listener);
136
137     /**
138      * Removes the given part-specific post selection listener.
139      * Has no effect if an identical listener is not registered for the given part id.
140      *
141      * @param partId the id of the part to track
142      * @param listener a selection listener
143      * @since 2.0
144      */

145     public void removePostSelectionListener(String JavaDoc partId,
146             ISelectionListener listener);
147 }
148
Popular Tags