// {{{ loadDirectory() method
  public void loadDirectory(
      final Object node, String path, final boolean addToHistory, final Runnable delayedAWTTask) {
    path = MiscUtilities.constructPath(browser.getDirectory(), path);
    VFS vfs = VFSManager.getVFSForPath(path);

    Object session = vfs.createVFSSession(path, this);
    if (session == null) {
      if (delayedAWTTask != null) ThreadUtilities.runInDispatchThread(delayedAWTTask);
      return;
    }

    if (node == null) {
      parentDirectories.setListData(new Object[] {new LoadingPlaceholder()});
    }

    final Object[] loadInfo = new Object[2];
    Runnable awtRunnable =
        new Runnable() {
          public void run() {
            browser.directoryLoaded(node, loadInfo, addToHistory);
            if (delayedAWTTask != null) delayedAWTTask.run();
          }
        };
    ThreadUtilities.runInBackground(
        new ListDirectoryBrowserTask(browser, session, vfs, path, loadInfo, awtRunnable));
  } // }}}
  // {{{ updatePluginList() method
  private void updatePluginList() {
    if (jEdit.getSettingsDirectory() == null && jEdit.getJEditHome() == null) {
      GUIUtilities.error(this, "no-settings", null);
      return;
    }
    if (!shouldUpdatePluginList()) {
      return;
    }

    ThreadUtilities.runInBackground(
        new Task() {
          @Override
          public void _run() {
            try {
              downloadingPluginList = true;
              setStatus(jEdit.getProperty("plugin-manager.list-download-connect"));
              pluginList = new PluginList(this);
            } finally {
              downloadingPluginList = false;
            }
            ThreadUtilities.runInDispatchThread(
                new Runnable() {
                  public void run() {
                    pluginListUpdated();
                  }
                });
          }
        });
  } // }}}
Beispiel #3
0
 // {{{ copy() method
 private void copy(
     Object vfsSession, VFS vfs, String sourcePath, String sourceName, String targetPath)
     throws IOException, InterruptedException {
   String name = getTargetName(vfsSession, vfs, targetPath, sourceName);
   if (name == null) {
     return;
   }
   String targetName = MiscUtilities.constructPath(targetPath, name);
   CountDownLatch latch = new CountDownLatch(1);
   ThreadUtilities.runInBackground(new CopyFileWorker(comp, sourcePath, targetName, latch));
   latch.await();
 } // }}}
  // {{{ updateModel() method
  public void updateModel() {
    final Set<String> savedChecked = new HashSet<String>();
    final Set<String> savedSelection = new HashSet<String>();
    pluginModel.saveSelection(savedChecked, savedSelection);
    pluginModel.clear();
    infoBox.setText(jEdit.getProperty("plugin-manager.list-download"));

    ThreadUtilities.runInDispatchThread(
        new Runnable() {
          @Override
          public void run() {
            infoBox.setText(null);
            pluginModel.update();
            pluginModel.restoreSelection(savedChecked, savedSelection);
          }
        });
  } // }}}
  public void addWorkRequest(Runnable run, boolean inAWT) {
    if (threads == null) {
      run.run();
      return;
    }

    synchronized (lock) {
      if (started && inAWT && requestCount == 0 && awtRequestCount == 0) {

        ThreadUtilities.runInDispatchThread(run);
        return;
      }

      Request request = new Request(run);

      if (inAWT) {
        if (firstAWTRequest == null && lastAWTRequest == null)
          firstAWTRequest = lastAWTRequest = request;
        else {
          lastAWTRequest.next = request;
          lastAWTRequest = request;
        }

        awtRequestCount++;

        if (started && requestCount == 0) queueAWTRunner();
      } else {
        if (firstRequest == null && lastRequest == null) firstRequest = lastRequest = request;
        else {
          lastRequest.next = request;
          lastRequest = request;
        }

        requestCount++;
      }

      lock.notifyAll();
    }
  }
  /**
   * Performs a HyperSearch.
   *
   * @param view The view
   * @param selection If true, will only search in the current selection. Note that the file set
   *     must be the current buffer file set for this to work.
   * @since jEdit 4.0pre1
   */
  public static boolean hyperSearch(View view, boolean selection) {
    // component that will parent any dialog boxes
    Component comp = SearchDialog.getSearchDialog(view);
    if (comp == null) comp = view;

    record(view, "hyperSearch(view," + selection + ')', false, !selection);

    view.getDockableWindowManager().addDockableWindow(HyperSearchResults.NAME);
    HyperSearchResults results =
        (HyperSearchResults) view.getDockableWindowManager().getDockable(HyperSearchResults.NAME);
    results.searchStarted();

    try {
      SearchMatcher matcher = getSearchMatcher();
      if (matcher == null) {
        view.getToolkit().beep();
        results.searchFailed();
        return false;
      }

      Selection[] s;
      if (selection) {
        s = view.getTextArea().getSelection();
        if (s == null) {
          results.searchFailed();
          return false;
        }
      } else s = null;
      ThreadUtilities.runInBackground(new HyperSearchRequest(view, matcher, results, s));
      return true;
    } catch (Exception e) {
      results.searchFailed();
      handleError(comp, e);
      return false;
    }
  } // }}}