Index: utilities/src/org/netbeans/modules/group/GroupShadow.java =================================================================== RCS file: /cvs/utilities/src/org/netbeans/modules/group/GroupShadow.java,v retrieving revision 1.29 diff -u -r1.29 GroupShadow.java --- utilities/src/org/netbeans/modules/group/GroupShadow.java 27 Feb 2002 14:51:22 -0000 1.29 +++ utilities/src/org/netbeans/modules/group/GroupShadow.java 15 May 2002 17:38:05 -0000 @@ -96,39 +96,19 @@ /** Generated serial version UID. */ static final long serialVersionUID =-5086491126656157958L; + private static TemplateWizard.Iterator groupTemplateIterator = null; + private static synchronized TemplateWizard.Iterator getGroupTemplateIterator() { + if (groupTemplateIterator == null) { + groupTemplateIterator = new GroupTemplateIterator(); + } + return groupTemplateIterator; + } + /** Constructs group shadow data object. */ public GroupShadow(final FileObject fo, DataLoader dl) throws DataObjectExistsException, IllegalArgumentException, IOException { super(fo, dl); - - if (isTemplate() && TemplateWizard.getIterator(this) == null - && !fo.isReadOnly()) - try { - TemplateWizard.setIterator(this, new GroupTemplateIterator()); - } catch (IOException ioe) { - if(Boolean.getBoolean("netbeans.debug.exceptions")) { // NOI18N - System.err.println("[WARNING] Cannot attach template iterator to "+fo.getName()+" group."); // NOI18N - ioe.printStackTrace(); - } - } - - // track changes when dataobject becomes template; listener is - // attached all the time (filesystem attributes could be deleted...) - addPropertyChangeListener(new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent evt) { - if (DataObject.PROP_TEMPLATE.equals(evt.getPropertyName()) - && new Boolean(true).equals(evt.getNewValue())) { - try { - if (TemplateWizard.getIterator(GroupShadow.this) == null) - TemplateWizard.setIterator(GroupShadow.this, - new GroupTemplateIterator()); - } - catch (IOException ex) { // do nothing... - } - } - } - }); } @@ -226,11 +206,13 @@ /** Adds a {@link CompilerCookie compilation cookie}. */ public Node.Cookie getCookie (Class cookie) { - if (CompilerCookie.class.isAssignableFrom (cookie)) { - GroupShadowCompiler c = new GroupShadowCompiler (this, cookie); - return c; + if (cookie.isAssignableFrom(GroupShadowCompiler.class)) { + return new GroupShadowCompiler (this, cookie); + } else if (cookie == TemplateWizard.Iterator.class) { + return getGroupTemplateIterator(); + } else { + return super.getCookie (cookie); } - return super.getCookie (cookie); } /** Reads whole file to the List.