01: package org.acm.seguin.completer.popup;
02:
03: import java.util.Vector;
04: import org.gjt.sp.jedit.jEdit; //import anthelper.JavaUtils;
05: import org.gjt.sp.jedit.View;
06: import java.util.Set;
07: import org.acm.seguin.completer.Config;
08: import org.acm.seguin.ide.jedit.Navigator;
09: import org.acm.seguin.completer.Completer;
10: import org.acm.seguin.completer.info.*;
11: import javax.swing.ImageIcon;
12: import java.lang.reflect.*;
13:
14: //import anthelper.utils.ReflectUtils;
15:
16: /**
17: * Description of the Class
18: *
19: * @author btateyama@yahoo.com
20: * @created December 11, 2002
21: */
22: public class ClassPopupItem extends PopupItem {
23:
24: static final Navigator.NavigatorLogger logger = Navigator
25: .getLogger(ClassPopupItem.class);
26:
27: public ClassPopupItem(String argName) {
28: _objDataSource = argName;
29:
30: _strData = getPlainName(argName);
31: int iTruncateLen = 20;
32: String strPkg = argName.substring(0, argName.length()
33: - _strData.length());
34: if (strPkg.length() > iTruncateLen) {
35: strPkg = " " + strPkg.substring(0, iTruncateLen - 2) + "~.";
36: }
37: _strLeftText = strPkg;
38:
39: _strBeforeCaret = _strData;
40: _strAfterCaret = "";
41: }
42:
43: public static void main(String[] args) {
44: try {
45: ClassPopupItem pi = new ClassPopupItem(
46: "java.util.foo.bar.NameFrame");
47: logger.msg("left", pi._strLeftText);
48: logger.msg("Data", pi._strData);
49: } catch (Throwable t) {
50: t.printStackTrace();
51: }
52: }
53:
54: public static class ImportInsertListener implements InsertListener {
55: Set _setImports = null;
56: boolean _bAutoImport = false;
57: boolean _bPopupMsg = false;
58:
59: public ImportInsertListener(Set argImportSet,
60: boolean argAutoImport, boolean argPopupMsg) {
61: _setImports = argImportSet;
62: _bAutoImport = argAutoImport;
63: _bPopupMsg = argPopupMsg;
64: }
65:
66: public void insertPerformed(PopupItem argItem,
67: String argPrefix, String argInsertedText, View argView) {
68:
69: if (argItem instanceof ClassPopupItem) {
70: String strMsg, strCN = argItem.getDataSource()
71: .toString();
72: if (!_setImports.contains(strCN)) {
73: if (_bAutoImport) {
74: //FIXME: JavaUtils.doImport(argView, strCN);
75: strMsg = "Imported " + strCN;
76: } else {
77: strMsg = "Missing import: " + strCN;
78: }
79: logger.msg(strMsg);
80: if (_bPopupMsg) {
81: new SuicidalMsgPopup(argView, strMsg, 1000 * 3);
82: }
83: }
84: }
85: }
86: }
87:
88: }
|