use of com.intellij.ui.CollectionListModel in project intellij-community by JetBrains.
the class ProjectTemplateList method restoreSelection.
void restoreSelection() {
final String templateName = PropertiesComponent.getInstance().getValue(PROJECT_WIZARD_TEMPLATE);
if (templateName != null && myList.getModel() instanceof CollectionListModel) {
@SuppressWarnings("unchecked") List<ProjectTemplate> list = ((CollectionListModel<ProjectTemplate>) myList.getModel()).toList();
ProjectTemplate template = ContainerUtil.find(list, template1 -> templateName.equals(template1.getName()));
if (template != null) {
myList.setSelectedValue(template, true);
}
}
myList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
ProjectTemplate template = getSelectedTemplate();
if (template != null) {
PropertiesComponent.getInstance().setValue(PROJECT_WIZARD_TEMPLATE, template.getName());
}
}
});
}
Aggregations