01: package net.sourceforge.squirrel_sql.plugins.sqlbookmark;
02:
03: import net.sourceforge.squirrel_sql.fw.completion.CompletionInfo;
04:
05: public class BookmarkCompletionInfo extends CompletionInfo {
06: private Bookmark _bookmark;
07: private int maxCandidateNameLen;
08:
09: public BookmarkCompletionInfo(Bookmark bookmark) {
10: _bookmark = bookmark;
11: }
12:
13: public String getCompareString() {
14: return _bookmark.getName();
15: }
16:
17: public String getCompletionString() {
18: return _bookmark.getSql();
19: }
20:
21: public String toString() {
22:
23: return _bookmark.getName()
24: + getDist()
25: + (null == _bookmark.getDescription() ? "" : _bookmark
26: .getDescription());
27: }
28:
29: private String getDist() {
30: int len = maxCandidateNameLen - _bookmark.getName().length()
31: + 4;
32:
33: StringBuffer ret = new StringBuffer();
34:
35: for (int i = 0; i < len; ++i) {
36: ret.append(' ');
37: }
38:
39: return ret.toString();
40: }
41:
42: public void setMaxCandidateNameLen(int maxNameLen) {
43: this .maxCandidateNameLen = maxNameLen;
44: }
45:
46: public Bookmark getBookmark() {
47: return _bookmark;
48: }
49: }
|