private JPanel createSignaturePanel() { mySignature = new GrMethodSignatureComponent("", myProject); myTable = new ParameterTablePanel() { @Override protected void updateSignature() { GrIntroduceParameterDialog.this.updateSignature(); } @Override protected void doEnterAction() { clickDefaultButton(); } @Override protected void doCancelAction() { GrIntroduceParameterDialog.this.doCancelAction(); } }; mySignature.setBorder( IdeBorderFactory.createTitledBorder( GroovyRefactoringBundle.message("signature.preview.border.title"), false)); Splitter splitter = new Splitter(true); splitter.setFirstComponent(myTable); splitter.setSecondComponent(mySignature); mySignature.setPreferredSize(JBUI.size(500, 100)); mySignature.setSize(JBUI.size(500, 100)); splitter.setShowDividerIcon(false); final JPanel panel = new JPanel(new BorderLayout()); panel.add(splitter, BorderLayout.CENTER); myForceReturnCheckBox = new JCheckBox(UIUtil.replaceMnemonicAmpersand("Use e&xplicit return statement")); panel.add(myForceReturnCheckBox, BorderLayout.NORTH); return panel; }
private void updateSignature() { StringBuilder b = new StringBuilder(); b.append("{ "); String[] params = ExtractUtil.getParameterString(myInfo, false); for (int i = 0; i < params.length; i++) { if (i > 0) { b.append(" "); } b.append(params[i]); b.append('\n'); } b.append(" ->\n}"); mySignature.setSignature(b.toString()); }