IDEA-165089 add ability to remove a label before combobox

This commit is contained in:
Sergey Malenkov
2017-05-11 22:03:55 +03:00
parent 5490631f39
commit 3569a4c4a9
2 changed files with 19 additions and 2 deletions
@@ -70,8 +70,11 @@ public abstract class AbstractSchemesPanel<T extends Scheme, InfoComponent exten
private void createUIComponents() {
JPanel controlsPanel = new JPanel();
controlsPanel.setLayout(new BoxLayout(controlsPanel, BoxLayout.LINE_AXIS));
controlsPanel.add(new JLabel(getSchemeTypeName() + ":"));
controlsPanel.add(Box.createRigidArea(new JBDimension(10, 0)));
String label = getComboBoxLabel();
if (label != null) {
controlsPanel.add(new JLabel(label));
controlsPanel.add(Box.createRigidArea(new JBDimension(10, 0)));
}
myActions = createSchemeActions();
mySchemesCombo = new EditableSchemesCombo<>(this);
controlsPanel.add(mySchemesCombo.getComponent());
@@ -172,6 +175,14 @@ public abstract class AbstractSchemesPanel<T extends Scheme, InfoComponent exten
@NotNull
protected abstract InfoComponent createInfoComponent();
/**
* @return a string label to place before the combobox or {@code null} if it is not needed
*/
@Nullable
protected String getComboBoxLabel() {
return getSchemeTypeName() + ":";
}
protected String getSchemeTypeName() {
return ApplicationBundle.message("editbox.scheme.type.name");
}
@@ -52,6 +52,12 @@ final class KeymapSelector extends SimpleSchemesPanel<KeymapScheme> {
return getManager();
}
@Nullable
@Override
protected String getComboBoxLabel() {
return null;
}
@Override
protected String getSchemeTypeName() {
return "Keymap";