PageRenderTime 46ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/jEdit/tags/jedit-4-3-pre5/org/gjt/sp/jedit/search/HyperSearchFileNode.java

#
Java | 87 lines | 49 code | 12 blank | 26 comment | 8 complexity | 014b27fb9773ff796fa82c9ad5f9959c MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0
  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. package org.gjt.sp.jedit.search;
  23. import org.gjt.sp.jedit.Buffer;
  24. import org.gjt.sp.jedit.EditPane;
  25. import org.gjt.sp.jedit.MiscUtilities;
  26. import org.gjt.sp.jedit.jEdit;
  27. public class HyperSearchFileNode implements HyperSearchNode
  28. {
  29. public String path;
  30. public Buffer buffer;
  31. public boolean showFullPath = true;
  32. private static String fileSep = System.getProperty("file.separator");
  33. static
  34. {
  35. if (fileSep.equals("\\"))
  36. fileSep = "\\\\";
  37. }
  38. //{{{ HyperSearchFileNode constructor
  39. public HyperSearchFileNode(String path)
  40. {
  41. this.path = path;
  42. } //}}}
  43. //{{{ getBuffer() method
  44. public Buffer getBuffer()
  45. {
  46. if(buffer == null)
  47. buffer = jEdit.openFile(null,path);
  48. return buffer;
  49. } //}}}
  50. //{{{ goTo() method
  51. public void goTo(final EditPane editPane)
  52. {
  53. Buffer buffer = getBuffer();
  54. if(buffer == null)
  55. return;
  56. editPane.setBuffer(buffer);
  57. } //}}}
  58. //{{{ toString() method
  59. public String toString()
  60. {
  61. if (showFullPath)
  62. return path;
  63. String paths[] = path.split(fileSep);
  64. return paths[paths.length - 1];
  65. } //}}}
  66. //{{{ equals() method
  67. public boolean equals(Object compareObj)
  68. {
  69. if (!(compareObj instanceof HyperSearchFileNode))
  70. return false;
  71. HyperSearchFileNode otherResult = (HyperSearchFileNode)compareObj;
  72. return path.equals(MiscUtilities.resolveSymlinks(otherResult.path))
  73. && buffer.equals(otherResult.buffer);
  74. }//}}}
  75. }