예제 #1
0
  /**
   * Constructor.
   *
   * @param win parent reference
   * @param mouse mouse interaction
   */
  public BaseXMem(final Window win, final boolean mouse) {
    super(win);
    BaseXLayout.setWidth(this, DWIDTH);
    BaseXLayout.setHeight(this, getFont().getSize() + 6);
    if (mouse) {
      setCursor(CURSORHAND);
      addMouseListener(this);
      addMouseMotionListener(this);
    }

    final Thread t =
        new Thread() {
          @Override
          public void run() {
            repaint();
            Performance.sleep(500);
          }
        };
    t.setDaemon(true);
    t.start();
  }
예제 #2
0
 /**
  * Returns the current file cache.
  *
  * @param root root directory
  * @return id, or {@code null} if newer file cache exists
  * @throws InterruptedException interruption
  */
 ProjectCache cache(final IOFile root) throws InterruptedException {
   final ProjectCache pc = cache;
   if (pc == null) {
     // no file cache available: create and return new one
     cache = new ProjectCache();
     add(root, cache);
     cache.finish();
   } else {
     // wait until file cache is initialized
     while (!pc.valid()) {
       Thread.yield();
       // file cache was replaced with newer version
       if (pc != cache) throw new InterruptedException();
     }
   }
   // return existing file cache
   return cache;
 }