PageRenderTime 60ms CodeModel.GetById 55ms app.highlight 3ms RepoModel.GetById 1ms 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
  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
 24package org.gjt.sp.jedit.browser;
 25
 26//{{{ Imports
 27import org.gjt.sp.jedit.io.VFS;
 28import org.gjt.sp.jedit.io.VFSFile;
 29import org.gjt.sp.jedit.io.VFSManager;
 30import org.gjt.sp.jedit.jEdit;
 31import org.gjt.sp.util.Log;
 32
 33import java.io.IOException;
 34//}}}
 35
 36/**
 37 * @author Matthieu Casanova
 38 * @version $Id: ListDirectoryBrowserTask.java 19705 2011-07-26 17:19:05Z kpouer $
 39 */
 40class ListDirectoryBrowserTask extends AbstractBrowserTask
 41{
 42	private final Object[] loadInfo;
 43	//{{{ BrowserIORequest constructor
 44	/**
 45	 * Creates a new browser I/O request.
 46	 * @param browser The VFS browser instance
 47	 * @param path The first path name to operate on
 48	 * @param loadInfo A two-element array filled out by the request;
 49	 * element 1 is the canonical path, element 2 is the file list.
 50	 */
 51	ListDirectoryBrowserTask(VFSBrowser browser,
 52		Object session, VFS vfs, String path,
 53		Object[] loadInfo, Runnable awtRunnable)
 54	{
 55		super(browser, session, vfs, path, awtRunnable);
 56		this.loadInfo = loadInfo;
 57	} //}}}
 58
 59	//{{{ run() method
 60	@Override
 61	public void _run()
 62	{
 63		String[] args = {path};
 64		setStatus(jEdit.getProperty("vfs.status.listing-directory",args));
 65
 66		String canonPath = path;
 67
 68		VFSFile[] directory = null;
 69		try
 70		{
 71			setCancellable(true);
 72
 73			canonPath = vfs._canonPath(session, path,browser);
 74			directory = vfs._listFiles(session,canonPath,browser);
 75		}
 76		catch(IOException io)
 77		{
 78			setCancellable(false);
 79			Log.log(Log.ERROR,this,io);
 80			String[] pp = { io.toString() };
 81			VFSManager.error(browser, path,"ioerror.directory-error",pp);
 82		}
 83		finally
 84		{
 85			try
 86			{
 87				vfs._endVFSSession(session,browser);
 88			}
 89			catch(IOException io)
 90			{
 91				setCancellable(false);
 92				Log.log(Log.ERROR,this,io);
 93				String[] pp = { io.toString() };
 94				VFSManager.error(browser, path,"ioerror.directory-error",pp);
 95			}
 96		}
 97
 98		setCancellable(false);
 99
100		loadInfo[0] = canonPath;
101		loadInfo[1] = directory;
102	} //}}}
103
104	//{{{ toString() method
105	public String toString()
106	{
107		return getClass().getName() + "[type=LIST_DIRECTORY"
108			+ ",vfs=" + vfs + ",path=" + path + ']';
109	} //}}}
110}