diff --git a/java/idea-ui/src/com/intellij/facet/impl/ProjectFacetsConfigurator.java b/java/idea-ui/src/com/intellij/facet/impl/ProjectFacetsConfigurator.java index 0aeed154483c..81574cea6abf 100644 --- a/java/idea-ui/src/com/intellij/facet/impl/ProjectFacetsConfigurator.java +++ b/java/idea-ui/src/com/intellij/facet/impl/ProjectFacetsConfigurator.java @@ -103,14 +103,30 @@ public class ProjectFacetsConfigurator implements FacetsProvider, ModuleEditor.C return removed; } - public Facet createAndAddFacet(Module module, FacetType type, String name, final @Nullable FacetInfo underlyingFacet) { - final Facet facet = FacetManager.getInstance(module).createFacet(type, name, myInfo2Facet.get(underlyingFacet)); + public Facet createAndAddFacet(Module module, FacetType type, final @Nullable Facet underlying) { + final Collection facets = getFacetsByType(module, type.getId()); + String facetName = type.getDefaultFacetName(); + int i = 2; + while (facetExists(facetName, facets)) { + facetName = type.getDefaultFacetName() + i; + i++; + } + final Facet facet = FacetManager.getInstance(module).createFacet(type, facetName, underlying); myCreatedFacets.add(facet); addFacetInfo(facet); getOrCreateModifiableModel(module).addFacet(facet); return facet; } + private boolean facetExists(final String facetName, final Collection facets) { + for (Facet facet : facets) { + if (getFacetName(facet).equals(facetName)) { + return true; + } + } + return false; + } + public void addFacetInfo(final Facet facet) { final FacetInfo exiting = myFacet2Info.get(facet); if (exiting != null) { @@ -336,6 +352,17 @@ public class ProjectFacetsConfigurator implements FacetsProvider, ModuleEditor.C return myProjectData; } + public String getFacetName(Facet facet) { + final ModifiableFacetModel model = myModifiableModels.get(facet.getModule()); + if (model != null) { + final String newName = model.getNewName(facet); + if (newName != null) { + return newName; + } + } + return facet.getName(); + } + public List removeAllFacets(final Module module) { List facets = new ArrayList(); FacetModel facetModel = getOrCreateModifiableModel(module); @@ -351,6 +378,12 @@ public class ProjectFacetsConfigurator implements FacetsProvider, ModuleEditor.C return facets; } + public boolean hasFacetOfType(Module module, @Nullable Facet parent, FacetTypeId typeId) { + final FacetTreeModel treeModel = getTreeModel(module); + final FacetInfo parentInfo = getFacetInfo(parent); + return treeModel.hasFacetOfType(parentInfo, typeId); + } + private class MyProjectConfigurableContext extends ProjectConfigurableContext { private final LibrariesContainer myContainer; diff --git a/java/idea-ui/src/com/intellij/facet/impl/ui/FacetEditorFacade.java b/java/idea-ui/src/com/intellij/facet/impl/ui/FacetEditorFacade.java index 2314d0eb2b4d..2d0f9f62670b 100644 --- a/java/idea-ui/src/com/intellij/facet/impl/ui/FacetEditorFacade.java +++ b/java/idea-ui/src/com/intellij/facet/impl/ui/FacetEditorFacade.java @@ -16,6 +16,7 @@ package com.intellij.facet.impl.ui; +import com.intellij.facet.Facet; import org.jetbrains.annotations.Nullable; import com.intellij.facet.FacetType; import com.intellij.facet.FacetInfo; @@ -37,7 +38,7 @@ public interface FacetEditorFacade { @Nullable ModuleType getSelectedModuleType(); - void createFacet(final FacetInfo parent, final FacetType type, final String name); + Facet createFacet(final FacetInfo parent, final FacetType type); Collection getFacetsByType(FacetType type); diff --git a/java/idea-ui/src/com/intellij/facet/impl/ui/actions/AddFacetAction.java b/java/idea-ui/src/com/intellij/facet/impl/ui/actions/AddFacetAction.java index 10b6477f47ec..033ca8078519 100644 --- a/java/idea-ui/src/com/intellij/facet/impl/ui/actions/AddFacetAction.java +++ b/java/idea-ui/src/com/intellij/facet/impl/ui/actions/AddFacetAction.java @@ -16,17 +16,18 @@ package com.intellij.facet.impl.ui.actions; -import com.intellij.facet.FacetInfo; -import com.intellij.facet.FacetType; -import com.intellij.facet.FacetTypeId; +import com.intellij.facet.*; import com.intellij.facet.impl.ui.FacetEditorFacade; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.module.ModuleType; import com.intellij.openapi.project.DumbAware; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable; -import java.util.Collection; +import java.util.Arrays; +import java.util.Comparator; /** * @author nik @@ -34,43 +35,31 @@ import java.util.Collection; public class AddFacetAction extends AnAction implements DumbAware { private static final Logger LOG = Logger.getInstance("#com.intellij.facet.impl.ui.actions.AddFacetAction"); private final FacetEditorFacade myEditor; + private final Project myProject; private final FacetType myType; - public AddFacetAction(final FacetEditorFacade editor, final FacetType type) { + public AddFacetAction(final FacetEditorFacade editor, Project project, final FacetType type) { super(type.getPresentableName(), null, type.getIcon()); myEditor = editor; + myProject = project; myType = type; } public void actionPerformed(AnActionEvent e) { FacetInfo parent = myEditor.getSelectedFacetInfo(); - final Collection facetInfos = myEditor.getFacetsByType(myType); - String facetName = myType.getDefaultFacetName(); - int i = 2; - while (facetExists(facetName, facetInfos)) { - facetName = myType.getPresentableName() + i; - i++; - } final FacetTypeId underlyingFacetType = myType.getUnderlyingFacetType(); + Facet facet; if (parent == null && underlyingFacetType == null || parent != null && parent.getFacetType().getId() == underlyingFacetType) { - myEditor.createFacet(parent, myType, facetName); + facet = myEditor.createFacet(parent, myType); } else { LOG.assertTrue(parent != null); final FacetInfo grandParent = myEditor.getParent(parent); LOG.assertTrue(grandParent == null && underlyingFacetType == null || grandParent != null && grandParent.getFacetType().getId() == underlyingFacetType); - myEditor.createFacet(grandParent, myType, facetName); + facet = myEditor.createFacet(grandParent, myType); } - } - - private static boolean facetExists(final String facetName, final Collection facetInfos) { - for (FacetInfo facetInfo : facetInfos) { - if (facetInfo.getName().equals(facetName)) { - return true; - } - } - return false; + ProjectStructureConfigurable.getInstance(myProject).select(facet, true); } public void update(AnActionEvent e) { @@ -104,4 +93,19 @@ public class AddFacetAction extends AnAction implements DumbAware { private static boolean canAddFacet(final FacetInfo selectedFacet, final FacetType type, final FacetEditorFacade editor) { return !(type.isOnlyOneFacetAllowed() && editor.nodeHasFacetOfType(selectedFacet, type.getId())); } + + public static AnAction[] createAddFacetActions(FacetEditorFacade editor, Project project) { + final FacetType[] types = FacetTypeRegistry.getInstance().getFacetTypes(); + Arrays.sort(types, new Comparator() { + public int compare(final FacetType o1, final FacetType o2) { + return o1.getPresentableName().compareTo(o2.getPresentableName()); + } + }); + + AnAction[] actions = new AnAction[types.length]; + for (int i = 0; i < types.length; i++) { + actions[i] = new AddFacetAction(editor, project, types[i]); + } + return actions; + } } diff --git a/java/idea-ui/src/com/intellij/facet/impl/ui/actions/AddFacetActionGroup.java b/java/idea-ui/src/com/intellij/facet/impl/ui/actions/AddFacetActionGroup.java deleted file mode 100644 index 0624e929c045..000000000000 --- a/java/idea-ui/src/com/intellij/facet/impl/ui/actions/AddFacetActionGroup.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2000-2009 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.facet.impl.ui.actions; - -import com.intellij.facet.impl.ui.FacetEditorFacade; -import com.intellij.facet.FacetType; -import com.intellij.facet.FacetTypeRegistry; -import com.intellij.openapi.actionSystem.ActionGroup; -import com.intellij.openapi.actionSystem.AnAction; -import com.intellij.openapi.actionSystem.AnActionEvent; -import com.intellij.openapi.project.DumbAware; -import org.jetbrains.annotations.Nullable; - -import java.util.Arrays; -import java.util.Comparator; - -/** - * @author nik -*/ -public class AddFacetActionGroup extends ActionGroup implements DumbAware { - private final boolean myFromPopup; - private final FacetEditorFacade myEditor; - private AnAction[] myCachedChildren; - - public AddFacetActionGroup(final String groupName, final boolean fromPopup, final FacetEditorFacade editor) { - super(groupName, true); - myFromPopup = fromPopup; - myEditor = editor; - } - - public AnAction[] getChildren(@Nullable AnActionEvent e) { - if (myCachedChildren == null) { - final FacetType[] types = FacetTypeRegistry.getInstance().getFacetTypes(); - Arrays.sort(types, new Comparator() { - public int compare(final FacetType o1, final FacetType o2) { - return o1.getPresentableName().compareTo(o2.getPresentableName()); - } - }); - myCachedChildren = new AnAction[types.length]; - for (int i = 0; i < types.length; i++) { - myCachedChildren[i] = new AddFacetAction(myEditor, types[i]); - } - } - - return myCachedChildren; - } - - public void update(AnActionEvent e) { - final boolean visible = isVisible(); - if (myFromPopup) { - e.getPresentation().setVisible(visible); - } - else { - e.getPresentation().setEnabled(visible); - } - } - - private boolean isVisible() { - for (FacetType type : FacetTypeRegistry.getInstance().getFacetTypes()) { - if (AddFacetAction.isVisible(myEditor, type)) { - return true; - } - } - return false; - } -} diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/ChooseModulesDialog.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/ChooseModulesDialog.java index 25859918a85e..e876f5588a5f 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/ChooseModulesDialog.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/ChooseModulesDialog.java @@ -40,6 +40,10 @@ public class ChooseModulesDialog extends ChooseElementsDialog { super(project, items, title, description, true); } + public void setSingleSelectionMode() { + myChooser.setSingleSelectionMode(); + } + protected Icon getItemIcon(final Module item) { return item.getModuleType().getNodeIcon(false); } diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/AddFacetOfTypeAction.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/AddFacetOfTypeAction.java new file mode 100644 index 000000000000..ff4c4d492786 --- /dev/null +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/AddFacetOfTypeAction.java @@ -0,0 +1,164 @@ +/* + * Copyright 2000-2010 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.openapi.roots.ui.configuration.projectRoot; + +import com.intellij.facet.Facet; +import com.intellij.facet.FacetType; +import com.intellij.facet.FacetTypeId; +import com.intellij.facet.FacetTypeRegistry; +import com.intellij.facet.impl.ProjectFacetsConfigurator; +import com.intellij.ide.util.ChooseElementsDialog; +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.module.Module; +import com.intellij.openapi.project.DumbAwareAction; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable; +import com.intellij.openapi.roots.ui.configuration.libraryEditor.ChooseModulesDialog; +import com.intellij.openapi.ui.Messages; +import com.intellij.openapi.ui.NamedConfigurable; +import com.intellij.util.Icons; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import javax.swing.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; + +/** +* @author nik +*/ +class AddFacetOfTypeAction extends DumbAwareAction { + private FacetStructureConfigurable myFacetStructureConfigurable; + + AddFacetOfTypeAction(FacetStructureConfigurable facetStructureConfigurable) { + super("New Facet", null, Icons.ADD_ICON); + this.myFacetStructureConfigurable = facetStructureConfigurable; + } + + @Override + public void actionPerformed(AnActionEvent e) { + final FacetType type = getSelectedType(); + if (type == null) return; + + final FacetTypeId underlyingFacetType = type.getUnderlyingFacetType(); + if (underlyingFacetType == null) { + addFacetToModule(type); + } + else { + addSubFacet(type, underlyingFacetType); + } + } + + private void addSubFacet(FacetType type, FacetTypeId underlyingType) { + final StructureConfigurableContext context = myFacetStructureConfigurable.myContext; + final ProjectFacetsConfigurator facetsConfigurator = context.getModulesConfigurator().getFacetsConfigurator(); + List suitableParents = new ArrayList(); + for (Module module : context.getModules()) { + if (type.isSuitableModuleType(module.getModuleType())) { + suitableParents.addAll(facetsConfigurator.getFacetsByType(module, underlyingType)); + } + } + + final Iterator iterator = suitableParents.iterator(); + while (iterator.hasNext()) { + Facet parent = iterator.next(); + if (type.isOnlyOneFacetAllowed() && facetsConfigurator.hasFacetOfType(parent.getModule(), parent, type.getId())) { + iterator.remove(); + } + } + + final Project project = context.getProject(); + if (suitableParents.isEmpty()) { + final String parentType = FacetTypeRegistry.getInstance().findFacetType(underlyingType).getPresentableName(); + Messages.showErrorDialog(project, "No suitable parent " + parentType + " facets found", "Cannot Create " + type.getPresentableName() + " Facet"); + return; + } + + ChooseParentFacetDialog dialog = new ChooseParentFacetDialog(project, suitableParents, "Select Parent Facet", null); + dialog.show(); + final List chosen = dialog.getChosenElements(); + if (!dialog.isOK() || chosen.size() != 1) return; + final Facet parent = chosen.get(0); + final Facet facet = + ModuleStructureConfigurable.getInstance(project).getFacetEditorFacade().createAndAddFacet(type, parent.getModule(), parent); + ProjectStructureConfigurable.getInstance(project).select(facet, true); + } + + private void addFacetToModule(@NotNull FacetType type) { + final StructureConfigurableContext context = myFacetStructureConfigurable.myContext; + final ProjectFacetsConfigurator facetsConfigurator = context.getModulesConfigurator().getFacetsConfigurator(); + List suitableModules = new ArrayList(Arrays.asList(context.getModules())); + final Iterator iterator = suitableModules.iterator(); + while (iterator.hasNext()) { + Module module = iterator.next(); + if (!type.isSuitableModuleType(module.getModuleType()) || (type.isOnlyOneFacetAllowed() && facetsConfigurator.hasFacetOfType(module, null, type.getId()))) { + iterator.remove(); + } + } + final Project project = context.getProject(); + if (suitableModules.isEmpty()) { + Messages.showErrorDialog(project, "No suitable modules for " + type.getPresentableName() + " facet found.", "Cannot Create Facet"); + return; + } + + final ChooseModulesDialog dialog = new ChooseModulesDialog(project, suitableModules, "Choose Module", + type.getPresentableName() + " facet will be added to selected module"); + dialog.setSingleSelectionMode(); + dialog.show(); + final List elements = dialog.getChosenElements(); + if (!dialog.isOK() || elements.size() != 1) return; + + final Module module = elements.get(0); + final Facet facet = ModuleStructureConfigurable.getInstance(project).getFacetEditorFacade().createAndAddFacet(type, module, null); + ProjectStructureConfigurable.getInstance(project).select(facet, true); + } + + @Override + public void update(AnActionEvent e) { + e.getPresentation().setEnabled(myFacetStructureConfigurable.myContext.getModules().length > 0 && getSelectedType() != null); + } + + @Nullable + private FacetType getSelectedType() { + final NamedConfigurable configurable = myFacetStructureConfigurable.getSelectedConfugurable(); + if (configurable instanceof FacetTypeConfigurable) { + return ((FacetTypeConfigurable)configurable).getFacetType(); + } + else if (configurable instanceof FacetConfigurable) { + return ((FacetConfigurable)configurable).getEditableObject().getType(); + } + return null; + } + + private static class ChooseParentFacetDialog extends ChooseElementsDialog { + private ChooseParentFacetDialog(Project project, List items, String title, String description) { + super(project, items, title, description); + myChooser.setSingleSelectionMode(); + } + + @Override + protected String getItemText(Facet item) { + return item.getName() + " (module " + item.getModule().getName() + ")"; + } + + @Override + protected Icon getItemIcon(Facet item) { + return item.getType().getIcon(); + } + } +} diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/FacetEditorFacadeImpl.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/FacetEditorFacadeImpl.java index 3df5907a7f27..325a7a91d2fd 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/FacetEditorFacadeImpl.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/FacetEditorFacadeImpl.java @@ -59,6 +59,12 @@ public class FacetEditorFacadeImpl implements FacetEditorFacade { return facetsExist; } + private void addFacetNode(Facet facet) { + addFacetNode(facet, myStructureConfigurable.findModuleNode(facet.getModule())); + final FacetStructureConfigurable facetStructureConfigurable = FacetStructureConfigurable.getInstance(myStructureConfigurable.getProject()); + facetStructureConfigurable.addFacetNode(facetStructureConfigurable.findFacetTypeNode(facet.getType()), facet, this); + } + private MasterDetailsComponent.MyNode addFacetNode(final Facet facet, final MasterDetailsComponent.MyNode moduleNode) { final MasterDetailsComponent.MyNode existing = findFacetNode(facet, moduleNode); if (existing != null) return existing; @@ -113,12 +119,14 @@ public class FacetEditorFacadeImpl implements FacetEditorFacade { return facetTreeModel.hasFacetOfType(facet, typeId); } - public void createFacet(final FacetInfo parent, FacetType type, final String name) { - Module module = getSelectedModule(); + public Facet createFacet(final FacetInfo parent, FacetType type) { + return createAndAddFacet(type, getSelectedModule(), getFacetConfigurator().getFacet(parent)); + } - final Facet facet = getFacetConfigurator().createAndAddFacet(module, type, name, parent); - final MasterDetailsComponent.MyNode node = addFacetNode(facet, myStructureConfigurable.findModuleNode(module)); - myStructureConfigurable.selectNodeInTree(node); + public Facet createAndAddFacet(FacetType type, Module module, final Facet underlying) { + final Facet facet = getFacetConfigurator().createAndAddFacet(module, type, underlying); + addFacetNode(facet); + return facet; } public Collection getFacetsByType(final FacetType type) { diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/FacetStructureConfigurable.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/FacetStructureConfigurable.java index d1dee3ae62d1..dac9283414d5 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/FacetStructureConfigurable.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/FacetStructureConfigurable.java @@ -81,13 +81,21 @@ public class FacetStructureConfigurable extends BaseStructureConfigurable { Collection facets = FacetManager.getInstance(module).getFacetsByType(facetType.getId()); for (Facet facet : facets) { FacetEditorFacadeImpl editorFacade = ModuleStructureConfigurable.getInstance(myProject).getFacetEditorFacade(); - FacetConfigurable facetConfigurable = editorFacade.getOrCreateConfigurable(facet); - addNode(new FacetConfigurableNode(facetConfigurable), facetTypeNode); + addFacetNode(facetTypeNode, facet, editorFacade); } } } } + public MyNode findFacetTypeNode(FacetType facetType) { + return findNodeByObject(myRoot, facetType); + } + + public void addFacetNode(MyNode facetTypeNode, Facet facet, FacetEditorFacadeImpl editorFacade) { + FacetConfigurable facetConfigurable = editorFacade.getOrCreateConfigurable(facet); + addNode(new FacetConfigurableNode(facetConfigurable), facetTypeNode); + } + @Nullable public FacetTypeEditor getFacetTypeEditor(@NotNull FacetType facetType) { return myFacetTypeEditors.get(facetType); @@ -144,6 +152,7 @@ public class FacetStructureConfigurable extends BaseStructureConfigurable { @NotNull protected ArrayList createActions(final boolean fromPopup) { ArrayList actions = new ArrayList(); + actions.add(new AddFacetOfTypeAction(this)); if (fromPopup) { actions.add(new MyNavigateAction()); } diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/FacetTypeConfigurable.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/FacetTypeConfigurable.java index 88db4c5dfe01..567290019169 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/FacetTypeConfigurable.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/FacetTypeConfigurable.java @@ -58,6 +58,10 @@ public class FacetTypeConfigurable extends NamedConfigurable { return myFacetType.getIcon(); } + public FacetType getFacetType() { + return myFacetType; + } + public String getHelpTopic() { final FacetTypeEditor editor = myFacetStructureConfigurable.getFacetTypeEditor(myFacetType); return editor != null ? editor.getHelpTopic() : null; diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/ModuleStructureConfigurable.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/ModuleStructureConfigurable.java index c89cf77288ba..cd13f8c68cf6 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/ModuleStructureConfigurable.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/ModuleStructureConfigurable.java @@ -19,7 +19,7 @@ package com.intellij.openapi.roots.ui.configuration.projectRoot; import com.intellij.CommonBundle; import com.intellij.facet.Facet; import com.intellij.facet.impl.ProjectFacetsConfigurator; -import com.intellij.facet.impl.ui.actions.AddFacetActionGroup; +import com.intellij.facet.impl.ui.actions.AddFacetAction; import com.intellij.ide.IdeBundle; import com.intellij.ide.highlighter.ModuleFileType; import com.intellij.ide.projectView.impl.ModuleGroup; @@ -646,8 +646,6 @@ public class ModuleStructureConfigurable extends BaseStructureConfigurable imple } protected AbstractAddGroup createAddAction() { - final AddFacetActionGroup addFacetGroup = new AddFacetActionGroup("", true, myFacetEditorFacade); - return new AbstractAddGroup(ProjectBundle.message("add.new.header.text")) { @NotNull public AnAction[] getChildren(@Nullable final AnActionEvent e) { @@ -656,7 +654,7 @@ public class ModuleStructureConfigurable extends BaseStructureConfigurable imple ArrayList result = new ArrayList(); result.add(module); - final AnAction[] facets = addFacetGroup.getChildren(e); + final AnAction[] facets = AddFacetAction.createAddFacetActions(myFacetEditorFacade, myProject); if (facets.length > 0) { result.add(new Separator(ProjectBundle.message("add.group.facet.separator"))); ContainerUtil.addAll(result, facets); diff --git a/platform/platform-impl/src/com/intellij/ide/util/ElementsChooser.java b/platform/platform-impl/src/com/intellij/ide/util/ElementsChooser.java index 0a3566bd76a6..a23f0065155a 100644 --- a/platform/platform-impl/src/com/intellij/ide/util/ElementsChooser.java +++ b/platform/platform-impl/src/com/intellij/ide/util/ElementsChooser.java @@ -134,6 +134,10 @@ public class ElementsChooser extends JPanel { setElements(elements, marked); } + public void setSingleSelectionMode() { + myTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + } + public void refresh() { myTableModel.fireTableDataChanged(); }