KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > gjt > sp > jedit > search > HyperSearchFileNode


1 /*
2  * HyperSearchFileNode.java - HyperSearch file node
3  * :tabSize=8:indentSize=8:noTabs=false:
4  * :folding=explicit:collapseFolds=1:
5  *
6  * Copyright (C) 2005 Slava Pestov
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21  */

22
23 package org.gjt.sp.jedit.search;
24
25 import org.gjt.sp.jedit.Buffer;
26 import org.gjt.sp.jedit.EditPane;
27 import org.gjt.sp.jedit.MiscUtilities;
28 import org.gjt.sp.jedit.jEdit;
29
30 /**
31  * HyperSearch results window.
32  * @author Slava Pestov
33  * @version $Id: HyperSearchFileNode.java 8219 2006-12-10 22:58:04Z kpouer $
34  */

35 public class HyperSearchFileNode implements HyperSearchNode
36 {
37     public String JavaDoc path;
38     public Buffer buffer;
39     public boolean showFullPath = true;
40
41     private static String JavaDoc fileSep = System.getProperty("file.separator");
42     static
43     {
44         if (fileSep.equals("\\"))
45             fileSep = "\\\\";
46     }
47
48     //{{{ HyperSearchFileNode constructor
49
public HyperSearchFileNode(String JavaDoc path)
50     {
51         this.path = path;
52     } //}}}
53

54     //{{{ getBuffer() method
55
public Buffer getBuffer()
56     {
57         if(buffer == null)
58             buffer = jEdit.openFile(null,path);
59         return buffer;
60     } //}}}
61

62     //{{{ goTo() method
63
public void goTo(EditPane editPane)
64     {
65         Buffer buffer = getBuffer();
66         if(buffer == null)
67             return;
68
69         editPane.setBuffer(buffer);
70     } //}}}
71

72     //{{{ toString() method
73
public String JavaDoc toString()
74     {
75         if (showFullPath)
76             return path;
77         String JavaDoc[] paths = path.split(fileSep);
78         return paths[paths.length - 1];
79     } //}}}
80

81     //{{{ equals() method
82
public boolean equals(Object JavaDoc compareObj)
83     {
84         if (!(compareObj instanceof HyperSearchFileNode))
85             return false;
86         HyperSearchFileNode otherResult = (HyperSearchFileNode)compareObj;
87         
88         return path.equals(MiscUtilities.resolveSymlinks(otherResult.path))
89             && buffer.equals(otherResult.buffer);
90     }//}}}
91

92     /**
93      * Returns the result count.
94      *
95      * @return the result count
96      * @since jEdit 4.3pre9
97      */

98     public int getCount()
99     {
100         return count;
101     }
102
103     /**
104      * Set the result count.
105      *
106      * @param count the result count
107      * @since jEdit 4.3pre9
108      */

109     public void setCount(int count)
110     {
111         this.count = count;
112     }
113
114     private int count;
115 }
116
Popular Tags