inplace introduce: type mnemonics, etc

This commit is contained in:
anna
2011-06-17 19:35:20 +04:00
parent 504030bc87
commit 3b360d4f34
4 changed files with 22 additions and 5 deletions
@@ -114,7 +114,10 @@ public class InplaceIntroduceConstantPopup extends AbstractJavaInplaceIntroducer
gc.gridy = 2;
gc.gridx = 0;
gc.gridwidth = 2;
myWholePanel.add(typeComponent(), gc);
JComponent typeChooser = typeComponent();
if (typeChooser != null) {
myWholePanel.add(typeChooser, gc);
}
}
@Nullable
@@ -111,7 +111,10 @@ public class InplaceIntroduceFieldPopup extends AbstractJavaInplaceIntroducer {
myWholePanel.add(myIntroduceFieldPanel.createCenterPanel(), gc);
gc.gridy++ ;
myWholePanel.add(typeComponent(), gc);
JComponent typeChooser = typeComponent();
if (typeChooser != null) {
myWholePanel.add(typeChooser, gc);
}
myIntroduceFieldPanel.initializeControls(initializerExpression, ourLastInitializerPlace);
@@ -15,6 +15,7 @@ import com.intellij.psi.codeStyle.JavaCodeStyleManager;
import com.intellij.psi.codeStyle.VariableKind;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.refactoring.introduce.inplace.AbstractInplaceIntroducer;
import com.intellij.refactoring.introduceField.InplaceCombosUtil;
import com.intellij.refactoring.ui.TypeSelector;
import com.intellij.refactoring.ui.TypeSelectorManagerImpl;
import com.intellij.util.ArrayUtil;
@@ -92,10 +93,17 @@ public abstract class AbstractJavaInplaceIntroducer extends AbstractInplaceIntro
return myTypeSelector.getSelectedType();
}
@Nullable
protected JComponent typeComponent() {
JComponent component = myTypeSelector.getComponent();
if (component instanceof JLabel) return null;
LOG.assertTrue(component instanceof JComboBox);
InplaceCombosUtil.appendActions((JComboBox)component, myProject);
JPanel panel = new JPanel(new BorderLayout());
panel.add(new JLabel("Type: "), BorderLayout.WEST);
JLabel label = new JLabel("Type: ");
label.setLabelFor(component);
label.setDisplayedMnemonic('T');
panel.add(label, BorderLayout.WEST);
panel.add(component, BorderLayout.CENTER);
return panel;
}
@@ -85,8 +85,11 @@ public class InplaceIntroduceParameterPopup extends AbstractJavaInplaceIntroduce
}
};
myPanel.append2MainPanel(myWholePanel);
myWholePanel.add(typeComponent(), new GridBagConstraints(0, GridBagConstraints.RELATIVE, 2, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL,
new Insets(0,0,0,0), 0,0));
JComponent typeChooser = typeComponent();
if (typeChooser != null) {
myWholePanel.add(typeChooser, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 2, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL,
new Insets(0,0,0,0), 0,0));
}
}
@Override