mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
project templates: showing descriptions
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
<?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.SelectTemplateStep">
|
||||
<grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="2" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="3" column-count="2" 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="470" height="400"/>
|
||||
<xy x="20" y="20" width="503" height="400"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="ac540" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="8" fill="2" indent="0" use-parent-layout="false"/>
|
||||
<grid row="1" column="0" row-span="2" col-span="1" vsize-policy="3" hsize-policy="3" anchor="8" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
@@ -36,25 +36,41 @@
|
||||
</grid>
|
||||
<grid id="caf4" binding="mySettingsPanel" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<clientProperties>
|
||||
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"/>
|
||||
</clientProperties>
|
||||
<border type="etched" title="Settings"/>
|
||||
<children/>
|
||||
</grid>
|
||||
<hspacer id="fc0b6">
|
||||
<constraints>
|
||||
<grid row="1" 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="dafde" class="com.intellij.ui.components.JBLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
<grid row="0" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Please select desired template from the list"/>
|
||||
</properties>
|
||||
</component>
|
||||
<grid id="c0238" binding="myDescriptionPanel" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="7" anchor="1" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<clientProperties>
|
||||
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"/>
|
||||
</clientProperties>
|
||||
<border type="etched" title="Description"/>
|
||||
<children>
|
||||
<component id="1d5a0" class="com.intellij.ui.components.JBLabel" binding="myDescriptionLabel">
|
||||
<constraints border-constraint="Center"/>
|
||||
<properties>
|
||||
<text value="some description"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.intellij.ui.CollectionListModel;
|
||||
import com.intellij.ui.ColoredListCellRenderer;
|
||||
import com.intellij.ui.DocumentAdapter;
|
||||
import com.intellij.ui.SearchTextField;
|
||||
import com.intellij.ui.components.JBLabel;
|
||||
import com.intellij.ui.components.JBList;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
|
||||
@@ -48,6 +49,8 @@ public class SelectTemplateStep extends ModuleWizardStep {
|
||||
private JBList myTemplatesList;
|
||||
private JPanel mySettingsPanel;
|
||||
private SearchTextField mySearchField;
|
||||
private JBLabel myDescriptionLabel;
|
||||
private JPanel myDescriptionPanel;
|
||||
|
||||
public SelectTemplateStep(WizardContext context) {
|
||||
|
||||
@@ -78,6 +81,10 @@ public class SelectTemplateStep extends ModuleWizardStep {
|
||||
if (settingsPanel != null) {
|
||||
mySettingsPanel.add(settingsPanel, BorderLayout.NORTH);
|
||||
}
|
||||
mySettingsPanel.setVisible(settingsPanel != null);
|
||||
String description = template.getDescription();
|
||||
myDescriptionLabel.setText(description);
|
||||
myDescriptionPanel.setVisible(description != null);
|
||||
}
|
||||
mySettingsPanel.revalidate();
|
||||
mySettingsPanel.repaint();
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ui.configuration.ModulesProvider;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.io.StreamUtil;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.newvfs.RefreshQueue;
|
||||
@@ -35,9 +36,9 @@ import org.jetbrains.annotations.Nullable;
|
||||
import javax.swing.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
/**
|
||||
@@ -45,18 +46,16 @@ import java.util.zip.ZipInputStream;
|
||||
* Date: 10/1/12
|
||||
*/
|
||||
public class ArchivedProjectTemplate implements ProjectTemplate {
|
||||
|
||||
private final String myDisplayName;
|
||||
private final String myDescription;
|
||||
private final URL myArchivePath;
|
||||
private final WizardContext myContext;
|
||||
|
||||
public ArchivedProjectTemplate(String displayName,
|
||||
String description,
|
||||
URL archivePath,
|
||||
WizardContext context) {
|
||||
|
||||
myDisplayName = displayName;
|
||||
myDescription = description;
|
||||
myArchivePath = archivePath;
|
||||
myContext = context;
|
||||
}
|
||||
@@ -68,7 +67,19 @@ public class ArchivedProjectTemplate implements ProjectTemplate {
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return myDescription;
|
||||
try {
|
||||
ZipInputStream stream = getStream();
|
||||
ZipEntry entry;
|
||||
while ((entry = stream.getNextEntry()) != null) {
|
||||
if (entry.getName().endsWith("/description.html")) {
|
||||
return StreamUtil.readText(stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -81,9 +92,9 @@ public class ArchivedProjectTemplate implements ProjectTemplate {
|
||||
final String path = myContext.getProjectFileDirectory();
|
||||
String iml;
|
||||
try {
|
||||
InputStream stream = myArchivePath.openStream();
|
||||
File dir = new File(path);
|
||||
ZipUtil.unzip(null, dir, new ZipInputStream(stream));
|
||||
ZipInputStream zipInputStream = getStream();
|
||||
ZipUtil.unzip(null, dir, zipInputStream);
|
||||
VirtualFile virtualFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(dir);
|
||||
RefreshQueue.getInstance().refresh(false, true, null, virtualFile);
|
||||
iml = ContainerUtil.find(dir.list(), new Condition<String>() {
|
||||
@@ -101,6 +112,10 @@ public class ArchivedProjectTemplate implements ProjectTemplate {
|
||||
};
|
||||
}
|
||||
|
||||
private ZipInputStream getStream() throws IOException {
|
||||
return new ZipInputStream(myArchivePath.openStream());
|
||||
}
|
||||
|
||||
@Override
|
||||
public JComponent getSettingsPanel() {
|
||||
return null;
|
||||
|
||||
@@ -16,7 +16,10 @@
|
||||
package com.intellij.platform.templates;
|
||||
|
||||
import com.intellij.ide.fileTemplates.impl.UrlUtil;
|
||||
import com.intellij.ide.plugins.IdeaPluginDescriptor;
|
||||
import com.intellij.ide.plugins.PluginManager;
|
||||
import com.intellij.ide.util.projectWizard.WizardContext;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.platform.ProjectTemplate;
|
||||
import com.intellij.platform.ProjectTemplatesFactory;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -34,23 +37,36 @@ public class ArchivedTemplatesFactory implements ProjectTemplatesFactory {
|
||||
@NotNull
|
||||
@Override
|
||||
public ProjectTemplate[] createTemplates(WizardContext context) {
|
||||
try {
|
||||
List<ProjectTemplate> templates = new ArrayList<ProjectTemplate>();
|
||||
Enumeration<URL> resources = getClass().getClassLoader().getResources("resources/projectTemplates");
|
||||
Set<URL> urls = new HashSet<URL>(Collections.list(resources));
|
||||
for (URL url : urls) {
|
||||
|
||||
IdeaPluginDescriptor[] plugins = PluginManager.getPlugins();
|
||||
Set<URL> urls = new HashSet<URL>();
|
||||
for (IdeaPluginDescriptor plugin : plugins) {
|
||||
try {
|
||||
Enumeration<URL> resources = plugin.getPluginClassLoader().getResources("resources/projectTemplates");
|
||||
urls.addAll(Collections.list(resources));
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
List<ProjectTemplate> templates = new ArrayList<ProjectTemplate>();
|
||||
for (URL url : urls) {
|
||||
try {
|
||||
final List<String> children = UrlUtil.getChildrenRelativePaths(url);
|
||||
for (String child : children) {
|
||||
if (child.endsWith(".zip")) {
|
||||
final URL templateUrl = new URL(url.toExternalForm() + "/" + child);
|
||||
templates.add(new ArchivedProjectTemplate(child, null, templateUrl, context));
|
||||
templates.add(new ArchivedProjectTemplate(child, templateUrl, context));
|
||||
}
|
||||
}
|
||||
}
|
||||
return templates.toArray(new ProjectTemplate[templates.size()]);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
catch (IOException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
}
|
||||
return templates.toArray(new ProjectTemplate[templates.size()]);
|
||||
}
|
||||
|
||||
private final static Logger LOG = Logger.getInstance(ArchivedTemplatesFactory.class);
|
||||
}
|
||||
|
||||
-3
@@ -118,9 +118,6 @@ public abstract class AbstractGithubTagDownloadedProjectGenerator extends WebPro
|
||||
Messages.showErrorDialog(project, fullMessage, title);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public abstract String getHomepageUrl();
|
||||
|
||||
@Nullable
|
||||
public abstract String getDescription();
|
||||
}
|
||||
|
||||
+8
-28
@@ -1,16 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.platform.templates.github.GithubProjectGeneratorPeer">
|
||||
<grid id="27dc6" binding="myComponent" layout-manager="GridLayoutManager" row-count="5" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="27dc6" binding="myComponent" layout-manager="GridLayoutManager" row-count="3" column-count="4" 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="400"/>
|
||||
<xy x="20" y="20" width="500" height="100"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="7efaf" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
<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="7379c"/>
|
||||
@@ -19,17 +19,17 @@
|
||||
</component>
|
||||
<hspacer id="cb5b0">
|
||||
<constraints>
|
||||
<grid row="2" column="3" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</hspacer>
|
||||
<vspacer id="61e03">
|
||||
<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"/>
|
||||
<grid row="2" 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>
|
||||
<component id="7379c" class="javax.swing.JComboBox" binding="myComboBox">
|
||||
<constraints>
|
||||
<grid row="2" 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="2" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<minimum-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
@@ -37,7 +37,7 @@
|
||||
</component>
|
||||
<component id="6cca1" class="javax.swing.JLabel" binding="myErrorMessage">
|
||||
<constraints>
|
||||
<grid row="3" column="0" row-span="1" col-span="4" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
<grid row="1" column="0" row-span="1" col-span="4" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<background color="-52429"/>
|
||||
@@ -47,32 +47,12 @@
|
||||
</component>
|
||||
<component id="dd95a" class="javax.swing.JButton" binding="myReloadButton">
|
||||
<constraints>
|
||||
<grid row="2" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
<grid row="0" 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 value="&Reload"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="e74f1" class="com.intellij.ui.components.JBLabel" binding="myHomepageLabel">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="2" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Homepage:"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="e1779" class="com.intellij.ui.HyperlinkLabel" binding="myHyperlink">
|
||||
<constraints>
|
||||
<grid row="1" column="1" row-span="1" col-span="3" vsize-policy="3" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="5b63b" class="com.intellij.ui.components.JBLabel" binding="myDescriptionLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="4" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
|
||||
+1
-21
@@ -5,9 +5,7 @@ import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.intellij.openapi.ui.ValidationInfo;
|
||||
import com.intellij.platform.WebProjectGenerator;
|
||||
import com.intellij.ui.HyperlinkLabel;
|
||||
import com.intellij.ui.ListCellRendererWrapper;
|
||||
import com.intellij.ui.components.JBLabel;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
@@ -32,11 +30,8 @@ public class GithubProjectGeneratorPeer implements WebProjectGenerator.Generator
|
||||
private JComboBox myComboBox;
|
||||
private final GithubTagListProvider myProvider;
|
||||
private JComponent myComponent;
|
||||
private HyperlinkLabel myHyperlink;
|
||||
private JLabel myErrorMessage;
|
||||
private JButton myReloadButton;
|
||||
private JBLabel myHomepageLabel;
|
||||
private JBLabel myDescriptionLabel;
|
||||
|
||||
public GithubProjectGeneratorPeer(@NotNull AbstractGithubTagDownloadedProjectGenerator generator) {
|
||||
String ghUserName = generator.getGithubUserName();
|
||||
@@ -45,19 +40,6 @@ public class GithubProjectGeneratorPeer implements WebProjectGenerator.Generator
|
||||
"master",
|
||||
String.format("https://github.com/%s/%s/zipball/master", ghUserName, ghRepoName)
|
||||
);
|
||||
String url = generator.getHomepageUrl();
|
||||
if (url != null) {
|
||||
myHomepageLabel.setVisible(true);
|
||||
myHyperlink.setVisible(true);
|
||||
myHyperlink.setHyperlinkText(url);
|
||||
myHyperlink.setHyperlinkTarget(url);
|
||||
myHyperlink.revalidate();
|
||||
}
|
||||
else {
|
||||
myHomepageLabel.setVisible(false);
|
||||
myHyperlink.setVisible(false);
|
||||
}
|
||||
myDescriptionLabel.setText(generator.getDescription());
|
||||
|
||||
myComboBox.setRenderer(new ListCellRendererWrapper<GithubTagInfo>() {
|
||||
@Override
|
||||
@@ -120,9 +102,7 @@ public class GithubProjectGeneratorPeer implements WebProjectGenerator.Generator
|
||||
UIUtil.invokeLaterIfNeeded(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (false) {
|
||||
myErrorMessage.setText(message);
|
||||
}
|
||||
myErrorMessage.setText(message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ public interface ProjectTemplate {
|
||||
|
||||
String getName();
|
||||
|
||||
@Nullable
|
||||
String getDescription();
|
||||
|
||||
@Nullable
|
||||
|
||||
Reference in New Issue
Block a user