PageRenderTime 47ms CodeModel.GetById 22ms RepoModel.GetById 0ms 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
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. * 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. package org.gjt.sp.jedit.browser;
  23. //{{{ Imports
  24. import org.gjt.sp.jedit.io.VFS;
  25. import org.gjt.sp.util.Task;
  26. import org.gjt.sp.util.TaskListener;
  27. import org.gjt.sp.util.TaskManager;
  28. import org.gjt.sp.util.ThreadUtilities;
  29. //}}}
  30. /**
  31. * @author Matthieu Casanova
  32. * @version $Id: AbstractBrowserTask.java 19705 2011-07-26 17:19:05Z kpouer $
  33. */
  34. abstract class AbstractBrowserTask extends Task
  35. {
  36. //{{{ BrowserIORequest constructor
  37. /**
  38. * Creates a new browser I/O request.
  39. * @param browser The VFS browser instance
  40. * @param path The first path name to operate on
  41. */
  42. AbstractBrowserTask(VFSBrowser browser,
  43. Object session, VFS vfs, String path, Runnable awtTask)
  44. {
  45. this.browser = browser;
  46. this.session = session;
  47. this.vfs = vfs;
  48. this.path = path;
  49. if (awtTask != null)
  50. {
  51. MyTaskListener listener = new MyTaskListener(awtTask);
  52. TaskManager.instance.addTaskListener(listener);
  53. }
  54. } //}}}
  55. //{{{ Instance variables
  56. protected VFSBrowser browser;
  57. protected Object session;
  58. protected VFS vfs;
  59. protected String path;
  60. //}}}
  61. private class MyTaskListener implements TaskListener
  62. {
  63. private final Runnable runnable;
  64. private MyTaskListener(Runnable runnable)
  65. {
  66. this.runnable = runnable;
  67. }
  68. @Override
  69. public void waiting(Task task)
  70. {
  71. }
  72. @Override
  73. public void running(Task task)
  74. {
  75. }
  76. @Override
  77. public void done(Task task)
  78. {
  79. if (task == AbstractBrowserTask.this)
  80. {
  81. TaskManager.instance.removeTaskListener(this);
  82. ThreadUtilities.runInDispatchThread(runnable);
  83. }
  84. }
  85. @Override
  86. public void statusUpdated(Task task)
  87. {
  88. }
  89. @Override
  90. public void maximumUpdated(Task task)
  91. {
  92. }
  93. @Override
  94. public void valueUpdated(Task task)
  95. {
  96. }
  97. }
  98. }