This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 13250
Collapse All | Expand All

(-)openide/dialogs/apichanges.xml (+13 lines)
Lines 23-28 Link Here
23
<apidef name="dialogs">Dialogs API</apidef>
23
<apidef name="dialogs">Dialogs API</apidef>
24
</apidefs>
24
</apidefs>
25
<changes>
25
<changes>
26
    <change id="WizardDescriptor.getProperties">
27
           <api name="dialogs"/>
28
           <summary>New method <code>getProperties</code> added to <code>WizardDescriptor</code></summary>
29
           <version major="7" minor="2"/>
30
           <date day="8" month="2" year="2007"/>
31
           <author login="jtulach"/>
32
           <compatibility addition="yes" binary="compatible" semantic="compatible" source="compatible" deprecation="no" deletion="no" modification="no"/>
33
           <description>
34
               New method to get list of all properties of the <code>WizardDescriptor</code>
35
               added to the class.
36
           </description>
37
           <class package="org.openide" name="WizardDescriptor"/>
38
    </change>
26
    <change id="WizardDescriptor.ProgressInstantiatingIterator">
39
    <change id="WizardDescriptor.ProgressInstantiatingIterator">
27
           <api name="dialogs"/>
40
           <api name="dialogs"/>
28
           <summary>Interface <code>ProgressInstantiatingIterator</code> added</summary>
41
           <summary>Interface <code>ProgressInstantiatingIterator</code> added</summary>
(-)openide/dialogs/manifest.mf (-1 / +1 lines)
Lines 1-5 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.openide.dialogs
2
OpenIDE-Module: org.openide.dialogs
3
OpenIDE-Module-Specification-Version: 7.1
3
OpenIDE-Module-Specification-Version: 7.2
4
OpenIDE-Module-Localizing-Bundle: org/openide/Bundle.properties
4
OpenIDE-Module-Localizing-Bundle: org/openide/Bundle.properties
5
5
(-)openide/dialogs/nbproject/project.properties (+2 lines)
Lines 16-21 Link Here
16
# Microsystems, Inc. All Rights Reserved.
16
# Microsystems, Inc. All Rights Reserved.
17
17
18
is.autoload=true
18
is.autoload=true
19
javac.compilerargs=-Xlint:unchecked
20
javac.source=1.5
19
#javadoc.main.page=org/openide/doc-files/api.html
21
#javadoc.main.page=org/openide/doc-files/api.html
20
javadoc.arch=${basedir}/../arch/arch-openide-dialogs.xml
22
javadoc.arch=${basedir}/../arch/arch-openide-dialogs.xml
21
javadoc.apichanges=${basedir}/apichanges.xml
23
javadoc.apichanges=${basedir}/apichanges.xml
(-)openide/dialogs/src/org/openide/WizardDescriptor.java (-18 / +23 lines)
Lines 279-285 Link Here
279
    /** hashtable with additional settings that is usually used
279
    /** hashtable with additional settings that is usually used
280
    * by Panels to store their data
280
    * by Panels to store their data
281
    */
281
    */
282
    private Map properties;
282
    private Map<String,Object> properties;
283
    ResourceBundle bundle = NbBundle.getBundle(WizardDescriptor.class);
283
    ResourceBundle bundle = NbBundle.getBundle(WizardDescriptor.class);
284
284
285
    /** Request processor that is used for asynchronous jobs (background validation, 
285
    /** Request processor that is used for asynchronous jobs (background validation, 
Lines 348-369 Link Here
348
348
349
        baseListener = new Listener();
349
        baseListener = new Listener();
350
350
351
        try {
351
        weakNextButtonListener = WeakListeners.create(
352
            weakNextButtonListener = (ActionListener) WeakListeners.create(
352
                ActionListener.class, baseListener, nextButton
353
                    Class.forName("java.awt.event.ActionListener"), baseListener, nextButton
353
            ); // NOI18N
354
                ); // NOI18N
354
        weakPreviousButtonListener = WeakListeners.create(
355
            weakPreviousButtonListener = (ActionListener) WeakListeners.create(
355
                ActionListener.class, baseListener, previousButton
356
                    Class.forName("java.awt.event.ActionListener"), baseListener, previousButton
356
            ); // NOI18N
357
                ); // NOI18N
357
        weakFinishButtonListener = WeakListeners.create(
358
            weakFinishButtonListener = (ActionListener) WeakListeners.create(
358
                ActionListener.class, baseListener, finishButton
359
                    Class.forName("java.awt.event.ActionListener"), baseListener, finishButton
359
            ); // NOI18N
360
                ); // NOI18N
360
        weakCancelButtonListener = WeakListeners.create(
361
            weakCancelButtonListener = (ActionListener) WeakListeners.create(
361
                ActionListener.class, baseListener, cancelButton
362
                    Class.forName("java.awt.event.ActionListener"), baseListener, cancelButton
362
            ); // NOI18N
363
                ); // NOI18N
364
        } catch (ClassNotFoundException e) {
365
            // cannot happen, java.awt.event.ActionListener listener can always be found
366
        }
367
363
368
        nextButton.addActionListener(weakNextButtonListener);
364
        nextButton.addActionListener(weakNextButtonListener);
369
        previousButton.addActionListener(weakPreviousButtonListener);
365
        previousButton.addActionListener(weakPreviousButtonListener);
Lines 576-582 Link Here
576
572
577
        synchronized (this) {
573
        synchronized (this) {
578
            if (properties == null) {
574
            if (properties == null) {
579
                properties = new HashMap(7);
575
                properties = new HashMap<String,Object>(7);
580
            }
576
            }
581
577
582
            oldValue = properties.get(name);
578
            oldValue = properties.get(name);
Lines 616-621 Link Here
616
    public synchronized Object getProperty(String name) {
612
    public synchronized Object getProperty(String name) {
617
        return (properties == null) ? null : properties.get(name);
613
        return (properties == null) ? null : properties.get(name);
618
    }
614
    }
615
    
616
    /** Read only map with stored properties.
617
     * @return read only map of properties stored using {@link #putProperty} method
618
     * @since 7.2
619
     */
620
    public synchronized Map<String,Object> getProperties() {
621
        return properties == null ? Collections.<String,Object>emptyMap() : new HashMap<String,Object>(properties);
622
    }
619
623
620
    public void setHelpCtx(final HelpCtx helpCtx) {
624
    public void setHelpCtx(final HelpCtx helpCtx) {
621
        if ((wizardPanel != null) && (helpCtx != null)) {
625
        if ((wizardPanel != null) && (helpCtx != null)) {
Lines 2546-2551 Link Here
2546
2550
2547
        /** Overriden to delegate call to user component.
2551
        /** Overriden to delegate call to user component.
2548
         */
2552
         */
2553
        @Deprecated
2549
        public boolean requestDefaultFocus() {
2554
        public boolean requestDefaultFocus() {
2550
            if (rightComponent instanceof JComponent) {
2555
            if (rightComponent instanceof JComponent) {
2551
                return ((JComponent) rightComponent).requestDefaultFocus();
2556
                return ((JComponent) rightComponent).requestDefaultFocus();
(-)openide/dialogs/test/unit/src/org/openide/PropertiesTest.java (+40 lines)
Added Link Here
1
/*
2
 * The contents of this file are subject to the terms of the Common Development
3
 * and Distribution License (the License). You may not use this file except in
4
 * compliance with the License.
5
 *
6
 * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7
 * or http://www.netbeans.org/cddl.txt.
8
 *
9
 * When distributing Covered Code, include this CDDL Header Notice in each file
10
 * and include the License file at http://www.netbeans.org/cddl.txt.
11
 * If applicable, add the following below the CDDL Header, with the fields
12
 * enclosed by brackets [] replaced by your own identifying information:
13
 * "Portions Copyrighted [year] [name of copyright owner]"
14
 *
15
 * The Original Software is NetBeans. The Initial Developer of the Original
16
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17
 * Microsystems, Inc. All Rights Reserved.
18
 */
19
20
package org.openide;
21
22
import junit.framework.TestCase;
23
24
/**
25
 *
26
 * @author Jaroslav Tulach
27
 */
28
public class PropertiesTest extends TestCase {
29
    
30
    public PropertiesTest(String testName) {
31
        super(testName);
32
    }
33
    
34
    public void testGetProperties() throws Exception {
35
        WizardDescriptor d = new WizardDescriptor(new WizardDescriptor.Panel[0]);
36
        assertTrue(d.getProperties().isEmpty());
37
        d.putProperty("Kuk", "Ahoj");
38
        assertEquals("Ahoj", d.getProperties().get("Kuk"));
39
    }
40
}
(-)openide/loaders/nbproject/project.xml (-1 / +1 lines)
Lines 53-59 Link Here
53
                    <build-prerequisite/>
53
                    <build-prerequisite/>
54
                    <compile-dependency/>
54
                    <compile-dependency/>
55
                    <run-dependency>
55
                    <run-dependency>
56
                        <specification-version>6.2</specification-version>
56
                        <specification-version>7.2</specification-version>
57
                    </run-dependency>
57
                    </run-dependency>
58
                </dependency>
58
                </dependency>
59
                <dependency>
59
                <dependency>
(-)openide/loaders/src/org/openide/loaders/CreateFromTemplateAttributesProvider.java (+31 lines)
Added Link Here
1
/*
2
 * The contents of this file are subject to the terms of the Common Development
3
 * and Distribution License (the License). You may not use this file except in
4
 * compliance with the License.
5
 *
6
 * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7
 * or http://www.netbeans.org/cddl.txt.
8
 *
9
 * When distributing Covered Code, include this CDDL Header Notice in each file
10
 * and include the License file at http://www.netbeans.org/cddl.txt.
11
 * If applicable, add the following below the CDDL Header, with the fields
12
 * enclosed by brackets [] replaced by your own identifying information:
13
 * "Portions Copyrighted [year] [name of copyright owner]"
14
 *
15
 * The Original Software is NetBeans. The Initial Developer of the Original
16
 * Software is Sun Microsystems, Inc. 
17
 * 
18
 * Portions Copyrighted 2007 Sun Microsystems, Inc. 
19
 */
20
21
package org.openide.loaders;
22
23
import java.util.Map;
24
25
/**
26
 *
27
 * @author Jaroslav Tulach
28
 */
29
public abstract class CreateFromTemplateAttributesProvider {
30
    protected abstract Map<String,? extends Object> attributesFor(DataObject template, DataFolder target, String name);
31
}
(-)openide/loaders/src/org/openide/loaders/CreateFromTemplateHandler.java (+42 lines)
Added Link Here
1
/*
2
 * The contents of this file are subject to the terms of the Common Development
3
 * and Distribution License (the License). You may not use this file except in
4
 * compliance with the License.
5
 *
6
 * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7
 * or http://www.netbeans.org/cddl.txt.
8
 *
9
 * When distributing Covered Code, include this CDDL Header Notice in each file
10
 * and include the License file at http://www.netbeans.org/cddl.txt.
11
 * If applicable, add the following below the CDDL Header, with the fields
12
 * enclosed by brackets [] replaced by your own identifying information:
13
 * "Portions Copyrighted [year] [name of copyright owner]"
14
 *
15
 * The Original Software is NetBeans. The Initial Developer of the Original
16
 * Software is Sun Microsystems, Inc. 
17
 * 
18
 * Portions Copyrighted 2007 Sun Microsystems, Inc. 
19
 */
20
21
package org.openide.loaders;
22
23
import java.io.IOException;
24
import java.util.Map;
25
import org.openide.filesystems.FileObject;
26
27
/**
28
 *
29
 * @author Jaroslav Tulach
30
 */
31
public abstract class CreateFromTemplateHandler {
32
    
33
    protected abstract boolean accept(FileObject orig);
34
    
35
    protected abstract FileObject createFromTemplate(
36
        FileObject orig,
37
        FileObject f, 
38
        String name,
39
        Map<String,Object> parameters
40
    ) throws IOException;
41
    
42
}
(-)openide/loaders/src/org/openide/loaders/DataObject.java (-11 / +88 lines)
Lines 22-27 Link Here
22
22
23
import java.beans.*;
23
import java.beans.*;
24
import java.io.*;
24
import java.io.*;
25
import java.text.DateFormat;
25
import java.util.*;
26
import java.util.*;
26
import java.util.logging.Level;
27
import java.util.logging.Level;
27
import java.util.logging.Logger;
28
import java.util.logging.Logger;
Lines 704-722 Link Here
704
    public final DataObject createFromTemplate (
705
    public final DataObject createFromTemplate (
705
        final DataFolder f, final String name
706
        final DataFolder f, final String name
706
    ) throws IOException {
707
    ) throws IOException {
707
        final DataObject[] result = new DataObject[1];
708
        return createFromTemplate(f, name, Collections.<String,Object>emptyMap());
708
709
    }
709
        invokeAtomicAction (f.getPrimaryFile (), new FileSystem.AtomicAction () {
710
    
710
                                public void run () throws IOException {
711
    /** More generic way how to instantiate a {@link DataObject}. One can
711
                                    result[0] = handleCreateFromTemplate (f, name);
712
    * not only specify its name, but also pass a map of parameters that
712
                                }
713
    * can influence the copying of the stream.
713
                            }, null);
714
    *
714
715
    * @param f folder to create object in
716
    * @param name name of object that should be created, or <CODE>null</CODE> if the
717
    *    name should be same as that of the template (or otherwise mechanically generated)
718
    * @param parameters map of named objects that are going to be used when
719
    *    creating the new object
720
    * @return the new data object
721
    * @exception IOException if an error occured
722
    * @since JST-PENDING
723
    */
724
    public final DataObject createFromTemplate(
725
        final DataFolder f, final String name, final Map<String,? extends Object> parameters
726
    ) throws IOException {
727
        CreateAction create = new CreateAction(this, f, name, parameters);
728
        invokeAtomicAction (f.getPrimaryFile (), create, null);
715
        fireOperationEvent (
729
        fireOperationEvent (
716
            new OperationEvent.Copy (result[0], this), OperationEvent.TEMPL
730
            new OperationEvent.Copy (create.result, this), OperationEvent.TEMPL
717
        );
731
        );
718
732
        return create.result;
719
        return result[0];
720
    }
733
    }
721
734
722
    /** Create a new data object from template (implemented in subclasses).
735
    /** Create a new data object from template (implemented in subclasses).
Lines 1137-1140 Link Here
1137
            }
1150
            }
1138
        }
1151
        }
1139
    }
1152
    }
1153
    static final class CreateAction implements FileSystem.AtomicAction {
1154
        public DataObject result;
1155
        private String name;
1156
        private DataFolder f;
1157
        private DataObject orig;
1158
        private Map<String, ? extends Object> param;
1159
        
1160
        private static ThreadLocal<CreateAction> CURRENT = new ThreadLocal<CreateAction>();
1161
        
1162
        public CreateAction(DataObject orig, DataFolder f, String name, Map<String, ? extends Object> param) {
1163
            this.orig = orig;
1164
            this.f = f;
1165
            this.name = name;
1166
            this.param = param;
1167
        }
1168
        
1169
        public void run () throws IOException {
1170
            CreateAction prev = CURRENT.get();
1171
            try {
1172
                CURRENT.set(this);
1173
                result = orig.handleCreateFromTemplate(f, name);
1174
            } finally {
1175
                CURRENT.set(prev);
1176
            }
1177
        }
1178
        
1179
        public static Map<String,Object> findParameters(String name) {
1180
            CreateAction c  = CURRENT.get();
1181
            if (c == null) {
1182
                return Collections.emptyMap();
1183
            }
1184
            HashMap<String,Object> all = new HashMap<String,Object>();
1185
            for (CreateFromTemplateAttributesProvider provider : Lookup.getDefault().lookupAll(CreateFromTemplateAttributesProvider.class)) {
1186
                Map<String,? extends Object> map = provider.attributesFor(c.orig, c.f, c.name);
1187
                if (map != null) {
1188
                    for (Map.Entry<String,? extends Object> e : map.entrySet()) {
1189
                        all.put(e.getKey(), e.getValue());
1190
                    }
1191
                }
1192
            }
1193
            if (c.param != null) {
1194
                for (Map.Entry<String,? extends Object> e : c.param.entrySet()) {
1195
                    all.put(e.getKey(), e.getValue());
1196
                }
1197
            }
1198
            
1199
            if (!all.containsKey("name") && name != null) { // NOI18N
1200
                all.put("name", name); // NOI18N
1201
            }
1202
            if (!all.containsKey("user")) { // NOI18N
1203
                all.put("user", System.getProperty("user.name")); // NOI18N
1204
            }
1205
            Date d = new Date();
1206
            if (!all.containsKey("date")) { // NOI18N
1207
                all.put("date", DateFormat.getDateInstance().format(d)); // NOI18N
1208
            }
1209
            if (!all.containsKey("time")) { // NOI18N
1210
                all.put("time", DateFormat.getTimeInstance().format(d)); // NOI18N
1211
            }
1212
            
1213
            return Collections.unmodifiableMap(all);
1214
        }
1215
        
1216
    } // end of CreateAction
1140
}
1217
}
(-)openide/loaders/src/org/openide/loaders/FileEntry.java (-3 / +39 lines)
Lines 20-27 Link Here
20
package org.openide.loaders;
20
package org.openide.loaders;
21
21
22
import java.io.*;
22
import java.io.*;
23
24
import org.openide.filesystems.*;
23
import org.openide.filesystems.*;
24
import org.openide.util.Lookup;
25
import org.openide.util.NbBundle;
25
import org.openide.util.NbBundle;
26
26
27
/** Entry that works with plain files. Copies, moves,
27
/** Entry that works with plain files. Copies, moves,
Lines 122-128 Link Here
122
                       getFile ().getName (), getFile ().getExt ()
122
                       getFile ().getName (), getFile ().getExt ()
123
                   );
123
                   );
124
        }
124
        }
125
        FileObject fo = getFile().copy (f, name, getFile().getExt ());
125
        
126
        
127
        FileObject fo = null;
128
        boolean done = false;
129
        for (CreateFromTemplateHandler h : Lookup.getDefault().lookupAll(CreateFromTemplateHandler.class)) {
130
            if (h.accept(getFile())) {
131
                done = true;
132
                fo = h.createFromTemplate(getFile(), f, name, DataObject.CreateAction.findParameters(name));
133
                assert fo != null;
134
                break;
135
            }
136
        }
137
        
138
        if (!done) {
139
            fo = getFile().copy (f, name, getFile().getExt ());
140
        }
141
        
142
        
126
        // unmark template state
143
        // unmark template state
127
        DataObject.setTemplate (fo, false);
144
        DataObject.setTemplate (fo, false);
128
145
Lines 161-167 Link Here
161
                           getFile ().getName (), ext
178
                           getFile ().getName (), ext
162
                       );
179
                       );
163
            }
180
            }
164
            FileObject fo = f.createData (name, ext);
181
            
182
            
183
            FileObject fo = null;
184
            boolean done = false;
185
            for (CreateFromTemplateHandler h : Lookup.getDefault().lookupAll(CreateFromTemplateHandler.class)) {
186
                if (h.accept(getFile())) {
187
                    done = true;
188
                    fo = h.createFromTemplate(getFile(), f, name, DataObject.CreateAction.findParameters(name));
189
                    assert fo != null;
190
                    break;
191
                }
192
            }
193
194
            if (done) {
195
                // unmark template state
196
                DataObject.setTemplate (fo, false);
197
                return fo;
198
            }
199
            
200
            fo = f.createData (name, ext);
165
201
166
            java.text.Format frm = createFormat (f, name, ext);
202
            java.text.Format frm = createFormat (f, name, ext);
167
203
(-)openide/loaders/src/org/openide/loaders/MultiDataObject.java (-5 / +31 lines)
Lines 659-676 Link Here
659
    protected DataObject handleCreateFromTemplate (
659
    protected DataObject handleCreateFromTemplate (
660
        DataFolder df, String name
660
        DataFolder df, String name
661
    ) throws IOException {
661
    ) throws IOException {
662
        FileObject fo;
663
664
665
        if (name == null) {
662
        if (name == null) {
666
            name = FileUtil.findFreeFileName(
663
            name = FileUtil.findFreeFileName(
667
                       df.getPrimaryFile (), getPrimaryFile ().getName (), getPrimaryFile ().getExt ()
664
                       df.getPrimaryFile (), getPrimaryFile ().getName (), getPrimaryFile ().getExt ()
668
                   );
665
                   );
669
        }
666
        }
670
667
671
        fo = getPrimaryEntry().createFromTemplate (df.getPrimaryFile (), name);
668
        FileObject fo = null;
669
        Map<String,Object> params = null;
670
        for (CreateFromTemplateHandler h : Lookup.getDefault().lookupAll(CreateFromTemplateHandler.class)) {
671
            FileObject current = getPrimaryEntry().getFile();
672
            if (h.accept(current)) {
673
                if (params == null) {
674
                    params = DataObject.CreateAction.findParameters(name);
675
                }
676
                fo = h.createFromTemplate(current, df.getPrimaryFile(), name, params);
677
                assert fo != null;
678
                break;
679
            }
680
        }
681
        if (params == null) {
682
            // do the regular creation
683
            fo = getPrimaryEntry().createFromTemplate (df.getPrimaryFile (), name);
684
        }
685
        
686
        
672
        Iterator it = secondaryEntries().iterator();
687
        Iterator it = secondaryEntries().iterator();
673
        while (it.hasNext ()) {
688
        NEXT_ENTRY: while (it.hasNext ()) {
689
            for (CreateFromTemplateHandler h : Lookup.getDefault().lookupAll(CreateFromTemplateHandler.class)) {
690
                FileObject current = getPrimaryEntry().getFile();
691
                if (h.accept(current)) {
692
                    if (params == null) {
693
                        params = DataObject.CreateAction.findParameters(name);
694
                    }
695
                    fo = h.createFromTemplate(current, df.getPrimaryFile(), name, params);
696
                    assert fo != null;
697
                    continue NEXT_ENTRY;
698
                }
699
            }
674
            ((Entry)it.next()).createFromTemplate (df.getPrimaryFile (), name);
700
            ((Entry)it.next()).createFromTemplate (df.getPrimaryFile (), name);
675
        }
701
        }
676
        
702
        
(-)openide/loaders/src/org/openide/loaders/TemplateWizard.java (-4 / +1 lines)
Lines 858-867 Link Here
858
            String n = wiz.getTargetName ();
858
            String n = wiz.getTargetName ();
859
            DataFolder folder = wiz.getTargetFolder ();
859
            DataFolder folder = wiz.getTargetFolder ();
860
            DataObject template = wiz.getTemplate ();
860
            DataObject template = wiz.getTemplate ();
861
            DataObject obj = n == null ?
861
            DataObject obj = template.createFromTemplate (folder, n, wiz.getProperties());
862
                             template.createFromTemplate (folder)
863
                             :
864
                             template.createFromTemplate (folder, n);
865
862
866
            // run default action (hopefully should be here)
863
            // run default action (hopefully should be here)
867
            final Node node = obj.getNodeDelegate ();
864
            final Node node = obj.getNodeDelegate ();
(-)openide/loaders/test/unit/src/org/openide/loaders/CreateFromTemplateHandlerTest.java (+264 lines)
Added Link Here
1
/*
2
 * The contents of this file are subject to the terms of the Common Development
3
 * and Distribution License (the License). You may not use this file except in
4
 * compliance with the License.
5
 *
6
 * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7
 * or http://www.netbeans.org/cddl.txt.
8
 *
9
 * When distributing Covered Code, include this CDDL Header Notice in each file
10
 * and include the License file at http://www.netbeans.org/cddl.txt.
11
 * If applicable, add the following below the CDDL Header, with the fields
12
 * enclosed by brackets [] replaced by your own identifying information:
13
 * "Portions Copyrighted [year] [name of copyright owner]"
14
 *
15
 * The Original Software is NetBeans. The Initial Developer of the Original
16
 * Software is Sun Microsystems, Inc. 
17
 * 
18
 * Portions Copyrighted 2007 Sun Microsystems, Inc. 
19
 */
20
21
package org.openide.loaders;
22
23
import java.awt.Dialog;
24
import java.io.IOException;
25
import java.util.Arrays;
26
import java.util.Collections;
27
import java.util.Enumeration;
28
import java.util.Map;
29
import java.util.Set;
30
import javax.swing.JButton;
31
import javax.swing.JDialog;
32
import org.netbeans.junit.MockServices;
33
import org.netbeans.junit.NbTestCase;
34
import org.openide.DialogDescriptor;
35
import org.openide.DialogDisplayer;
36
import org.openide.NotifyDescriptor;
37
import org.openide.WizardDescriptor;
38
import org.openide.filesystems.FileObject;
39
import org.openide.filesystems.FileUtil;
40
import org.openide.util.Enumerations;
41
42
/**
43
 *
44
 * @author Jaroslav Tulach
45
 */
46
public class CreateFromTemplateHandlerTest extends NbTestCase {
47
    
48
    public CreateFromTemplateHandlerTest(String testName) {
49
        super(testName);
50
    }
51
    
52
    protected boolean runInEQ() {
53
        return true;
54
    }
55
    
56
    protected void setUp() throws Exception {
57
        Hand.acceptObject = null;
58
        Hand.fileObject = null;
59
        Hand.origObject = null;
60
        Hand.name = null;
61
        Hand.parameters = null;
62
        
63
        MockServices.setServices(Hand.class, Attr.class, DD.class, Pool.class);
64
    }
65
66
    protected void tearDown() throws Exception {
67
        super.tearDown();
68
    }
69
70
    public void testCreateFromTemplate() throws Exception {
71
        FileObject root = FileUtil.createMemoryFileSystem().getRoot();
72
        FileObject fo = FileUtil.createData(root, "simpleObject.txt");
73
        
74
        DataObject obj = DataObject.find(fo);
75
        
76
        DataFolder folder = DataFolder.findFolder(FileUtil.createFolder(root, "target"));
77
        
78
        Map<String,String> parameters = Collections.singletonMap("type", "empty");
79
        DataObject n = obj.createFromTemplate(folder, "complex", parameters);
80
        
81
        assertEquals("Created in right place", folder, n.getFolder());
82
        assertEquals("Created with right name", "complex.txt", n.getName());
83
        
84
        assertEquals("The right source", fo, Hand.origObject);
85
        assertEquals("The right source in query", fo, Hand.acceptObject);
86
        assertEquals("The right destiny folder", folder.getPrimaryFile(), Hand.fileObject);
87
        assertEquals("The right name", "complex", Hand.name);
88
        assertEquals("Two elements: " + Hand.parameters, 2, Hand.parameters.size());
89
        assertEquals("empty", Hand.parameters.get("type"));
90
        assertEquals("complex", Hand.parameters.get("name"));
91
        try {
92
            Hand.parameters.put("kuk", "buk");
93
        } catch (UnsupportedOperationException ex) {
94
            // ok
95
            return;
96
        }
97
        fail("Modifications shall be unsupported");
98
    }
99
    
100
    public void testTemplateWizardCopiesItsPropertiesToMap() throws Exception {
101
        doTemplateWizardCopiesItsPropertiesToMap("simpleObject.txt");
102
    }
103
    
104
    public void testTemplateWizardCopiesItsPropertiesToMapForOverridenEntry() throws Exception {
105
        DataObject obj = doTemplateWizardCopiesItsPropertiesToMap("simpleObject.prima");
106
        assertEquals("The right loader", SimpleLoader.class, obj.getLoader().getClass());
107
    }
108
    
109
    private DataObject doTemplateWizardCopiesItsPropertiesToMap(String fileName) throws Exception {
110
        FileObject root = FileUtil.createMemoryFileSystem().getRoot();
111
        FileObject fo = FileUtil.createData(root, fileName);
112
        
113
        DataObject obj = DataObject.find(fo);
114
        
115
        DataFolder folder = DataFolder.findFolder(FileUtil.createFolder(root, "target"));
116
        
117
        TemplateWizard t = new TemplateWizard();
118
        t.putProperty("type", "empty");
119
        Set<DataObject> created = t.instantiate(obj, folder);
120
        assertNotNull(created);
121
        assertEquals("One is created: " + created, 1, created.size());
122
        
123
        DataObject n = created.iterator().next();
124
        
125
        assertEquals("Created in right place", folder, n.getFolder());
126
        assertEquals("Created with right name", fileName, n.getName());
127
        
128
        assertEquals("The right source", fo, Hand.origObject);
129
        assertEquals("The right source in query", fo, Hand.acceptObject);
130
        assertEquals("The right destiny folder", folder.getPrimaryFile(), Hand.fileObject);
131
        assertEquals("The right name", "simpleObject", Hand.name);
132
        assertTrue("At least two elements: " + Hand.parameters, 2 <= Hand.parameters.size());
133
        assertEquals("empty", Hand.parameters.get("type"));
134
        assertEquals("There was no name, just default", null, Hand.parameters.get("name"));
135
        assertTrue("the argument is there", Hand.parameters.containsKey("name"));
136
        try {
137
            Hand.parameters.put("kuk", "buk");
138
        } catch (UnsupportedOperationException ex) {
139
            // ok
140
            return obj;
141
        }
142
        fail("Modifications shall be unsupported");
143
        throw new NullPointerException();
144
    }
145
146
    public static final class Hand extends CreateFromTemplateHandler {
147
        public static FileObject fileObject, origObject, acceptObject;
148
        public static String name;
149
        public static Map<String, Object> parameters;
150
    
151
        protected boolean accept(FileObject fo) {
152
            assertNull(acceptObject);
153
            acceptObject = fo;
154
            return true;
155
        }
156
157
        protected FileObject createFromTemplate(
158
            FileObject orig, FileObject f, String n,
159
            Map<String, Object> p
160
        ) throws IOException {
161
            assertNull("Not yet filled", fileObject);
162
            
163
            origObject = orig;
164
            fileObject = f;
165
            name = n;
166
            parameters = p;
167
168
            return FileUtil.copyFile(orig, fileObject, name);
169
        }
170
    }
171
    
172
    public static final class Attr extends CreateFromTemplateAttributesProvider {
173
        
174
    
175
        protected Map<String, ? extends Object> attributesFor(
176
            DataObject template,
177
            DataFolder target,
178
            String name
179
        ) {
180
            return Collections.singletonMap("name", name);
181
        }
182
    }
183
    
184
    public static final class DD extends DialogDisplayer {
185
        public Object notify(NotifyDescriptor descriptor) {
186
            throw new UnsupportedOperationException("Not supported yet.");
187
        }
188
189
        public Dialog createDialog(final DialogDescriptor descriptor) {
190
            return new JDialog() {
191
                @Deprecated
192
                public void show() {
193
                    for (Object object : descriptor.getOptions()) {
194
                        if (object instanceof JButton) {
195
                            JButton b = (JButton)object;
196
                            if (b.getText().equals("Finish")) {
197
                                descriptor.setValue(WizardDescriptor.FINISH_OPTION);
198
                                b.doClick();
199
                                return;
200
                            }
201
                        }
202
                    }
203
                    fail("Cannot find Finish button: " + Arrays.asList(descriptor.getOptions()));
204
                }
205
            };
206
        }
207
    }
208
    
209
    public static final class Pool extends DataLoaderPool {
210
        protected Enumeration<DataLoader> loaders() {
211
            return Enumerations.<DataLoader>singleton(SimpleLoader.getLoader(SimpleLoader.class));
212
        }
213
    }
214
    
215
    public static final class SimpleLoader extends MultiFileLoader {
216
        public SimpleLoader() {
217
            super(SimpleObject.class.getName());
218
        }
219
        protected String displayName() {
220
            return "SimpleLoader";
221
        }
222
        protected FileObject findPrimaryFile(FileObject fo) {
223
            if (fo.hasExt("prima")) {
224
                return fo;
225
            }
226
            return null;
227
        }
228
        protected MultiDataObject createMultiObject(FileObject primaryFile) throws DataObjectExistsException, IOException {
229
            return new SimpleObject(this, primaryFile);
230
        }
231
        protected MultiDataObject.Entry createPrimaryEntry(MultiDataObject obj, FileObject primaryFile) {
232
            return new FE(obj, primaryFile);
233
        }
234
        protected MultiDataObject.Entry createSecondaryEntry(MultiDataObject obj, FileObject secondaryFile) {
235
            return new FileEntry(obj, secondaryFile);
236
        }
237
    }
238
    
239
    private static final class FE extends FileEntry {
240
        public FE(MultiDataObject mo, FileObject fo) {
241
            super(mo, fo);
242
        }
243
244
        @Override
245
        public FileObject createFromTemplate(FileObject f, String name) throws IOException {
246
            fail("I do not want to be called");
247
            return null;
248
        }
249
250
        
251
        
252
    }
253
    
254
    public static final class SimpleObject extends MultiDataObject {
255
        public SimpleObject(SimpleLoader l, FileObject fo) throws DataObjectExistsException {
256
            super(fo, l);
257
        }
258
        
259
        public String getName() {
260
            return getPrimaryFile().getNameExt();
261
        }
262
    }
263
    
264
}
(-)openide/templates/.cvsignore (+1 lines)
Added Link Here
1
build
(-)openide/templates/build.xml (+5 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<project basedir="." default="netbeans" name="openide/templates">
3
    <description>Builds, tests, and runs the project org.netbeans.modules.templates</description>
4
    <import file="../../nbbuild/templates/projectized.xml"/>
5
</project>
(-)openide/templates/manifest.mf (+6 lines)
Added Link Here
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.netbeans.modules.templates
3
OpenIDE-Module-Layer: org/netbeans/modules/templates/layer.xml
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/templates/Bundle.properties
5
OpenIDE-Module-Specification-Version: 1.0
6
(-)openide/templates/nbproject/.cvsignore (+1 lines)
Added Link Here
1
private
(-)openide/templates/nbproject/project.properties (+3 lines)
Added Link Here
1
is.autoload=true
2
javac.compilerargs=-Xlint:unchecked
3
javac.source=1.5
(-)openide/templates/nbproject/project.xml (+70 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<project xmlns="http://www.netbeans.org/ns/project/1">
3
    <type>org.netbeans.modules.apisupport.project</type>
4
    <configuration>
5
        <data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
6
            <code-name-base>org.netbeans.modules.templates</code-name-base>
7
            <module-dependencies>
8
                <dependency>
9
                    <code-name-base>org.netbeans.libs.jsr223</code-name-base>
10
                    <build-prerequisite/>
11
                    <compile-dependency/>
12
                    <run-dependency>
13
                        <release-version>1</release-version>
14
                        <specification-version>1.6</specification-version>
15
                    </run-dependency>
16
                </dependency>
17
                <dependency>
18
                    <code-name-base>org.openide.dialogs</code-name-base>
19
                    <build-prerequisite/>
20
                    <compile-dependency/>
21
                    <run-dependency>
22
                        <specification-version>7.2</specification-version>
23
                    </run-dependency>
24
                </dependency>
25
                <dependency>
26
                    <code-name-base>org.openide.filesystems</code-name-base>
27
                    <build-prerequisite/>
28
                    <compile-dependency/>
29
                    <run-dependency>
30
                        <specification-version>7.0</specification-version>
31
                    </run-dependency>
32
                </dependency>
33
                <dependency>
34
                    <code-name-base>org.openide.loaders</code-name-base>
35
                    <build-prerequisite/>
36
                    <compile-dependency/>
37
                    <run-dependency>
38
                        <specification-version>6.0</specification-version>
39
                    </run-dependency>
40
                </dependency>
41
                <dependency>
42
                    <code-name-base>org.openide.nodes</code-name-base>
43
                    <build-prerequisite/>
44
                    <compile-dependency/>
45
                    <run-dependency>
46
                        <specification-version>7.0</specification-version>
47
                    </run-dependency>
48
                </dependency>
49
                <dependency>
50
                    <code-name-base>org.openide.util</code-name-base>
51
                    <build-prerequisite/>
52
                    <compile-dependency/>
53
                    <run-dependency>
54
                        <specification-version>7.7</specification-version>
55
                    </run-dependency>
56
                </dependency>
57
            </module-dependencies>
58
            <test-dependencies>
59
                <test-type>
60
                    <name>unit</name>
61
                    <test-dependency>
62
                        <code-name-base>org.netbeans.libs.freemarker</code-name-base>
63
                        <compile-dependency/>
64
                    </test-dependency>
65
                </test-type>
66
            </test-dependencies>
67
            <public-packages/>
68
        </data>
69
    </configuration>
70
</project>
(-)openide/templates/src/META-INF/services/org.openide.loaders.CreateFromTemplateHandler (+1 lines)
Added Link Here
1
org.netbeans.modules.templates.ScriptingCreateFromTemplateHandler
(-)openide/templates/src/org/netbeans/modules/templates/Bundle.properties (+6 lines)
Added Link Here
1
OpenIDE-Module-Display-Category=Infrastructure
2
OpenIDE-Module-Long-Description=\
3
    This module binds the Datasystems API with Scripting API. \
4
    As a result it is possible to use any scripting and templating language to generate templates.
5
OpenIDE-Module-Name=Advanced Templating
6
OpenIDE-Module-Short-Description=Advanced Templating not only for Datasystems
(-)openide/templates/src/org/netbeans/modules/templates/ScriptingCreateFromTemplateHandler.java (+104 lines)
Added Link Here
1
/*
2
 * The contents of this file are subject to the terms of the Common Development
3
 * and Distribution License (the License). You may not use this file except in
4
 * compliance with the License.
5
 *
6
 * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7
 * or http://www.netbeans.org/cddl.txt.
8
 *
9
 * When distributing Covered Code, include this CDDL Header Notice in each file
10
 * and include the License file at http://www.netbeans.org/cddl.txt.
11
 * If applicable, add the following below the CDDL Header, with the fields
12
 * enclosed by brackets [] replaced by your own identifying information:
13
 * "Portions Copyrighted [year] [name of copyright owner]"
14
 *
15
 * The Original Software is NetBeans. The Initial Developer of the Original
16
 * Software is Sun Microsystems, Inc. 
17
 *
18
 * Portions Copyrighted 2007 Sun Microsystems, Inc.
19
 */
20
21
package org.netbeans.modules.templates;
22
23
import java.io.IOException;
24
import java.io.InputStreamReader;
25
import java.io.OutputStreamWriter;
26
import java.io.Reader;
27
import java.util.Map;
28
import java.util.logging.Level;
29
import java.util.logging.Logger;
30
import javax.script.Bindings;
31
import javax.script.ScriptContext;
32
import javax.script.ScriptEngine;
33
import javax.script.ScriptEngineManager;
34
import javax.script.ScriptException;
35
import org.openide.filesystems.FileObject;
36
import org.openide.filesystems.FileUtil;
37
import org.openide.loaders.CreateFromTemplateHandler;
38
39
40
/** Processeses templates that have associated attribute
41
* with name of the scripting engine.
42
*
43
* @author  Jaroslav Tulach
44
*/
45
public class ScriptingCreateFromTemplateHandler extends CreateFromTemplateHandler {
46
    private static ScriptEngineManager manager;
47
    private static final Logger LOG = Logger.getLogger(ScriptingCreateFromTemplateHandler.class.getName());
48
    
49
    protected boolean accept(FileObject orig) {
50
        return engine(orig) != null;
51
    }
52
53
    protected FileObject createFromTemplate(FileObject template, FileObject f,
54
                                            String name,
55
                                            Map<String, Object> values) throws IOException {
56
        
57
        ScriptEngineManager mgr = new ScriptEngineManager();
58
        ScriptEngine eng = mgr.getEngineByName("freemarker");
59
        Bindings bind = eng.getContext().getBindings(ScriptContext.ENGINE_SCOPE);
60
        bind.putAll(values);
61
        for (Map.Entry<String, Object> entry : values.entrySet()) {
62
            eng.getContext().setAttribute(entry.getKey(), entry.getValue(), ScriptContext.ENGINE_SCOPE);
63
        }
64
        
65
        String nameUniq = FileUtil.findFreeFileName(f, name, template.getExt());
66
        FileObject output = FileUtil.createData(f, nameUniq + '.' + template.getExt());
67
68
        OutputStreamWriter w = null;
69
        Reader is = null;
70
        try {
71
            w = new OutputStreamWriter(output.getOutputStream());
72
            eng.getContext().setWriter(w);
73
            //eng.getContext().setBindings(bind, ScriptContext.ENGINE_SCOPE);
74
            eng.getContext().setAttribute(FileObject.class.getName(), template, ScriptContext.ENGINE_SCOPE);
75
            eng.getContext().setAttribute(ScriptEngine.FILENAME, template.getNameExt(), ScriptContext.ENGINE_SCOPE);
76
            is = new InputStreamReader(template.getInputStream());
77
            eng.eval(is);
78
        }catch (ScriptException ex) {
79
            IOException io = new IOException(ex.getMessage());
80
            io.initCause(ex);
81
            throw io;
82
        } finally {
83
            if (w != null) w.close();
84
            if (is != null) is.close();
85
        }
86
        return output;
87
    }
88
    
89
    private static ScriptEngine engine(FileObject fo) {
90
        Object obj = fo.getAttribute("javax.script.ScriptEngine"); // NOI18N
91
        if (obj instanceof ScriptEngine) {
92
            return (ScriptEngine)obj;
93
        }
94
        if (obj instanceof String) {
95
            synchronized (ScriptingCreateFromTemplateHandler.class) {
96
                if (manager == null) {
97
                    manager = new ScriptEngineManager();
98
                }
99
            }
100
            return manager.getEngineByName((String)obj);
101
        }
102
        return null;
103
    }
104
}
(-)openide/templates/src/org/netbeans/modules/templates/layer.xml (+4 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.1//EN" "http://www.netbeans.org/dtds/filesystem-1_1.dtd">
3
<filesystem>
4
</filesystem>
(-)openide/templates/test/unit/src/org/netbeans/modules/templates/SCFTHandlerTest.java (+217 lines)
Added Link Here
1
/*
2
 * The contents of this file are subject to the terms of the Common Development
3
 * and Distribution License (the License). You may not use this file except in
4
 * compliance with the License.
5
 *
6
 * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7
 * or http://www.netbeans.org/cddl.txt.
8
 *
9
 * When distributing Covered Code, include this CDDL Header Notice in each file
10
 * and include the License file at http://www.netbeans.org/cddl.txt.
11
 * If applicable, add the following below the CDDL Header, with the fields
12
 * enclosed by brackets [] replaced by your own identifying information:
13
 * "Portions Copyrighted [year] [name of copyright owner]"
14
 *
15
 * The Original Software is NetBeans. The Initial Developer of the Original
16
 * Software is Sun Microsystems, Inc. 
17
 *
18
 * Portions Copyrighted 2007 Sun Microsystems, Inc.
19
 */
20
21
package org.netbeans.modules.templates;
22
23
import java.awt.Dialog;
24
import java.io.IOException;
25
import java.io.OutputStream;
26
import java.util.Collections;
27
import java.util.Enumeration;
28
import java.util.Map;
29
import javax.swing.JDialog;
30
import org.netbeans.junit.MockServices;
31
import org.netbeans.junit.NbTestCase;
32
import org.openide.DialogDescriptor;
33
import org.openide.DialogDisplayer;
34
import org.openide.NotifyDescriptor;
35
import org.openide.filesystems.FileObject;
36
import org.openide.filesystems.FileUtil;
37
import org.openide.loaders.DataFolder;
38
import org.openide.loaders.DataLoader;
39
import org.openide.loaders.DataLoaderPool;
40
import org.openide.loaders.DataObject;
41
import org.openide.loaders.DataObjectExistsException;
42
import org.openide.loaders.FileEntry;
43
import org.openide.loaders.MultiDataObject;
44
import org.openide.loaders.MultiFileLoader;
45
import org.openide.util.Enumerations;
46
47
/**
48
 *
49
 * @author Jaroslav Tulach
50
 */
51
public class SCFTHandlerTest extends NbTestCase {
52
    
53
    public SCFTHandlerTest(String testName) {
54
        super(testName);
55
    }
56
    
57
    protected boolean runInEQ() {
58
        return true;
59
    }
60
    
61
    protected void setUp() throws Exception {
62
        MockServices.setServices(DD.class, Pool.class);
63
    }
64
65
    protected void tearDown() throws Exception {
66
        super.tearDown();
67
    }
68
69
    public void testCreateFromTemplateUsingFreemarker() throws Exception {
70
        FileObject root = FileUtil.createMemoryFileSystem().getRoot();
71
        FileObject fo = FileUtil.createData(root, "simpleObject.txt");
72
        OutputStream os = fo.getOutputStream();
73
        String txt = "<html><h1>${title}</h1></html>";
74
        os.write(txt.getBytes());
75
        os.close();
76
        fo.setAttribute("javax.script.ScriptEngine", "freemarker");
77
        
78
        
79
        DataObject obj = DataObject.find(fo);
80
        
81
        DataFolder folder = DataFolder.findFolder(FileUtil.createFolder(root, "target"));
82
        
83
        Map<String,String> parameters = Collections.singletonMap("title", "Nazdar");
84
        DataObject n = obj.createFromTemplate(folder, "complex", parameters);
85
        
86
        assertEquals("Created in right place", folder, n.getFolder());
87
        assertEquals("Created with right name", "complex.txt", n.getName());
88
        
89
        String exp = "<html><h1>Nazdar</h1></html>";
90
        assertEquals(exp, readFile(n.getPrimaryFile()));
91
        
92
    }
93
    
94
    
95
    public void testBasePropertiesAlwaysPresent() throws Exception {
96
        FileObject root = FileUtil.createMemoryFileSystem().getRoot();
97
        FileObject fo = FileUtil.createData(root, "simpleObject.txt");
98
        OutputStream os = fo.getOutputStream();
99
        String txt = "<html><h1>${name}</h1>" +
100
            "<h2>${date}</h2>" +
101
            "<h3>${time}</h3>" +
102
            "<h4>${user}</h4>" +
103
            "</html>";
104
        os.write(txt.getBytes());
105
        os.close();
106
        fo.setAttribute("javax.script.ScriptEngine", "freemarker");
107
        
108
        
109
        DataObject obj = DataObject.find(fo);
110
        
111
        DataFolder folder = DataFolder.findFolder(FileUtil.createFolder(root, "target"));
112
        
113
        Map<String,String> parameters = Collections.singletonMap("title", "Nazdar");
114
        DataObject n = obj.createFromTemplate(folder, "complex", parameters);
115
        
116
        assertEquals("Created in right place", folder, n.getFolder());
117
        assertEquals("Created with right name", "complex.txt", n.getName());
118
        
119
        String res = readFile(n.getPrimaryFile());
120
        
121
        if (res.indexOf("date") >= 0) fail(res);
122
        if (res.indexOf("time") >= 0) fail(res);
123
        if (res.indexOf("user") >= 0) fail(res);
124
        if (res.indexOf("name") >= 0) fail(res);
125
    }
126
    
127
    private static String readFile(FileObject fo) throws IOException {
128
        byte[] arr = new byte[(int)fo.getSize()];
129
        int len = fo.getInputStream().read(arr);
130
        assertEquals("Fully read", arr.length, len);
131
        return new String(arr);
132
    }
133
    
134
    public static final class DD extends DialogDisplayer {
135
        public Object notify(NotifyDescriptor descriptor) {
136
            throw new UnsupportedOperationException("Not supported yet.");
137
        }
138
139
        public Dialog createDialog(final DialogDescriptor descriptor) {
140
            throw new UnsupportedOperationException("Not supported yet.");
141
            /*
142
            return new JDialog() {
143
                @Deprecated
144
                public void show() {
145
                    for (Object object : descriptor.getOptions()) {
146
                        if (object instanceof JButton) {
147
                            JButton b = (JButton)object;
148
                            if (b.getText().equals("Finish")) {
149
                                descriptor.setValue(WizardDescriptor.FINISH_OPTION);
150
                                b.doClick();
151
                                return;
152
                            }
153
                        }
154
                    }
155
                    fail("Cannot find Finish button: " + Arrays.asList(descriptor.getOptions()));
156
                }
157
            };
158
             */
159
        }
160
    }
161
    
162
    public static final class Pool extends DataLoaderPool {
163
        protected Enumeration<DataLoader> loaders() {
164
            return Enumerations.<DataLoader>singleton(SimpleLoader.getLoader(SimpleLoader.class));
165
        }
166
    }
167
    
168
    public static final class SimpleLoader extends MultiFileLoader {
169
        public SimpleLoader() {
170
            super(SimpleObject.class.getName());
171
        }
172
        protected String displayName() {
173
            return "SimpleLoader";
174
        }
175
        protected FileObject findPrimaryFile(FileObject fo) {
176
            if (fo.hasExt("prima")) {
177
                return fo;
178
            }
179
            return null;
180
        }
181
        protected MultiDataObject createMultiObject(FileObject primaryFile) throws DataObjectExistsException, IOException {
182
            return new SimpleObject(this, primaryFile);
183
        }
184
        protected MultiDataObject.Entry createPrimaryEntry(MultiDataObject obj, FileObject primaryFile) {
185
            return new FE(obj, primaryFile);
186
        }
187
        protected MultiDataObject.Entry createSecondaryEntry(MultiDataObject obj, FileObject secondaryFile) {
188
            return new FileEntry(obj, secondaryFile);
189
        }
190
    }
191
    
192
    private static final class FE extends FileEntry {
193
        public FE(MultiDataObject mo, FileObject fo) {
194
            super(mo, fo);
195
        }
196
197
        @Override
198
        public FileObject createFromTemplate(FileObject f, String name) throws IOException {
199
            fail("I do not want to be called");
200
            return null;
201
        }
202
203
        
204
        
205
    }
206
    
207
    public static final class SimpleObject extends MultiDataObject {
208
        public SimpleObject(SimpleLoader l, FileObject fo) throws DataObjectExistsException {
209
            super(fo, l);
210
        }
211
        
212
        public String getName() {
213
            return getPrimaryFile().getNameExt();
214
        }
215
    }
216
    
217
}
(-)libs/external/.cvsignore (+2 lines)
Line 1 Link Here
1
jsr223-api.jar
1
dtds
2
dtds
3
freemarker-2.3.8.jar
(-)libs/external/freemarker-2.3.8-license.txt (+46 lines)
Added Link Here
1
FreeMarker 1.x was released under the LGPL license. Later, by community
2
consensus, we have switched over to a BSD-style license. As of FreeMarker
3
2.2pre1, the original author, Benjamin Geer, has relinquished the copyright in
4
behalf of Visigoth Software Society. The current copyright holder is the
5
Visigoth Software Society.
6
7
------------------------------------------------------------------------------
8
Copyright (c) 2003 The Visigoth Software Society. All rights reserved.
9
10
Redistribution and use in source and binary forms, with or without
11
modification, are permitted provided that the following conditions are met:
12
13
1.  Redistributions of source code must retain the above copyright notice,
14
    this list of conditions and the following disclaimer.
15
16
2.  The end-user documentation included with the redistribution, if any, must
17
    include the following acknowlegement:
18
      "This product includes software developed by the 
19
      Visigoth Software Society (http://www.visigoths.org/)."
20
    Alternately, this acknowlegement may appear in the software itself, if and
21
    wherever such third-party acknowlegements normally appear.
22
23
3.  Neither the name "FreeMarker", "Visigoth", nor any of the names of the
24
    project contributors may be used to endorse or promote products derived
25
    from this software without prior written permission. For written
26
    permission, please contact visigoths@visigoths.org.
27
28
4.  Products derived from this software may not be called "FreeMarker" or
29
    "Visigoth" nor may "FreeMarker" or "Visigoth" appear in their names
30
    without prior written permission of the Visigoth Software Society.
31
32
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
33
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
34
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
35
VISIGOTH SOFTWARE SOCIETY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
36
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
37
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
38
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
39
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
40
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
41
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42
------------------------------------------------------------------------------
43
44
This software consists of voluntary contributions made by many individuals on
45
behalf of the Visigoth Software Society. For more information on the Visigoth
46
Software Society, please see http://www.visigoths.org/
(-)libs/external/jsr223-api-license.txt (+225 lines)
Added Link Here
1
SUN MICROSYSTEMS, INC. ("SUN") IS WILLING TO LICENSE THIS SPECIFICATION
2
TO YOU ONLY UPON THE CONDITION THAT YOU ACCEPT ALL OF THE TERMS
3
CONTAINED IN THIS AGREEMENT. PLEASE READ THE TERMS AND CONDITIONS OF
4
THIS AGREEMENT CAREFULLY. BY DOWNLOADING THIS SPECIFICATION, YOU ACCEPT
5
THE TERMS AND CONDITIONS OF THE AGREEMENT. IF YOU ARE NOT WILLING TO BE
6
BOUND BY IT, SELECT THE "DECLINE" BUTTON AT THE BOTTOM OF THIS PAGE.
7
8
9
Specification: JSR-000223 Scripting for the Java(tm) Platform ("Specification")
10
11
12
Version: 1.0
13
14
15
Status: Final Release
16
17
18
Release: 7 December 2006
19
20
21
Copyright 2006 SUN MICROSYSTEMS, INC.
22
23
4150 Network Circle, Santa Clara, California 95054, U.S.A
24
25
All rights reserved.
26
27
28
LIMITED LICENSE GRANTS
29
30
31
1. _License for Evaluation Purposes_. Sun hereby grants you a
32
fully-paid, non-exclusive, non-transferable, worldwide, limited license
33
(without the right to sublicense), under Sun's applicable intellectual
34
property rights to view, download, use and reproduce the Specification
35
only for the purpose of internal evaluation. This includes (i)
36
developing applications intended to run on an implementation of the
37
Specification, provided that such applications do not themselves
38
implement any portion(s) of the Specification, and (ii) discussing the
39
Specification with any third party; and (iii) excerpting brief portions
40
of the Specification in oral or written communications which discuss the
41
Specification provided that such excerpts do not in the aggregate
42
constitute a significant portion of the Specification.
43
44
45
2. _License for the Distribution of Compliant Implementations_. Sun also
46
grants you a perpetual, non-exclusive, non-transferable, worldwide,
47
fully paid-up, royalty free, limited license (without the right to
48
sublicense) under any applicable copyrights or, subject to the
49
provisions of subsection 4 below, patent rights it may have covering the
50
Specification to create and/or distribute an Independent Implementation
51
of the Specification that: (a) fully implements the Specification
52
including all its required interfaces and functionality; (b) does not
53
modify, subset, superset or otherwise extend the Licensor Name Space, or
54
include any public or protected packages, classes, Java interfaces,
55
fields or methods within the Licensor Name Space other than those
56
required/authorized by the Specification or Specifications being
57
implemented; and (c) passes the Technology Compatibility Kit (including
58
satisfying the requirements of the applicable TCK Users Guide) for such
59
Specification ("Compliant Implementation"). In addition, the foregoing
60
license is expressly conditioned on your not acting outside its scope.
61
No license is granted hereunder for any other purpose (including, for
62
example, modifying the Specification, other than to the extent of your
63
fair use rights, or distributing the Specification to third parties).
64
Also, no right, title, or interest in or to any trademarks, service
65
marks, or trade names of Sun or Sun's licensors is granted hereunder.
66
Java, and Java-related logos, marks and names are trademarks or
67
registered trademarks of Sun Microsystems, Inc. in the U.S. and other
68
countries.
69
70
71
3. _Pass-through Conditions_. You need not include limitations (a)-(c)
72
from the previous paragraph or any other particular "pass through"
73
requirements in any license You grant concerning the use of your
74
Independent Implementation or products derived from it. However, except
75
with respect to Independent Implementations (and products derived from
76
them) that satisfy limitations (a)-(c) from the previous paragraph, You
77
may neither: (a) grant or otherwise pass through to your licensees any
78
licenses under Sun's applicable intellectual property rights; nor (b)
79
authorize your licensees to make any claims concerning their
80
implementation's compliance with the Specification in question.
81
82
83
4. _Reciprocity Concerning Patent Licenses_.
84
85
86
a. With respect to any patent claims covered by the license granted
87
under subparagraph 2 above that would be infringed by all technically
88
feasible implementations of the Specification, such license is
89
conditioned upon your offering on fair, reasonable and
90
non-discriminatory terms, to any party seeking it from You, a perpetual,
91
non-exclusive, non-transferable, worldwide license under Your patent
92
rights which are or would be infringed by all technically feasible
93
implementations of the Specification to develop, distribute and use a
94
Compliant Implementation.
95
96
97
b With respect to any patent claims owned by Sun and covered by the
98
license granted under subparagraph 2, whether or not their infringement
99
can be avoided in a technically feasible manner when implementing the
100
Specification, such license shall terminate with respect to such claims
101
if You initiate a claim against Sun that it has, in the course of
102
performing its responsibilities as the Specification Lead, induced any
103
other entity to infringe Your patent rights.
104
105
106
c Also with respect to any patent claims owned by Sun and covered by the
107
license granted under subparagraph 2 above, where the infringement of
108
such claims can be avoided in a technically feasible manner when
109
implementing the Specification such license, with respect to such
110
claims, shall terminate if You initiate a claim against Sun that its
111
making, having made, using, offering to sell, selling or importing a
112
Compliant Implementation infringes Your patent rights.
113
114
115
5. _Definitions_. For the purposes of this Agreement: "Independent
116
Implementation" shall mean an implementation of the Specification that
117
neither derives from any of Sun's source code or binary code materials
118
nor, except with an appropriate and separate license from Sun, includes
119
any of Sun's source code or binary code materials; "Licensor Name Space"
120
shall mean the public class or interface declarations whose names begin
121
with "java", "javax", "com.sun" or their equivalents in any subsequent
122
naming convention adopted by Sun through the Java Community Process, or
123
any recognized successors or replacements thereof; and "Technology
124
Compatibility Kit" or "TCK" shall mean the test suite and accompanying
125
TCK User's Guide provided by Sun which corresponds to the Specification
126
and that was available either (i) from Sun's 120 days before the first
127
release of Your Independent Implementation that allows its use for
128
commercial purposes, or (ii) more recently than 120 days from such
129
release but against which You elect to test Your implementation of the
130
Specification.
131
132
133
This Agreement will terminate immediately without notice from Sun if you
134
breach the Agreement or act outside the scope of the licenses granted above.
135
136
137
DISCLAIMER OF WARRANTIES
138
139
140
THE SPECIFICATION IS PROVIDED "AS IS". SUN MAKES NO REPRESENTATIONS OR
141
WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO,
142
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
143
NON-INFRINGEMENT (INCLUDING AS A CONSEQUENCE OF ANY PRACTICE OR
144
IMPLEMENTATION OF THE SPECIFICATION), OR THAT THE CONTENTS OF THE
145
SPECIFICATION ARE SUITABLE FOR ANY PURPOSE. This document does not
146
represent any commitment to release or implement any portion of the
147
Specification in any product. In addition, the Specification could
148
include technical inaccuracies or typographical errors.
149
150
151
LIMITATION OF LIABILITY
152
153
154
TO THE EXTENT NOT PROHIBITED BY LAW, IN NO EVENT WILL SUN OR ITS
155
LICENSORS BE LIABLE FOR ANY DAMAGES, INCLUDING WITHOUT LIMITATION, LOST
156
REVENUE, PROFITS OR DATA, OR FOR SPECIAL, INDIRECT, CONSEQUENTIAL,
157
INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE
158
THEORY OF LIABILITY, ARISING OUT OF OR RELATED IN ANY WAY TO YOUR
159
HAVING, IMPLEMENTING OR OTHERWISE USING THE SPECIFICATION, EVEN
160
IF SUN AND/OR ITS LICENSORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH
161
DAMAGES.
162
163
You will indemnify, hold harmless, and defend Sun and its licensors from
164
any claims arising or resulting from: (i) your use of the Specification;
165
(ii) the use or distribution of your Java application, applet and/or
166
implementation; and/or (iii) any claims that later versions or releases
167
of any Specification furnished to you are incompatible with the
168
Specification provided to you under this license.
169
170
171
RESTRICTED RIGHTS LEGEND
172
173
174
U.S. Government: If this Specification is being acquired by or on behalf
175
of the U.S. Government or by a U.S. Government prime contractor or
176
subcontractor (at any tier), then the Government's rights in the
177
Software and accompanying documentation shall be only as set forth in
178
this license; this is in accordance with 48 C.F.R. 227.7201 through
179
227.7202-4 (for Department of Defense (DoD) acquisitions) and with 48
180
C.F.R. 2.101 and 12.212 (for non-DoD acquisitions).
181
182
183
REPORT
184
185
186
If you provide Sun with any comments or suggestions concerning the
187
Specification ("Feedback"), you hereby: (i) agree that such Feedback is
188
provided on a non-proprietary and non-confidential basis, and (ii) grant
189
Sun a perpetual, non-exclusive, worldwide, fully paid-up, irrevocable
190
license, with the right to sublicense through multiple levels of
191
sublicensees, to incorporate, disclose, and use without limitation the
192
Feedback for any purpose.
193
194
195
GENERAL TERMS
196
197
198
Any action related to this Agreement will be governed by California law
199
and controlling U.S. federal law. The U.N. Convention for the
200
International Sale of Goods and the choice of law rules of any
201
jurisdiction will not apply.
202
203
204
The Specification is subject to U.S. export control laws and may be
205
subject to export or import regulations in other countries. Licensee
206
agrees to comply strictly with all such laws and regulations and
207
acknowledges that it has the responsibility to obtain such licenses to
208
export, re-export or import as may be required after delivery to Licensee.
209
210
211
This Agreement is the parties' entire agreement relating to its subject
212
matter. It supersedes all prior or contemporaneous oral or written
213
communications, proposals, conditions, representations and warranties
214
and prevails over any conflicting or additional terms of any quote,
215
order, acknowledgment, or other communication between the parties
216
relating to its subject matter during the term of this Agreement. No
217
modification to this Agreement will be binding, unless in writing and
218
signed by an authorized representative of each party.
219
220
221
222
223
Rev. April, 2006
224
225
Sun/Final/Full
(-)libs/freemarker/.cvsignore (+1 lines)
Added Link Here
1
build
(-)libs/freemarker/build.xml (+101 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<!--
3
The contents of this file are subject to the terms of the Common Development
4
and Distribution License (the License). You may not use this file except in
5
compliance with the License.
6
7
You can obtain a copy of the License at http://www.netbeans.org/cddl.html
8
or http://www.netbeans.org/cddl.txt.
9
10
When distributing Covered Code, include this CDDL Header Notice in each file
11
and include the License file at http://www.netbeans.org/cddl.txt.
12
If applicable, add the following below the CDDL Header, with the fields
13
enclosed by brackets [] replaced by your own identifying information:
14
"Portions Copyrighted [year] [name of copyright owner]"
15
16
The Original Software is NetBeans. The Initial Developer of the Original
17
Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
18
Microsystems, Inc. All Rights Reserved.
19
-->
20
21
<project name="libs/freemarker" default="netbeans" basedir=".">
22
23
  <import file="../../nbbuild/templates/projectized.xml"/>
24
    
25
  <property name="freemarker.jar" location="${basedir}/../external/freemarker-2.3.8.jar"/>
26
  <property name="freemarker.license" location="${freemarker.jar}/../freemarker-2.3.8-license.txt"/>
27
28
  <available
29
    classname="freemarker.template.Template"
30
    property="script.engine.present"
31
    classpath="${freemarker.jar}"
32
  />
33
34
  <target name="download-freemarker" depends="init" unless="script.engine.present">
35
    <echo>
36
Going to download freemarker binaries! Distributed from http://freemarker.sourceforge.net/
37
Or you need to provide path to the freemarker JAR using -Dfreemarker.jar=, download from:
38
http://mesh.dl.sourceforge.net/sourceforge/freemarker/freemarker-2.3.8.tar.gz
39
    </echo>
40
    <tempfile deleteonexit="true" destdir="build" property="freemarker.tgz" prefix="freemarker" suffix=".tgz"/>
41
    <get dest="${freemarker.tgz}" src="http://mesh.dl.sourceforge.net/sourceforge/freemarker/freemarker-2.3.8.tar.gz"/>
42
    <mkdir dir="${freemarker.tgz}.dir"/>
43
    <gunzip src="${freemarker.tgz}" dest="${freemarker.tgz}.dir/freemarker.tar"/>
44
    <untar src="${freemarker.tgz}.dir/freemarker.tar" dest="${freemarker.tgz}.dir/">
45
        <patternset>
46
            <include name="**/freemarker*.jar"/>
47
        </patternset>
48
    </untar>
49
    <!-- this makes the freemarker-2.3.8.jar smaller by 300Kb, and
50
      also prevents most of the messages about missing class dependencies
51
      -->
52
    <jar destfile="${freemarker.jar}" compress="true">
53
        <zipfileset src="${freemarker.tgz}.dir/freemarker-2.3.8/lib/freemarker.jar">
54
            <include name="**/*"/>
55
            <exclude name="freemarker/ext/*"/>
56
            <exclude name="freemarker/ext/dom/*"/>
57
            <exclude name="freemarker/ext/jdom/*"/>
58
            <exclude name="freemarker/ext/jsp/*"/>
59
            <exclude name="freemarker/ext/rhino/*"/>
60
            <exclude name="freemarker/ext/servlet/*"/>
61
            <exclude name="freemarker/ext/xml/*"/>
62
            <exclude name="freemarker/log/**/Log4J*"/>
63
            <exclude name="freemarker/log/**/Avalon*"/>
64
            <exclude name="freemarker/**/*Jython*"/>
65
            <exclude name="freemarker/cache/WebappTemplateLoader*"/>
66
        </zipfileset>
67
    </jar>
68
    <!--<delete dir="${freemarker.tgz}.dir"/>-->
69
  </target>    
70
71
    <target name="netbeans-extra" depends="release"/>
72
73
    <target name="release" depends="init,download-freemarker">
74
        <mkdir dir="${cluster}/modules/ext"/>
75
        <copy todir="${cluster}/modules/ext" file="${freemarker.jar}"/>
76
    </target>
77
78
    <target name="nbm" depends="init,netbeans" description="Build NBM archive.">
79
        <mkdir dir="build"/>
80
        <property name="nbm.target.cluster" value=""/> <!-- fallback -->
81
        <makenbm file="build/${nbm}"
82
                 productdir="${cluster}"
83
                 module="${module.jar}"
84
                 homepage="${nbm.homepage}"
85
                 distribution="http://${dist.base}/${nbm}"
86
                 needsrestart="${nbm.needs.restart}"
87
                 releasedate="${nbm.release.date}"
88
		 moduleauthor="${nbm.module.author}"
89
                 global="${nbm.is.global}"
90
                 targetcluster="${nbm.target.cluster}">
91
            <license>
92
                <text>For the integration module:</text>
93
                <file location="${license.file}"/>
94
                <text>For the freemarker:</text>
95
                <file location="${freemarker.license}"/>
96
            </license>
97
            <signature keystore="${keystore}" storepass="${storepass}" alias="${nbm_alias}"/>
98
        </makenbm>
99
    </target>
100
101
</project>
(-)libs/freemarker/manifest.mf (+7 lines)
Added Link Here
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.netbeans.libs.freemarker/1
3
OpenIDE-Module-Provides: javax.script.ScriptEngine.freemarker
4
OpenIDE-Module-Specification-Version: 2.3.8
5
OpenIDE-Module-Implementation-Version: 238
6
OpenIDE-Module-Localizing-Bundle: org/netbeans/libs/freemarker/Bundle.properties
7
(-)libs/freemarker/nbproject/.cvsignore (+1 lines)
Added Link Here
1
private
(-)libs/freemarker/nbproject/project.properties (+22 lines)
Added Link Here
1
# The contents of this file are subject to the terms of the Common Development
2
# and Distribution License (the License). You may not use this file except in
3
# compliance with the License.
4
#
5
# You can obtain a copy of the License at http://www.netbeans.org/cddl.html
6
# or http://www.netbeans.org/cddl.txt.
7
#
8
# When distributing Covered Code, include this CDDL Header Notice in each file
9
# and include the License file at http://www.netbeans.org/cddl.txt.
10
# If applicable, add the following below the CDDL Header, with the fields
11
# enclosed by brackets [] replaced by your own identifying information:
12
# "Portions Copyrighted [year] [name of copyright owner]"
13
#
14
# The Original Software is NetBeans. The Initial Developer of the Original
15
# Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
16
# Microsystems, Inc. All Rights Reserved.
17
18
is.autoload=true
19
20
21
javac.compilerargs=-Xlint:unchecked
22
javac.source=1.5
(-)libs/freemarker/nbproject/project.xml (+61 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<!--
3
The contents of this file are subject to the terms of the Common Development
4
and Distribution License (the License). You may not use this file except in
5
compliance with the License.
6
7
You can obtain a copy of the License at http://www.netbeans.org/cddl.html
8
or http://www.netbeans.org/cddl.txt.
9
10
When distributing Covered Code, include this CDDL Header Notice in each file
11
and include the License file at http://www.netbeans.org/cddl.txt.
12
If applicable, add the following below the CDDL Header, with the fields
13
enclosed by brackets [] replaced by your own identifying information:
14
"Portions Copyrighted [year] [name of copyright owner]"
15
16
The Original Software is NetBeans. The Initial Developer of the Original
17
Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
18
Microsystems, Inc. All Rights Reserved.
19
-->
20
<project xmlns="http://www.netbeans.org/ns/project/1">
21
    <type>org.netbeans.modules.apisupport.project</type>
22
    <configuration>
23
        <data xmlns="http://www.netbeans.org/ns/nb-module-project/2">
24
            <code-name-base>org.netbeans.libs.freemarker</code-name-base>
25
            <module-dependencies>
26
                <dependency>
27
                    <code-name-base>org.netbeans.libs.jsr223</code-name-base>
28
                    <build-prerequisite/>
29
                    <compile-dependency/>
30
                    <run-dependency>
31
                        <release-version>1</release-version>
32
                        <specification-version>1.6</specification-version>
33
                    </run-dependency>
34
                </dependency>
35
                <dependency>
36
                    <code-name-base>org.openide.filesystems</code-name-base>
37
                    <build-prerequisite/>
38
                    <compile-dependency/>
39
                    <run-dependency>
40
                        <specification-version>7.0</specification-version>
41
                    </run-dependency>
42
                </dependency>
43
                <dependency>
44
                    <code-name-base>org.openide.util</code-name-base>
45
                    <build-prerequisite/>
46
                    <compile-dependency/>
47
                    <run-dependency>
48
                        <specification-version>7.7</specification-version>
49
                    </run-dependency>
50
                </dependency>
51
            </module-dependencies>
52
            <public-packages>
53
                <package>org.netbeans.libs.freemarker</package>
54
            </public-packages>
55
            <class-path-extension>
56
                <runtime-relative-path>ext/freemarker-2.3.8.jar</runtime-relative-path>
57
                <binary-origin>../external/freemarker-2.3.8.jar</binary-origin>
58
            </class-path-extension>
59
        </data>
60
    </configuration>
61
</project>
(-)libs/freemarker/src/META-INF/services/javax.script.ScriptEngineFactory (+1 lines)
Added Link Here
1
org.netbeans.libs.freemarker.FreemarkerFactory
(-)libs/freemarker/src/org/netbeans/libs/freemarker/Bundle.properties (+24 lines)
Added Link Here
1
# The contents of this file are subject to the terms of the Common Development
2
# and Distribution License (the License). You may not use this file except in
3
# compliance with the License.
4
#
5
# You can obtain a copy of the License at http://www.netbeans.org/cddl.html
6
# or http://www.netbeans.org/cddl.txt.
7
#
8
# When distributing Covered Code, include this CDDL Header Notice in each file
9
# and include the License file at http://www.netbeans.org/cddl.txt.
10
# If applicable, add the following below the CDDL Header, with the fields
11
# enclosed by brackets [] replaced by your own identifying information:
12
# "Portions Copyrighted [year] [name of copyright owner]"
13
#
14
# The Original Software is NetBeans. The Initial Developer of the Original
15
# Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
16
# Microsystems, Inc. All Rights Reserved.
17
18
OpenIDE-Module-Name=Freemarker Integration
19
OpenIDE-Module-Display-Category=Libraries
20
OpenIDE-Module-Short-Description=This module bundles Freemarker.
21
OpenIDE-Module-Long-Description=\
22
    The module bundles FreeMarker http://freemarker.sf.net and integrates\
23
    it into NetBeans.
24
(-)libs/freemarker/src/org/netbeans/libs/freemarker/FreemarkerEngine.java (+205 lines)
Added Link Here
1
/*
2
 * The contents of this file are subject to the terms of the Common Development
3
 * and Distribution License (the License). You may not use this file except in
4
 * compliance with the License.
5
 *
6
 * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7
 * or http://www.netbeans.org/cddl.txt.
8
 *
9
 * When distributing Covered Code, include this CDDL Header Notice in each file
10
 * and include the License file at http://www.netbeans.org/cddl.txt.
11
 * If applicable, add the following below the CDDL Header, with the fields
12
 * enclosed by brackets [] replaced by your own identifying information:
13
 * "Portions Copyrighted [year] [name of copyright owner]"
14
 *
15
 * The Original Software is scripting.dev.java.net. The Initial Developer of the Original
16
 * Software is Sun Microsystems, Inc. 
17
 * 
18
 * Portions Copyrighted 2006 Sun Microsystems, Inc.
19
 */
20
21
package org.netbeans.libs.freemarker;
22
23
24
import javax.script.*;
25
import java.io.*;
26
import java.util.Properties;
27
import java.util.Set;
28
import freemarker.template.*;
29
import org.openide.filesystems.FileObject;
30
31
/* Taken from A. Sundararajan and adopted by Jaroslav Tulach 
32
 * for NetBeans needs.
33
 * 
34
 * @author A. Sundararajan
35
 */
36
class FreemarkerEngine extends AbstractScriptEngine {
37
38
    public static final String STRING_OUTPUT_MODE = "com.sun.script.freemarker.stringOut";
39
    public static final String FREEMARKER_CONFIG = "com.sun.script.freemarker.config";
40
    public static final String FREEMARKER_PROPERTIES = "com.sun.script.freemarker.properties";
41
    public static final String FREEMARKER_TEMPLATE_DIR = "com.sun.script.freemarker.template.dir";
42
    public static final String FREEMARKER_TEMPLATE = "org.openide.filesystems.FileObject";
43
44
    // my factory, may be null
45
    private volatile ScriptEngineFactory factory;
46
    private volatile Configuration conf;
47
48
    public FreemarkerEngine(ScriptEngineFactory factory) {
49
        this.factory = factory;
50
    }   
51
52
    public FreemarkerEngine() {
53
        this(null);
54
    }
55
	
56
    // ScriptEngine methods
57
    public Object eval(String str, ScriptContext ctx) 
58
                       throws ScriptException {	
59
        return eval(new StringReader(str), ctx);
60
    }
61
62
    public Object eval(Reader reader, ScriptContext ctx)
63
                       throws ScriptException { 
64
        ctx.setAttribute("context", ctx, ScriptContext.ENGINE_SCOPE);
65
        initFreeMarkerConfiguration(ctx);
66
        String fileName = getFilename(ctx);
67
        boolean outputAsString = isStringOutputMode(ctx);
68
        Writer out;
69
        if (outputAsString) {
70
            out = new StringWriter();
71
        } else {
72
            out = ctx.getWriter();
73
        }
74
        Bindings engineScope = ctx.getBindings(ScriptContext.ENGINE_SCOPE);
75
76
        try {
77
            Template template = new Template(fileName, reader, conf);
78
            template.process(engineScope, out);
79
            out.flush();
80
        } catch (Exception exp) {
81
            throw new ScriptException(exp);
82
        }
83
        return outputAsString? out.toString() : null;
84
    }
85
86
    public ScriptEngineFactory getFactory() {
87
        if (factory == null) {
88
            synchronized (this) {
89
	          if (factory == null) {
90
	              factory = new FreemarkerFactory();
91
	          }
92
            }
93
        }
94
	  return factory;
95
    }
96
97
    public Bindings createBindings() {
98
        return new SimpleBindings();
99
    }
100
101
    // internals only below this point  
102
    private static String getFilename(ScriptContext ctx) {
103
        Object fileName = ctx.getAttribute(ScriptEngine.FILENAME);
104
        return fileName != null? fileName.toString() : "<unknown>";
105
    }
106
107
    private static boolean isStringOutputMode(ScriptContext ctx) {
108
        Object flag = ctx.getAttribute(STRING_OUTPUT_MODE);
109
        if (flag != null) {
110
            return flag.equals(Boolean.TRUE);
111
        } else {
112
            return false;
113
        }
114
    }
115
116
    private void initFreeMarkerConfiguration(ScriptContext ctx) {
117
        if (conf == null) {
118
            synchronized (this) {
119
                if (conf != null) {
120
                    return;
121
                }
122
                Object cfg = ctx.getAttribute(FREEMARKER_CONFIG);
123
                if (cfg instanceof Configuration) {
124
                    conf = (Configuration) cfg;
125
                    return;
126
                }
127
128
                Object tfo = ctx.getAttribute(FREEMARKER_TEMPLATE);
129
                FileObject fo = tfo instanceof FileObject ? (FileObject)tfo : null;
130
                
131
                Configuration tmpConf = new RsrcLoader(fo, ctx);
132
                try {
133
                    initConfProps(tmpConf, ctx);
134
                    initTemplateDir(tmpConf, fo, ctx);
135
                } catch (RuntimeException rexp) {
136
                    throw rexp;
137
                } catch (Exception exp) {
138
                    throw new RuntimeException(exp);
139
                }
140
                conf = tmpConf;
141
            }
142
        }
143
    }    
144
145
    private static void initConfProps(Configuration conf, ScriptContext ctx) {         
146
        try {
147
            Properties props = null;
148
            Object tmp = ctx.getAttribute(FREEMARKER_PROPERTIES);
149
            if (props instanceof Properties) {
150
                props = (Properties) tmp;
151
            } else {
152
                String propsName = System.getProperty(FREEMARKER_PROPERTIES);
153
                if (propsName != null) {                    
154
                    File propsFile = new File(propsName);
155
                    if (propsFile.exists() && propsFile.canRead()) {
156
                        props = new Properties();
157
                        props.load(new FileInputStream(propsFile));
158
                    }               
159
                }
160
            }
161
            if (props != null) {
162
                Set<Object> keys = props.keySet();
163
                for (Object obj : keys) {
164
                    String key;
165
                    if (obj instanceof String) {
166
                        key = (String) obj;
167
                    } else {
168
                        continue;
169
                    }
170
                    try {
171
                        conf.setSetting(key, props.get(key).toString());
172
                    } catch (TemplateException te) {
173
                        // ignore
174
                    }
175
                }
176
            }
177
        } catch (RuntimeException re) {
178
            throw re;
179
        } catch (Exception exp) {
180
            throw new RuntimeException(exp);
181
        }
182
    }
183
184
    private static void initTemplateDir(Configuration conf, FileObject fo, ScriptContext ctx) {
185
        try {
186
            Object tmp = ctx.getAttribute(FREEMARKER_TEMPLATE_DIR);
187
            String dirName;
188
            if (tmp != null) {
189
                dirName = tmp.toString();
190
            } else {
191
                if (fo != null) {
192
                    return;
193
                }
194
                tmp = System.getProperty(FREEMARKER_TEMPLATE_DIR);
195
                dirName = (tmp == null)? "." : tmp.toString();
196
            }
197
            File dir = new File(dirName);
198
            if (dir.exists() && dir.isDirectory()) {
199
                conf.setDirectoryForTemplateLoading(dir);
200
            }
201
        } catch (IOException exp) {
202
            throw new RuntimeException(exp);
203
        }
204
    }
205
}
(-)libs/freemarker/src/org/netbeans/libs/freemarker/FreemarkerFactory.java (+144 lines)
Added Link Here
1
/*
2
 * The contents of this file are subject to the terms of the Common Development
3
 * and Distribution License (the License). You may not use this file except in
4
 * compliance with the License.
5
 *
6
 * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7
 * or http://www.netbeans.org/cddl.txt.
8
 *
9
 * When distributing Covered Code, include this CDDL Header Notice in each file
10
 * and include the License file at http://www.netbeans.org/cddl.txt.
11
 * If applicable, add the following below the CDDL Header, with the fields
12
 * enclosed by brackets [] replaced by your own identifying information:
13
 * "Portions Copyrighted [year] [name of copyright owner]"
14
 *
15
 * The Original Software is scripting.dev.java.net. The Initial Developer of the Original
16
 * Software is Sun Microsystems, Inc. 
17
 * 
18
 * Portions Copyrighted 2006 Sun Microsystems, Inc.
19
 */
20
21
/*
22
 * @author A. Sundararajan
23
 */
24
package org.netbeans.libs.freemarker;
25
26
import javax.script.*;
27
import java.util.*;
28
29
public class FreemarkerFactory implements ScriptEngineFactory {
30
    public String getEngineName() { 
31
        return "freemarker";
32
    }
33
34
    public String getEngineVersion() {
35
        return "2.3.8";
36
    }
37
38
    public List<String> getExtensions() {
39
        return extensions;
40
    }
41
42
    public String getLanguageName() {
43
        return "freemarker";
44
    }
45
46
    public String getLanguageVersion() {
47
        return "2.3.8";
48
    }
49
50
    public String getMethodCallSyntax(String obj, String m, String... args) {
51
        StringBuffer buf = new StringBuffer();
52
        buf.append("${");
53
        buf.append(obj);
54
        buf.append(".");
55
        buf.append(m);
56
        buf.append("(");
57
        if (args.length != 0) {
58
            int i = 0;
59
            for (; i < args.length - 1; i++) {
60
                buf.append("$" + args[i]);
61
                buf.append(", ");
62
            }
63
            buf.append("$" + args[i]);
64
        }        
65
        buf.append(")}");
66
        return buf.toString();
67
    }
68
69
    public List<String> getMimeTypes() {
70
        return mimeTypes;
71
    }
72
73
    public List<String> getNames() {
74
        return names;
75
    }
76
77
    public String getOutputStatement(String toDisplay) {
78
        StringBuffer buf = new StringBuffer();
79
        int len = toDisplay.length();
80
        buf.append("${context.getWriter().write(\"");
81
        for (int i = 0; i < len; i++) {
82
            char ch = toDisplay.charAt(i);
83
            switch (ch) {
84
            case '"':
85
                buf.append("\\\"");
86
                break;
87
            case '\\':
88
                buf.append("\\\\");
89
                break;
90
            default:
91
                buf.append(ch);
92
                break;
93
            }
94
        }
95
        buf.append("\")}");
96
        return buf.toString();
97
    }
98
99
    public String getParameter(String key) {
100
        if (key.equals(ScriptEngine.NAME)) {
101
            return getLanguageName();
102
        } else if (key.equals(ScriptEngine.ENGINE)) {
103
            return getEngineName();
104
        } else if (key.equals(ScriptEngine.ENGINE_VERSION)) {
105
            return getEngineVersion();
106
        } else if (key.equals(ScriptEngine.LANGUAGE)) {
107
            return getLanguageName();
108
        } else if (key.equals(ScriptEngine.LANGUAGE_VERSION)) {
109
            return getLanguageVersion();
110
        } else if (key.equals("THREADING")) {
111
            return "MULTITHREADED";
112
        } else {
113
            return null;
114
        }
115
    } 
116
117
    public String getProgram(String... statements) {
118
        StringBuffer buf = new StringBuffer();
119
        for (int i = 0; i < statements.length; i++) {
120
            buf.append(statements[i]);
121
            buf.append("\n");
122
        }
123
        return buf.toString();
124
    }
125
126
    public ScriptEngine getScriptEngine() {
127
        return new FreemarkerEngine(this);
128
    }
129
130
    private static List<String> names;
131
    private static List<String> extensions;
132
    private static List<String> mimeTypes;
133
    static {
134
        names = new ArrayList<String>(2);
135
        names.add("FreeMarker");
136
        names.add("freemarker");
137
        names = Collections.unmodifiableList(names);
138
        extensions = new ArrayList<String>(1);
139
        extensions.add("fm");
140
        extensions = Collections.unmodifiableList(extensions);
141
        mimeTypes = new ArrayList<String>(0);
142
        mimeTypes = Collections.unmodifiableList(mimeTypes);
143
    }
144
}
(-)libs/freemarker/src/org/netbeans/libs/freemarker/RsrcLoader.java (+128 lines)
Added Link Here
1
/*
2
* The contents of this file are subject to the terms of the
3
* Common Development and Distribution License, Version 1.0 only
4
* (the "License"). You may not use this file except in compliance
5
* with the License. A copy of the license is available
6
* at http://www.opensource.org/licenses/cddl1.php
7
*
8
* See the License for the specific language governing permissions
9
* and limitations under the License.
10
*
11
* The Original Code is the nbdoclet.sf.net project.
12
* The Initial Developer of the Original Code is Petr Zajac.
13
* Portions created by Petr Zajac are Copyright (C) 2006.
14
* Portions created by Jaroslav Tulach are Copyright (C) 2006.
15
* Portions Copyrighted 2007 Sun Microsystems, Inc.
16
* All Rights Reserved.
17
*/
18
package org.netbeans.libs.freemarker;
19
20
import freemarker.cache.TemplateLoader;
21
import freemarker.template.Configuration;
22
import freemarker.template.TemplateModel;
23
import freemarker.template.TemplateModelException;
24
import java.io.IOException;
25
import java.io.InputStreamReader;
26
import java.io.Reader;
27
import java.util.Enumeration;
28
import java.util.LinkedHashSet;
29
import java.util.Set;
30
import javax.script.ScriptContext;
31
import org.openide.filesystems.FileObject;
32
import org.openide.filesystems.Repository;
33
import org.openide.util.Exceptions;
34
35
/**
36
 *  Velocity templates resource loader rewritten for Freemarker to
37
 *  access resources via FileSystem.
38
 * 
39
 * @author Petr Zajac, adopted by Jaroslav Tulach
40
 */
41
42
final class RsrcLoader extends Configuration implements TemplateLoader {
43
    private FileObject fo;
44
    private ScriptContext map;
45
46
    RsrcLoader(FileObject fo, ScriptContext map) {
47
        this.fo = fo;
48
        this.map = map;
49
        setTemplateLoader(this);
50
    }
51
52
    private FileObject getFile(String name) {
53
       FileObject fo = (getFolder() == null) ? null : getFolder().getFileObject(name);
54
       return fo;
55
    } 
56
57
    private FileObject getFolder() {
58
        return fo != null ? fo.getParent() : Repository.getDefault().getDefaultFileSystem().getRoot();
59
    }
60
61
    public Object findTemplateSource(String string) throws IOException {
62
        FileObject fo = getFile(string);
63
        return fo == null ? null : new Wrap(fo);
64
    }
65
66
    public long getLastModified(Object object) {
67
        return ((Wrap)object).fo.lastModified().getTime();
68
    }
69
70
    public Reader getReader(Object object, String encoding) throws IOException {
71
        Wrap w = (Wrap)object;
72
        if (w.reader == null) {
73
            w.reader = new InputStreamReader(w.fo.getInputStream(), encoding);
74
        }
75
        return w.reader;
76
    }
77
78
    public void closeTemplateSource(Object object) throws IOException {
79
        Wrap w = (Wrap)object;
80
        if (w.reader != null) {
81
            w.reader.close();
82
        }
83
    }
84
        
85
    public Object put(String string, Object object) {
86
        assert false;
87
        return null;
88
    }
89
90
    public TemplateModel getSharedVariable(String string) {
91
        Object value = map == null ? null : map.getAttribute(string);
92
        if (value == null || fo != null) {
93
            value = fo.getAttribute(string);
94
        }
95
        try {
96
            return getObjectWrapper().wrap(value);
97
        } catch (TemplateModelException ex) {
98
            Exceptions.printStackTrace(ex);
99
            return null;
100
        }
101
    }
102
103
    public Set getSharedVariableNames() {
104
        LinkedHashSet<String> keys = new LinkedHashSet<String>();
105
106
        if (map != null) {
107
            keys.addAll(map.getBindings(map.ENGINE_SCOPE).keySet());
108
        }
109
110
        if (fo != null) {
111
            Enumeration<String> en = fo.getAttributes();
112
            while (en.hasMoreElements()) {
113
                keys.add(en.nextElement());
114
            }
115
        }
116
117
        return keys;
118
    }
119
120
    private static final class Wrap {
121
        public FileObject fo;
122
        public Reader reader;
123
        
124
        public Wrap(FileObject fo) {
125
            this.fo = fo;
126
        }
127
    } // end Wrap
128
}
(-)libs/freemarker/test/unit/src/org/netbeans/api/templates/ProcessorTest.java (+215 lines)
Added Link Here
1
/*
2
* The contents of this file are subject to the terms of the
3
* Common Development and Distribution License, Version 1.0 only
4
* (the "License"). You may not use this file except in compliance
5
* with the License. A copy of the license is available 
6
* at http://www.opensource.org/licenses/cddl1.php
7
* 
8
* See the License for the specific language governing permissions
9
* and limitations under the License.
10
*
11
* The Original Code is the dvbcentral.sf.net project.
12
* The Initial Developer of the Original Code is Jaroslav Tulach.
13
* Portions created by Jaroslav Tulach are Copyright (C) 2006.
14
* All Rights Reserved.
15
*/
16
package org.netbeans.api.templates;
17
18
import java.awt.Color;
19
import java.awt.Panel;
20
import java.io.IOException;
21
import java.io.InputStreamReader;
22
import java.io.OutputStream;
23
import java.io.StringWriter;
24
import java.io.Writer;
25
import java.util.Collections;
26
import java.util.HashMap;
27
import java.util.Map;
28
import javax.script.ScriptContext;
29
import javax.script.ScriptEngine;
30
import javax.script.ScriptEngineManager;
31
import junit.framework.TestCase;
32
import org.openide.filesystems.FileObject;
33
import org.openide.filesystems.FileUtil;
34
import org.openide.filesystems.Repository;
35
36
/**
37
 *
38
 * @author Jaroslav Tulach
39
 */
40
public class ProcessorTest extends TestCase {
41
    FileObject root;
42
    
43
    public ProcessorTest(String testName) {
44
        super(testName);
45
    }
46
47
    protected void setUp() throws Exception {
48
        root = Repository.getDefault().getDefaultFileSystem().getRoot();
49
        for (FileObject f : root.getChildren()) {
50
            f.delete();
51
        }
52
    }
53
54
    protected void tearDown() throws Exception {
55
    }
56
57
    public void testApply() throws Exception {
58
        FileObject template = FileUtil.createData(root, "some.txt");
59
        OutputStream os = template.getOutputStream();
60
        String txt = "<html><h1>${title}</h1></html>";
61
        os.write(txt.getBytes());
62
        os.close();
63
        template.setAttribute("title", "Nazdar");
64
        
65
        StringWriter w = new StringWriter();
66
        
67
        apply(template, w);
68
        
69
        String exp = "<html><h1>Nazdar</h1></html>";
70
        assertEquals(exp, w.toString());
71
    }
72
73
    public void testCanHandleComplexData() throws Exception {
74
        Panel p = new Panel();
75
        p.setForeground(Color.BLUE);
76
        
77
        FileObject template = FileUtil.createData(root, "some.txt");
78
        OutputStream os = template.getOutputStream();
79
        String txt = "<html><h1>${panel.foreground.red} ${panel.foreground.green} ${panel.foreground.blue}</h1></html>";
80
        os.write(txt.getBytes());
81
        os.close();
82
        template.setAttribute("panel", p);
83
        
84
        StringWriter w = new StringWriter();
85
        
86
        apply(template, w);
87
        
88
        String exp = "<html><h1>0 0 255</h1></html>";
89
        assertEquals(exp, w.toString());
90
    }
91
    
92
    public void testCanHandleImport() throws Exception {
93
        Panel p = new Panel();
94
        p.setForeground(Color.BLUE);
95
96
        FileObject imp = FileUtil.createData(root, "import.txt");
97
        {
98
            OutputStream os = imp.getOutputStream();
99
            String txt = "${panel.foreground.blue}";
100
            os.write(txt.getBytes());
101
            os.close();
102
        }
103
        
104
        FileObject template = FileUtil.createData(root, "some.txt");
105
        {
106
            OutputStream os = template.getOutputStream();
107
            String txt = "<html><h1><#include \"import.txt\"></h1></html>";
108
            os.write(txt.getBytes());
109
            os.close();
110
            template.setAttribute("panel", p);
111
        }        
112
        StringWriter w = new StringWriter();
113
        
114
        apply(template, w);
115
        
116
        String exp = "<html><h1>255</h1></html>";
117
        assertEquals(exp, w.toString());
118
    }
119
    public void testImportCanInheritVariable() throws Exception {
120
        Panel p = new Panel();
121
        p.setForeground(Color.BLUE);
122
123
        FileObject imp = FileUtil.createData(root, "import.txt");
124
        {
125
            OutputStream os = imp.getOutputStream();
126
            String txt = "${prefix} First Line\n" +
127
                         "${prefix} Second Line\n";
128
            os.write(txt.getBytes());
129
            os.close();
130
        }
131
        
132
        FileObject template = FileUtil.createData(root, "some.txt");
133
        {
134
            OutputStream os = template.getOutputStream();
135
            String txt = "<#assign prefix = \"#\">" +
136
                         "<#include \"import.txt\">";
137
            os.write(txt.getBytes());
138
            os.close();
139
            template.setAttribute("panel", p);
140
        }        
141
        StringWriter w = new StringWriter();
142
        
143
        apply(template, w);
144
        
145
        String exp = "# First Line\n" +
146
                     "# Second Line\n";
147
        assertEquals(exp, w.toString());
148
    }
149
    public void testImportCanInheritVariableInSubFolder() throws Exception {
150
        Panel p = new Panel();
151
        p.setForeground(Color.BLUE);
152
153
        FileObject imp = FileUtil.createData(root, "sub/import.txt");
154
        {
155
            OutputStream os = imp.getOutputStream();
156
            String txt = "${prefix} First Line\n" +
157
                         "${prefix} Second Line\n";
158
            os.write(txt.getBytes());
159
            os.close();
160
        }
161
        
162
        FileObject template = FileUtil.createData(root, "sub/some.txt");
163
        {
164
            OutputStream os = template.getOutputStream();
165
            String txt = "<#assign prefix=\"#\">" +
166
                         "<#include \"import.txt\">";
167
            os.write(txt.getBytes());
168
            os.close();
169
            template.setAttribute("panel", p);
170
        }        
171
        StringWriter w = new StringWriter();
172
        
173
        apply(template, w);
174
        
175
        String exp = "# First Line\n" +
176
                     "# Second Line\n";
177
        assertEquals(exp, w.toString());
178
    }
179
    public void testAbilityToSendOwnTemplate() throws Exception {
180
        Map<String,Object> myValues = new HashMap<String, Object>();
181
        myValues.put("prefix", "#");
182
183
        FileObject template = FileUtil.createData(root, "some.txt");
184
        {
185
            OutputStream os = template.getOutputStream();
186
            String txt = "${prefix} First Line\n" +
187
                         "${prefix} Second Line\n";
188
            os.write(txt.getBytes());
189
            os.close();
190
            template.setAttribute("prefix", " * ");
191
        }        
192
        StringWriter w = new StringWriter();
193
        
194
        apply(template, w, myValues);
195
        
196
        String exp = "# First Line\n" +
197
                     "# Second Line\n";
198
        assertEquals(exp, w.toString());
199
    }
200
    
201
    private static void apply(FileObject template, Writer w) throws Exception {
202
        apply(template, w, Collections.<String,Object>emptyMap());
203
    }
204
    
205
    private static void apply(FileObject template, Writer w, Map<String,? extends Object> values) throws Exception {
206
        ScriptEngineManager mgr = new ScriptEngineManager();
207
        ScriptEngine eng = mgr.getEngineByName("freemarker");
208
        assertNotNull("We do have such engine", eng);
209
        eng.getContext().setWriter(w);
210
        eng.getContext().setAttribute(FileObject.class.getName(), template, ScriptContext.ENGINE_SCOPE);
211
        eng.getContext().getBindings(ScriptContext.ENGINE_SCOPE).putAll(values);
212
        eng.eval(new InputStreamReader(template.getInputStream()));
213
    }
214
    
215
}

Return to bug 13250