KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jface > fieldassist > IControlContentAdapter


1 /*******************************************************************************
2  * Copyright (c) 2005, 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.jface.fieldassist;
12
13 import org.eclipse.swt.graphics.Rectangle;
14 import org.eclipse.swt.widgets.Control;
15
16 /**
17  * This interface is used to set and retrieve text content from an arbitrary
18  * control. Clients are expected to implement this interface when defining a
19  * {@link ContentProposalAdapter}, in order to specify how to retrieve and set
20  * the contents of the control being adapted.
21  *
22  * @since 3.2
23  */

24 public interface IControlContentAdapter {
25     /**
26      * Set the contents of the specified control to the specified text. Must not
27      * be <code>null</code>.
28      *
29      * @param control
30      * the control whose contents are to be set (replaced).
31      * @param contents
32      * the String specifying the new control content.
33      * @param cursorPosition
34      * the zero-based index representing the desired cursor position
35      * in the control's contents after the contents are set.
36      */

37     public void setControlContents(Control control, String JavaDoc contents,
38             int cursorPosition);
39
40     /**
41      * Insert the specified contents into the control's current contents. Must
42      * not be <code>null</code>.
43      *
44      * @param control
45      * the control whose contents are to be altered.
46      * @param contents
47      * the String to be inserted into the control contents.
48      * @param cursorPosition
49      * the zero-based index representing the desired cursor position
50      * within the inserted contents after the insertion is made.
51      */

52     public void insertControlContents(Control control, String JavaDoc contents,
53             int cursorPosition);
54
55     /**
56      * Get the text contents of the control.
57      *
58      * @param control
59      * the control whose contents are to be retrieved.
60      * @return the String contents of the control.
61      */

62     public String JavaDoc getControlContents(Control control);
63
64     /**
65      * Get the current cursor position in the control. The position is specified
66      * as a zero-based index into the string. Valid ranges are from 0 to N,
67      * where N is the size of the contents string. A value of N indicates that
68      * the cursor is at the end of the contents.
69      *
70      * @param control
71      * the control whose position is to be retrieved.
72      * @return the zero-based index representing the cursor position in the
73      * control's contents.
74      */

75     public int getCursorPosition(Control control);
76
77     /**
78      * Get the bounds (in pixels) of the insertion point for the control
79      * content. This is a rectangle, in coordinates relative to the control,
80      * where the insertion point is displayed. If the implementer does not have
81      * an insertion point, or cannot determine the location of the insertion
82      * point, it is appropriate to return the bounds of the entire control. This
83      * value may be used to position a content proposal popup.
84      *
85      * @param control
86      * the control whose offset is to be retrieved.
87      * @return the pixel width representing the distance between the edge of the
88      * control and the insertion point.
89      */

90     public Rectangle getInsertionBounds(Control control);
91
92     /**
93      * Set the current cursor position in the control. The position is specified
94      * as a zero-based index into the string. Valid ranges are from 0 to N,
95      * where N is the size of the contents string. A value of N indicates that
96      * the cursor is at the end of the contents.
97      *
98      * @param control
99      * the control whose cursor position is to be set.
100      * @param index
101      * the zero-based index representing the cursor position in the
102      * control's contents.
103      */

104     public void setCursorPosition(Control control, int index);
105 }
106
Popular Tags