How to use custom templates

2013-02-19
2013-02-21
  • monkeybanjo

    monkeybanjo - 2013-02-19

    Hi,

    I've just started using FastCode, and it seems like a great plugin. However, I'm having some trouble creating my own templates.

    After installation I've done the following -
    1 exported template, which created a "Fast Code Eclipse Plugin" project in my workspace.
    2 Edited the templates-config.xml, deleted all original templates and added my own( see below)
    3 Imported all templates. (and got a dialog saying import successful)

    I now see my template in the "Fast Code > Templates > Templates" Preferences page, but I don't see how i can use the template. The "Fast code > Templates" menu still contains the original list of templates, and I don't see my own. Additionally, the Ctrl-Shift-Alt-T shortcut doesn't seem to be working for me.

    I'd be really grateful if someone could help, as I'm not sure if there is something broken, or am i just doing things the wrong way?

    Thanks a lot,
    Dave

    setup info:
    FastCode Version: 1.6.0
    eclipse Version: 3.7.2
    OS: MAC OS X 10.6.8

    eclipse.buildId M20120208-0800
    java.version= 1.6.0_37
    java.vendor= Apple Inc.
    BootLoader constants: OS=macosx, ARCH=x86, WS=cocoa, NL=en_US

    templates-config.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <templates>
        <template name="BEAN_SETTER_GETTER">
            <description>Create normal getters, and setters which fire propety changes</description>
            <variation></variation>
            <class-pattern></class-pattern>
            <getter-setter>none</getter-setter>
            <allow-multiple-variation>false</allow-multiple-variation>
            <number-required-classes>0</number-required-classes>
            <class-file-choice></class-file-choice>
            <method-field-choice></method-field-choice>
            <additional-parameters></additional-parameters>
            <allowed-file-names>*.java </allowed-file-names>
            <template-body>
                <![CDATA[
                    enum BoundProperty {
                    #foreach ($field in ${fields})
                        ${field.toUpperCase()} #if( $foreach.hasNext ), #end
                    #end
                    }
                    #foreach ($field in ${fields})
                        public void set${field.name.substring(0,1).toUpperCase()}${field.name.substring(1)}(${field.type} newValue) {
                            Type oldValue = ${field.name};
                            ${field.name} = newValue;
                            firePropertyChange(BoundProperty.${field.name}, oldValue, newValue);       
                        }
                    #end
                    #foreach ($field in ${fields})
                        public ${field.type} get${field.name.substring(0,1).toUpperCase()}${field.name.substring(1)}() {
                            return ${field.name};       
                        }
                    #end
                ]]>
            </template-body>
        </template>
    </templates>
    
     
    • Support

      Support - 2013-02-21

      Hi,

      For now i would suggest you a work around.
      In the template-config.xml, retain the existing templates, and add your template along with them and try. You may added it in the beginning so that it is easy for you to see it in the preference page.

       

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks