Пример #1
0
 @Override
 public String getDescription(RunConfigurableBeforeRunTask task) {
   if (task.getSettings() == null) {
     return ExecutionBundle.message("before.launch.run.another.configuration");
   } else {
     return ExecutionBundle.message(
         "before.launch.run.certain.configuration", task.getSettings().getName());
   }
 }
  private ValidationResult getValidationResult() {
    if (!myValidationResultValid) {
      myLastValidationResult = null;
      try {
        RunnerAndConfigurationSettings snapshot = getSnapshot();
        if (snapshot != null) {
          snapshot.setName(getNameText());
          snapshot.checkSettings();
          for (ProgramRunner runner : RunnerRegistry.getInstance().getRegisteredRunners()) {
            for (Executor executor : ExecutorRegistry.getInstance().getRegisteredExecutors()) {
              if (runner.canRun(executor.getId(), snapshot.getConfiguration())) {
                checkConfiguration(runner, snapshot);
                break;
              }
            }
          }
        }
      } catch (RuntimeConfigurationException exception) {
        myLastValidationResult =
            exception != null
                ? new ValidationResult(
                    exception.getLocalizedMessage(), exception.getTitle(), exception.getQuickFix())
                : null;
      } catch (ConfigurationException e) {
        myLastValidationResult =
            new ValidationResult(
                e.getLocalizedMessage(),
                ExecutionBundle.message("invalid.data.dialog.title"),
                null);
      }

      myValidationResultValid = true;
    }
    return myLastValidationResult;
  }
Пример #3
0
 public void restart() {
   final Project project =
       PlatformDataKeys.PROJECT.getData(
           DataManager.getInstance().getDataContext(myDescriptor.getComponent()));
   if (ExecutorRegistry.getInstance()
       .isStarting(project, myExecutor.getId(), myRunner.getRunnerId())) {
     return;
   }
   try {
     final ExecutionEnvironment old = myEnvironment;
     myRunner.execute(
         myExecutor,
         new ExecutionEnvironment(
             old.getRunProfile(),
             old.getExecutionTarget(),
             project,
             old.getRunnerSettings(),
             old.getConfigurationSettings(),
             myDescriptor,
             old.getRunnerAndConfigurationSettings()));
   } catch (RunCanceledByUserException ignore) {
   } catch (ExecutionException e1) {
     Messages.showErrorDialog(
         project, e1.getMessage(), ExecutionBundle.message("restart.error.message.title"));
   }
 }
Пример #4
0
 private SelectionDialog(
     RunnerAndConfigurationSettings selectedSettings,
     @NotNull List<RunnerAndConfigurationSettings> settings) {
   super(myProject);
   setTitle(ExecutionBundle.message("before.launch.run.another.configuration.choose"));
   mySelectedSettings = selectedSettings;
   mySettings = settings;
   init();
   myJBList.setSelectedValue(mySelectedSettings, true);
   myJBList.addMouseListener(
       new MouseAdapter() {
         @Override
         public void mouseClicked(MouseEvent e) {
           if (SwingUtilities.isLeftMouseButton(e) && e.getClickCount() == 2) {
             doOKAction();
           }
         }
       });
   FontMetrics fontMetrics = myJBList.getFontMetrics(myJBList.getFont());
   int maxWidth = fontMetrics.stringWidth("m") * 30;
   for (RunnerAndConfigurationSettings setting : settings) {
     maxWidth =
         Math.max(fontMetrics.stringWidth(setting.getConfiguration().getName()), maxWidth);
   }
   maxWidth += 24; // icon and gap
   myJBList.setMinimumSize(new Dimension(maxWidth, myJBList.getPreferredSize().height));
 }
  private static boolean userApprovesStopForSameTypeConfigurations(
      Project project, String configName, int instancesCount) {
    RunManagerImpl runManager = RunManagerImpl.getInstanceImpl(project);
    final RunManagerConfig config = runManager.getConfig();
    if (!config.isRestartRequiresConfirmation()) return true;

    DialogWrapper.DoNotAskOption option =
        new DialogWrapper.DoNotAskOption() {
          @Override
          public boolean isToBeShown() {
            return config.isRestartRequiresConfirmation();
          }

          @Override
          public void setToBeShown(boolean value, int exitCode) {
            config.setRestartRequiresConfirmation(value);
          }

          @Override
          public boolean canBeHidden() {
            return true;
          }

          @Override
          public boolean shouldSaveOptionsOnCancel() {
            return false;
          }

          @NotNull
          @Override
          public String getDoNotShowMessage() {
            return CommonBundle.message("dialog.options.do.not.show");
          }
        };
    return Messages.showOkCancelDialog(
            project,
            ExecutionBundle.message(
                "rerun.singleton.confirmation.message", configName, instancesCount),
            ExecutionBundle.message("process.is.running.dialog.title", configName),
            ExecutionBundle.message("rerun.confirmation.button.text"),
            CommonBundle.message("button.cancel"),
            Messages.getQuestionIcon(),
            option)
        == Messages.OK;
  }
Пример #6
0
  @Override
  public void update(final AnActionEvent event) {
    final Presentation presentation = event.getPresentation();
    String name = myEnvironment.getRunProfile().getName();
    ProcessHandler processHandler = myDescriptor.getProcessHandler();
    final boolean isRunning = processHandler != null && !processHandler.isProcessTerminated();

    presentation.setText(ExecutionBundle.message("rerun.configuration.action.name", name));
    presentation.setIcon(isRunning ? AllIcons.Actions.Restart : myExecutor.getIcon());
    presentation.setEnabled(isEnabled());
  }
 @Override
 public void update(final AnActionEvent e) {
   final Presentation presentation = e.getPresentation();
   final Project project = e.getData(CommonDataKeys.PROJECT);
   if (project == null) {
     disable(presentation);
     return;
   }
   RunnerAndConfigurationSettings settings = chooseTempSettings(project);
   if (settings == null) {
     disable(presentation);
   } else {
     presentation.setText(
         ExecutionBundle.message(
             "save.temporary.run.configuration.action.name", settings.getName()));
     presentation.setDescription(presentation.getText());
     presentation.setVisible(true);
     presentation.setEnabled(true);
   }
 }
 @Override
 public void update(AnActionEvent e) {
   Presentation presentation = e.getPresentation();
   Project project = e.getData(CommonDataKeys.PROJECT);
   if (ActionPlaces.isMainMenuOrActionSearch(e.getPlace())) {
     presentation.setDescription(
         ExecutionBundle.message("choose.run.configuration.action.description"));
   }
   try {
     if (project == null || project.isDisposed() || !project.isInitialized()) {
       updatePresentation(null, null, null, presentation);
       presentation.setEnabled(false);
     } else {
       updatePresentation(
           ExecutionTargetManager.getActiveTarget(project),
           RunManagerEx.getInstanceEx(project).getSelectedConfiguration(),
           project,
           presentation);
       presentation.setEnabled(true);
     }
   } catch (IndexNotReadyException e1) {
     presentation.setEnabled(false);
   }
 }
  public static void handleExecutionError(
      @NotNull final Project project,
      @NotNull final String toolWindowId,
      @NotNull String taskName,
      @NotNull ExecutionException e) {
    if (e instanceof RunCanceledByUserException) {
      return;
    }

    LOG.debug(e);

    String description = e.getMessage();
    if (description == null) {
      LOG.warn("Execution error without description", e);
      description = "Unknown error";
    }

    HyperlinkListener listener = null;
    if ((description.contains("87") || description.contains("111") || description.contains("206"))
        && e instanceof ProcessNotCreatedException
        && !PropertiesComponent.getInstance(project).isTrueValue("dynamic.classpath")) {
      final String commandLineString =
          ((ProcessNotCreatedException) e).getCommandLine().getCommandLineString();
      if (commandLineString.length() > 1024 * 32) {
        description =
            "Command line is too long. In order to reduce its length classpath file can be used.<br>"
                + "Would you like to enable classpath file mode for all run configurations of your project?<br>"
                + "<a href=\"\">Enable</a>";

        listener =
            new HyperlinkListener() {
              @Override
              public void hyperlinkUpdate(HyperlinkEvent event) {
                PropertiesComponent.getInstance(project).setValue("dynamic.classpath", "true");
              }
            };
      }
    }
    final String title = ExecutionBundle.message("error.running.configuration.message", taskName);
    final String fullMessage = title + ":<br>" + description;

    if (ApplicationManager.getApplication().isUnitTestMode()) {
      LOG.error(fullMessage, e);
    }

    if (listener == null && e instanceof HyperlinkListener) {
      listener = (HyperlinkListener) e;
    }

    final HyperlinkListener finalListener = listener;
    final String finalDescription = description;
    UIUtil.invokeLaterIfNeeded(
        new Runnable() {
          @Override
          public void run() {
            if (project.isDisposed()) {
              return;
            }

            ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
            if (toolWindowManager.canShowNotification(toolWindowId)) {
              //noinspection SSBasedInspection
              toolWindowManager.notifyByBalloon(
                  toolWindowId, MessageType.ERROR, fullMessage, null, finalListener);
            } else {
              Messages.showErrorDialog(project, UIUtil.toHtml(fullMessage), "");
            }
            NotificationListener notificationListener =
                finalListener == null
                    ? null
                    : new NotificationListener() {
                      @Override
                      public void hyperlinkUpdate(
                          @NotNull Notification notification, @NotNull HyperlinkEvent event) {
                        finalListener.hyperlinkUpdate(event);
                      }
                    };
            ourNotificationGroup
                .createNotification(
                    title, finalDescription, NotificationType.ERROR, notificationListener)
                .notify(project);
          }
        });
  }
  private static boolean userApprovesStopForIncompatibleConfigurations(
      Project project,
      String configName,
      List<RunContentDescriptor> runningIncompatibleDescriptors) {
    RunManagerImpl runManager = RunManagerImpl.getInstanceImpl(project);
    final RunManagerConfig config = runManager.getConfig();
    if (!config.isStopIncompatibleRequiresConfirmation()) return true;

    DialogWrapper.DoNotAskOption option =
        new DialogWrapper.DoNotAskOption() {
          @Override
          public boolean isToBeShown() {
            return config.isStopIncompatibleRequiresConfirmation();
          }

          @Override
          public void setToBeShown(boolean value, int exitCode) {
            config.setStopIncompatibleRequiresConfirmation(value);
          }

          @Override
          public boolean canBeHidden() {
            return true;
          }

          @Override
          public boolean shouldSaveOptionsOnCancel() {
            return false;
          }

          @NotNull
          @Override
          public String getDoNotShowMessage() {
            return CommonBundle.message("dialog.options.do.not.show");
          }
        };

    final StringBuilder names = new StringBuilder();
    for (final RunContentDescriptor descriptor : runningIncompatibleDescriptors) {
      String name = descriptor.getDisplayName();
      if (names.length() > 0) {
        names.append(", ");
      }
      names.append(
          StringUtil.isEmpty(name)
              ? ExecutionBundle.message("run.configuration.no.name")
              : String.format("'%s'", name));
    }

    //noinspection DialogTitleCapitalization
    return Messages.showOkCancelDialog(
            project,
            ExecutionBundle.message(
                "stop.incompatible.confirmation.message",
                configName,
                names.toString(),
                runningIncompatibleDescriptors.size()),
            ExecutionBundle.message(
                "incompatible.configuration.is.running.dialog.title",
                runningIncompatibleDescriptors.size()),
            ExecutionBundle.message("stop.incompatible.confirmation.button.text"),
            CommonBundle.message("button.cancel"),
            Messages.getQuestionIcon(),
            option)
        == Messages.OK;
  }
Пример #11
0
 @Override
 public String getName() {
   return ExecutionBundle.message("before.launch.run.another.configuration");
 }