01: package net.xoetrope.builder.editor.helper;
02:
03: import javax.swing.text.BadLocationException;
04:
05: import net.xoetrope.builder.editor.XSourceEditor;
06: import net.xoetrope.xui.XProjectManager;
07: import java.util.Vector;
08: import java.awt.event.KeyEvent;
09: import java.util.ArrayList;
10: import net.xoetrope.builder.editor.XPageResource;
11: import net.xoetrope.builder.editor.XEditorProject;
12:
13: /**
14: * A code helper for inserting of 'for' loops
15: * <p> Copyright (c) Xoetrope Ltd., 2002-2003</p>
16: * <p> $Revision: 1.4 $</p>
17: * <p> License: see License.txt</p>
18: */
19: public class ForCodeHelper extends CodeHelper {
20: private static ForCodeHelper instance = new ForCodeHelper();
21:
22: private ForCodeHelper() {
23: }
24:
25: public static void register(ArrayList resources) {
26: if (resources != null && !resources.contains(instance))
27: resources.add(instance);
28: }
29:
30: /**
31: * Insert the new codes
32: */
33: public void doInsert(XSourceEditor editor,
34: XEditorProject currentProject, XPageResource pageRes) {
35: try {
36: editor
37: .getDocument()
38: .insertString(
39: editor.getCaretPosition(),
40: "\n\tfor ( int i = 0; i < ; i++ ) {\n\t\n\t}",
41: null);
42: } catch (BadLocationException ex) {
43: }
44: }
45:
46: /**
47: * Get the caption displayed on the popup menu
48: * @return the caption
49: */
50: public String getCaption() {
51: return "for loop";
52: }
53:
54: /**
55: * Get the mnemonic key for this item
56: * @return the mnemonic
57: */
58: public Integer getMnemonic() {
59: return new Integer(KeyEvent.VK_F);
60: }
61: }
|