@Override
 protected void saveSettings(@NotNull PsiVariable psiVariable) {
   super.saveSettings(psiVariable);
   JavaRefactoringSettings.getInstance().INTRODUCE_FIELD_VISIBILITY =
       myIntroduceFieldPanel.getFieldVisibility();
   myIntroduceFieldPanel.saveFinalState();
 }
 private void updateInitializer(PsiElementFactory elementFactory, PsiField variable) {
   if (variable != null) {
     if (myIntroduceFieldPanel.getInitializerPlace()
         == GosuBaseExpressionToFieldHandler.InitializationPlace.IN_FIELD_DECLARATION) {
       variable.setInitializer(elementFactory.createExpressionFromText(myExprText, variable));
     } else {
       variable.setInitializer(null);
     }
   }
 }
  @Override
  protected JComponent getComponent() {
    myIntroduceFieldPanel.addOccurrenceListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            restartInplaceIntroduceTemplate();
          }
        });

    return myWholePanel;
  }
 protected void performIntroduce() {
   ourLastInitializerPlace = myIntroduceFieldPanel.getInitializerPlace();
   final GosuBaseExpressionToFieldHandler.Settings settings =
       new GosuBaseExpressionToFieldHandler.Settings(
           getInputName(),
           getExpr(),
           getOccurrences(),
           myIntroduceFieldPanel.isReplaceAllOccurrences(),
           myStatic,
           myIntroduceFieldPanel.isDeclareFinal(),
           myIntroduceFieldPanel.getInitializerPlace(),
           myIntroduceFieldPanel.getFieldVisibility(),
           (PsiLocalVariable) getLocalVariable(),
           getType(),
           myIntroduceFieldPanel.isDeleteVariable(),
           myParentClass,
           false,
           false);
   new WriteCommandAction(myProject, getCommandName(), getCommandName()) {
     @Override
     protected void run(Result result) throws Throwable {
       if (getLocalVariable() != null) {
         final GosuLocalToFieldHandler.IntroduceFieldRunnable fieldRunnable =
             new GosuLocalToFieldHandler.IntroduceFieldRunnable(
                 false,
                 (PsiLocalVariable) getLocalVariable(),
                 myParentClass,
                 settings,
                 myStatic,
                 myOccurrences);
         fieldRunnable.run();
       } else {
         final GosuBaseExpressionToFieldHandler.ConvertToFieldRunnable convertToFieldRunnable =
             new GosuBaseExpressionToFieldHandler.ConvertToFieldRunnable(
                 myExpr,
                 settings,
                 settings.getForcedType(),
                 myOccurrences,
                 myOccurrenceManager,
                 getAnchorElementIfAll(),
                 getAnchorElement(),
                 myEditor,
                 myParentClass);
         convertToFieldRunnable.run();
       }
     }
   }.execute();
 }
  public GosuInplaceIntroduceFieldPopup(
      PsiLocalVariable localVariable,
      PsiClass parentClass,
      boolean aStatic,
      boolean currentMethodConstructor,
      PsiExpression[] occurrences,
      PsiExpression initializerExpression,
      TypeSelectorManagerImpl typeSelectorManager,
      Editor editor,
      final boolean allowInitInMethod,
      boolean allowInitInMethodIfAll,
      final PsiElement anchorElement,
      final PsiElement anchorElementIfAll,
      final OccurrenceManager occurrenceManager,
      Project project) {
    super(
        project,
        editor,
        initializerExpression,
        localVariable,
        occurrences,
        typeSelectorManager,
        IntroduceFieldHandler.REFACTORING_NAME,
        parentClass,
        anchorElement,
        occurrenceManager,
        anchorElementIfAll);
    myStatic = aStatic;
    myIntroduceFieldPanel =
        new GosuIntroduceFieldPopupPanel(
            parentClass,
            initializerExpression,
            localVariable,
            currentMethodConstructor,
            localVariable != null,
            aStatic,
            myOccurrences,
            allowInitInMethod,
            allowInitInMethodIfAll,
            typeSelectorManager);

    final GridBagConstraints constraints =
        new GridBagConstraints(
            0,
            GridBagConstraints.RELATIVE,
            1,
            1,
            1,
            0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, 0, 0, 0),
            0,
            0);
    myWholePanel.add(getPreviewComponent(), constraints);

    final JComponent centerPanel = myIntroduceFieldPanel.createCenterPanel();

    myWholePanel.add(centerPanel, constraints);

    myIntroduceFieldPanel.initializeControls(initializerExpression, ourLastInitializerPlace);
  }
 public GosuBaseExpressionToFieldHandler.InitializationPlace getInitializerPlace() {
   return myIntroduceFieldPanel.getInitializerPlace();
 }
 @Override
 public boolean isReplaceAllOccurrences() {
   return myIntroduceFieldPanel.isReplaceAllOccurrences();
 }
 public void setVisibility(String visibility) {
   myIntroduceFieldPanel.setVisibility(visibility);
 }
 public void setReplaceAllOccurrences(boolean replaceAllOccurrences) {
   myIntroduceFieldPanel.setReplaceAllOccurrences(replaceAllOccurrences);
 }