コード例 #1
0
  @Override
  public void runCheckinHandlers(@NotNull final Runnable finishAction) {
    final VcsConfiguration configuration = VcsConfiguration.getInstance(myProject);
    final Collection<VirtualFile> files = myPanel.getVirtualFiles();

    final Runnable performCheckoutAction =
        new Runnable() {
          @Override
          public void run() {
            FileDocumentManager.getInstance().saveAllDocuments();
            finishAction.run();
          }
        };

    if (reformat(configuration, true) && !DumbService.isDumb(myProject)) {
      new ReformatCodeProcessor(
              myProject,
              CheckinHandlerUtil.getPsiFiles(myProject, files),
              FormatterUtil.REFORMAT_BEFORE_COMMIT_COMMAND_NAME,
              performCheckoutAction,
              true)
          .run();
    } else {
      performCheckoutAction.run();
    }
  }
コード例 #2
0
  @Override
  @Nullable
  public RefreshableOnComponent getBeforeCheckinConfigurationPanel() {
    final JCheckBox reformatBox =
        new NonFocusableCheckBox(VcsBundle.message("checkbox.checkin.options.reformat.code"));
    CheckinHandlerUtil.disableWhenDumb(
        myProject, reformatBox, "Impossible until indices are up-to-date");
    return new RefreshableOnComponent() {
      @Override
      public JComponent getComponent() {
        final JPanel panel = new JPanel(new GridLayout(1, 0));
        panel.add(reformatBox);
        return panel;
      }

      @Override
      public void refresh() {}

      @Override
      public void saveState() {
        getSettings().REFORMAT_BEFORE_PROJECT_COMMIT = reformatBox.isSelected();
      }

      @Override
      public void restoreState() {
        reformatBox.setSelected(getSettings().REFORMAT_BEFORE_PROJECT_COMMIT);
      }
    };
  }