예제 #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;
  }
  public void doExecute(@NotNull final AnActionEvent event, final Map<String, Object> _params) {
    try {
      SNodePointer script =
          new SNodePointer(
              "r:00000000-0000-4000-0000-011c89590367(jetbrains.mps.lang.plugin.scripts)",
              "4214874532454943783");

      MigrationScriptExecutor executor =
          new MigrationScriptExecutor(
              script,
              "Resolve Broken Stub References",
              ((IOperationContext) MapSequence.fromMap(_params).get("context")),
              ((Project) MapSequence.fromMap(_params).get("project")));
      if (CommandProcessorEx.getInstance().getCurrentCommand() != null) {
        executor.execImmediately(new ProgressMonitorAdapter(new EmptyProgressIndicator()));
      } else {
        executor.execAsCommand(((Frame) MapSequence.fromMap(_params).get("frame")));
      }
    } catch (Throwable t) {
      if (log.isErrorEnabled()) {
        log.error(
            "User's action execute method failed. Action:" + "MigrationScript_ResolveBrokenRefs",
            t);
      }
    }
  }