482600368473bd9f1e7ada0ea63526c28b3b1fca
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.quantum.sql / src / com / quantum / view / bookmark / QueryNode.java
1 package com.quantum.view.bookmark;
2
3 import com.quantum.sql.metadata.ObjectMetaData;
4
5 public class QueryNode extends TreeNode {
6     
7     private String query;
8     private static final int MAX_SIZE = 30;
9         
10         public QueryNode(TreeNode parent, String query) {
11         super(parent);
12                 this.query = query;
13         }
14
15         public ObjectMetaData getMetaData() {
16                  return null;   //no metadata implementation for now
17          }
18
19         public String getQuery() {
20                 return this.query;
21         }
22
23     public String getName() {
24         String name = this.query.trim();
25         boolean trimmed = false;
26         name = name.replace('\n', ' ');
27         
28         if (name.length() > MAX_SIZE) {
29             name = name.substring(0, MAX_SIZE);
30             trimmed = true;
31         }
32         if (trimmed) {
33             name += "...->"; //$NON-NLS-1$
34         }
35                 return name;
36         }
37
38     /**
39      * @see com.quantum.view.bookmark.TreeNode#getChildren()
40      */
41     public Object[] getChildren() {
42         return BookmarkListNode.EMPTY_ARRAY;
43     }
44
45     /**
46      * @see com.quantum.view.bookmark.TreeNode#hasChildren()
47      */
48     public boolean hasChildren() {
49         return false;
50     }
51
52     /**
53      * @see com.quantum.view.bookmark.TreeNode#getImageName()
54      */
55     protected String getImageName() {
56         return "script.gif";
57     }
58
59     /* (non-Javadoc)
60      * @see com.quantum.view.bookmark.TreeNode#initializeChildren()
61      */
62     protected void initializeChildren() {
63     }
64 }