mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
template-based project types?
This commit is contained in:
@@ -45,4 +45,6 @@ public class CommonJavaProjectCategory extends ProjectCategory {
|
||||
public String getDescription() {
|
||||
return "Common Java Project";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.intellij.util.containers.Convertor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -46,6 +47,10 @@ public abstract class ProjectCategory {
|
||||
return createModuleBuilder().getPresentableName();
|
||||
}
|
||||
|
||||
public Icon getIcon() {
|
||||
return createModuleBuilder().getNodeIcon();
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return createModuleBuilder().getDescription();
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.ui.CheckedTreeNode;
|
||||
import com.intellij.ui.CollectionListModel;
|
||||
import com.intellij.ui.ColoredListCellRenderer;
|
||||
import com.intellij.ui.components.JBList;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.containers.FactoryMap;
|
||||
@@ -91,6 +92,15 @@ public class ProjectTypeStep extends StepAdapter {
|
||||
}
|
||||
};
|
||||
|
||||
myProjectTypeList.setCellRenderer(new ColoredListCellRenderer() {
|
||||
@Override
|
||||
protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
|
||||
ProjectCategory category = (ProjectCategory)value;
|
||||
append(category.getDisplayName());
|
||||
setIcon(category.getIcon());
|
||||
}
|
||||
});
|
||||
|
||||
ProjectCategory[] projectCategories = ProjectCategory.EXTENSION_POINT_NAME.getExtensions();
|
||||
myProjectTypeList.setModel(new CollectionListModel<ProjectCategory>(Arrays.asList(projectCategories)));
|
||||
myProjectTypeList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.ide.projectWizard;
|
||||
|
||||
import com.intellij.ide.util.projectWizard.ModuleBuilder;
|
||||
import com.intellij.platform.templates.ArchivedTemplatesFactory;
|
||||
import com.intellij.platform.templates.LocalArchivedTemplate;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* @author Dmitry Avdeev
|
||||
* Date: 20.09.13
|
||||
*/
|
||||
public abstract class TemplateBasedProjectType extends ProjectCategory {
|
||||
|
||||
private final LocalArchivedTemplate myTemplate;
|
||||
|
||||
public TemplateBasedProjectType(String templatePath) {
|
||||
ClassLoader loader = getClass().getClassLoader();
|
||||
URL resource = loader.getResource(templatePath);
|
||||
assert resource != null : templatePath;
|
||||
String name = ArchivedTemplatesFactory.getTemplateName(new File(templatePath).getName());
|
||||
myTemplate = new LocalArchivedTemplate(name, resource, loader);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ModuleBuilder createModuleBuilder() {
|
||||
return myTemplate.createModuleBuilder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return myTemplate.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return myTemplate.getDescription();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon() {
|
||||
return myTemplate.getIcon();
|
||||
}
|
||||
}
|
||||
@@ -132,7 +132,7 @@ public class ArchivedTemplatesFactory extends ProjectTemplatesFactory {
|
||||
for (String child : children) {
|
||||
if (child.endsWith(ZIP)) {
|
||||
URL templateUrl = new URL(url.first.toExternalForm() + "/" + child);
|
||||
String name = child.substring(0, child.length() - ZIP.length()).replace('_', ' ');
|
||||
String name = getTemplateName(child);
|
||||
templates.add(new LocalArchivedTemplate(name, templateUrl, url.second));
|
||||
}
|
||||
}
|
||||
@@ -144,6 +144,10 @@ public class ArchivedTemplatesFactory extends ProjectTemplatesFactory {
|
||||
return templates.toArray(new ProjectTemplate[templates.size()]);
|
||||
}
|
||||
|
||||
public static String getTemplateName(String child) {
|
||||
return child.substring(0, child.length() - ZIP.length()).replace('_', ' ');
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGroupWeight(String group) {
|
||||
return CUSTOM_GROUP.equals(group) ? -2 : 0;
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
<orderEntry type="module" module-name="compiler-impl" />
|
||||
<orderEntry type="module" module-name="common-javaFX-plugin" />
|
||||
<orderEntry type="module" module-name="manifest" />
|
||||
<orderEntry type="module" module-name="idea-ui" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
|
||||
@@ -50,6 +50,9 @@
|
||||
<renamePsiElementProcessor implementation="org.jetbrains.plugins.javaFX.JavaFxRenameAttributeProcessor" order="before xmlAttribute"/>
|
||||
<completion.contributor implementationClass="org.jetbrains.plugins.javaFX.fxml.refs.JavaFxCompletionContributor" language="XML" order="before xmlNonFirst"/>
|
||||
<manifest.parser.provider implementation="org.jetbrains.plugins.javaFX.manifest.JavaFxManifestHeaderParsers"/>
|
||||
<!--
|
||||
<projectWizard.projectCategory implementation="org.jetbrains.plugins.javaFX.JavaFxProjectType"/>
|
||||
-->
|
||||
</extensions>
|
||||
|
||||
<actions>
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.jetbrains.plugins.javaFX;
|
||||
|
||||
import com.intellij.ide.projectWizard.TemplateBasedProjectType;
|
||||
|
||||
/**
|
||||
* @author Dmitry Avdeev
|
||||
* Date: 20.09.13
|
||||
*/
|
||||
public class JavaFxProjectType extends TemplateBasedProjectType {
|
||||
|
||||
public JavaFxProjectType() {
|
||||
super("/resources/projectTemplates/Java/JavaFX Application.zip");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return "JavaFX";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user