/** Set the template status of this data object. * @param newTempl <code>true</code> if the object should be a template * @exception IOException if setting the template state fails */ public final void setTemplate (boolean newTempl) throws IOException { if (!setTemplate (getPrimaryFile(), newTempl)) { // no change in state return; } firePropertyChange(DataObject.PROP_TEMPLATE, !newTempl ? Boolean.TRUE : Boolean.FALSE, newTempl ? Boolean.TRUE : Boolean.FALSE); }
DataObject.setTemplate (fo, false);
/** Performs the work of creating a new template */ private void createNewTemplate(DataObject source, DataFolder targetFolder) { try { SaveCookie cookie = (SaveCookie)source.getCookie (SaveCookie.class); if (cookie != null) { cookie.save (); } DataObject newTemplate = source.copy(targetFolder); newTemplate.setTemplate(true); } catch (IOException ex) { ErrorManager.getDefault().notify(ex); } }
template.setTemplate(true); if (shouldSetScriptEngine) { if (templateSample == null) {
public FileObject createFromTemplate (FileObject f, String name) throws IOException { if (name == null) { name = FileUtil.findFreeFileName( f, getFile ().getName (), getFile ().getExt () ); } FileObject fo = getFile().copy (f, name, getFile().getExt ()); // unmark template state DataObject.setTemplate (fo, false); return fo; }
/** Creates new folder and copies attributes, the template flag is cleared. * @param f the folder to create this entry in * @param name the new name to use * @return the copied <code>FileObject</code> or <code>null</code> if it cannot be copied * @exception IOException when the operation fails */ public FileObject createFromTemplate (FileObject f, String name) throws IOException { if (name == null) { name = FileUtil.findFreeFileName( f, getFile ().getName (), getFile ().getExt () ); } FileObject fo = FileUtil.createFolder (f, name); FileUtil.copyAttributes (getFile (), fo); DataObject.setTemplate (fo, false); return fo; }