Package com.intellij.ide.fileTemplates

Examples of com.intellij.ide.fileTemplates.FileTemplate


  }

  public static PsiElement createFromTemplate(String templateName, String fileName, @NotNull PsiDirectory directory, Properties properties)
      throws Exception {
    FileTemplateManager manager = FileTemplateManager.getInstance();
    FileTemplate template = manager.getInternalTemplate(templateName);
    return FileTemplateUtil.createFromTemplate(template, fileName, properties, directory);
  }
View Full Code Here


    return obj instanceof CreateMathematicaFile;
  }

  @Override
  protected PsiFile createFile(String name, String templateName, PsiDirectory dir) {
    final FileTemplate template = FileTemplateManager.getInstance().getInternalTemplate(templateName);
    String fileName = removeExtension(name);
    return createFileFromTemplate(fileName, template, dir);
  }
View Full Code Here

    throws Exception {
    final Properties props = new Properties(FileTemplateManager.getInstance().getDefaultProperties(directory.getProject()));
    props.setProperty(FileTemplate.ATTRIBUTE_NAME, className);
    props.setProperty(FileTemplate.ATTRIBUTE_PACKAGE_NAME, packageName);

    final FileTemplate template = FileTemplateManager.getInstance().getInternalTemplate(templateName);

    return FileTemplateUtil.createFromTemplate(template, className, props, directory, CreateClassAction.class.getClassLoader());
  }
View Full Code Here

        if (errorMessage != null) {
            Messages.showMessageDialog(directory.getProject(), errorMessage, CommonBundle.getErrorTitle(), Messages.getErrorIcon());
            return null;
        }

        final FileTemplate template = FileTemplateManager.getInstance().getJ2eeTemplate(templateName);

        Properties props = FileTemplateManager.getInstance().getDefaultProperties();
        props.put(Constants.PROP_WICKET_NS, WicketVersion.getVersion(directory).getNS());
        try {
            return FileTemplateUtil.createFromTemplate(template, fileName, props, directory);
View Full Code Here

                                                         @NonNls String... parameters )
        throws IncorrectOperationException
    {
        // Load template
        FileTemplateManager fileTemplateManager = FileTemplateManager.getInstance();
        FileTemplate template = fileTemplateManager.getJ2eeTemplate( templateName );

        // Process template properties
        Properties properties = new Properties( fileTemplateManager.getDefaultProperties() );
        JavaTemplateUtil.setPackageNameAttribute( properties, directory );
        properties.setProperty( NAME_TEMPLATE_PROPERTY, name );

        // Add parameters
        for( int i = 0; i < parameters.length; i += 2 )
        {
            properties.setProperty( parameters[ i ], parameters[ i + 1 ] );
        }

        // Create text from template with specified properties
        String text;
        try
        {
            text = template.getText( properties );
        }
        catch( Exception e )
        {
            String message = "Unable to load template for " +
                             fileTemplateManager.internalTemplateToSubject( templateName );
View Full Code Here

            directory.findFile(StrutsConstants.STRUTS_XML_DEFAULT_FILENAME) != null) {
          return;
        }

        final StrutsFileTemplateProvider templateProvider = new StrutsFileTemplateProvider(module);
        final FileTemplate strutsXmlTemplate = templateProvider.determineFileTemplate();

        try {
          final StrutsFacetConfiguration strutsFacetConfiguration = strutsFacet.getConfiguration();

          // create empty struts.xml & fileset with all found struts-*.xml files (struts2.jar, plugins)
View Full Code Here

    final PsiDirectory directory = manager.findDirectory(sourceRoot);
    assert directory != null : sourceRoot.getPresentableUrl();

    final FileTemplateManager templateManager = FileTemplateManager.getInstance();
    final FileTemplate validationTemplate = templateManager.getJ2eeTemplate(StrutsFileTemplateGroupDescriptorFactory.VALIDATION_XML);

    final PsiDirectory packageDirectoryInSourceRoot = RefactoringUtil.createPackageDirectoryInSourceRoot(targetPackage, sourceRoot);
    try {
      final String filename = path == null ? actionClass.getName() + "-validation.xml" : actionClass.getName() + "-" + path + "-validation.xml";
      final PsiElement psiElement = FileTemplateUtil.createFromTemplate(validationTemplate, filename, null, packageDirectoryInSourceRoot);
View Full Code Here

  protected PsiElement[] create(final String newName, final PsiDirectory directory) throws Exception {
    @NonNls final String fileName = getFileName(newName);

    final Module module = ModuleUtilCore.findModuleForPsiElement(directory);
    StrutsFileTemplateProvider templateProvider = new StrutsFileTemplateProvider(module);
    final FileTemplate strutsXmlTemplate = templateProvider.determineFileTemplate();
    final PsiElement file = FileTemplateUtil.createFromTemplate(strutsXmlTemplate,
                                                                fileName,
                                                                null,
                                                                directory);
    return new PsiElement[]{file};
View Full Code Here

        return null;
    }

    //todo: taken from 12 implementation, remove when retire 11.1 compatibility
    public PsiMethod createSetUpPatternMethod(JVMElementFactory factory) {
        final FileTemplate template = FileTemplateManager.getInstance().getCodeTemplate(getSetUpMethodFileTemplateDescriptor().getFileName());
        return factory.createMethodFromText(StringUtil.replace(template.getText(), "${BODY}\n", ""), null);
    }
View Full Code Here

    public static PsiFile createFromTemplate(@NotNull final PsiDirectory directory,
                                             @NotNull final String name,
                                             @NotNull String fileName,
                                             @NotNull String templateName,
                                             @NonNls String... parameters) throws IncorrectOperationException {
        final FileTemplate template = FileTemplateManager.getInstance().getInternalTemplate(templateName);

        Properties properties = new Properties(FileTemplateManager.getInstance().getDefaultProperties());
        JavaTemplateUtil.setPackageNameAttribute(properties, directory);
        properties.setProperty(NAME_TEMPLATE_PROPERTY, name);
        properties.setProperty(LOW_CASE_NAME_TEMPLATE_PROPERTY, name.substring(0, 1).toLowerCase() + name.substring(1));
        for (int i = 0; i < parameters.length; i += 2) {
            properties.setProperty(parameters[i], parameters[i + 1]);
        }
        String text;
        try {
            text = template.getText(properties);
        } catch (Exception e) {
            throw new RuntimeException("Unable to load template for " + FileTemplateManager.getInstance().internalTemplateToSubject(templateName),
                    e);
        }
View Full Code Here

TOP

Related Classes of com.intellij.ide.fileTemplates.FileTemplate

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.