PageRenderTime 40ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/jEdit/tags/jedit-4-5-pre1/org/gjt/sp/jedit/browser/ListDirectoryBrowserTask.java

#
Java | 110 lines | 61 code | 11 blank | 38 comment | 0 complexity | 6767aabd846bed86507baf3e90363188 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. * ListDirectoryBrowserTask
  3. * :tabSize=8:indentSize=8:noTabs=false:
  4. * :folding=explicit:collapseFolds=1:
  5. *
  6. * Copyright Š 2010 Matthieu Casanova
  7. * Portions Copyright (C) 2000, 2003 Slava Pestov
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version 2
  12. * of the License, or any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  22. */
  23. package org.gjt.sp.jedit.browser;
  24. //{{{ Imports
  25. import org.gjt.sp.jedit.io.VFS;
  26. import org.gjt.sp.jedit.io.VFSFile;
  27. import org.gjt.sp.jedit.io.VFSManager;
  28. import org.gjt.sp.jedit.jEdit;
  29. import org.gjt.sp.util.Log;
  30. import java.io.IOException;
  31. //}}}
  32. /**
  33. * @author Matthieu Casanova
  34. * @version $Id: ListDirectoryBrowserTask.java 19705 2011-07-26 17:19:05Z kpouer $
  35. */
  36. class ListDirectoryBrowserTask extends AbstractBrowserTask
  37. {
  38. private final Object[] loadInfo;
  39. //{{{ BrowserIORequest constructor
  40. /**
  41. * Creates a new browser I/O request.
  42. * @param browser The VFS browser instance
  43. * @param path The first path name to operate on
  44. * @param loadInfo A two-element array filled out by the request;
  45. * element 1 is the canonical path, element 2 is the file list.
  46. */
  47. ListDirectoryBrowserTask(VFSBrowser browser,
  48. Object session, VFS vfs, String path,
  49. Object[] loadInfo, Runnable awtRunnable)
  50. {
  51. super(browser, session, vfs, path, awtRunnable);
  52. this.loadInfo = loadInfo;
  53. } //}}}
  54. //{{{ run() method
  55. @Override
  56. public void _run()
  57. {
  58. String[] args = {path};
  59. setStatus(jEdit.getProperty("vfs.status.listing-directory",args));
  60. String canonPath = path;
  61. VFSFile[] directory = null;
  62. try
  63. {
  64. setCancellable(true);
  65. canonPath = vfs._canonPath(session, path,browser);
  66. directory = vfs._listFiles(session,canonPath,browser);
  67. }
  68. catch(IOException io)
  69. {
  70. setCancellable(false);
  71. Log.log(Log.ERROR,this,io);
  72. String[] pp = { io.toString() };
  73. VFSManager.error(browser, path,"ioerror.directory-error",pp);
  74. }
  75. finally
  76. {
  77. try
  78. {
  79. vfs._endVFSSession(session,browser);
  80. }
  81. catch(IOException io)
  82. {
  83. setCancellable(false);
  84. Log.log(Log.ERROR,this,io);
  85. String[] pp = { io.toString() };
  86. VFSManager.error(browser, path,"ioerror.directory-error",pp);
  87. }
  88. }
  89. setCancellable(false);
  90. loadInfo[0] = canonPath;
  91. loadInfo[1] = directory;
  92. } //}}}
  93. //{{{ toString() method
  94. public String toString()
  95. {
  96. return getClass().getName() + "[type=LIST_DIRECTORY"
  97. + ",vfs=" + vfs + ",path=" + path + ']';
  98. } //}}}
  99. }