KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > text > completion > EndTagAutocompletionResultItem


1 /*
2  * EndTagAutocompletionResultItem.java
3  *
4  * Created on September 11, 2006, 4:07 PM
5  *
6  * To change this template, choose Tools | Template Manager
7  * and open the template in the editor.
8  */

9
10 package org.netbeans.modules.xml.text.completion;
11
12 import javax.swing.text.JTextComponent JavaDoc;
13
14 /**
15  *
16  * @author marek
17  */

18 public class EndTagAutocompletionResultItem extends XMLResultItem {
19     
20     /** Creates a new instance of EndTagAutocompletionResultItem */
21     public EndTagAutocompletionResultItem(String JavaDoc text) {
22         super(endtagize(text));
23     }
24
25     private static String JavaDoc endtagize(String JavaDoc text) {
26         return "</" + text + ">";
27     }
28     
29     boolean replaceText( JTextComponent JavaDoc component, String JavaDoc text, int offset, int len) {
30         boolean replaced = super.replaceText(component, text, offset, len);
31         if(replaced) {
32             //shift the cursor between tags
33
component.setCaretPosition(offset);
34         }
35         return replaced;
36     }
37 }
38
Popular Tags