'add framework support' ui imporved & FrameworkSupportProvider moved to open api

This commit is contained in:
Nikolay Chashnikov
2009-09-18 10:32:46 +04:00
parent d6eab791b2
commit abe0170ced
33 changed files with 763 additions and 540 deletions
@@ -1,69 +0,0 @@
package com.intellij.facet.impl.ui;
import com.intellij.facet.ui.libraries.LibraryInfo;
import com.intellij.ide.util.newProjectWizard.FrameworkSupportConfigurable;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.roots.ModifiableRootModel;
import com.intellij.openapi.roots.libraries.Library;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
/**
* @author Dmitry Avdeev
*/
public class VersionConfigurable extends FrameworkSupportConfigurable {
private JComboBox myComboBox;
private final VersionedFrameworkSupportProvider myFrameworkSupportProvider;
public VersionConfigurable(final VersionedFrameworkSupportProvider frameworkSupportProvider, String[] versions, String defaultVersion) {
myFrameworkSupportProvider = frameworkSupportProvider;
if (versions.length > 0) {
if (defaultVersion == null) {
defaultVersion = versions[versions.length - 1];
}
myComboBox = new JComboBox();
String maxValue = "";
for (String version : versions) {
myComboBox.addItem(version);
FontMetrics fontMetrics = myComboBox.getFontMetrics(myComboBox.getFont());
if (fontMetrics.stringWidth(version) > fontMetrics.stringWidth(maxValue)) {
maxValue = version;
}
}
myComboBox.setPrototypeDisplayValue(maxValue + "_");
myComboBox.setSelectedItem(defaultVersion);
}
}
public JComponent getComponent() {
return myComboBox;
}
@NotNull
public LibraryInfo[] getLibraries() {
return myFrameworkSupportProvider.getLibraries(getSelectedVersion());
}
@NonNls
@NotNull
public String getLibraryName() {
return myFrameworkSupportProvider.getLibraryName(getSelectedVersion());
}
public void addSupport(final Module module, final ModifiableRootModel rootModel, final @Nullable Library library) {
myFrameworkSupportProvider.addSupport(module, rootModel, getSelectedVersion(), library);
}
public String getSelectedVersion() {
String version = null;
if (myComboBox != null) {
version = myComboBox.getSelectedItem().toString();
}
return version;
}
}
@@ -1,55 +0,0 @@
/*
* Copyright (c) 2000-2007 JetBrains s.r.o. All Rights Reserved.
*/
package com.intellij.facet.impl.ui;
import com.intellij.facet.ui.libraries.LibraryInfo;
import com.intellij.ide.util.newProjectWizard.FrameworkSupportConfigurable;
import com.intellij.ide.util.newProjectWizard.FrameworkSupportModel;
import com.intellij.ide.util.newProjectWizard.FrameworkSupportProvider;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.roots.ModifiableRootModel;
import com.intellij.openapi.roots.libraries.Library;
import com.intellij.util.ArrayUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* @author nik
*/
public abstract class VersionedFrameworkSupportProvider extends FrameworkSupportProvider {
protected VersionedFrameworkSupportProvider(final @NonNls @NotNull String id, final @NotNull String title) {
super(id, title);
}
protected abstract void addSupport(Module module, ModifiableRootModel rootModel, String version, final @Nullable Library library);
@NotNull
public String[] getVersions() {
return ArrayUtil.EMPTY_STRING_ARRAY;
}
@Nullable
public String getDefaultVersion() {
return null;
}
@NotNull
public VersionConfigurable createConfigurable(final @NotNull FrameworkSupportModel model) {
return new VersionConfigurable(this, getVersions(), getDefaultVersion());
}
@NotNull
protected LibraryInfo[] getLibraries(final String selectedVersion) {
return LibraryInfo.EMPTY_ARRAY;
}
@NotNull @NonNls
protected String getLibraryName(final String selectedVersion) {
return FrameworkSupportConfigurable.DEFAULT_LIBRARY_NAME;
}
}
@@ -17,24 +17,20 @@
<properties/>
<border type="none"/>
<children>
<component id="b6bf5" class="javax.swing.JTextArea" binding="myMissingLibrariesArea">
<component id="3966c" class="javax.swing.JLabel" binding="myMissingLibrariesLabel">
<constraints>
<card name="shown"/>
</constraints>
<properties>
<editable value="false"/>
<lineWrap value="true"/>
<wrapStyleWord value="true"/>
<text value="Label"/>
</properties>
</component>
<component id="9f0b5" class="javax.swing.JTextArea" binding="myHiddenTextArea">
<component id="3125c" class="javax.swing.JLabel" binding="myHiddenLabel">
<constraints>
<card name="hidden"/>
</constraints>
<properties>
<editable value="false"/>
<lineWrap value="true"/>
<wrapStyleWord value="true"/>
<text value="Label"/>
</properties>
</component>
</children>
@@ -50,7 +46,7 @@
<grid id="c7640" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
@@ -79,12 +75,6 @@
</hspacer>
</children>
</grid>
<component id="bbb02" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="myDirectoryField">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="3" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<grid id="1f138" binding="myMirrorsPanel" layout-manager="FlowLayout" hgap="5" vgap="5" flow-align="1">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="2" use-parent-layout="false"/>
@@ -93,6 +83,12 @@
<border type="none"/>
<children/>
</grid>
<component id="bbb02" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="myDirectoryField">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="3" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
</children>
</grid>
<grid id="f7f4" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
@@ -135,11 +131,6 @@
<text resource-bundle="messages/ProjectBundle" key="composing.library.name.label"/>
</properties>
</component>
<hspacer id="3d2d2">
<constraints>
<grid row="2" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<component id="2cb6b" class="javax.swing.JTextField" binding="myLibraryNameField">
<constraints>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
@@ -179,6 +170,11 @@
<text resource-bundle="messages/ProjectBundle" key="composing.liibrary.new.library.label"/>
</properties>
</component>
<hspacer id="31c96">
<constraints>
<grid row="2" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
</children>
</grid>
</children>
@@ -20,6 +20,7 @@ import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.IdeBorderFactory;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.*;
@@ -38,14 +39,14 @@ public class LibraryCompositionOptionsPanel {
private JButton myAddJarsButton;
private JCheckBox myDownloadMissingJarsCheckBox;
private TextFieldWithBrowseButton myDirectoryField;
private JTextArea myMissingLibrariesArea;
private JComboBox myLibraryLevelComboBox;
private JTextField myLibraryNameField;
private JPanel myMissingLibrariesPanel;
private JTextArea myHiddenTextArea;
private JPanel myNewLibraryPanel;
private JPanel myLibraryPropertiesPanel;
private JPanel myMirrorsPanel;
private JLabel myMissingLibrariesLabel;
private JLabel myHiddenLabel;
private final List<VirtualFile> myAddedJars = new ArrayList<VirtualFile>();
private final List<Library> myUsedLibraries = new ArrayList<Library>();
private final LibrariesContainer myLibrariesContainer;
@@ -54,8 +55,8 @@ public class LibraryCompositionOptionsPanel {
private final LibraryDownloadingMirrorsMap myMirrorsMap;
private List<RemoteRepositoryMirrorPanel> myMirrorPanelsList;
public LibraryCompositionOptionsPanel(final LibrariesContainer librariesContainer, final LibraryCompositionSettings libraryCompositionSettings,
final LibraryDownloadingMirrorsMap mirrorsMap) {
public LibraryCompositionOptionsPanel(final @NotNull LibrariesContainer librariesContainer, final @NotNull LibraryCompositionSettings libraryCompositionSettings,
final @NotNull LibraryDownloadingMirrorsMap mirrorsMap) {
myLibrariesContainer = librariesContainer;
myLibraryCompositionSettings = libraryCompositionSettings;
myMirrorsMap = mirrorsMap;
@@ -96,11 +97,10 @@ public class LibraryCompositionOptionsPanel {
myLibraryLevelComboBox.setSelectedItem(myLibraryLevels.getValue(myLibraryCompositionSettings.getLibraryLevel()));
myLibraryNameField.setText(myLibraryCompositionSettings.getLibraryName());
myMissingLibrariesArea.setBackground(myMainPanel.getBackground());
myDirectoryField.setText(FileUtil.toSystemDependentName(myLibraryCompositionSettings.getDirectoryForDownloadedLibrariesPath()));
String jars = RequiredLibrariesInfo.getLibrariesPresentableText(myLibraryCompositionSettings.getLibraryInfos());
myHiddenTextArea.setText(ProjectBundle.message("label.text.libraries.are.missing", jars));
myHiddenLabel.setText(UIUtil.toHtml(ProjectBundle.message("label.text.libraries.are.missing", jars)));
updateAll();
myMissingLibrariesPanel.getPreferredSize();
@@ -190,7 +190,7 @@ public class LibraryCompositionOptionsPanel {
else {
missingJarsText = ProjectBundle.message("label.text.all.library.files.found");
}
myMissingLibrariesArea.setText(missingJarsText);
myMissingLibrariesLabel.setText(UIUtil.toHtml(missingJarsText));
((CardLayout)myMissingLibrariesPanel.getLayout()).show(myMissingLibrariesPanel, "shown");
if (info == null) {
myDownloadMissingJarsCheckBox.setSelected(false);
@@ -10,7 +10,7 @@
<children>
<component id="9ac48" class="javax.swing.JComboBox" binding="myMirrorComboBox">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<editable value="true"/>
@@ -6,7 +6,7 @@ package com.intellij.ide.util.frameworkSupport;
import com.intellij.CommonBundle;
import com.intellij.ide.util.newProjectWizard.AddSupportForFrameworksPanel;
import com.intellij.ide.util.newProjectWizard.FrameworkSupportProvider;
import com.intellij.ide.util.frameworkSupport.FrameworkSupportProvider;
import com.intellij.openapi.application.Result;
import com.intellij.openapi.application.WriteAction;
import com.intellij.openapi.module.Module;
@@ -4,7 +4,7 @@
package com.intellij.ide.util.frameworkSupport;
import com.intellij.ide.util.newProjectWizard.FrameworkSupportProvider;
import com.intellij.ide.util.frameworkSupport.FrameworkSupportProvider;
import com.intellij.ide.util.projectWizard.ModuleBuilder;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.module.Module;
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.ide.util.newProjectWizard.AddSupportForFrameworksPanel">
<grid id="27dc6" binding="myMainPanel" layout-manager="GridLayoutManager" row-count="5" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="27dc6" binding="myMainPanel" layout-manager="GridLayoutManager" row-count="4" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="5" left="5" bottom="5" right="5"/>
<constraints>
<xy x="20" y="20" width="500" height="400"/>
<xy x="20" y="20" width="487" height="400"/>
</constraints>
<properties/>
<border type="etched"/>
@@ -14,7 +14,7 @@
</constraints>
<properties>
<enabled value="true"/>
<font size="14"/>
<font/>
<text resource-bundle="messages/ProjectBundle" key="label.text.please.select.desired.technologies"/>
</properties>
</component>
@@ -26,7 +26,12 @@
<text resource-bundle="messages/ProjectBundle" key="label.text.framework.support.description"/>
</properties>
</component>
<grid id="3bb23" binding="myFrameworksTreePanel" layout-manager="BorderLayout" hgap="0" vgap="0">
<vspacer id="97860">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<grid id="4fc0e" binding="myFrameworksPanel" layout-manager="BorderLayout" hgap="0" vgap="0">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
@@ -34,66 +39,6 @@
<border type="none"/>
<children/>
</grid>
<vspacer id="97860">
<constraints>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<grid id="5532e" binding="myDownloadingOptionsPanel" layout-manager="CardLayout" hgap="0" vgap="0">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<grid id="82a80" layout-manager="GridLayoutManager" row-count="2" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<card name="options"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="da035" class="javax.swing.JLabel">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages/ProjectBundle" key="label.text.libraries.will.be.downloaded.by.default"/>
</properties>
</component>
<hspacer id="2f3cd">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<component id="36f74" class="javax.swing.JButton" binding="myChangeButton" default-binding="true">
<constraints>
<grid row="1" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages/ProjectBundle" key="button.text.change.downloading.policy"/>
</properties>
</component>
<component id="e41c1" class="javax.swing.JSeparator">
<constraints>
<grid row="0" column="0" row-span="1" col-span="3" vsize-policy="7" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
</children>
</grid>
<grid id="f3bdd" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<card name="empty"/>
</constraints>
<properties/>
<border type="none"/>
<children/>
</grid>
</children>
</grid>
</children>
</grid>
</form>
@@ -4,37 +4,43 @@
package com.intellij.ide.util.newProjectWizard;
import com.intellij.facet.impl.ui.FacetTypeFrameworkSupportProvider;
import com.intellij.facet.impl.ui.libraries.LibrariesCompositionDialog;
import com.intellij.facet.ui.FacetBasedFrameworkSupportProvider;
import com.intellij.facet.impl.ui.libraries.LibraryCompositionOptionsPanel;
import com.intellij.facet.impl.ui.libraries.LibraryCompositionSettings;
import com.intellij.facet.impl.ui.libraries.LibraryDownloadingMirrorsMap;
import com.intellij.facet.ui.libraries.LibraryDownloadInfo;
import com.intellij.facet.ui.libraries.LibraryInfo;
import com.intellij.facet.ui.libraries.RemoteRepositoryInfo;
import com.intellij.ide.util.frameworkSupport.FrameworkSupportProvider;
import com.intellij.ide.util.newProjectWizard.impl.FrameworkSupportModelImpl;
import com.intellij.ide.util.projectWizard.ModuleBuilder;
import com.intellij.ide.util.frameworkSupport.FrameworkSupportConfigurable;
import com.intellij.ide.util.frameworkSupport.FrameworkSupportConfigurableListener;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.roots.ModifiableRootModel;
import com.intellij.openapi.roots.libraries.Library;
import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainer;
import com.intellij.openapi.ui.Splitter;
import com.intellij.openapi.ui.VerticalFlowLayout;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.MultiValuesMap;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.ui.CheckedTreeNode;
import com.intellij.ui.ScrollPaneFactory;
import com.intellij.ui.TitledSeparator;
import com.intellij.util.graph.CachingSemiGraph;
import com.intellij.util.graph.DFSTBuilder;
import com.intellij.util.graph.GraphGenerator;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.*;
import java.util.List;
@@ -43,20 +49,21 @@ import java.util.List;
*/
public class AddSupportForFrameworksPanel {
private static final Logger LOG = Logger.getInstance("#com.intellij.ide.util.newProjectWizard.AddSupportForFrameworksStep");
private static final int INDENT = 20;
private static final int SPACE_AFTER_TITLE = 5;
private static final int VERTICAL_SPACE = 5;
private static final int GAP_BETWEEN_GROUPS = 10;
@NonNls private static final String UNCHECKED_CARD = "unchecked";
@NonNls private static final String EMPTY_CARD = "empty";
private JPanel myMainPanel;
private JPanel myFrameworksTreePanel;
private JButton myChangeButton;
private JPanel myDownloadingOptionsPanel;
private List<List<FrameworkSupportSettings>> myGroups;
private JPanel myFrameworksPanel;
private List<List<FrameworkSupportNode>> myGroups;
private final LibrariesContainer myLibrariesContainer;
private final Computable<String> myBaseDirForLibrariesGetter;
private final List<FrameworkSupportProvider> myProviders;
private final LibraryDownloadingMirrorsMap myMirrorsMap;
private final FrameworkSupportModelImpl myModel;
private JPanel myOptionsPanel;
private FrameworksTree myFrameworksTree;
private Set<String> myInitializedOptionsPanelIds = new HashSet<String>();
private FrameworkSupportNode myLastSelectedNode;
private JLabel myTickCheckboxLabel;
public AddSupportForFrameworksPanel(final List<FrameworkSupportProvider> providers, final @NotNull LibrariesContainer librariesContainer,
@Nullable ModuleBuilder builder, Computable<String> baseDirForLibrariesGetter) {
@@ -65,31 +72,127 @@ public class AddSupportForFrameworksPanel {
myProviders = providers;
myModel = new FrameworkSupportModelImpl(myLibrariesContainer.getProject(), builder);
createNodes();
myMirrorsMap = creatMirrorsMap();
myMirrorsMap = createMirrorsMap();
final JPanel treePanel = new JPanel(new GridBagLayout());
addGroupPanels(myGroups, treePanel, 0);
myFrameworksTreePanel.add(treePanel, BorderLayout.WEST);
myChangeButton.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
final List<LibraryCompositionSettings> compositionSettingsList = getLibrariesCompositionSettingsList();
new LibrariesCompositionDialog(myMainPanel, myLibrariesContainer, compositionSettingsList, myMirrorsMap).show();
updateDownloadingOptionsPanel();
final Splitter splitter = new Splitter(false, 0.35f, 0.1f, 0.7f);
myFrameworksTree = new FrameworksTree(myGroups) {
@Override
protected void onNodeStateChanged(CheckedTreeNode node) {
if (!(node instanceof FrameworkSupportNode)) return;
final FrameworkSupportNode frameworkSupportNode = (FrameworkSupportNode)node;
frameworkSupportNode.setConfigurableComponentEnabled(node.isChecked());
updateOptionsPanel();
myModel.onFrameworkSelectionChanged(frameworkSupportNode);
}
};
myFrameworksTree.addTreeSelectionListener(new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent e) {
onSelectionChanged();
}
});
updateDownloadingOptionsPanel();
splitter.setFirstComponent(ScrollPaneFactory.createScrollPane(myFrameworksTree));
myOptionsPanel = new JPanel(new CardLayout());
myOptionsPanel.add(EMPTY_CARD, new JPanel());
final JPanel uncheckedLabelPanel = new JPanel(new BorderLayout());
myTickCheckboxLabel = new JLabel("Tick checkbox");
uncheckedLabelPanel.add(BorderLayout.NORTH, myTickCheckboxLabel);
myOptionsPanel.add(UNCHECKED_CARD, uncheckedLabelPanel);
splitter.setSecondComponent(myOptionsPanel);
myFrameworksPanel.add(splitter, BorderLayout.CENTER);
}
private LibraryDownloadingMirrorsMap creatMirrorsMap() {
private void onSelectionChanged() {
if (!myFrameworksTree.isProcessingMouseEventOnCheckbox()) {
updateOptionsPanel();
}
final FrameworkSupportNode selectedNode = getSelectedNode();
if (!Comparing.equal(selectedNode, myLastSelectedNode)) {
if (myLastSelectedNode != null) {
final LibraryCompositionOptionsPanel optionsPanel = myLastSelectedNode.getLibraryCompositionOptionsPanel(myLibrariesContainer, myMirrorsMap);
if (optionsPanel != null) {
optionsPanel.saveSelectedRepositoriesMirrors(myMirrorsMap);
optionsPanel.apply();
}
}
myLastSelectedNode = selectedNode;
if (selectedNode != null) {
final LibraryCompositionOptionsPanel newOptionsPanel = selectedNode.getLibraryCompositionOptionsPanel(myLibrariesContainer, myMirrorsMap);
if (newOptionsPanel != null) {
newOptionsPanel.updateRepositoriesMirrors(myMirrorsMap);
}
}
}
}
private void updateOptionsPanel() {
final FrameworkSupportNode node = getSelectedNode();
if (node != null) {
if (node.isChecked()) {
initializeOptionsPanel(node);
showCard(node.getProvider().getId());
}
else {
myTickCheckboxLabel.setText("Tick checkbox to add support for '" + node.getTitle() + "'");
showCard(UNCHECKED_CARD);
}
}
else {
showCard(EMPTY_CARD);
}
}
@Nullable
private FrameworkSupportNode getSelectedNode() {
final FrameworkSupportNode[] nodes = myFrameworksTree.getSelectedNodes(FrameworkSupportNode.class, null);
return nodes.length == 1 ? nodes[0] : null;
}
private void initializeOptionsPanel(final FrameworkSupportNode node) {
final String id = node.getProvider().getId();
if (!myInitializedOptionsPanelIds.contains(id)) {
final JPanel optionsPanel = new JPanel(new VerticalFlowLayout());
optionsPanel.add(new TitledSeparator(node.getTitle() + " Settings"));
final FrameworkSupportConfigurable configurable = node.getConfigurable();
optionsPanel.add(configurable.getComponent());
final JPanel librariesOptionsPanelWrapper = new JPanel(new BorderLayout());
optionsPanel.add(librariesOptionsPanelWrapper);
configurable.addListener(new FrameworkSupportConfigurableListener() {
public void frameworkVersionChanged() {
librariesOptionsPanelWrapper.removeAll();
addLibrariesOptionsPanel(node, librariesOptionsPanelWrapper);
librariesOptionsPanelWrapper.revalidate();
}
});
addLibrariesOptionsPanel(node, librariesOptionsPanelWrapper);
myOptionsPanel.add(id, optionsPanel);
myInitializedOptionsPanelIds.add(id);
}
}
private void addLibrariesOptionsPanel(FrameworkSupportNode node, JPanel librariesOptionsPanelWrapper) {
final LibraryCompositionOptionsPanel libraryOptionsPanel = node.getLibraryCompositionOptionsPanel(myLibrariesContainer, myMirrorsMap);
if (libraryOptionsPanel != null) {
librariesOptionsPanelWrapper.add(BorderLayout.CENTER, libraryOptionsPanel.getMainPanel());
}
}
private void showCard(String cardName) {
((CardLayout)myOptionsPanel.getLayout()).show(myOptionsPanel, cardName);
}
private LibraryDownloadingMirrorsMap createMirrorsMap() {
List<RemoteRepositoryInfo> repositoryInfos = getRemoteRepositories();
return new LibraryDownloadingMirrorsMap(repositoryInfos.toArray(new RemoteRepositoryInfo[repositoryInfos.size()]));
}
private List<RemoteRepositoryInfo> getRemoteRepositories() {
List<RemoteRepositoryInfo> repositoryInfos = new ArrayList<RemoteRepositoryInfo>();
List<FrameworkSupportSettings> frameworksSettingsList = getFrameworksSettingsList(false);
for (FrameworkSupportSettings settings : frameworksSettingsList) {
LibraryInfo[] libraries = settings.getConfigurable().getLibraries();
List<FrameworkSupportNode> frameworkNodes = getFrameworkNodes(false);
for (FrameworkSupportNode node : frameworkNodes) {
LibraryInfo[] libraries = node.getLibraries();
for (LibraryInfo library : libraries) {
LibraryDownloadInfo downloadInfo = library.getDownloadingInfo();
if (downloadInfo != null) {
@@ -103,18 +206,13 @@ public class AddSupportForFrameworksPanel {
return repositoryInfos;
}
private void updateDownloadingOptionsPanel() {
@NonNls String card = getLibrariesCompositionSettingsList().isEmpty() ? "empty" : "options";
((CardLayout)myDownloadingOptionsPanel.getLayout()).show(myDownloadingOptionsPanel, card);
}
private List<LibraryCompositionSettings> getLibrariesCompositionSettingsList() {
List<LibraryCompositionSettings> list = new ArrayList<LibraryCompositionSettings>();
List<FrameworkSupportSettings> selected = getFrameworksSettingsList(true);
for (FrameworkSupportSettings settings : selected) {
LibraryInfo[] libraries = settings.getConfigurable().getLibraries();
if (libraries.length > 0) {
list.add(settings.getLibraryCompositionSettings());
List<FrameworkSupportNode> selected = getFrameworkNodes(true);
for (FrameworkSupportNode node : selected) {
final LibraryCompositionSettings settings = node.getLibraryCompositionSettings();
if (settings != null) {
list.add(settings);
}
}
return list;
@@ -128,80 +226,36 @@ public class AddSupportForFrameworksPanel {
return true;
}
private JPanel addGroupPanels(final List<List<FrameworkSupportSettings>> groups, JPanel treePanel, int level) {
boolean first = true;
for (List<FrameworkSupportSettings> group : groups) {
addSettingsComponents(group, treePanel, level, !first);
first = false;
}
return treePanel;
}
private void addSettingsComponents(final List<FrameworkSupportSettings> list, JPanel treePanel, int level, boolean addGapBefore) {
boolean first = true;
for (FrameworkSupportSettings root : list) {
addSettingsComponents(root, treePanel, level, first && addGapBefore);
first = false;
}
}
private void addSettingsComponents(final FrameworkSupportSettings frameworkSupport, JPanel parentPanel, int level, boolean addGapBefore) {
if (frameworkSupport.getParentNode() != null) {
frameworkSupport.setEnabled(false);
}
JComponent configurableComponent = frameworkSupport.getConfigurable().getComponent();
int gridwidth = configurableComponent != null ? 1 : GridBagConstraints.REMAINDER;
final int gap = addGapBefore ? GAP_BETWEEN_GROUPS : 0;
parentPanel.add(frameworkSupport.myCheckBox, createConstraints(0, GridBagConstraints.RELATIVE, gridwidth, 1,
new Insets(gap, INDENT * level, VERTICAL_SPACE, SPACE_AFTER_TITLE)));
if (configurableComponent != null) {
parentPanel.add(configurableComponent, createConstraints(1, GridBagConstraints.RELATIVE, GridBagConstraints.REMAINDER, 1,
new Insets(gap, 0, VERTICAL_SPACE, 0)));
}
if (frameworkSupport.myChildren.isEmpty()) {
return;
}
addSettingsComponents(frameworkSupport.myChildren, parentPanel, level + 1, false);
}
private static GridBagConstraints createConstraints(final int gridx, final int gridy, final int gridwidth, final int gridheight,
final Insets insets) {
return new GridBagConstraints(gridx, gridy, gridwidth, gridheight, 1, 1, GridBagConstraints.NORTHWEST,
GridBagConstraints.NONE, insets, 0, 0);
}
private void createNodes() {
Map<String, FrameworkSupportSettings> nodes = new HashMap<String, FrameworkSupportSettings>();
MultiValuesMap<String, FrameworkSupportSettings> groups = new MultiValuesMap<String, FrameworkSupportSettings>(true);
Map<String, FrameworkSupportNode> nodes = new HashMap<String, FrameworkSupportNode>();
MultiValuesMap<String, FrameworkSupportNode> groups = new MultiValuesMap<String, FrameworkSupportNode>(true);
for (FrameworkSupportProvider frameworkSupport : myProviders) {
createNode(frameworkSupport, nodes, groups);
}
myGroups = new ArrayList<List<FrameworkSupportSettings>>();
myGroups = new ArrayList<List<FrameworkSupportNode>>();
for (String groupId : groups.keySet()) {
final Collection<FrameworkSupportSettings> collection = groups.get(groupId);
final Collection<FrameworkSupportNode> collection = groups.get(groupId);
if (collection != null) {
final List<FrameworkSupportSettings> group = new ArrayList<FrameworkSupportSettings>();
for (FrameworkSupportSettings settings : collection) {
if (settings.getParentNode() == null) {
group.add(settings);
final List<FrameworkSupportNode> group = new ArrayList<FrameworkSupportNode>();
for (FrameworkSupportNode node : collection) {
if (node.getParentNode() == null) {
group.add(node);
}
}
sortByTitle(group);
FrameworkSupportNode.sortByTitle(group);
myGroups.add(group);
}
}
}
@Nullable
private FrameworkSupportSettings createNode(final FrameworkSupportProvider provider, final Map<String, FrameworkSupportSettings> nodes,
final MultiValuesMap<String, FrameworkSupportSettings> groups) {
FrameworkSupportSettings node = nodes.get(provider.getId());
private FrameworkSupportNode createNode(final FrameworkSupportProvider provider, final Map<String, FrameworkSupportNode> nodes,
final MultiValuesMap<String, FrameworkSupportNode> groups) {
FrameworkSupportNode node = nodes.get(provider.getId());
if (node == null) {
String underlyingFrameworkId = provider.getUnderlyingFrameworkId();
FrameworkSupportSettings parentNode = null;
FrameworkSupportNode parentNode = null;
if (underlyingFrameworkId != null) {
FrameworkSupportProvider parentProvider = findProvider(underlyingFrameworkId);
if (parentProvider == null) {
@@ -210,17 +264,13 @@ public class AddSupportForFrameworksPanel {
}
parentNode = createNode(parentProvider, nodes, groups);
}
node = new FrameworkSupportSettings(provider, parentNode, myModel);
node = new FrameworkSupportNode(provider, parentNode, myModel, myBaseDirForLibrariesGetter);
nodes.put(provider.getId(), node);
groups.put(provider.getGroupId(), node);
}
return node;
}
private String getBaseModuleDirectoryPath() {
return myBaseDirForLibrariesGetter.compute();
}
@Nullable
private FrameworkSupportProvider findProvider(@NotNull String id) {
for (FrameworkSupportProvider provider : myProviders) {
@@ -232,75 +282,50 @@ public class AddSupportForFrameworksPanel {
return null;
}
private static void setDescendantsEnabled(FrameworkSupportSettings frameworkSupport, final boolean enable) {
for (FrameworkSupportSettings child : frameworkSupport.myChildren) {
child.setEnabled(enable);
setDescendantsEnabled(child, enable);
}
}
public JComponent getMainPanel() {
return myMainPanel;
}
private List<FrameworkSupportSettings> getFrameworksSettingsList(final boolean selectedOnly) {
ArrayList<FrameworkSupportSettings> list = new ArrayList<FrameworkSupportSettings>();
private List<FrameworkSupportNode> getFrameworkNodes(final boolean selectedOnly) {
ArrayList<FrameworkSupportNode> list = new ArrayList<FrameworkSupportNode>();
if (myGroups != null) {
for (List<FrameworkSupportSettings> group : myGroups) {
for (List<FrameworkSupportNode> group : myGroups) {
addChildFrameworks(group, list, selectedOnly);
}
}
return list;
}
private static void sortByTitle(List<FrameworkSupportSettings> settingsList) {
if (settingsList.isEmpty()) return;
Collections.sort(settingsList, new Comparator<FrameworkSupportSettings>() {
public int compare(final FrameworkSupportSettings o1, final FrameworkSupportSettings o2) {
return getTitleWithoutMnemonic(o1.getProvider()).compareTo(getTitleWithoutMnemonic(o2.getProvider()));
}
});
for (FrameworkSupportSettings settings : settingsList) {
sortByTitle(settings.myChildren);
}
}
private static String getTitleWithoutMnemonic(final FrameworkSupportProvider provider) {
return StringUtil.replace(provider.getTitle(), String.valueOf(UIUtil.MNEMONIC), "");
}
private static void addChildFrameworks(final List<FrameworkSupportSettings> list, final ArrayList<FrameworkSupportSettings> selected,
private static void addChildFrameworks(final List<FrameworkSupportNode> list, final List<FrameworkSupportNode> result,
final boolean selectedOnly) {
for (FrameworkSupportSettings settings : list) {
if (!selectedOnly || settings.myCheckBox.isSelected()) {
selected.add(settings);
addChildFrameworks(settings.myChildren, selected, selectedOnly);
for (FrameworkSupportNode node : list) {
if (!selectedOnly || node.isChecked()) {
result.add(node);
addChildFrameworks(node.getChildren(), result, selectedOnly);
}
}
}
public void addSupport(final Module module, final ModifiableRootModel rootModel) {
public void addSupport(final @NotNull Module module, final @NotNull ModifiableRootModel rootModel) {
List<Library> addedLibraries = new ArrayList<Library>();
List<FrameworkSupportSettings> selectedFrameworks = getFrameworksSettingsList(true);
List<FrameworkSupportNode> selectedFrameworks = getFrameworkNodes(true);
sortFrameworks(selectedFrameworks);
for (FrameworkSupportSettings settings : selectedFrameworks) {
FrameworkSupportConfigurable configurable = settings.getConfigurable();
Library library = settings.getLibraryCompositionSettings().addLibraries(rootModel, addedLibraries);
for (FrameworkSupportNode node : selectedFrameworks) {
FrameworkSupportConfigurable configurable = node.getConfigurable();
final LibraryCompositionSettings settings = node.getLibraryCompositionSettings();
Library library = settings != null ? settings.addLibraries(rootModel, addedLibraries) : null;
configurable.addSupport(module, rootModel, library);
}
for (FrameworkSupportSettings settings : selectedFrameworks) {
FrameworkSupportProvider provider = settings.myProvider;
if (provider instanceof FacetTypeFrameworkSupportProvider && !addedLibraries.isEmpty()) {
((FacetTypeFrameworkSupportProvider)provider).processAddedLibraries(module, addedLibraries);
for (FrameworkSupportNode node : selectedFrameworks) {
FrameworkSupportProvider provider = node.getProvider();
if (provider instanceof FacetBasedFrameworkSupportProvider && !addedLibraries.isEmpty()) {
((FacetBasedFrameworkSupportProvider)provider).processAddedLibraries(module, addedLibraries);
}
}
}
private void sortFrameworks(final List<FrameworkSupportSettings> selectedFrameworks) {
private void sortFrameworks(final List<FrameworkSupportNode> nodes) {
DFSTBuilder<FrameworkSupportProvider> builder = new DFSTBuilder<FrameworkSupportProvider>(GraphGenerator.create(CachingSemiGraph.create(new ProvidersGraph(myProviders))));
if (!builder.isAcyclic()) {
Pair<FrameworkSupportProvider,FrameworkSupportProvider> pair = builder.getCircularDependency();
@@ -308,93 +333,13 @@ public class AddSupportForFrameworksPanel {
}
final Comparator<FrameworkSupportProvider> comparator = builder.comparator();
Collections.sort(selectedFrameworks, new Comparator<FrameworkSupportSettings>() {
public int compare(final FrameworkSupportSettings o1, final FrameworkSupportSettings o2) {
Collections.sort(nodes, new Comparator<FrameworkSupportNode>() {
public int compare(final FrameworkSupportNode o1, final FrameworkSupportNode o2) {
return comparator.compare(o1.getProvider(), o2.getProvider());
}
});
}
public class FrameworkSupportSettings {
private final FrameworkSupportProvider myProvider;
private final FrameworkSupportSettings myParentNode;
private final FrameworkSupportConfigurable myConfigurable;
private final JCheckBox myCheckBox;
private final List<FrameworkSupportSettings> myChildren = new ArrayList<FrameworkSupportSettings>();
private LibraryCompositionSettings myLibraryCompositionSettings;
private FrameworkSupportSettings(final FrameworkSupportProvider provider, final FrameworkSupportSettings parentNode,
final FrameworkSupportModelImpl context) {
myProvider = provider;
myParentNode = parentNode;
myCheckBox = new JCheckBox(provider.getTitle());
context.registerComponent(provider, this);
myConfigurable = provider.createConfigurable(context);
if (parentNode != null) {
parentNode.myChildren.add(this);
}
myCheckBox.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
setConfigurableComponentEnabled(myCheckBox.isSelected());
setDescendantsEnabled(FrameworkSupportSettings.this, myCheckBox.isSelected());
}
});
setConfigurableComponentEnabled(false);
}
public JCheckBox getCheckBox() {
return myCheckBox;
}
public void setEnabled(final boolean enable) {
myCheckBox.setEnabled(enable);
if (!enable) {
myCheckBox.setSelected(false);
setConfigurableComponentEnabled(false);
}
}
private void setConfigurableComponentEnabled(final boolean enable) {
JComponent component = getConfigurable().getComponent();
if (component != null) {
UIUtil.setEnabled(component, enable, true);
}
updateDownloadingOptionsPanel();
}
public FrameworkSupportProvider getProvider() {
return myProvider;
}
public FrameworkSupportSettings getParentNode() {
return myParentNode;
}
public FrameworkSupportConfigurable getConfigurable() {
return myConfigurable;
}
public String getModuleDirectoryPath() {
return getBaseModuleDirectoryPath();
}
private boolean isObsolete(@NotNull LibraryCompositionSettings settings) {
return !settings.getBaseDirectoryForDownloadedFiles().equals(getBaseModuleDirectoryPath())
|| !Comparing.equal(settings.getLibraryInfos(), myConfigurable.getLibraries());
}
public LibraryCompositionSettings getLibraryCompositionSettings() {
if (myLibraryCompositionSettings == null || isObsolete(myLibraryCompositionSettings)) {
final String title = getTitleWithoutMnemonic(myProvider);
myLibraryCompositionSettings = new LibraryCompositionSettings(myConfigurable.getLibraries(), myConfigurable.getLibraryName(), getBaseModuleDirectoryPath(),
title, myProvider.getIcon());
}
return myLibraryCompositionSettings;
}
}
private class ProvidersGraph implements GraphGenerator.SemiGraph<FrameworkSupportProvider> {
private final List<FrameworkSupportProvider> myFrameworkSupportProviders;
@@ -1,37 +0,0 @@
/*
* Copyright (c) 2000-2007 JetBrains s.r.o. All Rights Reserved.
*/
package com.intellij.ide.util.newProjectWizard;
import com.intellij.facet.ui.libraries.LibraryInfo;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.roots.ModifiableRootModel;
import com.intellij.openapi.roots.libraries.Library;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
/**
* @author nik
*/
public abstract class FrameworkSupportConfigurable {
@NonNls public static final String DEFAULT_LIBRARY_NAME = "lib";
@Nullable
public abstract JComponent getComponent();
public abstract void addSupport(Module module, ModifiableRootModel model, final @Nullable Library library);
@NonNls @NotNull
public String getLibraryName() {
return DEFAULT_LIBRARY_NAME;
}
@NotNull
public LibraryInfo[] getLibraries() {
return LibraryInfo.EMPTY_ARRAY;
}
}
@@ -0,0 +1,143 @@
package com.intellij.ide.util.newProjectWizard;
import com.intellij.facet.impl.ui.libraries.LibraryCompositionSettings;
import com.intellij.facet.impl.ui.libraries.LibraryCompositionOptionsPanel;
import com.intellij.facet.impl.ui.libraries.LibraryDownloadingMirrorsMap;
import com.intellij.ide.util.frameworkSupport.FrameworkSupportConfigurable;
import com.intellij.ide.util.frameworkSupport.FrameworkSupportProvider;
import com.intellij.ide.util.frameworkSupport.FrameworkVersion;
import com.intellij.facet.ui.libraries.LibraryInfo;
import com.intellij.ide.util.newProjectWizard.impl.FrameworkSupportModelImpl;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainer;
import com.intellij.ui.CheckedTreeNode;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
/**
* @author nik
*/
public class FrameworkSupportNode extends CheckedTreeNode {
private final FrameworkSupportProvider myProvider;
private final FrameworkSupportNode myParentNode;
private final FrameworkSupportConfigurable myConfigurable;
private final List<FrameworkSupportNode> myChildren = new ArrayList<FrameworkSupportNode>();
private LibraryCompositionSettings myLibraryCompositionSettings;
private final Computable<String> myBaseDirForLibrariesGetter;
private LibraryCompositionOptionsPanel myLibraryCompositionOptionsPanel;
FrameworkSupportNode(final FrameworkSupportProvider provider, final FrameworkSupportNode parentNode, final FrameworkSupportModelImpl model,
Computable<String> baseDirForLibrariesGetter) {
super(provider);
myBaseDirForLibrariesGetter = baseDirForLibrariesGetter;
setChecked(false);
myProvider = provider;
myParentNode = parentNode;
model.registerComponent(provider, this);
myConfigurable = provider.createConfigurable(model);
if (parentNode != null) {
parentNode.add(this);
parentNode.myChildren.add(this);
}
setConfigurableComponentEnabled(false);
}
public List<FrameworkSupportNode> getChildren() {
return myChildren;
}
@Nullable
public LibraryCompositionOptionsPanel getLibraryCompositionOptionsPanel(LibrariesContainer librariesContainer,
LibraryDownloadingMirrorsMap mirrorsMap) {
final LibraryCompositionSettings libraryCompositionSettings = getLibraryCompositionSettings();
if (myLibraryCompositionOptionsPanel == null || !myLibraryCompositionOptionsPanel.getLibraryCompositionSettings().equals(libraryCompositionSettings)) {
if (libraryCompositionSettings != null) {
myLibraryCompositionOptionsPanel = new LibraryCompositionOptionsPanel(librariesContainer, libraryCompositionSettings, mirrorsMap);
}
else {
myLibraryCompositionOptionsPanel = null;
}
}
return myLibraryCompositionOptionsPanel;
}
public void setConfigurableComponentEnabled(final boolean enable) {
JComponent component = getConfigurable().getComponent();
if (component != null) {
UIUtil.setEnabled(component, enable, true);
}
}
public FrameworkSupportProvider getProvider() {
return myProvider;
}
public FrameworkSupportNode getParentNode() {
return myParentNode;
}
public FrameworkSupportConfigurable getConfigurable() {
return myConfigurable;
}
private boolean isObsolete(@NotNull LibraryCompositionSettings settings) {
final LibraryInfo[] libraries = getLibraries();
return !settings.getBaseDirectoryForDownloadedFiles().equals(myBaseDirForLibrariesGetter.compute())
|| !Comparing.equal(settings.getLibraryInfos(), libraries);
}
public LibraryInfo[] getLibraries() {
final FrameworkVersion version = myConfigurable.getSelectedVersion();
return version != null ? version.getLibraries() : LibraryInfo.EMPTY_ARRAY;
}
@Nullable
public LibraryCompositionSettings getLibraryCompositionSettings() {
if (myLibraryCompositionSettings == null || isObsolete(myLibraryCompositionSettings)) {
final LibraryInfo[] libraries = getLibraries();
if (libraries.length != 0) {
myLibraryCompositionSettings = new LibraryCompositionSettings(libraries, myConfigurable.getSelectedVersion().getLibraryName(), myBaseDirForLibrariesGetter.compute(),
"Libraries", myProvider.getIcon());
}
else {
myLibraryCompositionSettings = null;
}
}
return myLibraryCompositionSettings;
}
public static void sortByTitle(List<FrameworkSupportNode> nodes) {
if (nodes.isEmpty()) return;
Collections.sort(nodes, new Comparator<FrameworkSupportNode>() {
public int compare(final FrameworkSupportNode o1, final FrameworkSupportNode o2) {
return getTitleWithoutMnemonic(o1.getProvider()).compareTo(getTitleWithoutMnemonic(o2.getProvider()));
}
});
for (FrameworkSupportNode node : nodes) {
node.sortChildren();
}
}
public String getTitle() {
return getTitleWithoutMnemonic(myProvider);
}
private static String getTitleWithoutMnemonic(final FrameworkSupportProvider provider) {
return StringUtil.replace(provider.getTitle(), String.valueOf(UIUtil.MNEMONIC), "");
}
private void sortChildren() {
sortByTitle(myChildren);
}
}
@@ -0,0 +1,78 @@
package com.intellij.ide.util.newProjectWizard;
import com.intellij.ui.CheckboxTree;
import com.intellij.ui.CheckedTreeNode;
import com.intellij.util.ui.tree.TreeUtil;
import javax.swing.*;
import javax.swing.tree.TreePath;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.util.List;
/**
* @author nik
*/
public class FrameworksTree extends CheckboxTree {
private boolean myProcessingMouseEventOnCheckbox;
public FrameworksTree(List<List<FrameworkSupportNode>> groups) {
super(new FrameworksTreeRenderer(), new FrameworksRootNode(groups), new CheckPolicy(false, true, true, false));
setRootVisible(false);
setShowsRootHandles(false);
TreeUtil.expandAll(this);
}
@Override
protected void processMouseEvent(MouseEvent e) {
final TreePath path = getPathForLocation(e.getX(), e.getY());
if (path != null) {
final Object node = path.getLastPathComponent();
if (node instanceof FrameworkSupportNode) {
final Rectangle checkboxBounds = ((CheckboxTreeCellRendererBase)getCellRenderer()).myCheckbox.getBounds();
final Rectangle pathBounds = getPathBounds(path);
checkboxBounds.setLocation(pathBounds.getLocation());
if (checkboxBounds.contains(e.getPoint())) {
try {
myProcessingMouseEventOnCheckbox = true;
super.processMouseEvent(e);
}
finally {
myProcessingMouseEventOnCheckbox = false;
}
return;
}
}
}
super.processMouseEvent(e);
}
public boolean isProcessingMouseEventOnCheckbox() {
return myProcessingMouseEventOnCheckbox;
}
private static class FrameworksTreeRenderer extends CheckboxTreeCellRenderer {
private FrameworksTreeRenderer() {
super(true, false);
}
@Override
public void customizeRenderer(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
if (value instanceof FrameworkSupportNode) {
getTextRenderer().append(((FrameworkSupportNode)value).getTitle());
}
}
}
private static class FrameworksRootNode extends CheckedTreeNode {
public FrameworksRootNode(List<List<FrameworkSupportNode>> groups) {
super(null);
for (List<FrameworkSupportNode> group : groups) {
for (FrameworkSupportNode node : group) {
add(node);
}
}
}
}
}
@@ -9,6 +9,7 @@ import com.intellij.ide.util.frameworkSupport.FrameworkSupportUtil;
import com.intellij.ide.util.projectWizard.JavaModuleBuilder;
import com.intellij.ide.util.projectWizard.ModuleBuilder;
import com.intellij.ide.util.projectWizard.ModuleWizardStep;
import com.intellij.ide.util.frameworkSupport.FrameworkSupportProvider;
import com.intellij.ide.wizard.CommitStepException;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.ProjectBundle;
@@ -38,7 +39,7 @@ public class SupportForFrameworksStep extends ModuleWizardStep {
}
});
builder.addModuleConfigurationUpdater(new ModuleBuilder.ModuleConfigurationUpdater() {
public void update(final Module module, final ModifiableRootModel rootModel) {
public void update(@NotNull final Module module, @NotNull final ModifiableRootModel rootModel) {
mySupportForFrameworksPanel.addSupport(module, rootModel);
}
});
@@ -1,7 +1,10 @@
package com.intellij.ide.util.newProjectWizard.impl;
import com.intellij.ide.util.frameworkSupport.*;
import com.intellij.ide.util.newProjectWizard.*;
import com.intellij.ide.util.projectWizard.ModuleBuilder;
import com.intellij.ide.util.frameworkSupport.FrameworkSupportConfigurable;
import com.intellij.ide.util.frameworkSupport.FrameworkSupportModel;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.UserDataHolderBase;
import com.intellij.util.EventDispatcher;
@@ -9,9 +12,6 @@ import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.HashMap;
import java.util.Map;
@@ -22,26 +22,15 @@ public class FrameworkSupportModelImpl extends UserDataHolderBase implements Fra
private final Project myProject;
private final ModuleBuilder myModuleBuilder;
private final EventDispatcher<FrameworkSupportModelListener> myDispatcher = EventDispatcher.create(FrameworkSupportModelListener.class);
private final Map<String, AddSupportForFrameworksPanel.FrameworkSupportSettings> mySettingsMap = new HashMap<String, AddSupportForFrameworksPanel.FrameworkSupportSettings>();
private final Map<String, FrameworkSupportNode> mySettingsMap = new HashMap<String, FrameworkSupportNode>();
public FrameworkSupportModelImpl(final @Nullable Project project, @Nullable ModuleBuilder builder) {
myProject = project;
myModuleBuilder = builder;
}
public void registerComponent(@NotNull final FrameworkSupportProvider provider, @NotNull final AddSupportForFrameworksPanel.FrameworkSupportSettings settings) {
mySettingsMap.put(provider.getId(), settings);
final JCheckBox checkBox = settings.getCheckBox();
checkBox.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
if (checkBox.isSelected()) {
myDispatcher.getMulticaster().frameworkSelected(provider);
}
else {
myDispatcher.getMulticaster().frameworkUnselected(provider);
}
}
});
public void registerComponent(@NotNull final FrameworkSupportProvider provider, @NotNull final FrameworkSupportNode node) {
mySettingsMap.put(provider.getId(), node);
}
public Project getProject() {
@@ -53,8 +42,8 @@ public class FrameworkSupportModelImpl extends UserDataHolderBase implements Fra
}
public boolean isFrameworkSelected(@NotNull @NonNls final String providerId) {
final AddSupportForFrameworksPanel.FrameworkSupportSettings settings = mySettingsMap.get(providerId);
return settings != null && settings.getCheckBox().isSelected();
final FrameworkSupportNode node = mySettingsMap.get(providerId);
return node != null && node.isChecked();
}
public void addFrameworkListener(@NotNull final FrameworkSupportModelListener listener) {
@@ -66,20 +55,30 @@ public class FrameworkSupportModelImpl extends UserDataHolderBase implements Fra
}
public void setFrameworkComponentEnabled(@NotNull @NonNls final String providerId, final boolean enable) {
final AddSupportForFrameworksPanel.FrameworkSupportSettings settings = mySettingsMap.get(providerId);
if (settings == null) {
final FrameworkSupportNode node = mySettingsMap.get(providerId);
if (node == null) {
throw new IllegalArgumentException("provider '" + providerId + " not found");
}
if (enable != settings.getCheckBox().isEnabled()) {
settings.setEnabled(enable);
if (enable != node.isChecked()) {
node.setChecked(enable);
}
}
public FrameworkSupportConfigurable getFrameworkConfigurable(@NotNull @NonNls String providerId) {
final AddSupportForFrameworksPanel.FrameworkSupportSettings settings = mySettingsMap.get(providerId);
if (settings == null) {
final FrameworkSupportNode node = mySettingsMap.get(providerId);
if (node == null) {
throw new IllegalArgumentException("provider '" + providerId + " not found");
}
return settings.getConfigurable();
return node.getConfigurable();
}
public void onFrameworkSelectionChanged(FrameworkSupportNode node) {
final FrameworkSupportModelListener multicaster = myDispatcher.getMulticaster();
if (node.isChecked()) {
multicaster.frameworkSelected(node.getProvider());
}
else {
multicaster.frameworkUnselected(node.getProvider());
}
}
}
@@ -2,9 +2,11 @@
* Copyright (c) 2000-2007 JetBrains s.r.o. All Rights Reserved.
*/
package com.intellij.facet.impl.ui;
package com.intellij.facet.ui;
import com.intellij.facet.*;
import com.intellij.ide.util.frameworkSupport.FrameworkSupportProviderBase;
import com.intellij.ide.util.frameworkSupport.FrameworkVersion;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleType;
@@ -20,12 +22,12 @@ import java.util.List;
/**
* @author nik
*/
public abstract class FacetTypeFrameworkSupportProvider<F extends Facet> extends VersionedFrameworkSupportProvider {
private static final Logger LOG = Logger.getInstance("#com.intellij.facet.impl.ui.FacetTypeFrameworkSupportProvider");
public abstract class FacetBasedFrameworkSupportProvider<F extends Facet> extends FrameworkSupportProviderBase {
private static final Logger LOG = Logger.getInstance("#com.intellij.facet.ui.FacetBasedFrameworkSupportProvider");
@NonNls private static final String FACET_SUPPORT_PREFIX = "facet:";
private final FacetType<F, ?> myFacetType;
protected FacetTypeFrameworkSupportProvider(FacetType<F, ?> facetType) {
protected FacetBasedFrameworkSupportProvider(FacetType<F, ?> facetType) {
super(getProviderId(facetType), facetType.getPresentableName());
myFacetType = facetType;
}
@@ -62,7 +64,7 @@ public abstract class FacetTypeFrameworkSupportProvider<F extends Facet> extends
return myFacetType.getIcon();
}
protected void addSupport(final Module module, final ModifiableRootModel rootModel, final String version, final @Nullable Library library) {
protected void addSupport(@NotNull final Module module, @NotNull final ModifiableRootModel rootModel, final FrameworkVersion version, final @Nullable Library library) {
FacetManager facetManager = FacetManager.getInstance(module);
ModifiableFacetModel model = facetManager.createModifiableModel();
Facet underlyingFacet = null;
@@ -81,13 +83,13 @@ public abstract class FacetTypeFrameworkSupportProvider<F extends Facet> extends
onFacetCreated(facet, rootModel, version);
}
protected void onFacetCreated(final F facet, final ModifiableRootModel rootModel, final String version) {
protected void onFacetCreated(final F facet, final ModifiableRootModel rootModel, final FrameworkVersion version) {
}
protected void onLibraryAdded(final F facet, final @NotNull Library library) {
}
protected abstract void setupConfiguration(final F facet, final ModifiableRootModel rootModel, final String version);
protected abstract void setupConfiguration(final F facet, final ModifiableRootModel rootModel, final FrameworkVersion version);
public void processAddedLibraries(final Module module, final List<Library> addedLibraries) {
}
@@ -0,0 +1,44 @@
/*
* Copyright (c) 2000-2007 JetBrains s.r.o. All Rights Reserved.
*/
package com.intellij.ide.util.frameworkSupport;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.roots.ModifiableRootModel;
import com.intellij.openapi.roots.libraries.Library;
import com.intellij.util.EventDispatcher;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
/**
* @author nik
*/
public abstract class FrameworkSupportConfigurable {
private final EventDispatcher<FrameworkSupportConfigurableListener> myDispatcher = EventDispatcher.create(FrameworkSupportConfigurableListener.class);
@Nullable
public abstract JComponent getComponent();
public abstract void addSupport(@NotNull Module module, @NotNull ModifiableRootModel model, final @Nullable Library library);
@Nullable
public FrameworkVersion getSelectedVersion() {
return null;
}
public void addListener(@NotNull FrameworkSupportConfigurableListener listener) {
myDispatcher.addListener(listener);
}
public void removeListener(@NotNull FrameworkSupportConfigurableListener listener) {
myDispatcher.removeListener(listener);
}
protected void fireFrameworkVersionChanged() {
myDispatcher.getMulticaster().frameworkVersionChanged();
}
}
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.ide.util.frameworkSupport.FrameworkSupportConfigurableBase">
<grid id="27dc6" binding="myMainPanel" layout-manager="GridLayoutManager" row-count="1" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="500" height="27"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="f8c40" class="javax.swing.JLabel" binding="myDescriptionLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<labelFor value="99c8f"/>
<text value="&amp;Version:"/>
</properties>
</component>
<hspacer id="22aa3">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<component id="99c8f" class="javax.swing.JComboBox" binding="myVersionComboBox">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
</children>
</grid>
</form>
@@ -0,0 +1,89 @@
package com.intellij.ide.util.frameworkSupport;
import com.intellij.facet.ui.libraries.LibraryInfo;
import com.intellij.ide.util.frameworkSupport.FrameworkSupportConfigurable;
import com.intellij.ide.util.frameworkSupport.FrameworkVersion;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.roots.ModifiableRootModel;
import com.intellij.openapi.roots.libraries.Library;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Collections;
import java.util.List;
/**
* @author Dmitry Avdeev
*/
public class FrameworkSupportConfigurableBase extends FrameworkSupportConfigurable {
private JComboBox myVersionComboBox;
private final FrameworkSupportProviderBase myFrameworkSupportProvider;
private JPanel myMainPanel;
private JLabel myDescriptionLabel;
public FrameworkSupportConfigurableBase(FrameworkSupportProviderBase frameworkSupportProvider) {
this(frameworkSupportProvider, Collections.<FrameworkVersion>emptyList(), null);
}
public FrameworkSupportConfigurableBase(final FrameworkSupportProviderBase frameworkSupportProvider, List<FrameworkVersion> versions, String versionLabelText) {
myFrameworkSupportProvider = frameworkSupportProvider;
if (versions.size() > 0) {
myDescriptionLabel.setText(versionLabelText);
String maxValue = "";
FrameworkVersion defaultVersion = versions.get(versions.size() - 1);
for (FrameworkVersion version : versions) {
myVersionComboBox.addItem(version);
FontMetrics fontMetrics = myVersionComboBox.getFontMetrics(myVersionComboBox.getFont());
if (fontMetrics.stringWidth(version.getVersionName()) > fontMetrics.stringWidth(maxValue)) {
maxValue = version.getVersionName();
}
if (version.isDefault()) {
defaultVersion = version;
}
}
myVersionComboBox.setPrototypeDisplayValue(maxValue + "_");
myVersionComboBox.setRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
final Component component = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value instanceof FrameworkVersion) {
setText(((FrameworkVersion)value).getVersionName());
}
return component;
}
});
myVersionComboBox.setSelectedItem(defaultVersion);
myVersionComboBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
fireFrameworkVersionChanged();
}
});
}
else {
myDescriptionLabel.setVisible(false);
myVersionComboBox.setVisible(false);
}
}
public JComponent getComponent() {
return myMainPanel;
}
@NotNull
public LibraryInfo[] getLibraries() {
return getSelectedVersion().getLibraries();
}
public void addSupport(@NotNull final Module module, @NotNull final ModifiableRootModel rootModel, final @Nullable Library library) {
myFrameworkSupportProvider.addSupport(module, rootModel, getSelectedVersion(), library);
}
public FrameworkVersion getSelectedVersion() {
return (FrameworkVersion)myVersionComboBox.getSelectedItem();
}
}
@@ -0,0 +1,12 @@
package com.intellij.ide.util.frameworkSupport;
import java.util.EventListener;
/**
* @author nik
*/
public interface FrameworkSupportConfigurableListener extends EventListener {
void frameworkVersionChanged();
}
@@ -1,4 +1,4 @@
package com.intellij.ide.util.newProjectWizard;
package com.intellij.ide.util.frameworkSupport;
import com.intellij.ide.util.projectWizard.ModuleBuilder;
import com.intellij.openapi.project.Project;
@@ -1,4 +1,4 @@
package com.intellij.ide.util.newProjectWizard;
package com.intellij.ide.util.frameworkSupport;
import org.jetbrains.annotations.NotNull;
@@ -2,15 +2,13 @@
* Copyright (c) 2000-2007 JetBrains s.r.o. All Rights Reserved.
*/
package com.intellij.ide.util.newProjectWizard;
package com.intellij.ide.util.frameworkSupport;
import com.intellij.ide.util.projectWizard.ModuleBuilder;
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.openapi.module.JavaModuleType;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleType;
import com.intellij.openapi.project.Project;
import com.intellij.util.ArrayUtil;
import com.intellij.ide.util.projectWizard.ModuleBuilder;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -31,18 +29,7 @@ public abstract class FrameworkSupportProvider {
}
@NotNull
public FrameworkSupportConfigurable createConfigurable(@NotNull FrameworkSupportModel model) {
return createConfigurable(model.getProject());
}
/**
* @deprecated override {@link FrameworkSupportProvider#createConfigurable(FrameworkSupportModel)} instead
*/
@Deprecated
@NotNull
public FrameworkSupportConfigurable createConfigurable(@Nullable final Project project) {
return null;
}
public abstract FrameworkSupportConfigurable createConfigurable(@NotNull FrameworkSupportModel model);
@NonNls
@Nullable
@@ -69,9 +56,7 @@ public abstract class FrameworkSupportProvider {
return null;
}
public boolean isEnabledForModuleType(@NotNull ModuleType moduleType) {
return moduleType instanceof JavaModuleType;
}
public abstract boolean isEnabledForModuleType(@NotNull ModuleType moduleType);
public boolean isEnabledForModuleBuilder(@NotNull ModuleBuilder builder) {
return isEnabledForModuleType(builder.getModuleType());
@@ -0,0 +1,41 @@
/*
* Copyright (c) 2000-2007 JetBrains s.r.o. All Rights Reserved.
*/
package com.intellij.ide.util.frameworkSupport;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.roots.ModifiableRootModel;
import com.intellij.openapi.roots.libraries.Library;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Collections;
import java.util.List;
/**
* @author nik
*/
public abstract class FrameworkSupportProviderBase extends FrameworkSupportProvider {
protected FrameworkSupportProviderBase(final @NonNls @NotNull String id, final @NotNull String title) {
super(id, title);
}
protected abstract void addSupport(@NotNull Module module, @NotNull ModifiableRootModel rootModel, FrameworkVersion version, final @Nullable Library library);
@NotNull
public List<FrameworkVersion> getVersions() {
return Collections.emptyList();
}
public String getVersionLabelText() {
return "Version:";
}
@NotNull
public FrameworkSupportConfigurableBase createConfigurable(final @NotNull FrameworkSupportModel model) {
return new FrameworkSupportConfigurableBase(this, getVersions(), getVersionLabelText());
}
}
@@ -0,0 +1,53 @@
package com.intellij.ide.util.frameworkSupport;
import com.intellij.facet.ui.libraries.LibraryInfo;
import org.jetbrains.annotations.NotNull;
/**
* @author nik
*/
public class FrameworkVersion {
public static final FrameworkVersion[] EMPTY_ARRAY = new FrameworkVersion[0];
private final String myVersionName;
private final String myLibraryName;
private final LibraryInfo[] myLibraries;
private final boolean myDefault;
public FrameworkVersion(String versionName) {
this(versionName, false);
}
public FrameworkVersion(@NotNull String versionName, boolean isDefault) {
myVersionName = versionName;
myDefault = isDefault;
myLibraryName = null;
myLibraries = LibraryInfo.EMPTY_ARRAY;
}
public FrameworkVersion(String versionName, String libraryName, LibraryInfo[] libraries) {
this(versionName, libraryName, libraries, false);
}
public FrameworkVersion(@NotNull String versionName, @NotNull String libraryName, @NotNull LibraryInfo[] libraries, boolean aDefault) {
myVersionName = versionName;
myLibraryName = libraryName;
myLibraries = libraries;
myDefault = aDefault;
}
public String getVersionName() {
return myVersionName;
}
public String getLibraryName() {
return myLibraryName;
}
public LibraryInfo[] getLibraries() {
return myLibraries;
}
public boolean isDefault() {
return myDefault;
}
}
@@ -54,7 +54,6 @@ public abstract class ModuleBuilder extends ProjectBuilder{
private static final Logger LOG = Logger.getInstance("#com.intellij.ide.util.projectWizard.ModuleBuilder");
private String myName;
@NonNls private String myModuleFilePath;
@Nullable
private final List<ModuleConfigurationUpdater> myUpdaters = new ArrayList<ModuleConfigurationUpdater>();
private final EventDispatcher<ModuleBuilderListener> myDispatcher = EventDispatcher.create(ModuleBuilderListener.class);
@@ -243,7 +242,7 @@ public abstract class ModuleBuilder extends ProjectBuilder{
public static abstract class ModuleConfigurationUpdater {
public abstract void update(Module module, ModifiableRootModel rootModel);
public abstract void update(@NotNull Module module, @NotNull ModifiableRootModel rootModel);
}
}
@@ -19,6 +19,7 @@ import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.ui.IdeBorderFactory;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.*;
@@ -35,6 +36,14 @@ public class LabeledComponent<Comp extends JComponent> extends JPanel {
updateUI();
}
@NotNull
public static <Comp extends JComponent> LabeledComponent<Comp> create(@NotNull Comp component, @NotNull String text) {
final LabeledComponent<Comp> labeledComponent = new LabeledComponent<Comp>();
labeledComponent.setComponent(component);
labeledComponent.setText(text);
return labeledComponent;
}
private void updateLabelBorder() {
int left = 0;
int bottom = 0;
@@ -284,9 +284,15 @@ public class CheckboxTreeBase extends Tree {
public static abstract class CheckboxTreeCellRendererBase extends JPanel implements TreeCellRenderer {
private final ColoredTreeCellRenderer myTextRenderer;
public final JCheckBox myCheckbox;
private final boolean myUsePartialStatusForParentNodes;
public CheckboxTreeCellRendererBase(boolean opaque) {
this(opaque, true);
}
public CheckboxTreeCellRendererBase(boolean opaque, final boolean usePartialStatusForParentNodes) {
super(new BorderLayout());
myUsePartialStatusForParentNodes = usePartialStatusForParentNodes;
myCheckbox = new JCheckBox();
myTextRenderer = new ColoredTreeCellRenderer() {
public void customizeCellRenderer(JTree tree,
@@ -337,7 +343,7 @@ public class CheckboxTreeBase extends Tree {
private NodeState getNodeStatus(final CheckedTreeNode node) {
final boolean checked = node.isChecked();
if (node.getChildCount() == 0) return checked ? NodeState.FULL : NodeState.CLEAR;
if (node.getChildCount() == 0 || !myUsePartialStatusForParentNodes) return checked ? NodeState.FULL : NodeState.CLEAR;
NodeState result = null;
@@ -16,6 +16,10 @@ public class CheckboxTree extends CheckboxTreeBase {
protected CheckboxTreeCellRenderer(final boolean opaque) {
super(opaque);
}
protected CheckboxTreeCellRenderer(boolean opaque, boolean usePartialStatusForParentNodes) {
super(opaque, usePartialStatusForParentNodes);
}
}
public CheckboxTree(final CheckboxTreeCellRenderer cellRenderer, CheckedTreeNode root) {
+1 -1
View File
@@ -123,7 +123,7 @@
<extensionPoint name="semContributor"
interface="com.intellij.semantic.SemContributor" area="IDEA_PROJECT"/>
<extensionPoint name="frameworkSupport" interface="com.intellij.ide.util.newProjectWizard.FrameworkSupportProvider"/>
<extensionPoint name="frameworkSupport" interface="com.intellij.ide.util.frameworkSupport.FrameworkSupportProvider"/>
<!--new project wizard-->
<extensionPoint name="wizardMode" interface="com.intellij.ide.util.newProjectWizard.modes.WizardMode"/>