use of com.intellij.ide.fileTemplates.FileTemplateManager in project android by JetBrains.
the class AndroidStudioInitializer method setUpNewProjectActions.
private static void setUpNewProjectActions() {
replaceAction("NewClass", new CreateClassAction());
// Update the text for the file creation templates.
FileTemplateManager fileTemplateManager = FileTemplateManager.getDefaultInstance();
fileTemplateManager.getTemplate("Singleton").setText(fileTemplateManager.getJ2eeTemplate("Singleton").getText());
for (String templateName : new String[] { "Class", "Interface", "Enum", "AnnotationType" }) {
FileTemplate template = fileTemplateManager.getInternalTemplate(templateName);
template.setText(fileTemplateManager.getJ2eeTemplate(templateName).getText());
}
}
use of com.intellij.ide.fileTemplates.FileTemplateManager in project Aspose.Imaging-for-Java by aspose-imaging.
the class AsposeMavenUtil method runOrApplyFileTemplate.
private static void runOrApplyFileTemplate(Project project, VirtualFile file, String templateName, Properties properties) throws IOException {
FileTemplateManager manager = FileTemplateManager.getInstance();
FileTemplate fileTemplate = manager.getJ2eeTemplate(templateName);
Properties allProperties = manager.getDefaultProperties(project);
allProperties.putAll(properties);
String text = fileTemplate.getText(allProperties);
Pattern pattern = Pattern.compile("\\$\\{(.*)\\}");
Matcher matcher = pattern.matcher(text);
StringBuffer builder = new StringBuffer();
while (matcher.find()) {
matcher.appendReplacement(builder, "\\$" + matcher.group(1).toUpperCase() + "\\$");
}
matcher.appendTail(builder);
text = builder.toString();
TemplateImpl template = (TemplateImpl) TemplateManager.getInstance(project).createTemplate("", "", text);
for (int i = 0; i < template.getSegmentsCount(); i++) {
if (i == template.getEndSegmentNumber())
continue;
String name = template.getSegmentName(i);
String value = "\"" + properties.getProperty(name, "") + "\"";
template.addVariable(name, value, value, true);
}
VfsUtil.saveText(file, template.getTemplateText());
PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
if (psiFile != null) {
new ReformatCodeProcessor(project, psiFile, null, false).run();
}
}
use of com.intellij.ide.fileTemplates.FileTemplateManager in project Aspose.BarCode-for-Java by aspose-barcode.
the class AsposeMavenUtil method runOrApplyFileTemplate.
private static void runOrApplyFileTemplate(Project project, VirtualFile file, String templateName, Properties properties) throws IOException {
FileTemplateManager manager = FileTemplateManager.getInstance();
FileTemplate fileTemplate = manager.getJ2eeTemplate(templateName);
Properties allProperties = manager.getDefaultProperties(project);
allProperties.putAll(properties);
String text = fileTemplate.getText(allProperties);
Pattern pattern = Pattern.compile("\\$\\{(.*)\\}");
Matcher matcher = pattern.matcher(text);
StringBuffer builder = new StringBuffer();
while (matcher.find()) {
matcher.appendReplacement(builder, "\\$" + matcher.group(1).toUpperCase() + "\\$");
}
matcher.appendTail(builder);
text = builder.toString();
TemplateImpl template = (TemplateImpl) TemplateManager.getInstance(project).createTemplate("", "", text);
for (int i = 0; i < template.getSegmentsCount(); i++) {
if (i == template.getEndSegmentNumber())
continue;
String name = template.getSegmentName(i);
String value = "\"" + properties.getProperty(name, "") + "\"";
template.addVariable(name, value, value, true);
}
VfsUtil.saveText(file, template.getTemplateText());
PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
if (psiFile != null) {
new ReformatCodeProcessor(project, psiFile, null, false).run();
}
}
use of com.intellij.ide.fileTemplates.FileTemplateManager in project Aspose.OCR-for-Java by aspose-ocr.
the class AsposeMavenUtil method runOrApplyFileTemplate.
private static void runOrApplyFileTemplate(Project project, VirtualFile file, String templateName, Properties properties) throws IOException {
FileTemplateManager manager = FileTemplateManager.getInstance();
FileTemplate fileTemplate = manager.getJ2eeTemplate(templateName);
Properties allProperties = manager.getDefaultProperties(project);
allProperties.putAll(properties);
String text = fileTemplate.getText(allProperties);
Pattern pattern = Pattern.compile("\\$\\{(.*)\\}");
Matcher matcher = pattern.matcher(text);
StringBuffer builder = new StringBuffer();
while (matcher.find()) {
matcher.appendReplacement(builder, "\\$" + matcher.group(1).toUpperCase() + "\\$");
}
matcher.appendTail(builder);
text = builder.toString();
TemplateImpl template = (TemplateImpl) TemplateManager.getInstance(project).createTemplate("", "", text);
for (int i = 0; i < template.getSegmentsCount(); i++) {
if (i == template.getEndSegmentNumber())
continue;
String name = template.getSegmentName(i);
String value = "\"" + properties.getProperty(name, "") + "\"";
template.addVariable(name, value, value, true);
}
VfsUtil.saveText(file, template.getTemplateText());
PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
if (psiFile != null) {
new ReformatCodeProcessor(project, psiFile, null, false).run();
}
}
use of com.intellij.ide.fileTemplates.FileTemplateManager in project Aspose.Cells-for-Java by aspose-cells.
the class AsposeMavenUtil method runOrApplyFileTemplate.
private static void runOrApplyFileTemplate(Project project, VirtualFile file, String templateName, Properties properties) throws IOException {
FileTemplateManager manager = FileTemplateManager.getInstance();
FileTemplate fileTemplate = manager.getJ2eeTemplate(templateName);
Properties allProperties = manager.getDefaultProperties(project);
allProperties.putAll(properties);
String text = fileTemplate.getText(allProperties);
Pattern pattern = Pattern.compile("\\$\\{(.*)\\}");
Matcher matcher = pattern.matcher(text);
StringBuffer builder = new StringBuffer();
while (matcher.find()) {
matcher.appendReplacement(builder, "\\$" + matcher.group(1).toUpperCase() + "\\$");
}
matcher.appendTail(builder);
text = builder.toString();
TemplateImpl template = (TemplateImpl) TemplateManager.getInstance(project).createTemplate("", "", text);
for (int i = 0; i < template.getSegmentsCount(); i++) {
if (i == template.getEndSegmentNumber())
continue;
String name = template.getSegmentName(i);
String value = "\"" + properties.getProperty(name, "") + "\"";
template.addVariable(name, value, value, true);
}
VfsUtil.saveText(file, template.getTemplateText());
PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
if (psiFile != null) {
new ReformatCodeProcessor(project, psiFile, null, false).run();
}
}
Aggregations