Example #1
0
  @Override
  public ActionCallback show() {
    LOG.assertTrue(
        EventQueue.isDispatchThread(), "Access is allowed from event dispatch thread only");
    if (myTypeAheadCallback != null) {
      IdeFocusManager.getInstance(myProject).typeAheadUntil(myTypeAheadCallback);
    }
    LOG.assertTrue(
        EventQueue.isDispatchThread(), "Access is allowed from event dispatch thread only");
    final ActionCallback result = new ActionCallback();

    final AnCancelAction anCancelAction = new AnCancelAction();
    final JRootPane rootPane = getRootPane();
    anCancelAction.registerCustomShortcutSet(
        new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0)), rootPane);
    myDisposeActions.add(
        new Runnable() {
          @Override
          public void run() {
            anCancelAction.unregisterCustomShortcutSet(rootPane);
          }
        });

    if (!myCanBeParent && myWindowManager != null) {
      myWindowManager.doNotSuggestAsParent(myDialog.getWindow());
    }

    final CommandProcessorEx commandProcessor =
        ApplicationManager.getApplication() != null
            ? (CommandProcessorEx) CommandProcessor.getInstance()
            : null;
    final boolean appStarted = commandProcessor != null;

    if (myDialog.isModal() && !isProgressDialog()) {
      if (appStarted) {
        commandProcessor.enterModal();
        LaterInvocator.enterModal(myDialog);
      }
    }

    if (appStarted) {
      hidePopupsIfNeeded();
    }

    try {
      myDialog.show();
    } finally {
      if (myDialog.isModal() && !isProgressDialog()) {
        if (appStarted) {
          commandProcessor.leaveModal();
          LaterInvocator.leaveModal(myDialog);
        }
      }

      myDialog.getFocusManager().doWhenFocusSettlesDown(result.createSetDoneRunnable());
    }

    return result;
  }
Example #2
0
    public final void onReady() {
      if (!isReady()) return;

      ActionCallback[] ready = getReadyCallbacks(true);
      for (ActionCallback each : ready) {
        if (each != null) {
          each.setDone();
        }
      }
    }
Example #3
0
 public ActionCallback execute(ActiveRunnable runnable) {
   myBusyCount.addAndGet(1);
   ActionCallback cb = runnable.run();
   cb.doWhenProcessed(
       new Runnable() {
         public void run() {
           myBusyCount.addAndGet(-1);
           if (isReady()) {
             onReady();
           }
         }
       });
   return cb;
 }
Example #4
0
    public MyDialog(
        Window owner,
        DialogWrapper dialogWrapper,
        Project project,
        @NotNull ActionCallback focused,
        @NotNull ActionCallback typeAheadDone,
        ActionCallback typeAheadCallback) {
      super(owner);
      myDialogWrapper = new WeakReference<DialogWrapper>(dialogWrapper);
      myProject = project != null ? new WeakReference<Project>(project) : null;

      setFocusTraversalPolicy(
          new LayoutFocusTraversalPolicyExt() {
            @Override
            protected boolean accept(Component aComponent) {
              if (UIUtil.isFocusProxy(aComponent)) return false;
              return super.accept(aComponent);
            }
          });

      myFocusedCallback = focused;
      myTypeAheadDone = typeAheadDone;
      myTypeAheadCallback = typeAheadCallback;

      final long typeAhead = getDialogWrapper().getTypeAheadTimeoutMs();
      if (typeAhead <= 0) {
        myTypeAheadDone.setDone();
      }

      setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
      myWindowListener = new MyWindowListener();
      addWindowListener(myWindowListener);

      myComponentListener = new MyComponentListener();
      addComponentListener(myComponentListener);
    }
Example #5
0
 public Future execute(ActionCallback callback) {
   log.trace("Invoking action in background: " + callback);
   callback.setControlPoint(this);
   ExecutorService executor = getConfiguration().getSyncProtocolExecutorService();
   return executor.submit(callback);
 }