private void updateControls() {
    if (myCbReplaceWrite != null) {
      if (myCbReplaceAll.isSelected()) {
        myCbReplaceWrite.makeSelectable();
      } else {
        myCbReplaceWrite.makeUnselectable(true);
      }
    }

    if (myCbReplaceAll != null) {
      myTypeSelectorManager.setAllOccurrences(myCbReplaceAll.isSelected());
    } else {
      myTypeSelectorManager.setAllOccurrences(false);
    }

    if (myDeclareFinalIfAll && myCbReplaceAll != null && myCbReplaceAll.isSelected()) {
      myCbFinal.setEnabled(false);
      myCbFinal.setSelected(true);
    } else if (myCbReplaceWrite != null
        && myCbReplaceWrite.isEnabled()
        && myCbReplaceWrite.isSelected()) {
      myCbFinal.setEnabled(false);
      myCbFinal.setSelected(false);
    } else {
      myCbFinal.setEnabled(true);
      myCbFinal.setSelected(myCbFinalState);
    }
  }
  protected void saveSettings(JavaRefactoringSettings settings) {
    if (myCbDeleteLocalVariable != null) {
      settings.INTRODUCE_PARAMETER_DELETE_LOCAL_VARIABLE =
          myCbDeleteLocalVariable.isSelectedWhenSelectable();
    }

    if (myCbUseInitializer != null) {
      settings.INTRODUCE_PARAMETER_USE_INITIALIZER = myCbUseInitializer.isSelectedWhenSelectable();
    }
  }
 public boolean isReplaceLValues() {
   if (myOccurrencesCount <= 1 || !myAnyLValueOccurences || myCbReplaceWrite == null) {
     return true;
   } else {
     return myCbReplaceWrite.isSelected();
   }
 }
 protected void updateControls(JCheckBox[] removeParamsCb) {
   if (myCbReplaceAllOccurences != null) {
     for (JCheckBox box : removeParamsCb) {
       if (box != null) {
         box.setEnabled(myCbReplaceAllOccurences.isSelected());
         box.setSelected(myCbReplaceAllOccurences.isSelected());
       }
     }
     if (myCbReplaceAllOccurences.isSelected()) {
       if (myCbDeleteLocalVariable != null) {
         myCbDeleteLocalVariable.makeSelectable();
       }
     } else {
       if (myCbDeleteLocalVariable != null) {
         myCbDeleteLocalVariable.makeUnselectable(false);
       }
     }
   }
 }
  protected void createLocalVariablePanel(
      GridBagConstraints gbConstraints, JPanel panel, JavaRefactoringSettings settings) {
    if (myIsLocalVariable && !myIsInvokedOnDeclaration) {
      myCbDeleteLocalVariable = new StateRestoringCheckBox();
      myCbDeleteLocalVariable.setText(RefactoringBundle.message("delete.variable.declaration"));
      myCbDeleteLocalVariable.setFocusable(false);

      gbConstraints.gridy++;
      panel.add(myCbDeleteLocalVariable, gbConstraints);
      myCbDeleteLocalVariable.setSelected(settings.INTRODUCE_PARAMETER_DELETE_LOCAL_VARIABLE);

      gbConstraints.insets = new Insets(0, 0, 4, 8);
      if (myHasInitializer) {
        myCbUseInitializer = new StateRestoringCheckBox();
        myCbUseInitializer.setText(
            RefactoringBundle.message("use.variable.initializer.to.initialize.parameter"));
        myCbUseInitializer.setSelected(settings.INTRODUCE_PARAMETER_USE_INITIALIZER);
        myCbUseInitializer.setFocusable(false);

        gbConstraints.gridy++;
        panel.add(myCbUseInitializer, gbConstraints);
      }
    }
  }
 protected boolean isUseInitializer() {
   if (myIsInvokedOnDeclaration) return myHasInitializer;
   return myCbUseInitializer != null && myCbUseInitializer.isSelected();
 }
 protected boolean isDeleteLocalVariable() {
   return myIsInvokedOnDeclaration
       || myCbDeleteLocalVariable != null && myCbDeleteLocalVariable.isSelected();
 }
  protected JComponent createCenterPanel() {
    JPanel panel = new JPanel(new GridBagLayout());
    GridBagConstraints gbConstraints = new GridBagConstraints();
    gbConstraints.fill = GridBagConstraints.HORIZONTAL;
    gbConstraints.weightx = 1;
    gbConstraints.weighty = 0;
    gbConstraints.gridwidth = 1;
    gbConstraints.gridx = 0;
    gbConstraints.gridy = 0;
    gbConstraints.insets = JBUI.emptyInsets();

    if (myOccurrencesCount > 1) {
      myCbReplaceAll = new NonFocusableCheckBox();
      myCbReplaceAll.setText(
          RefactoringBundle.message("replace.all.occurences", myOccurrencesCount));

      panel.add(myCbReplaceAll, gbConstraints);
      myReplaceAllListener =
          new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
              updateControls();
            }
          };
      myCbReplaceAll.addItemListener(myReplaceAllListener);

      if (myAnyLValueOccurences) {
        myCbReplaceWrite = new StateRestoringCheckBox();
        myCbReplaceWrite.setText(RefactoringBundle.message("replace.write.access.occurrences"));
        gbConstraints.insets = JBUI.insetsLeft(8);
        gbConstraints.gridy++;
        panel.add(myCbReplaceWrite, gbConstraints);
        myCbReplaceWrite.addItemListener(myReplaceAllListener);
      }
    }

    myCbFinal = new NonFocusableCheckBox();
    myCbFinal.setText(RefactoringBundle.message("declare.final"));
    final Boolean createFinals =
        JavaRefactoringSettings.getInstance().INTRODUCE_LOCAL_CREATE_FINALS;
    myCbFinalState =
        createFinals == null
            ? CodeStyleSettingsManager.getSettings(myProject).GENERATE_FINAL_LOCALS
            : createFinals.booleanValue();

    gbConstraints.insets = JBUI.emptyInsets();
    gbConstraints.gridy++;
    panel.add(myCbFinal, gbConstraints);
    myFinalListener =
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            if (myCbFinal.isEnabled()) {
              myCbFinalState = myCbFinal.isSelected();
            }
          }
        };
    myCbFinal.addItemListener(myFinalListener);

    updateControls();

    return panel;
  }