01: /*
02: * EndTagAutocompletionResultItem.java
03: *
04: * Created on September 11, 2006, 4:07 PM
05: *
06: * To change this template, choose Tools | Template Manager
07: * and open the template in the editor.
08: */
09:
10: package org.netbeans.modules.xml.text.completion;
11:
12: import javax.swing.text.JTextComponent;
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 text) {
22: super (endtagize(text));
23: }
24:
25: private static String endtagize(String text) {
26: return "</" + text + ">";
27: }
28:
29: boolean replaceText(JTextComponent component, String text,
30: int offset, int len) {
31: boolean replaced = super .replaceText(component, text, offset,
32: len);
33: if (replaced) {
34: //shift the cursor between tags
35: component.setCaretPosition(offset);
36: }
37: return replaced;
38: }
39: }
|