Java 类com.intellij.openapi.util.ExpirableRunnable 实例源码

项目:intellij-ce-playground    文件:JBTable.java   
private void permanentFocusOwnerChanged() {
  if (!isEditing()) {
    return;
  }

  myFocusManager.doWhenFocusSettlesDown(new ExpirableRunnable() {
    @Override
    public boolean isExpired() {
      return !isEditing();
    }

    @Override
    public void run() {
      Component c = myFocusManager.getFocusOwner();
      if (UIUtil.isMeaninglessFocusOwner(c)) {
        // this allows using popup menus and menu bar without stopping cell editing
        return;
      }
      while (c != null) {
        if (c instanceof JPopupMenu) {
          c = ((JPopupMenu)c).getInvoker();
        }
        if (c == JBTable.this) {
          // focus remains inside the table
          return;
        }
        else if (c instanceof Window) {
          if (c == SwingUtilities.getWindowAncestor(JBTable.this)) {
            removeCellEditor();
          }
          break;
        }
        c = c.getParent();
      }
    }
  });
}
项目:consulo    文件:JBTable.java   
private void permanentFocusOwnerChanged() {
  if (!isEditing()) {
    return;
  }

  final IdeFocusManager focusManager = IdeFocusManager.findInstanceByComponent(JBTable.this);
  focusManager.doWhenFocusSettlesDown(new ExpirableRunnable() {
    @Override
    public boolean isExpired() {
      return !isEditing();
    }

    @Override
    public void run() {
      Component c = focusManager.getFocusOwner();
      if (UIUtil.isMeaninglessFocusOwner(c)) {
        // this allows using popup menus and menu bar without stopping cell editing
        return;
      }
      while (c != null) {
        if (c instanceof JPopupMenu) {
          c = ((JPopupMenu)c).getInvoker();
        }
        if (c == JBTable.this) {
          // focus remains inside the table
          return;
        }
        else if (c instanceof Window) {
          if (c == SwingUtilities.getWindowAncestor(JBTable.this)) {
            removeCellEditor();
          }
          break;
        }
        c = c.getParent();
      }
    }
  });
}
项目:intellij-ce-playground    文件:PassThroughIdeFocusManager.java   
@Override
public void doWhenFocusSettlesDown(@NotNull ExpirableRunnable runnable) {
  if (!runnable.isExpired()) {
    runnable.run();
  }
}
项目:intellij-ce-playground    文件:IdeFocusManagerHeadless.java   
@Override
public void doWhenFocusSettlesDown(@NotNull ExpirableRunnable runnable) {
  if (!runnable.isExpired()) {
    runnable.run();
  }
}
项目:intellij-ce-playground    文件:IdeFocusManagerHeadless.java   
@Override
public void revalidateFocus(@NotNull ExpirableRunnable runnable) {
}
项目:intellij-ce-playground    文件:IdeFocusManagerImpl.java   
@Override
public void doWhenFocusSettlesDown(@NotNull ExpirableRunnable runnable) {
  getGlobalInstance().doWhenFocusSettlesDown(runnable);
}
项目:intellij-ce-playground    文件:IdeFocusManagerImpl.java   
@Override
public void revalidateFocus(@NotNull ExpirableRunnable runnable) {
  getGlobalInstance().revalidateFocus(runnable);
}
项目:intellij-ce-playground    文件:FocusTrackback.java   
public void restoreFocus() {
  final Application app = ApplicationManager.getApplication();
  if (app == null || wrongOS() || myConsumed || isSheduledForRestore()) return;

  Project project = null;
  DataManager dataManager = DataManager.getInstance();
  if (dataManager != null) {
    DataContext context = myParentWindow == null ? dataManager.getDataContext() : dataManager.getDataContext(myParentWindow);
    if (context != null) {
      project = CommonDataKeys.PROJECT.getData(context);
    }
  }

  mySheduledForRestore = true;
  final List<FocusTrackback> stack = getCleanStackForRoot();
  final int index = stack.indexOf(this);
  for (int i = index - 1; i >=0; i--) {
    if (stack.get(i).isSheduledForRestore()) {
      dispose();
      return;
    }
  }

  if (project != null && !project.isDisposed()) {
    final IdeFocusManager focusManager = IdeFocusManager.getInstance(project);
    cleanParentWindow();
    final Project finalProject = project;
    focusManager.requestFocus(new MyFocusCommand(), myForcedRestore).doWhenProcessed(new Runnable() {
      public void run() {
        dispose();
      }
    }).doWhenRejected(new Runnable() {
      @Override
      public void run() {
        focusManager.revalidateFocus(new ExpirableRunnable.ForProject(finalProject) {
          @Override
          public void run() {
            if (UIUtil.isMeaninglessFocusOwner(focusManager.getFocusOwner())) {
              focusManager.requestDefaultFocus(false);
            }
          }
        });
      }
    });
  }
  else {
    // no ide focus manager, so no way -- do just later
    //noinspection SSBasedInspection
    SwingUtilities.invokeLater(new Runnable() {
      public void run() {
        _restoreFocus();
        dispose();
      }
    });
  }
}
项目:tools-idea    文件:PassThroughIdeFocusManager.java   
@Override
public void doWhenFocusSettlesDown(@NotNull ExpirableRunnable runnable) {
  if (!runnable.isExpired()) {
    runnable.run();
  }
}
项目:tools-idea    文件:IdeFocusManagerHeadless.java   
@Override
public void doWhenFocusSettlesDown(@NotNull ExpirableRunnable runnable) {
  if (!runnable.isExpired()) {
    runnable.run();
  }
}
项目:tools-idea    文件:IdeFocusManagerHeadless.java   
@Override
public void revalidateFocus(@NotNull ExpirableRunnable runnable) {
}
项目:tools-idea    文件:IdeFocusManagerImpl.java   
@Override
public void doWhenFocusSettlesDown(@NotNull ExpirableRunnable runnable) {
  getGlobalInstance().doWhenFocusSettlesDown(runnable);
}
项目:tools-idea    文件:IdeFocusManagerImpl.java   
@Override
public void revalidateFocus(@NotNull ExpirableRunnable runnable) {
  getGlobalInstance().revalidateFocus(runnable);
}
项目:tools-idea    文件:FocusTrackback.java   
public void restoreFocus() {
  final Application app = ApplicationManager.getApplication();
  if (app == null || wrongOS() || myConsumed || isSheduledForRestore()) return;

  Project project = null;
  DataContext context =
      myParentWindow == null ? DataManager.getInstance().getDataContext() : DataManager.getInstance().getDataContext(myParentWindow);
  if (context != null) {
    project = PlatformDataKeys.PROJECT.getData(context);
  }

  mySheduledForRestore = true;
  final List<FocusTrackback> stack = getCleanStackForRoot();
  final int index = stack.indexOf(this);
  for (int i = index - 1; i >=0; i--) {
    if (stack.get(i).isSheduledForRestore()) {
      dispose();
      return;
    }
  }

  if (project != null && !project.isDisposed()) {
    final IdeFocusManager focusManager = IdeFocusManager.getInstance(project);
    cleanParentWindow();
    final Project finalProject = project;
    focusManager.requestFocus(new MyFocusCommand(), myForcedRestore).doWhenProcessed(new Runnable() {
      public void run() {
        dispose();
      }
    }).doWhenRejected(new Runnable() {
      @Override
      public void run() {
        focusManager.revalidateFocus(new ExpirableRunnable.ForProject(finalProject) {
          @Override
          public void run() {
            if (UIUtil.isMeaninglessFocusOwner(focusManager.getFocusOwner())) {
              focusManager.requestDefaultFocus(false);
            }
          }
        });
      }
    });
  }
  else {
    // no ide focus manager, so no way -- do just later
    //noinspection SSBasedInspection
    SwingUtilities.invokeLater(new Runnable() {
      public void run() {
        _restoreFocus();
        dispose();
      }
    });
  }
}
项目:consulo    文件:WebIdeFocusManagerImpl.java   
@Override
public void doWhenFocusSettlesDown(@Nonnull ExpirableRunnable runnable) {
  if (!runnable.isExpired()) {
    runnable.run();
  }
}
项目:consulo    文件:IdeFocusManagerHeadless.java   
@Override
public void doWhenFocusSettlesDown(@Nonnull ExpirableRunnable runnable) {
  if (!runnable.isExpired()) {
    runnable.run();
  }
}
项目:consulo    文件:PassThroughIdeFocusManager.java   
@Override
public void doWhenFocusSettlesDown(@Nonnull ExpirableRunnable runnable) {
  if (!runnable.isExpired()) {
    runnable.run();
  }
}
项目:consulo    文件:DesktopIdeFocusManagerImpl.java   
@Override
public void doWhenFocusSettlesDown(@Nonnull ExpirableRunnable runnable) {
  getGlobalInstance().doWhenFocusSettlesDown(runnable);
}
项目:intellij-ce-playground    文件:PassThroughIdeFocusManager.java   
@Override
public void revalidateFocus(@NotNull ExpirableRunnable runnable) {

}
项目:intellij-ce-playground    文件:IdeFocusManager.java   
/**
 * Executes given runnable after all focus activities are finished
 */
public abstract void doWhenFocusSettlesDown(@NotNull ExpirableRunnable runnable);
项目:intellij-ce-playground    文件:IdeFocusManager.java   
/**
 * Injects some procedure that will maybe do something with focus after all focus requests are fulfilled and
 * before focus transfer is reported ready.
 */
public abstract void revalidateFocus(@NotNull ExpirableRunnable runnable);
项目:tools-idea    文件:PassThroughIdeFocusManager.java   
@Override
public void revalidateFocus(@NotNull ExpirableRunnable runnable) {

}
项目:tools-idea    文件:IdeFocusManager.java   
/**
 * Executes given runnable after all focus activities are finished
 * @param runnable
 */
public abstract void doWhenFocusSettlesDown(@NotNull ExpirableRunnable runnable);
项目:tools-idea    文件:IdeFocusManager.java   
/**
 * Injects some procedure that will maybe do something with focus after all focus requests are fulfilled and
 * before focus transfer is reported ready.
 * @param runnable
 */
public abstract void revalidateFocus(@NotNull ExpirableRunnable runnable);
项目:consulo    文件:IdeFocusManager.java   
/**
 * Executes given runnable after all focus activities are finished
 */
public abstract void doWhenFocusSettlesDown(@Nonnull ExpirableRunnable runnable);