use of org.jetbrains.java.generate.view.TemplatesPanel in project intellij-community by JetBrains.
the class GenerateGetterSetterHandlerBase method getHeaderPanel.
protected static JComponent getHeaderPanel(final Project project, final TemplatesManager templatesManager, final String templatesTitle) {
final JPanel panel = new JPanel(new BorderLayout());
final JLabel templateChooserLabel = new JLabel(templatesTitle);
panel.add(templateChooserLabel, BorderLayout.WEST);
final ComboBox comboBox = new ComboBox();
templateChooserLabel.setLabelFor(comboBox);
comboBox.setRenderer(new ListCellRendererWrapper<TemplateResource>() {
@Override
public void customize(JList list, TemplateResource value, int index, boolean selected, boolean hasFocus) {
setText(value.getName());
}
});
final ComponentWithBrowseButton<ComboBox> comboBoxWithBrowseButton = new ComponentWithBrowseButton<>(comboBox, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final TemplatesPanel ui = new TemplatesPanel(project, templatesManager) {
@Override
protected boolean onMultipleFields() {
return false;
}
@Nls
@Override
public String getDisplayName() {
return StringUtil.capitalizeWords(UIUtil.removeMnemonic(StringUtil.trimEnd(templatesTitle, ":")), true);
}
};
ui.setHint("Visibility is applied according to File | Settings | Editor | Code Style | Java | Code Generation");
ui.selectNodeInTree(templatesManager.getDefaultTemplate());
if (ShowSettingsUtil.getInstance().editConfigurable(panel, ui)) {
setComboboxModel(templatesManager, comboBox);
}
}
});
setComboboxModel(templatesManager, comboBox);
comboBox.addActionListener(new ActionListener() {
public void actionPerformed(@NotNull final ActionEvent M) {
templatesManager.setDefaultTemplate((TemplateResource) comboBox.getSelectedItem());
}
});
panel.add(comboBoxWithBrowseButton, BorderLayout.CENTER);
return panel;
}
Aggregations