@OpenApiAll
public class TemplateHelper
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
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.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.
|
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 and Description |
---|
TemplateHelper() |
Modifier and Type | Method and Description |
---|---|
static void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Register a listener for the PropertyChange event.
|
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 java.io.File |
createTemplateFile(java.lang.String templateName)
Create a directory or file from given template name.
|
static java.io.File |
createTemplateFile(com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean templateBean)
Create a directory or file from given template bean.
|
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 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 void |
firePropertyChange(java.beans.PropertyChangeEvent evt)
Fire an existing PropertyChangeEvent to any registered listeners.
|
static java.lang.String |
getDefaultReportKey(com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean templateBean)
Return a key for default report preference.
|
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 name
|
static 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 of
TemplateBean . |
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 of
TemplateBean . |
static com.nomagic.magicdraw.magicreport.ui.bean.ReportBean |
loadReport(java.io.File reportFile)
Create a
ReportBean 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 a
TemplateBean from given templateFile. |
static com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean |
loadTemplate(java.io.File templateFile,
boolean checkValid)
Create a
TemplateBean from given templateFile. |
static com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean |
loadTemplateBean(java.io.File file) |
static void |
loadTemplateBean(com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean templateBean,
org.w3c.dom.Document document) |
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.
|
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.
|
static void |
unzipMRZipTemplates(java.io.File[] mrZipFile)
Unzip MRZip Templates files.
|
public static final java.lang.String TEMPLATE_EXTENSION
public static final java.lang.String PROPERTY_SAVE
public static final java.lang.String PROPERTY_DELETE
public static final java.lang.String PROPERTY_CREATE
public static final java.lang.String PROPERTY_RELOAD
public static final java.lang.String HTML
public static final java.lang.String RTF
public static final java.lang.String XML
public static final java.lang.String TXT
public static final java.lang.String ODT
public static final java.lang.String ODS
public static final java.lang.String ODP
public static final java.lang.String DOCX
public static final java.lang.String XLSX
public static final java.lang.String PPTX
public static final java.lang.String DBK
public static final java.lang.String DOCBOOK
public static org.apache.log4j.Logger LOG
public static final java.lang.String DESCRIPTOR_FILE
public static java.util.List<com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean> listTemplates()
TemplateBean
. TemplateBean
is a container of template information.TemplateBean
from "data" directory.java.security.AccessControlException
- when unable to locate and create directory for datalistTemplates(boolean)
,
listAvailableTemplates(MDVersion, UserMode)
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)
version
- MDVersionuserMode
- UserModelistTemplates()
public static boolean checkEdition(com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean bean, @CheckForNull com.nomagic.magicdraw.lic.MDVersion version)
version
- MDVersionpublic static java.lang.String checkRequiredPlugins(com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean bean)
public static void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- An object to be invoked when a PropertyChange event is fired.public static void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- The PropertyChange listener to be removed.public static void firePropertyChange(java.lang.Object source, java.lang.String propertyName, @CheckForNull java.lang.Object oldValue, java.lang.Object newValue)
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.public static void firePropertyChange(java.beans.PropertyChangeEvent evt)
evt
- The PropertyChangeEvent object.public static java.util.List<com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean> listTemplates(boolean forceReload)
TemplateBean
.forceReload
- true if you want this method to reload template from disk; false use template from cache.TemplateBean
from "data" directory.java.security.AccessControlException
- when unable to locate and create directory for datalistTemplates()
public static void listMRZipTemplates()
public static void unzipMRZipTemplates(java.io.File[] mrZipFile)
mrZipFile
- filepublic static void removeImportHistory(java.io.File[] importedMrzipFiles)
public static com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean reloadTemplate(com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean templateBean)
templateBean
- a target templatepublic static com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean getTemplateBean(java.lang.String path)
path
- path of template TemplateBean.getPath()
TemplateBean
public static com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean getTemplateBeanByName(java.lang.String catName, java.lang.String templateName)
catName
- template category nametemplateName
- template namepublic static com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean loadTemplate(java.io.File templateFile)
TemplateBean
from given templateFile. If template file is not valid template format, return
null.templateFile
- a File for template@CheckForNull public static com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean loadTemplate(java.io.File templateFile, boolean checkValid) throws com.nomagic.magicreport.TemplateException
TemplateBean
from given templateFile. If template file is not valid template format, return
null.templateFile
- a File for templatecheckValid
- true if this template file require format checkingcom.nomagic.magicreport.TemplateException
- if the template file is not valid format and check parameter is true.public static void loadReportDataAndConfig(java.io.File templateDir, com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean templateBean)
public static com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean importZip(java.io.File zipFile, boolean copyToData) throws java.io.IOException
zipFile
- an input zip file.copyToData
- copy template to data folder after successfully extract.java.io.IOException
- when unable to import zip file.importZip(File, boolean, ProgressStatus)
@CheckForNull public static com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean importZip(java.io.File zipFile, boolean copyToData, ProgressStatus progress) throws java.io.IOException
zipFile
- an input zip file.copyToData
- copy template to data folder after successfully extract.progress
- the progress statusjava.io.IOException
- when unable to import zip file.importZip(File, boolean)
public static boolean extractZip(java.io.File zipFile, java.io.File destinationDir, ProgressStatus progress) throws java.io.IOException
java.io.IOException
public static void exportZip(java.io.File zipFile, com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean templateBean) throws java.io.IOException
zipFile
- a output zip file.templateBean
- a template beanjava.io.IOException
- when unable to export zip file.exportZip(File, TemplateBean, ProgressStatus)
public static void exportZip(java.io.File zipFile, com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean templateBean, ProgressStatus progress) throws java.io.IOException
zipFile
- a output zip file.templateBean
- a template beanprogress
- the progress statusjava.io.IOException
- when unable to export zip file.exportZip(File, TemplateBean)
public static boolean isFileExternal(java.io.File file, com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean templateBean)
templateBean
- file
- to checkpublic static java.io.File getTemplateFile(com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean templateBean)
public static java.io.File getTemplateFile(com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean templateBean, boolean revolveDir)
public static com.nomagic.magicdraw.magicreport.ui.bean.ReportBean loadReport(java.io.File reportFile)
ReportBean
from given reportFile. If report file is not valid report format, return null.reportFile
- a File for reportpublic static void saveTemplate(com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean templateBean) throws java.io.IOException
TemplateBean.getPath()
exists, write a template
file to this value; if value doesn't exists create a new file with TemplateBean.getName()
as
template filename.templateBean
- a Template Beanjava.io.IOException
- if the template was not successfully createdpublic static com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean loadTemplateBean(java.io.File file) throws java.io.IOException
java.io.IOException
public static void loadTemplateBean(com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean templateBean, org.w3c.dom.Document document) throws java.io.IOException
java.io.IOException
public static void saveReport(com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean templateBean, com.nomagic.magicdraw.magicreport.ui.bean.ReportBean reportBean) throws java.io.IOException
ReportBean.getFileName()
exists, write a report file to
this value; if value doesn't exists create a new file with TemplateBean.getName()
as template
filename.templateBean
- a TemplateBeanreportBean
- a ReportBeanjava.io.IOException
- if the template was not successfully createdpublic static void saveReport(com.nomagic.magicdraw.magicreport.ui.bean.ReportBean reportBean) throws java.io.IOException
ReportBean.getFileName()
exists, write a report file to
this value; if value doesn't exists throw IOException.reportBean
- a ReportBeanjava.io.IOException
- if the report was not successfully createdpublic static void removeTemplate(com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean templateBean) throws java.io.IOException
templateBean
- a Template Beanjava.io.IOException
- if the template was not successfully deletedpublic static java.io.File createTemplateFile(com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean templateBean) throws java.io.IOException
templateBean
- a template beanjava.io.IOException
- if false to create directory.public static java.io.File createTemplateFile(java.lang.String templateName) throws java.io.IOException
templateName
- a template namejava.io.IOException
- if false to create directory.public static java.lang.String getTemplateType(java.lang.String extension)
extension
- a file extension.public static javax.swing.Icon createTemplateIcon(com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean templateBean)
templateBean
- a template beanpublic static java.lang.String getDefaultReportKey(com.nomagic.magicdraw.magicreport.ui.bean.TemplateBean templateBean) throws java.lang.IllegalArgumentException
#hashCode()
and ";default".templateBean
- a template beanjava.lang.IllegalArgumentException
- illegal argument is used.public static java.lang.String getOutputReportKey(com.nomagic.magicdraw.magicreport.ui.bean.ReportBean reportBean) throws java.lang.IllegalArgumentException
ReportBean#getModel()#getID()
and ";output" or ReportBean#getFileName()#hashCode()
+ ";output".reportBean
- a report beanjava.lang.IllegalArgumentException
- illegal argument is used.public static java.lang.String getViewerReportKey(com.nomagic.magicdraw.magicreport.ui.bean.ReportBean reportBean) throws java.lang.IllegalArgumentException
ReportBean#getModel()#getID()
and ";viewer" or ReportBean#getFileName()#hashCode()
+ ";viewer".reportBean
- a report beanjava.lang.IllegalArgumentException
- illegal argument is used.