View Javadoc

1   /*
2    * Copyright 1999-2006 Faculty of Mathematics, Physics
3    * and Informatics, Comenius University, Bratislava. This file is protected by
4    * the Mozilla Public License version 1.1 (the License); you may not use this
5    * file except in compliance with the License. You may obtain a copy of the
6    * License at http://euromath2.sourceforge.net/license.html Unless required by
7    * applicable law or agreed to in writing, software distributed under the
8    * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
9    * OF ANY KIND, either express or implied. See the License for the specific
10   * language governing permissions and limitations under the License.
11   */
12  package sk.uniba.euromath.editor.textEditor.requests;
13  
14  import org.eclipse.gef.EditPart;
15  import org.eclipse.gef.Request;
16  import org.eclipse.draw2d.geometry.Point;
17  
18  
19  
20  /***
21   * @author TV Created on 15.7.2004
22   * @author Martin Kollar
23   * Finds next text holder.
24   */
25  public class RetargetCaretRequest extends Request {
26  
27      private EditPart source;
28  
29      private int keyCode;
30      
31      private boolean acceptableChar;
32      
33  	private Point CaretXPartYPosition;
34  	
35  	private char character;
36  	
37  	private int caretOffset;
38  	
39      protected RetargetCaretRequest() {
40          super(RequestConstants.RETARGET_CARET_REQUEST);
41      }
42  
43      /***
44       * @param fromPart Part that made this Request
45       * @param keyCode 
46       * @param character 
47       * @param acceptableChar <code>true</code> if this request was created because od char input                            
48       * @param CaretXPartYPosition x-coordinate is absolute Caret x-coordinate
49       *                            y-coordinate is EditPart bounds y-coordinate
50       * @param caretOffset 
51       */
52      public RetargetCaretRequest(EditPart fromPart, int keyCode,char character, boolean acceptableChar, 
53      		                    Point CaretXPartYPosition, int caretOffset) {
54          this();
55          this.source = fromPart;
56          this.keyCode = keyCode;
57          this.character = character;
58          this.acceptableChar = acceptableChar;
59  		this.CaretXPartYPosition = CaretXPartYPosition;
60  		this.caretOffset = caretOffset;
61      }
62      
63  	/***
64  	 * @return Point, that x-coordinate is Caret x-coordinate
65  	 *                     y-coordinate is Part  y-coordinate
66  	 */
67  	public Point getPosition(){
68  		return this.CaretXPartYPosition;
69  	}
70  	
71  	/***
72  	 * @return offset from start of text piece
73  	 */
74  	public int getcaretOffset(){
75  		return caretOffset;
76  	}
77  	
78  	public void setKeyCode(int code){
79  		this.keyCode = code;
80  	}
81  	
82      public int getKeyCode() {
83      	return keyCode;
84      }
85      
86      public char getCharacter(){
87      	return character;
88      }
89      
90      public boolean isAcceptableChar(){
91      	return acceptableChar;
92      }
93  	
94      public EditPart getSource() {
95          return this.source;
96      }
97  
98  }