better presentation for the list of modules with Kotlin files
#KT-9025 Fixed
This commit is contained in:
@@ -29,7 +29,7 @@
|
|||||||
<grid row="3" column="0" row-span="1" col-span="3" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
<grid row="3" column="0" row-span="1" col-span="3" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
</vspacer>
|
</vspacer>
|
||||||
<component id="5ca07" class="javax.swing.JTextField" binding="allModulesWithKtNames">
|
<component id="ed75a" class="com.intellij.ui.HyperlinkLabel" binding="allModulesWithKtNames">
|
||||||
<constraints>
|
<constraints>
|
||||||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||||
<preferred-size width="150" height="-1"/>
|
<preferred-size width="150" height="-1"/>
|
||||||
@@ -37,7 +37,6 @@
|
|||||||
</grid>
|
</grid>
|
||||||
</constraints>
|
</constraints>
|
||||||
<properties>
|
<properties>
|
||||||
<editable value="false"/>
|
|
||||||
<enabled value="true"/>
|
<enabled value="true"/>
|
||||||
</properties>
|
</properties>
|
||||||
</component>
|
</component>
|
||||||
|
|||||||
@@ -19,13 +19,19 @@ package org.jetbrains.kotlin.idea.framework.ui;
|
|||||||
import com.intellij.openapi.module.Module;
|
import com.intellij.openapi.module.Module;
|
||||||
import com.intellij.openapi.module.ModuleManager;
|
import com.intellij.openapi.module.ModuleManager;
|
||||||
import com.intellij.openapi.project.Project;
|
import com.intellij.openapi.project.Project;
|
||||||
|
import com.intellij.openapi.ui.popup.JBPopupFactory;
|
||||||
|
import com.intellij.openapi.ui.popup.util.BaseListPopupStep;
|
||||||
import com.intellij.openapi.util.text.StringUtil;
|
import com.intellij.openapi.util.text.StringUtil;
|
||||||
|
import com.intellij.ui.HyperlinkLabel;
|
||||||
import com.intellij.util.Function;
|
import com.intellij.util.Function;
|
||||||
|
import com.intellij.xml.util.XmlUtil;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.kotlin.idea.configuration.ConfigureKotlinInProjectUtilsKt;
|
import org.jetbrains.kotlin.idea.configuration.ConfigureKotlinInProjectUtilsKt;
|
||||||
import org.jetbrains.kotlin.idea.configuration.KotlinProjectConfigurator;
|
import org.jetbrains.kotlin.idea.configuration.KotlinProjectConfigurator;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
import javax.swing.event.HyperlinkEvent;
|
||||||
|
import javax.swing.event.HyperlinkListener;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@@ -37,7 +43,7 @@ public class ChooseModulePanel {
|
|||||||
private JRadioButton allModulesWithKtRadioButton;
|
private JRadioButton allModulesWithKtRadioButton;
|
||||||
private JRadioButton singleModuleRadioButton;
|
private JRadioButton singleModuleRadioButton;
|
||||||
private JComboBox singleModuleComboBox;
|
private JComboBox singleModuleComboBox;
|
||||||
private JTextField allModulesWithKtNames;
|
private HyperlinkLabel allModulesWithKtNames;
|
||||||
private JRadioButton allModulesRadioButton;
|
private JRadioButton allModulesRadioButton;
|
||||||
|
|
||||||
@NotNull private final Project project;
|
@NotNull private final Project project;
|
||||||
@@ -71,14 +77,31 @@ public class ChooseModulePanel {
|
|||||||
allModulesWithKtRadioButton.addActionListener(listener);
|
allModulesWithKtRadioButton.addActionListener(listener);
|
||||||
allModulesRadioButton.addActionListener(listener);
|
allModulesRadioButton.addActionListener(listener);
|
||||||
|
|
||||||
String fullList = StringUtil.join(modulesWithKtFiles, new Function<Module, String>() {
|
if (modulesWithKtFiles.size() > 2) {
|
||||||
@Override
|
allModulesWithKtNames.setHtmlText("<html>" + XmlUtil.escape(modulesWithKtFiles.get(0).getName()) + ", " +
|
||||||
public String fun(Module module) {
|
XmlUtil.escape(modulesWithKtFiles.get(1).getName()) +
|
||||||
return module.getName();
|
" and <a href=\"#\">" + (modulesWithKtFiles.size() - 2) + " other modules</a>");
|
||||||
}
|
allModulesWithKtNames.addHyperlinkListener(new HyperlinkListener() {
|
||||||
}, ", ");
|
@Override
|
||||||
allModulesWithKtNames.setText(fullList);
|
public void hyperlinkUpdate(HyperlinkEvent event) {
|
||||||
allModulesWithKtNames.setBorder(null);
|
JBPopupFactory.getInstance().createListPopup(new BaseListPopupStep<Module>("Modules with Kotlin Files", modulesWithKtFiles) {
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public String getTextFor(Module value) {
|
||||||
|
return value.getName();
|
||||||
|
}
|
||||||
|
}).showUnderneathOf(allModulesWithKtNames);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
allModulesWithKtNames.setText(StringUtil.join(modules, new Function<Module, String>() {
|
||||||
|
@Override
|
||||||
|
public String fun(Module module) {
|
||||||
|
return module.getName();
|
||||||
|
}
|
||||||
|
}, ", "));
|
||||||
|
}
|
||||||
|
|
||||||
ButtonGroup modulesGroup = new ButtonGroup();
|
ButtonGroup modulesGroup = new ButtonGroup();
|
||||||
modulesGroup.add(allModulesRadioButton);
|
modulesGroup.add(allModulesRadioButton);
|
||||||
|
|||||||
Reference in New Issue
Block a user