コード例 #1
0
  @NotNull
  protected List<Pair<String, JPanel>> createAdditionalPanels() {
    // this method is invoked before constructor body
    myExceptionsModel = new ExceptionsTableModel(myMethod.getMethod().getThrowsList());
    myExceptionsModel.setTypeInfos(myMethod.getMethod());

    final JBTable table = new JBTable(myExceptionsModel);
    table.setStriped(true);
    table.setRowHeight(20);
    table
        .getColumnModel()
        .getColumn(0)
        .setCellRenderer(new CodeFragmentTableCellRenderer(myProject));
    final JavaCodeFragmentTableCellEditor cellEditor =
        new JavaCodeFragmentTableCellEditor(myProject);
    cellEditor.addDocumentListener(
        new DocumentAdapter() {
          @Override
          public void documentChanged(DocumentEvent e) {
            final int row = table.getSelectedRow();
            final int col = table.getSelectedColumn();
            myExceptionsModel.setValueAt(cellEditor.getCellEditorValue(), row, col);
            updateSignature();
          }
        });
    table.getColumnModel().getColumn(0).setCellEditor(cellEditor);
    table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.getSelectionModel().setSelectionInterval(0, 0);
    table.setSurrendersFocusOnKeystroke(true);

    myPropExceptionsButton =
        new AnActionButton(
            RefactoringBundle.message("changeSignature.propagate.exceptions.title"),
            null,
            PlatformIcons.NEW_EXCEPTION) {
          @Override
          public void actionPerformed(AnActionEvent e) {
            final Ref<JavaCallerChooser> chooser = new Ref<JavaCallerChooser>();
            Consumer<Set<PsiMethod>> callback =
                new Consumer<Set<PsiMethod>>() {
                  @Override
                  public void consume(Set<PsiMethod> psiMethods) {
                    myMethodsToPropagateExceptions = psiMethods;
                    myExceptionPropagationTree = chooser.get().getTree();
                  }
                };
            chooser.set(
                new JavaCallerChooser(
                    myMethod.getMethod(),
                    myProject,
                    RefactoringBundle.message("changeSignature.exception.caller.chooser"),
                    myExceptionPropagationTree,
                    callback));
            chooser.get().show();
          }
        };
    myPropExceptionsButton.setShortcut(CustomShortcutSet.fromString("alt X"));

    final JPanel panel =
        ToolbarDecorator.createDecorator(table)
            .addExtraAction(myPropExceptionsButton)
            .createPanel();
    panel.setBorder(IdeBorderFactory.createEmptyBorder(0));

    myExceptionsModel.addTableModelListener(mySignatureUpdater);

    final ArrayList<Pair<String, JPanel>> result = new ArrayList<Pair<String, JPanel>>();
    final String message =
        RefactoringBundle.message("changeSignature.exceptions.panel.border.title");
    result.add(Pair.create(message, panel));
    return result;
  }
コード例 #2
0
 @Override
 protected void updatePropagateButtons() {
   super.updatePropagateButtons();
   myPropExceptionsButton.setEnabled(!isGenerateDelegate() && mayPropagateExceptions());
 }