From 800eaba9f6e12c795aa7f2c84740ef2de10683bb Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Tue, 11 Feb 2014 13:07:50 +0400 Subject: [PATCH] IDEA-120544 13.1 EAP (134.1007): impossible to add empty Web module to the project --- .../projectWizard/ProjectTemplateList.java | 6 ++-- .../ide/projectWizard/ProjectTypeStep.java | 5 ++- .../com/intellij/ui/SingleSelectionModel.java | 35 +++++++++++++++++++ 3 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 platform/platform-api/src/com/intellij/ui/SingleSelectionModel.java diff --git a/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTemplateList.java b/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTemplateList.java index 7c76028d1a05..ffc07a593058 100644 --- a/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTemplateList.java +++ b/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTemplateList.java @@ -25,8 +25,8 @@ import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.text.StringUtil; import com.intellij.platform.ProjectTemplate; import com.intellij.platform.templates.ArchivedProjectTemplate; -import com.intellij.ui.CollectionListModel; -import com.intellij.ui.IdeBorderFactory; +import com.intellij.ui.*; +import com.intellij.ui.SingleSelectionModel; import com.intellij.ui.components.JBList; import com.intellij.ui.popup.list.GroupedItemsListRenderer; import com.intellij.util.containers.ContainerUtil; @@ -99,7 +99,7 @@ public class ProjectTemplateList extends JPanel { } }; myList.setCellRenderer(renderer); - + myList.setSelectionModel(new SingleSelectionModel()); myList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { diff --git a/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTypeStep.java b/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTypeStep.java index 4dfd99fc0c70..058bc7d19b10 100644 --- a/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTypeStep.java +++ b/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTypeStep.java @@ -56,6 +56,7 @@ import com.intellij.platform.templates.RemoteTemplatesFactory; import com.intellij.ui.CollectionListModel; import com.intellij.ui.ColoredListCellRenderer; import com.intellij.ui.IdeBorderFactory; +import com.intellij.ui.SingleSelectionModel; import com.intellij.ui.components.JBList; import com.intellij.util.Function; import com.intellij.util.containers.*; @@ -125,6 +126,7 @@ public class ProjectTypeStep extends ModuleWizardStep implements Disposable { List groups = fillTemplatesMap(context); myProjectTypeList.setModel(new CollectionListModel(groups)); + myProjectTypeList.setSelectionModel(new SingleSelectionModel()); myProjectTypeList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { @@ -178,6 +180,7 @@ public class ProjectTypeStep extends ModuleWizardStep implements Disposable { projectTypeChanged(); } }); + myTemplatesList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { @@ -236,7 +239,7 @@ public class ProjectTypeStep extends ModuleWizardStep implements Disposable { else { TemplatesGroup group = new TemplatesGroup(builder); groupMap.put(group.getName(), group); - myTemplatesMap.put(group, new ArrayList()); + myTemplatesMap.put(group, new ArrayList(Collections.singletonList(template))); } } diff --git a/platform/platform-api/src/com/intellij/ui/SingleSelectionModel.java b/platform/platform-api/src/com/intellij/ui/SingleSelectionModel.java new file mode 100644 index 000000000000..ed6ef740848b --- /dev/null +++ b/platform/platform-api/src/com/intellij/ui/SingleSelectionModel.java @@ -0,0 +1,35 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.ui; + +import javax.swing.*; + +/** +* @author Dmitry Avdeev +*/ +public class SingleSelectionModel extends DefaultListSelectionModel { + { + setSelectionMode(SINGLE_SELECTION); + } + + @Override + public void clearSelection() { + } + + @Override + public void removeSelectionInterval(int index0, int index1) { + } +}