001: /*
002: * HyperSearchFileNode.java - HyperSearch file node
003: * :tabSize=8:indentSize=8:noTabs=false:
004: * :folding=explicit:collapseFolds=1:
005: *
006: * Copyright (C) 2005 Slava Pestov
007: *
008: * This program is free software; you can redistribute it and/or
009: * modify it under the terms of the GNU General Public License
010: * as published by the Free Software Foundation; either version 2
011: * of the License, or any later version.
012: *
013: * This program is distributed in the hope that it will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
016: * GNU General Public License for more details.
017: *
018: * You should have received a copy of the GNU General Public License
019: * along with this program; if not, write to the Free Software
020: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
021: */
022:
023: package org.gjt.sp.jedit.search;
024:
025: import org.gjt.sp.jedit.Buffer;
026: import org.gjt.sp.jedit.EditPane;
027: import org.gjt.sp.jedit.MiscUtilities;
028: import org.gjt.sp.jedit.View;
029: import org.gjt.sp.jedit.jEdit;
030:
031: /**
032: * HyperSearch results window.
033: * @author Slava Pestov
034: * @version $Id: HyperSearchFileNode.java 9868 2007-06-28 13:35:01Z kpouer $
035: */
036: public class HyperSearchFileNode implements HyperSearchNode {
037: public String path;
038: public Buffer buffer;
039: public boolean showFullPath = true;
040:
041: private static String fileSep = System
042: .getProperty("file.separator");
043: static {
044: if (fileSep.equals("\\"))
045: fileSep = "\\\\";
046: }
047:
048: //{{{ HyperSearchFileNode constructor
049: public HyperSearchFileNode(String path) {
050: this .path = path;
051: } //}}}
052:
053: //{{{ getBuffer() method
054: public Buffer getBuffer(View view) {
055: if (buffer == null)
056: buffer = jEdit.openFile(view, path);
057: return buffer;
058: } //}}}
059:
060: //{{{ goTo() method
061: public void goTo(EditPane editPane) {
062: Buffer buffer = getBuffer(editPane.getView());
063: if (buffer == null)
064: return;
065:
066: editPane.setBuffer(buffer);
067: } //}}}
068:
069: //{{{ toString() method
070: public String toString() {
071: if (showFullPath)
072: return path;
073: String[] paths = path.split(fileSep);
074: return paths[paths.length - 1];
075: } //}}}
076:
077: //{{{ equals() method
078: public boolean equals(Object compareObj) {
079: if (!(compareObj instanceof HyperSearchFileNode))
080: return false;
081: HyperSearchFileNode otherResult = (HyperSearchFileNode) compareObj;
082:
083: return path.equals(MiscUtilities
084: .resolveSymlinks(otherResult.path))
085: && buffer.equals(otherResult.buffer);
086: }//}}}
087:
088: /**
089: * Returns the result count.
090: *
091: * @return the result count
092: * @since jEdit 4.3pre9
093: */
094: public int getCount() {
095: return count;
096: }
097:
098: /**
099: * Set the result count.
100: *
101: * @param count the result count
102: * @since jEdit 4.3pre9
103: */
104: public void setCount(int count) {
105: this .count = count;
106: }
107:
108: private int count;
109: }
|