private void saveSettings() {
   final JavaRefactoringSettings settings = JavaRefactoringSettings.getInstance();
   settings.INTRODUCE_PARAMETER_CREATE_FINALS = myDeclareFinalCheckBox.isSelected();
   if (myGetterPanel.isVisible()) {
     settings.INTRODUCE_PARAMETER_REPLACE_FIELDS_WITH_GETTERS = getReplaceFieldsWithGetter();
   }
   if (myForceReturnCheckBox.isEnabled() && mySignaturePanel.isVisible()) {
     GroovyApplicationSettings.getInstance().FORCE_RETURN = myForceReturnCheckBox.isSelected();
   }
 }
  private void createCheckBoxes(JPanel panel) {
    myDeclareFinalCheckBox = new JCheckBox(UIUtil.replaceMnemonicAmpersand("Declare &final"));
    myDeclareFinalCheckBox.setFocusable(false);
    panel.add(myDeclareFinalCheckBox);

    myDelegateViaOverloadingMethodCheckBox =
        new JCheckBox(UIUtil.replaceMnemonicAmpersand("De&legate via overloading method"));
    myDelegateViaOverloadingMethodCheckBox.setFocusable(false);
    panel.add(myDelegateViaOverloadingMethodCheckBox);

    for (Object o : toRemoveCBs.keys()) {
      final JCheckBox cb = (JCheckBox) o;
      cb.setFocusable(false);
      panel.add(cb);
    }
  }
  public GrIntroduceParameterDialog(IntroduceParameterInfo info) {
    super(info.getProject(), true);
    myInfo = info;
    myProject = info.getProject();
    myCanIntroduceSimpleParameter =
        GroovyIntroduceParameterUtil.findExpr(myInfo) != null
            || GroovyIntroduceParameterUtil.findVar(myInfo) != null
            || findStringPart() != null;

    TObjectIntHashMap<GrParameter> parametersToRemove =
        GroovyIntroduceParameterUtil.findParametersToRemove(info);
    toRemoveCBs = new TObjectIntHashMap<JCheckBox>(parametersToRemove.size());
    for (Object p : parametersToRemove.keys()) {
      JCheckBox cb =
          new JCheckBox(
              GroovyRefactoringBundle.message(
                  "remove.parameter.0.no.longer.used", ((GrParameter) p).getName()));
      toRemoveCBs.put(cb, parametersToRemove.get((GrParameter) p));
      cb.setSelected(true);
    }

    init();
  }
  @Override
  public void doOKAction() {
    saveSettings();

    super.doOKAction();

    final GrParametersOwner toReplaceIn = myInfo.getToReplaceIn();

    final GrExpression expr = GroovyIntroduceParameterUtil.findExpr(myInfo);
    final GrVariable var = GroovyIntroduceParameterUtil.findVar(myInfo);
    final StringPartInfo stringPart = findStringPart();

    if (myTypeComboBox.isClosureSelected() || expr == null && var == null && stringPart == null) {
      GrIntroduceParameterSettings settings =
          new ExtractClosureHelperImpl(
              myInfo,
              getEnteredName(),
              myDeclareFinalCheckBox.isSelected(),
              getParametersToRemove(),
              myDelegateViaOverloadingMethodCheckBox.isSelected(),
              getReplaceFieldsWithGetter(),
              myForceReturnCheckBox.isSelected(),
              myTypeComboBox.getSelectedType() == null);
      if (toReplaceIn instanceof GrMethod) {
        invokeRefactoring(new ExtractClosureFromMethodProcessor(settings));
      } else {
        invokeRefactoring(new ExtractClosureFromClosureProcessor(settings));
      }
    } else {

      GrIntroduceParameterSettings settings =
          new GrIntroduceExpressionSettingsImpl(
              myInfo,
              getEnteredName(),
              myDeclareFinalCheckBox.isSelected(),
              getParametersToRemove(),
              myDelegateViaOverloadingMethodCheckBox.isSelected(),
              getReplaceFieldsWithGetter(),
              expr,
              var,
              myTypeComboBox.getSelectedType(),
              myForceReturnCheckBox.isSelected());
      if (toReplaceIn instanceof GrMethod) {
        invokeRefactoring(new GrIntroduceParameterProcessor(settings));
      } else {
        invokeRefactoring(new GrIntroduceClosureParameterProcessor(settings));
      }
    }
  }
  @Override
  protected void init() {
    super.init();

    JavaRefactoringSettings settings = JavaRefactoringSettings.getInstance();

    initReplaceFieldsWithGetters(settings);

    myDeclareFinalCheckBox.setSelected(hasFinalModifier());
    myDelegateViaOverloadingMethodCheckBox.setVisible(myInfo.getToSearchFor() != null);

    setTitle(RefactoringBundle.message("introduce.parameter.title"));

    myTable.init(myInfo);

    final GrParameter[] parameters = myInfo.getToReplaceIn().getParameters();
    toRemoveCBs.forEachEntry(
        new TObjectIntProcedure<JCheckBox>() {
          @Override
          public boolean execute(JCheckBox checkbox, int index) {
            checkbox.setSelected(true);

            final GrParameter param = parameters[index];
            final ParameterInfo pinfo = findParamByOldName(param.getName());
            if (pinfo != null) {
              pinfo.setPassAsParameter(false);
            }
            return true;
          }
        });

    updateSignature();

    if (myCanIntroduceSimpleParameter) {
      mySignaturePanel.setVisible(false);

      // action to hide signature panel if we have variants to introduce simple parameter
      myTypeComboBox.addItemListener(
          new ItemListener() {
            @Override
            public void itemStateChanged(ItemEvent e) {
              mySignaturePanel.setVisible(myTypeComboBox.isClosureSelected());
              pack();
            }
          });
    }

    final PsiType closureReturnType = inferClosureReturnType();
    if (closureReturnType == PsiType.VOID) {
      myForceReturnCheckBox.setEnabled(false);
      myForceReturnCheckBox.setSelected(false);
    } else {
      myForceReturnCheckBox.setSelected(isForceReturn());
    }

    if (myInfo.getToReplaceIn() instanceof GrClosableBlock) {
      myDelegateViaOverloadingMethodCheckBox.setEnabled(false);
      myDelegateViaOverloadingMethodCheckBox.setToolTipText(
          "Delegating is not allowed in closure context");
    }

    pack();
  }