PageRenderTime 151ms CodeModel.GetById 90ms app.highlight 6ms RepoModel.GetById 35ms app.codeStats 0ms

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

#
Java | 110 lines | 63 code | 12 blank | 35 comment | 4 complexity | 545aeca5578eadbd3cb53860c1fd2127 MD5 | raw file
  1/*
  2 * AbstractBrowserTask
  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 * 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
 23package org.gjt.sp.jedit.browser;
 24
 25//{{{ Imports
 26import org.gjt.sp.jedit.io.VFS;
 27import org.gjt.sp.util.Task;
 28import org.gjt.sp.util.TaskListener;
 29import org.gjt.sp.util.TaskManager;
 30import org.gjt.sp.util.ThreadUtilities;
 31//}}}
 32
 33/**
 34 * @author Matthieu Casanova
 35 * @version $Id: AbstractBrowserTask.java 19705 2011-07-26 17:19:05Z kpouer $
 36 */
 37abstract class AbstractBrowserTask extends Task
 38{
 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	 */
 45	AbstractBrowserTask(VFSBrowser browser,
 46		Object session, VFS vfs, String path, Runnable awtTask)
 47	{
 48		this.browser = browser;
 49		this.session = session;
 50		this.vfs = vfs;
 51		this.path = path;
 52		if (awtTask != null)
 53		{
 54			MyTaskListener listener = new MyTaskListener(awtTask);
 55			TaskManager.instance.addTaskListener(listener);
 56		}
 57	} //}}}
 58
 59	//{{{ Instance variables
 60	protected VFSBrowser browser;
 61	protected Object session;
 62	protected VFS vfs;
 63	protected String path;
 64	//}}}
 65
 66	private class MyTaskListener implements TaskListener
 67	{
 68		private final Runnable runnable;
 69
 70		private MyTaskListener(Runnable runnable)
 71		{
 72			this.runnable = runnable;
 73		}
 74
 75		@Override
 76		public void waiting(Task task)
 77		{
 78		}
 79
 80		@Override
 81		public void running(Task task)
 82		{
 83		}
 84
 85		@Override
 86		public void done(Task task)
 87		{
 88			if (task == AbstractBrowserTask.this)
 89			{
 90				TaskManager.instance.removeTaskListener(this);
 91				ThreadUtilities.runInDispatchThread(runnable);
 92			}
 93		}
 94
 95		@Override
 96		public void statusUpdated(Task task)
 97		{
 98		}
 99
100		@Override
101		public void maximumUpdated(Task task)
102		{
103		}
104
105		@Override
106		public void valueUpdated(Task task)
107		{
108		}
109	}
110}