use of com.intellij.ide.fileTemplates.FileTemplateDescriptor in project qi4j-sdk by Qi4j.
the class Qi4jApplicationComponent method getFileTemplatesDescriptor.
public final FileTemplateGroupDescriptor getFileTemplatesDescriptor() {
FileTemplateGroupDescriptor group = new FileTemplateGroupDescriptor(message("qi4j.file.template.group.title"), null);
FileTypeManager fileTypeManager = FileTypeManager.getInstance();
for (@NonNls String template : FILE_TEMPLATES) {
Icon icon = fileTypeManager.getFileTypeByFileName(template).getIcon();
group.addTemplate(new FileTemplateDescriptor(template, icon));
}
return group;
}
use of com.intellij.ide.fileTemplates.FileTemplateDescriptor in project intellij-community by JetBrains.
the class MavenFileTemplateGroupFactory method getFileTemplatesDescriptor.
public FileTemplateGroupDescriptor getFileTemplatesDescriptor() {
FileTemplateGroupDescriptor group = new FileTemplateGroupDescriptor("Maven", MavenIcons.MavenLogo);
group.addTemplate(new FileTemplateDescriptor(MAVEN_PROJECT_XML_TEMPLATE, MavenIcons.MavenLogo));
group.addTemplate(new FileTemplateDescriptor(MAVEN_PROFILES_XML_TEMPLATE, MavenIcons.MavenLogo));
group.addTemplate(new FileTemplateDescriptor(MAVEN_SETTINGS_XML_TEMPLATE, MavenIcons.MavenLogo));
return group;
}
use of com.intellij.ide.fileTemplates.FileTemplateDescriptor in project intellij-community by JetBrains.
the class JavaTestGenerator method createTestClass.
@Nullable
private static PsiClass createTestClass(CreateTestDialog d) {
final TestFramework testFrameworkDescriptor = d.getSelectedTestFrameworkDescriptor();
final FileTemplateDescriptor fileTemplateDescriptor = TestIntegrationUtils.MethodKind.TEST_CLASS.getFileTemplateDescriptor(testFrameworkDescriptor);
final PsiDirectory targetDirectory = d.getTargetDirectory();
final PsiPackage aPackage = JavaDirectoryService.getInstance().getPackage(targetDirectory);
if (aPackage != null) {
final GlobalSearchScope scope = GlobalSearchScopesCore.directoryScope(targetDirectory, false);
final PsiClass[] classes = aPackage.findClassByShortName(d.getClassName(), scope);
if (classes.length > 0) {
if (!FileModificationService.getInstance().preparePsiElementForWrite(classes[0])) {
return null;
}
return classes[0];
}
}
if (fileTemplateDescriptor != null) {
final PsiClass classFromTemplate = createTestClassFromCodeTemplate(d, fileTemplateDescriptor, targetDirectory);
if (classFromTemplate != null) {
return classFromTemplate;
}
}
return JavaDirectoryService.getInstance().createClass(targetDirectory, d.getClassName());
}
use of com.intellij.ide.fileTemplates.FileTemplateDescriptor in project intellij-community by JetBrains.
the class BaseGenerateTestSupportMethodAction method createEditTemplateAction.
@Nullable
@Override
public AnAction createEditTemplateAction(DataContext dataContext) {
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
final Editor editor = CommonDataKeys.EDITOR.getData(dataContext);
final PsiFile file = CommonDataKeys.PSI_FILE.getData(dataContext);
final PsiClass targetClass = editor == null || file == null ? null : getTargetClass(editor, file);
if (targetClass != null) {
final List<TestFramework> frameworks = TestIntegrationUtils.findSuitableFrameworks(targetClass);
final TestIntegrationUtils.MethodKind methodKind = ((MyHandler) getHandler()).myMethodKind;
if (!frameworks.isEmpty()) {
return new AnAction("Edit Template") {
@Override
public void actionPerformed(AnActionEvent e) {
chooseAndPerform(editor, frameworks, framework -> {
final FileTemplateDescriptor descriptor = methodKind.getFileTemplateDescriptor(framework);
if (descriptor != null) {
final String fileName = descriptor.getFileName();
AllFileTemplatesConfigurable.editCodeTemplate(FileUtil.getNameWithoutExtension(fileName), project);
} else {
HintManager.getInstance().showErrorHint(editor, "No template found for " + framework.getName() + ":" + BaseGenerateTestSupportMethodAction.this.getTemplatePresentation().getText());
}
});
}
};
}
}
return null;
}
use of com.intellij.ide.fileTemplates.FileTemplateDescriptor in project intellij-community by JetBrains.
the class DevKitFileTemplatesFactory method getFileTemplatesDescriptor.
public FileTemplateGroupDescriptor getFileTemplatesDescriptor() {
FileTemplateGroupDescriptor descriptor = new FileTemplateGroupDescriptor(DevKitBundle.message("plugin.descriptor"), AllIcons.Nodes.Plugin);
descriptor.addTemplate(new FileTemplateDescriptor("plugin.xml", StdFileTypes.XML.getIcon()));
descriptor.addTemplate(new FileTemplateDescriptor("ProjectComponent.java", StdFileTypes.JAVA.getIcon()));
descriptor.addTemplate(new FileTemplateDescriptor("ApplicationComponent.java", StdFileTypes.JAVA.getIcon()));
descriptor.addTemplate(new FileTemplateDescriptor("ModuleComponent.java", StdFileTypes.JAVA.getIcon()));
descriptor.addTemplate(new FileTemplateDescriptor("Action.java", StdFileTypes.JAVA.getIcon()));
descriptor.addTemplate(new FileTemplateDescriptor("InspectionDescription.html", StdFileTypes.HTML.getIcon()));
return descriptor;
}
Aggregations