コード例 #1
0
 private void updateControlsEnabled() {
   myClassPackageChooser.setEnabled(myToPackageRadioButton.isSelected());
   myInnerClassChooser.setEnabled(myMakeInnerClassOfRadioButton.isSelected());
   UIUtil.setEnabled(
       myTargetPanel,
       isMoveToPackage() && getSourceRoots().length > 1 && !myTargetDirectoryFixed,
       true);
   validateButtons();
 }
コード例 #2
0
  private void updateEnabledState() {
    myLabelEditor.setEnabled(myRbExpressionLabel.isSelected());

    final boolean isChildrenExpression = myRbExpressionChildrenRenderer.isSelected();
    myChildrenExpandedEditor.setEnabled(isChildrenExpression);
    myExpandedLabel.setEnabled(isChildrenExpression);
    myChildrenEditor.setEnabled(isChildrenExpression);
    myTable.setEnabled(myRbListChildrenRenderer.isSelected());
  }
コード例 #3
0
  private String generateSignatureText() {
    String name = getNewName();
    String type = myReturnTypeField.getText().trim();

    StringBuilder builder = new StringBuilder();
    if (myPublicRadioButton.isSelected() && type.length() == 0) {
      builder.append(GrModifier.DEF);
    }
    if (myPrivateRadioButton.isSelected()) {
      builder.append(GrModifier.PRIVATE).append(' ');
    } else if (myProtectedRadioButton.isSelected()) {
      builder.append(GrModifier.PROTECTED).append(' ');
    }
    builder.append(type).append(' ');
    builder.append(name).append('(');

    final List<GrTableParameterInfo> infos = myParameterModel.getParameterInfos();
    if (infos.size() > 0) {
      final List<String> paramsText =
          ContainerUtil.map(
              infos,
              new Function<GrTableParameterInfo, String>() {
                public String fun(GrTableParameterInfo grParameterInfo) {
                  return generateParameterText(grParameterInfo);
                }
              });
      builder.append("\n").append(INDENT);
      builder.append(StringUtil.join(paramsText, ",\n" + INDENT));
      builder.append('\n');
    }
    builder.append(')');

    final PsiTypeCodeFragment[] exceptions = myExceptionTableModel.getTypeCodeFragments();
    if (exceptions.length > 0) {
      builder.append("\nthrows\n");
      final List<String> exceptionNames =
          ContainerUtil.map(
              exceptions,
              new Function<PsiTypeCodeFragment, String>() {
                public String fun(PsiTypeCodeFragment fragment) {
                  return fragment.getText();
                }
              });

      builder.append(INDENT).append(StringUtil.join(exceptionNames, ",\n" + INDENT));
    }
    return builder.toString();
  }
コード例 #4
0
  @Override
  protected void doAction() {
    if (!validateInputData()) {
      return;
    }

    stopEditing();
    String modifier = "";
    if (myPublicRadioButton.isSelected()) {
      modifier = GrModifier.PUBLIC;
    } else if (myPrivateRadioButton.isSelected()) {
      modifier = GrModifier.PRIVATE;
    } else if (myProtectedRadioButton.isSelected()) {
      modifier = GrModifier.PROTECTED;
    }

    PsiType returnType = null;
    try {
      returnType = myReturnTypeCodeFragment.getType();
    } catch (PsiTypeCodeFragment.TypeSyntaxException ignored) {
    } catch (PsiTypeCodeFragment.NoTypeException ignored) {
    }

    String newName = getNewName();
    final List<GrTableParameterInfo> tableParameterInfos = myParameterModel.getParameterInfos();
    final List<GrParameterInfo> parameterInfos =
        ContainerUtil.map(
            tableParameterInfos,
            new Function<GrTableParameterInfo, GrParameterInfo>() {
              public GrParameterInfo fun(GrTableParameterInfo info) {
                return info.generateParameterInfo();
              }
            });
    final ThrownExceptionInfo[] exceptionInfos = myExceptionTableModel.getThrownExceptions();
    invokeRefactoring(
        new GrChangeSignatureProcessor(
            myProject,
            new GrChangeInfoImpl(
                myMethod,
                modifier,
                returnType == null ? null : CanonicalTypes.createTypeWrapper(returnType),
                newName,
                parameterInfos,
                exceptionInfos,
                myDelegateRadioButton.isSelected())));
  }
コード例 #5
0
 private void flushDataTo(final CompoundReferenceRenderer renderer) { // label
   LabelRenderer labelRenderer = null;
   if (myRbExpressionLabel.isSelected()) {
     labelRenderer = new LabelRenderer();
     labelRenderer.setLabelExpression(myLabelEditor.getText());
   }
   renderer.setLabelRenderer(labelRenderer);
   // children
   ChildrenRenderer childrenRenderer = null;
   if (myRbExpressionChildrenRenderer.isSelected()) {
     childrenRenderer = new ExpressionChildrenRenderer();
     ((ExpressionChildrenRenderer) childrenRenderer)
         .setChildrenExpression(myChildrenEditor.getText());
     ((ExpressionChildrenRenderer) childrenRenderer)
         .setChildrenExpandable(myChildrenExpandedEditor.getText());
   } else if (myRbListChildrenRenderer.isSelected()) {
     childrenRenderer = new EnumerationChildrenRenderer(getTableModel().getExpressions());
   }
   renderer.setChildrenRenderer(childrenRenderer);
   // classname
   renderer.setClassName(myClassNameField.getText());
 }
コード例 #6
0
 protected boolean isMoveToPackage() {
   return myHavePackages || myToPackageRadioButton.isSelected();
 }