Class TemplateHelper
- java.lang.Object
-
- com.nomagic.magicdraw.magicreport.helper.TemplateHelper
-
@OpenApiAll public class TemplateHelper extends java.lang.Object
Provide helper methods for template such as create and save.- Since:
- May 10, 2007
-
-
Field Summary
Fields Modifier and Type Field Description private static int
BUFFER
private static javax.xml.parsers.DocumentBuilder
cachedDocumentBuilder
private static java.util.List<com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean>
cachedTemplateList
private static java.util.Comparator<com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean>
COMPARATOR_TEMPLATEBEAN_BY_DATE_MODIFIED
private static java.lang.String
CONFIG_FILE
static java.lang.String
DBK
Constants for Default DOCBOOK type.static java.lang.String
DESCRIPTOR_FILE
static java.lang.String
DOCBOOK
Constants for DOCBOOK type.static java.lang.String
DOCX
Constants for DOCX type.static java.lang.String
HTML
Constants for HTML type.static org.apache.logging.log4j.Logger
LOG
static java.lang.String
ODP
Constants for ODP type.static java.lang.String
ODS
Constants for ODS type.static java.lang.String
ODT
Constants for ODT type.static java.lang.String
PPTX
Constants for PPTX type.static java.lang.String
PROPERTY_CREATE
static java.lang.String
PROPERTY_DELETE
Delete property name.static java.lang.String
PROPERTY_RELOAD
Reload property name.static java.lang.String
PROPERTY_SAVE
Save property name.private static java.util.List<java.beans.PropertyChangeListener>
propertyChangeListenerList
private static java.lang.String
REPORT_DATA_DIR_NAME
private static java.lang.String
REPORT_DIR
private static java.lang.String
REPORT_PROPERTIES_FILE_NAME
private static java.lang.String
REPORT_PROPERTIES_TEMPLATE_LOC
static java.lang.String
RTF
Constants for RTF type.static java.lang.String
TEMPLATE_EXTENSION
Constants for template extension.static java.lang.String
TXT
Constants for TXT type.static java.lang.String
XLSX
Constants for XLSX type.static java.lang.String
XML
Constants for XML type.
-
Constructor Summary
Constructors Constructor Description TemplateHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Register a listener for the PropertyChange event.private static void
addTemplateToCachedList(com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean templateBean)
static boolean
checkEdition(com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean bean, com.nomagic.magicdraw.lic.MDVersion version)
Return true if this template is valid to MDVersion.static java.lang.String
checkRequiredPlugins(com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean bean)
static void
clearCachedElements()
private static void
createCachedDocumentBuilder()
private static javax.xml.parsers.DocumentBuilder
createDocumentBuilder()
static java.io.File
createTemplateFile(com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean templateBean)
Create a directory or file from given template bean.static java.io.File
createTemplateFile(java.lang.String templateName)
Create a directory or file from given template name.static javax.swing.Icon
createTemplateIcon(com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean templateBean)
Create and return icon for this template bean.static void
exportZip(java.io.File zipFile, com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean templateBean)
Export template bean to zip file with default progress status.static void
exportZip(java.io.File zipFile, com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean templateBean, ProgressStatus progress)
Export template bean to zip file.static boolean
extractZip(java.io.File zipFile, java.io.File destinationDir, ProgressStatus progress)
static com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean
findTemplateBean(java.lang.String catName, java.lang.String templName)
Get the templateBean by given category name and template name.static void
firePropertyChange(java.beans.PropertyChangeEvent evt)
Fire an existing PropertyChangeEvent to any registered listeners.static void
firePropertyChange(java.lang.Object source, java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)
Report a bound property update to any registered listeners.static java.util.Set<java.io.File>
getCustomTemplateLocations()
Get custom location that store template.static java.lang.String
getDefaultReportKey(com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean templateBean)
Return a key for default report preference.private static javax.xml.parsers.DocumentBuilder
getDocumentBuilder()
static ResizableIcon
getIconByFileExtension(java.lang.String ext)
static java.lang.String
getOutputReportKey(com.nomagic.magicdraw.magicreport.ui.bean.ReportBean reportBean)
Return a key for output report preference.static com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean
getTemplateBean(java.lang.String path)
Return existing template bean from the template path.static com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean
getTemplateBeanByName(java.lang.String catName, java.lang.String templateName)
Get template bean by category name and template namestatic java.io.File
getTemplateFile(com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean templateBean)
static java.io.File
getTemplateFile(com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean templateBean, boolean revolveDir)
static java.lang.String
getTemplateType(java.lang.String extension)
Consider template type from file extension.static java.lang.String
getViewerReportKey(com.nomagic.magicdraw.magicreport.ui.bean.ReportBean reportBean)
Return a key for viewer report preference.static com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean
importZip(java.io.File zipFile, boolean copyToData)
Import zip file to template bean.static com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean
importZip(java.io.File zipFile, boolean copyToData, ProgressStatus progress)
Import zip file to template bean.static boolean
isFileExternal(java.io.File file, com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean templateBean)
static java.util.List<com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean>
listAvailableTemplates(com.nomagic.magicdraw.lic.MDVersion version, com.nomagic.magicdraw.usermodes.UserMode userMode)
Return a list of available template to MDVersion and Perspective.static void
listMRZipTemplates()
Load and Unzip MRZip template file from template directory.static java.util.List<com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean>
listTemplates()
This method will automatically load all template file from "data" directory of report plugin and return a List ofTemplateBean
.static java.util.List<com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean>
listTemplates(boolean forceReload)
Load all template files from report plugin "data" directory and return to List ofTemplateBean
.private static java.util.Properties
loadProperties(java.io.InputStream inStream)
This function is create for read a property list (key and element pairs) from the input stream and set property.private static java.util.Properties
loadPropertiesFromFile(java.io.File pFile)
static com.nomagic.magicdraw.magicreport.ui.bean.ReportBean
loadReport(java.io.File reportFile)
Create aReportBean
from given reportFile.static void
loadReportDataAndConfig(java.io.File templateDir, com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean templateBean)
static com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean
loadTemplate(java.io.File templateFile)
Create aTemplateBean
from given templateFile.static com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean
loadTemplate(java.io.File templateFile, boolean checkValid)
Create aTemplateBean
from given templateFile.static void
loadTemplateBean(com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean templateBean, org.w3c.dom.Document document)
static com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean
loadTemplateBean(java.io.File file)
private static void
loadTemplatesFromDir(java.io.File dataDir)
static com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean
reloadTemplate(com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean templateBean)
Force the application to remove this template from cache and then reload it from file.static void
removeImportHistory(java.io.File[] importedMrzipFiles)
static void
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Remove a listener for the PropertyChange event.static void
removeTemplate(com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean templateBean)
Delete a template file from physical storage.private static void
removeTemplateFile(java.io.File templateFile)
private static java.util.List<com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean>
renameDuplicatedTemplates(java.util.List<com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean> templates)
Search and rename duplicated template.static void
saveReport(com.nomagic.magicdraw.magicreport.ui.bean.ReportBean reportBean)
Create a new report file from ReportBean.static void
saveReport(com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean templateBean, com.nomagic.magicdraw.magicreport.ui.bean.ReportBean reportBean)
Create a new report file from ReportBean.static void
saveTemplate(com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean templateBean)
Create a new template file from TemplateBean.private static void
saveTemplateBean(java.io.File file, com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean templateBean, boolean updateCache)
private static java.util.List<java.lang.String>
splitPropertyValue(java.lang.String input)
Break a string into tokens.private static void
unzipMRZipFile(java.io.File mrzipFile)
Unzip MRZip file to template folder.static void
unzipMRZipTemplates(java.io.File[] mrZipFile)
Unzip MRZip Templates files.
-
-
-
Field Detail
-
TEMPLATE_EXTENSION
public static final java.lang.String TEMPLATE_EXTENSION
Constants for template extension.- See Also:
- Constant Field Values
-
PROPERTY_SAVE
public static final java.lang.String PROPERTY_SAVE
Save property name.- See Also:
- Constant Field Values
-
PROPERTY_DELETE
public static final java.lang.String PROPERTY_DELETE
Delete property name.- See Also:
- Constant Field Values
-
PROPERTY_CREATE
public static final java.lang.String PROPERTY_CREATE
- See Also:
- Constant Field Values
-
PROPERTY_RELOAD
public static final java.lang.String PROPERTY_RELOAD
Reload property name.- See Also:
- Constant Field Values
-
HTML
public static final java.lang.String HTML
Constants for HTML type.- See Also:
- Constant Field Values
-
RTF
public static final java.lang.String RTF
Constants for RTF type.- See Also:
- Constant Field Values
-
XML
public static final java.lang.String XML
Constants for XML type.- See Also:
- Constant Field Values
-
TXT
public static final java.lang.String TXT
Constants for TXT type.- See Also:
- Constant Field Values
-
ODT
public static final java.lang.String ODT
Constants for ODT type.- See Also:
- Constant Field Values
-
ODS
public static final java.lang.String ODS
Constants for ODS type.- See Also:
- Constant Field Values
-
ODP
public static final java.lang.String ODP
Constants for ODP type.- See Also:
- Constant Field Values
-
DOCX
public static final java.lang.String DOCX
Constants for DOCX type.- See Also:
- Constant Field Values
-
XLSX
public static final java.lang.String XLSX
Constants for XLSX type.- See Also:
- Constant Field Values
-
PPTX
public static final java.lang.String PPTX
Constants for PPTX type.- See Also:
- Constant Field Values
-
DBK
public static final java.lang.String DBK
Constants for Default DOCBOOK type.- See Also:
- Constant Field Values
-
DOCBOOK
public static final java.lang.String DOCBOOK
Constants for DOCBOOK type.- See Also:
- Constant Field Values
-
DESCRIPTOR_FILE
public static final java.lang.String DESCRIPTOR_FILE
- See Also:
- Constant Field Values
-
LOG
public static final org.apache.logging.log4j.Logger LOG
-
REPORT_DIR
private static final java.lang.String REPORT_DIR
- See Also:
- Constant Field Values
-
REPORT_DATA_DIR_NAME
private static final java.lang.String REPORT_DATA_DIR_NAME
- See Also:
- Constant Field Values
-
REPORT_PROPERTIES_FILE_NAME
private static final java.lang.String REPORT_PROPERTIES_FILE_NAME
- See Also:
- Constant Field Values
-
REPORT_PROPERTIES_TEMPLATE_LOC
private static final java.lang.String REPORT_PROPERTIES_TEMPLATE_LOC
- See Also:
- Constant Field Values
-
CONFIG_FILE
private static final java.lang.String CONFIG_FILE
- See Also:
- Constant Field Values
-
cachedTemplateList
private static volatile java.util.List<com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean> cachedTemplateList
-
propertyChangeListenerList
private static final java.util.List<java.beans.PropertyChangeListener> propertyChangeListenerList
-
BUFFER
private static final int BUFFER
- See Also:
- Constant Field Values
-
cachedDocumentBuilder
private static javax.xml.parsers.DocumentBuilder cachedDocumentBuilder
-
COMPARATOR_TEMPLATEBEAN_BY_DATE_MODIFIED
private static final java.util.Comparator<com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean> COMPARATOR_TEMPLATEBEAN_BY_DATE_MODIFIED
-
-
Method Detail
-
listTemplates
public static java.util.List<com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean> listTemplates()
This method will automatically load all template file from "data" directory of report plugin and return a List ofTemplateBean
.TemplateBean
is a container of template information.- Returns:
- a List of
TemplateBean
from "data" directory. - Throws:
java.security.AccessControlException
- when unable to locate and create directory for data- See Also:
listTemplates(boolean)
,listAvailableTemplates(MDVersion, UserMode)
-
listAvailableTemplates
public static java.util.List<com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean> listAvailableTemplates(@CheckForNull com.nomagic.magicdraw.lic.MDVersion version, @CheckForNull com.nomagic.magicdraw.usermodes.UserMode userMode)
Return a list of available template to MDVersion and Perspective.- Parameters:
version
- MDVersionuserMode
- UserMode- Returns:
- a list of available template after filter out
- See Also:
listTemplates()
-
checkEdition
public static boolean checkEdition(com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean bean, @CheckForNull com.nomagic.magicdraw.lic.MDVersion version)
Return true if this template is valid to MDVersion.- Parameters:
version
- MDVersion- Returns:
- true if this template is valid to given MDVersion; otherwise false.
-
checkRequiredPlugins
public static java.lang.String checkRequiredPlugins(com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean bean)
- Returns:
- empty string if all required plugins are ok. Otherwise, a multiline info message for each missing/outdated plugin
-
addPropertyChangeListener
public static void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Register a listener for the PropertyChange event. When a Template changes its value it should fire a PropertyChange event on all registered PropertyChangeListeners.- Parameters:
listener
- An object to be invoked when a PropertyChange event is fired.
-
removePropertyChangeListener
public static void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Remove a listener for the PropertyChange event.- Parameters:
listener
- The PropertyChange listener to be removed.
-
firePropertyChange
public static void firePropertyChange(java.lang.Object source, java.lang.String propertyName, @CheckForNull java.lang.Object oldValue, java.lang.Object newValue)
Report a bound property update to any registered listeners. No event is fired if old and new are equal and non-null.- Parameters:
source
- property sourcepropertyName
- The programmatic name of the property that was changed.oldValue
- The old value of the property.newValue
- The new value of the property.
-
firePropertyChange
public static void firePropertyChange(java.beans.PropertyChangeEvent evt)
Fire an existing PropertyChangeEvent to any registered listeners. No event is fired if the given event's old and new values are equal and non-null.- Parameters:
evt
- The PropertyChangeEvent object.
-
listTemplates
public static java.util.List<com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean> listTemplates(boolean forceReload)
Load all template files from report plugin "data" directory and return to List ofTemplateBean
.- Parameters:
forceReload
- true if you want this method to reload template from disk; false use template from cache.- Returns:
- a List of
TemplateBean
from "data" directory. - Throws:
java.security.AccessControlException
- when unable to locate and create directory for data- See Also:
listTemplates()
-
loadPropertiesFromFile
@CheckForNull private static java.util.Properties loadPropertiesFromFile(java.io.File pFile)
-
loadProperties
private static java.util.Properties loadProperties(java.io.InputStream inStream) throws java.io.IOException
This function is create for read a property list (key and element pairs) from the input stream and set property.- Parameters:
inStream
- the stream of properties file to load- Returns:
- Properties properties
- Throws:
java.io.IOException
- IOException might be throw
-
splitPropertyValue
private static java.util.List<java.lang.String> splitPropertyValue(java.lang.String input)
Break a string into tokens. Token delimiter is ';' character. The delimiter can be escaped by insert '\' before ';' character.- Parameters:
input
- a string to be parsed.- Returns:
- token of string
-
renameDuplicatedTemplates
private static java.util.List<com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean> renameDuplicatedTemplates(java.util.List<com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean> templates)
Search and rename duplicated template. The new name will be DupName (0), DupName (1), ... Note: This method only sort templates and rename the argument template but does not save templates to file.- Parameters:
templates
- list of template to rename
-
loadTemplatesFromDir
private static void loadTemplatesFromDir(java.io.File dataDir)
-
createDocumentBuilder
private static javax.xml.parsers.DocumentBuilder createDocumentBuilder() throws javax.xml.parsers.ParserConfigurationException
- Throws:
javax.xml.parsers.ParserConfigurationException
-
createCachedDocumentBuilder
private static void createCachedDocumentBuilder()
-
getDocumentBuilder
private static javax.xml.parsers.DocumentBuilder getDocumentBuilder() throws javax.xml.parsers.ParserConfigurationException
- Throws:
javax.xml.parsers.ParserConfigurationException
-
listMRZipTemplates
public static void listMRZipTemplates()
Load and Unzip MRZip template file from template directory.
-
unzipMRZipTemplates
public static void unzipMRZipTemplates(java.io.File[] mrZipFile)
Unzip MRZip Templates files.- Parameters:
mrZipFile
- file
-
unzipMRZipFile
private static void unzipMRZipFile(java.io.File mrzipFile)
Unzip MRZip file to template folder.- Parameters:
mrzipFile
- MRZip file
-
removeImportHistory
public static void removeImportHistory(java.io.File[] importedMrzipFiles)
-
removeTemplateFile
private static void removeTemplateFile(java.io.File templateFile)
-
reloadTemplate
public static com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean reloadTemplate(com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean templateBean)
Force the application to remove this template from cache and then reload it from file.- Parameters:
templateBean
- a target template- Returns:
- TemplateBean or null if invalid template file format.
-
getTemplateBean
public static com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean getTemplateBean(java.lang.String path)
Return existing template bean from the template path.- Parameters:
path
- path of templateTemplateBean.getPath()
- Returns:
- the
TemplateBean
-
getTemplateBeanByName
public static com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean getTemplateBeanByName(java.lang.String catName, java.lang.String templateName)
Get template bean by category name and template name- Parameters:
catName
- template category nametemplateName
- template name- Returns:
- template bean
-
loadTemplate
public static com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean loadTemplate(java.io.File templateFile)
Create aTemplateBean
from given templateFile. If template file is not valid template format, return null.- Parameters:
templateFile
- a File for template- Returns:
- TemplateBean or null if invalid template file format.
-
loadTemplate
@CheckForNull public static com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean loadTemplate(java.io.File templateFile, boolean checkValid) throws com.nomagic.magicreport.TemplateException
Create aTemplateBean
from given templateFile. If template file is not valid template format, return null.- Parameters:
templateFile
- a File for templatecheckValid
- true if this template file require format checking- Returns:
- TemplateBean or null if invalid template file format.
- Throws:
com.nomagic.magicreport.TemplateException
- if the template file is not valid format and check parameter is true.
-
loadReportDataAndConfig
public static void loadReportDataAndConfig(java.io.File templateDir, com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean templateBean)
-
importZip
public static com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean importZip(java.io.File zipFile, boolean copyToData) throws java.io.IOException
Import zip file to template bean.- Parameters:
zipFile
- an input zip file.copyToData
- copy template to data folder after successfully extract.- Returns:
- templateBean a template bean
- Throws:
java.io.IOException
- when unable to import zip file.- See Also:
importZip(File, boolean, ProgressStatus)
-
importZip
@CheckForNull public static com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean importZip(java.io.File zipFile, boolean copyToData, ProgressStatus progress) throws java.io.IOException
Import zip file to template bean.- Parameters:
zipFile
- an input zip file.copyToData
- copy template to data folder after successfully extract.progress
- the progress status- Returns:
- templateBean a template bean
- Throws:
java.io.IOException
- when unable to import zip file.- See Also:
importZip(File, boolean)
-
extractZip
public static boolean extractZip(java.io.File zipFile, java.io.File destinationDir, ProgressStatus progress) throws java.io.IOException
- Throws:
java.io.IOException
-
exportZip
public static void exportZip(java.io.File zipFile, com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean templateBean) throws java.io.IOException
Export template bean to zip file with default progress status.- Parameters:
zipFile
- a output zip file.templateBean
- a template bean- Throws:
java.io.IOException
- when unable to export zip file.- See Also:
exportZip(File, TemplateBean, ProgressStatus)
-
exportZip
public static void exportZip(java.io.File zipFile, com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean templateBean, ProgressStatus progress) throws java.io.IOException
Export template bean to zip file.- Parameters:
zipFile
- a output zip file.templateBean
- a template beanprogress
- the progress status- Throws:
java.io.IOException
- when unable to export zip file.- See Also:
exportZip(File, TemplateBean)
-
isFileExternal
public static boolean isFileExternal(java.io.File file, com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean templateBean)
- Parameters:
templateBean
-file
- to check- Returns:
- true if checked file resides outside the template package
-
getTemplateFile
public static java.io.File getTemplateFile(com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean templateBean)
-
getTemplateFile
public static java.io.File getTemplateFile(com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean templateBean, boolean revolveDir)
-
loadReport
public static com.nomagic.magicdraw.magicreport.ui.bean.ReportBean loadReport(java.io.File reportFile)
Create aReportBean
from given reportFile. If report file is not valid report format, return null.- Parameters:
reportFile
- a File for report- Returns:
- ReportBean or null if invalid report file format.
-
saveTemplate
public static void saveTemplate(com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean templateBean) throws java.io.IOException
Create a new template file from TemplateBean. IfTemplateBean.getPath()
exists, write a template file to this value; if value doesn't exists create a new file withTemplateBean.getName()
as template filename.- Parameters:
templateBean
- a Template Bean- Throws:
java.io.IOException
- if the template was not successfully created
-
saveTemplateBean
private static void saveTemplateBean(java.io.File file, com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean templateBean, boolean updateCache) throws java.io.IOException
- Throws:
java.io.IOException
-
addTemplateToCachedList
private static void addTemplateToCachedList(com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean templateBean)
-
loadTemplateBean
public static com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean loadTemplateBean(java.io.File file) throws java.io.IOException
- Throws:
java.io.IOException
-
loadTemplateBean
public static void loadTemplateBean(com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean templateBean, org.w3c.dom.Document document) throws java.io.IOException
- Throws:
java.io.IOException
-
saveReport
public static void saveReport(com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean templateBean, com.nomagic.magicdraw.magicreport.ui.bean.ReportBean reportBean) throws java.io.IOException
Create a new report file from ReportBean. IfReportBean.getFileName()
exists, write a report file to this value; if value doesn't exists create a new file withTemplateBean.getName()
as template filename.- Parameters:
templateBean
- a TemplateBeanreportBean
- a ReportBean- Throws:
java.io.IOException
- if the template was not successfully created
-
saveReport
public static void saveReport(com.nomagic.magicdraw.magicreport.ui.bean.ReportBean reportBean) throws java.io.IOException
Create a new report file from ReportBean. IfReportBean.getFileName()
exists, write a report file to this value; if value doesn't exists throw IOException.- Parameters:
reportBean
- a ReportBean- Throws:
java.io.IOException
- if the report was not successfully created
-
removeTemplate
public static void removeTemplate(com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean templateBean) throws java.io.IOException
Delete a template file from physical storage. Physical storage meaning that template file will not be able to recovery after successfully deleted.- Parameters:
templateBean
- a Template Bean- Throws:
java.io.IOException
- if the template was not successfully deleted
-
createTemplateFile
public static java.io.File createTemplateFile(com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean templateBean) throws java.io.IOException
Create a directory or file from given template bean. This method use template name as a directory name.- Parameters:
templateBean
- a template bean- Returns:
- File references to template bean
- Throws:
java.io.IOException
- if false to create directory.
-
createTemplateFile
public static java.io.File createTemplateFile(java.lang.String templateName) throws java.io.IOException
Create a directory or file from given template name.- Parameters:
templateName
- a template name- Returns:
- File references to template bean
- Throws:
java.io.IOException
- if false to create directory.
-
findTemplateBean
public static com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean findTemplateBean(@CheckForNull java.lang.String catName, java.lang.String templName)
Get the templateBean by given category name and template name.- Parameters:
catName
- categoryName or nulltemplName
- the template name- Returns:
- the TemplateBean
-
getTemplateType
public static java.lang.String getTemplateType(java.lang.String extension)
Consider template type from file extension.- Parameters:
extension
- a file extension.- Returns:
- a template type.
-
createTemplateIcon
public static javax.swing.Icon createTemplateIcon(com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean templateBean)
Create and return icon for this template bean.- Parameters:
templateBean
- a template bean- Returns:
- template icon
-
getIconByFileExtension
public static ResizableIcon getIconByFileExtension(java.lang.String ext)
-
getDefaultReportKey
public static java.lang.String getDefaultReportKey(com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean templateBean) throws java.lang.IllegalArgumentException
Return a key for default report preference. A key is a concatenation of#hashCode()
and ";default".- Parameters:
templateBean
- a template bean- Returns:
- a key.
- Throws:
java.lang.IllegalArgumentException
- illegal argument is used.
-
getOutputReportKey
public static java.lang.String getOutputReportKey(com.nomagic.magicdraw.magicreport.ui.bean.ReportBean reportBean) throws java.lang.IllegalArgumentException
Return a key for output report preference. A key is a concatenation of {@link ReportBean#getModel()#getID()} and ";output" or {@link ReportBean#getFileName()#hashCode()} + ";output".- Parameters:
reportBean
- a report bean- Returns:
- a key.
- Throws:
java.lang.IllegalArgumentException
- illegal argument is used.
-
getViewerReportKey
public static java.lang.String getViewerReportKey(com.nomagic.magicdraw.magicreport.ui.bean.ReportBean reportBean) throws java.lang.IllegalArgumentException
Return a key for viewer report preference. A key is a concatenation of {@link ReportBean#getModel()#getID()} and ";viewer" or {@link ReportBean#getFileName()#hashCode()} + ";viewer".- Parameters:
reportBean
- a report bean- Returns:
- a key.
- Throws:
java.lang.IllegalArgumentException
- illegal argument is used.
-
getCustomTemplateLocations
public static java.util.Set<java.io.File> getCustomTemplateLocations()
Get custom location that store template.- Returns:
- list of custom location
-
clearCachedElements
public static void clearCachedElements()
-
-