PageRenderTime 50ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/jEdit/tags/jedit-4-0-pre3/org/gjt/sp/jedit/search/BufferListSet.java

#
Java | 120 lines | 68 code | 17 blank | 35 comment | 28 complexity | 9dddd16d5bfd30a359130367a31d3811 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. * BufferListSet.java - Buffer list matcher
  3. * :tabSize=8:indentSize=8:noTabs=false:
  4. * :folding=explicit:collapseFolds=1:
  5. *
  6. * Copyright (C) 1999, 2001 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. //{{{ Imports
  24. import javax.swing.SwingUtilities;
  25. import java.util.Vector;
  26. import org.gjt.sp.jedit.io.VFSManager;
  27. import org.gjt.sp.jedit.*;
  28. import org.gjt.sp.util.Log;
  29. //}}}
  30. /**
  31. * A file set for searching a user-specified list of buffers.
  32. * @author Slava Pestov
  33. * @version $Id: BufferListSet.java 3931 2001-12-02 11:40:51Z spestov $
  34. */
  35. public abstract class BufferListSet implements SearchFileSet
  36. {
  37. //{{{ getFirstFile() method
  38. public String getFirstFile(View view)
  39. {
  40. if(files == null)
  41. files = _getFiles();
  42. if(files == null || files.length == 0)
  43. return null;
  44. else
  45. return files[0];
  46. } //}}}
  47. //{{{ getNextFile() method
  48. public String getNextFile(View view, String file)
  49. {
  50. if(files == null)
  51. files = _getFiles();
  52. if(files == null || files.length == 0)
  53. return null;
  54. if(file == null)
  55. {
  56. file = view.getBuffer().getPath();
  57. for(int i = 0; i < files.length; i++)
  58. {
  59. if(files[i].equals(file))
  60. return file;
  61. }
  62. return getFirstFile(view);
  63. }
  64. else
  65. {
  66. // -1 so that the last isn't checked
  67. for(int i = 0; i < files.length - 1; i++)
  68. {
  69. if(files[i].equals(file))
  70. return files[i+1];
  71. }
  72. return null;
  73. }
  74. } //}}}
  75. //{{{ getFiles() method
  76. public String[] getFiles(View view)
  77. {
  78. if(files == null)
  79. files = _getFiles();
  80. if(files == null || files.length == 0)
  81. return null;
  82. else
  83. return files;
  84. } //}}}
  85. //{{{ getFileCount() method
  86. public int getFileCount()
  87. {
  88. if(files == null)
  89. files = _getFiles();
  90. if(files == null)
  91. return 0;
  92. else
  93. return files.length;
  94. } //}}}
  95. //{{{ getCode() method
  96. public String getCode()
  97. {
  98. // not supported for arbitriary filesets
  99. return null;
  100. } //}}}
  101. protected abstract String[] _getFiles();
  102. private String[] files;
  103. }