Class ExportTool3
- java.lang.Object
-
- java.util.Observable
-
- com.nomagic.magicreport.engine.Tool
-
- com.nomagic.magicreport.engine.ConcurrentTool
-
- com.nomagic.magicdraw.magicreport.tools.ExportTool3
-
- All Implemented Interfaces:
com.nomagic.magicreport.engine.ITool
,com.nomagic.magicreport.IVariable
,java.io.Serializable
,java.lang.Cloneable
@OpenApiAll public class ExportTool3 extends com.nomagic.magicreport.engine.ConcurrentTool
This class allow report to export element in other file format including tree folder.- Since:
- Mar 14, 2012
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
CONTEXT_NAME
Contains a context name.
-
Constructor Summary
Constructors Constructor Description ExportTool3()
Create an export tool.ExportTool3(com.nomagic.magicreport.engine.ITemplateEngine engine, java.util.Observer observer)
Create an export tool with observer.ExportTool3(java.util.Observer observer)
Create an export tool with observer.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
consume(com.nomagic.magicreport.engine.ConcurrentTool.ConsumeObject consumeObject)
Consume a object.protected void
createAndExportElement(org.codehaus.stax2.XMLStreamWriter2 document, Element exportingElement, boolean exportResources, boolean exportLinkedFile, com.nomagic.magicdraw.ui.ElementFilter filter)
protected void
createAndExportElement(org.codehaus.stax2.XMLStreamWriter2 document, Element exportingElement, boolean exportResources, boolean exportLinkedFile, com.nomagic.magicdraw.ui.ElementFilter filter, boolean isSmart)
protected void
createAndExportSmartElement(org.codehaus.stax2.XMLStreamWriter2 document, Element exportingElement, boolean exportResources, boolean exportLinkedFile, com.nomagic.magicdraw.ui.ElementFilter filter)
protected void
createAttributeAndExportElement(org.codehaus.stax2.XMLStreamWriter2 document, Element exportingElement, boolean exportResources, boolean exportLinkedFile, boolean skipData)
Create attributes for XML element represents theexportingElement
and offer the element to be created into file.protected java.io.File
createResourcesDir(java.lang.String resourcesLocation)
Create a resource directory.protected java.lang.String
createTagName(java.lang.String tagName)
void
destroy()
Called by the engine to inform this tool is no longer use and that it should destroy any resources that it has allocated.java.lang.String
exportAll(boolean exportResources, boolean exportLinkedFile)
Export current opened project into file.protected java.lang.String
exportCustomImageHolder(BaseElement exportingElement)
Export the image for the element.com.nomagic.magicreport.engine.ITool.Void
exportDiagramImage(DiagramPresentationElement diagramPresentation, boolean exportResources)
com.nomagic.magicreport.engine.ITool.Void
exportElement(java.io.File exportingFile, Element exportingElement, boolean exportResources)
Export element to XML file.com.nomagic.magicreport.engine.ITool.Void
exportElement(java.io.File exportingFile, Element exportingElement, boolean exportResources, boolean exportLinkedFile)
Export element to XML file.com.nomagic.magicreport.engine.ITool.Void
exportElement(java.io.File exportingFile, Element exportingElement, boolean exportResources, boolean exportLinkedFile, com.nomagic.magicdraw.ui.ElementFilter filter)
com.nomagic.magicreport.engine.ITool.Void
exportElementForTree(java.io.File exportingNodeFile, Element exportingElement, boolean exportResources)
Export element to XML file which is used for create tree.com.nomagic.magicreport.engine.ITool.Void
exportElementForTree(java.io.File exportingNodeFile, Element exportingElement, boolean exportResources, com.nomagic.magicdraw.ui.ElementFilter filter)
protected java.lang.String
exportIcon(BaseElement exportingElement)
Export the icon for element.java.lang.String
exportIcon(java.lang.String type)
protected java.lang.String
getElementType(Element element)
Return String representing element type.protected java.lang.String
getElementTypeForTagName(Element element)
static java.lang.String
getHumanName(java.lang.String propertyName, java.util.Map<java.lang.String,java.lang.String> nameMap)
java.lang.String
getPropertyHumanName(java.lang.String propertyName, java.util.Map<java.lang.String,java.lang.String> nameMap)
Get property human name of given property name.protected java.lang.String
getResourcesLocation()
Return location of resources directory.protected void
handleIOException(java.lang.Exception e)
protected boolean
isCancel()
void
setRecursive(boolean isRecursive)
void
setShowAuxiliary(boolean isShowAuxiliary)
-
Methods inherited from class com.nomagic.magicreport.engine.ConcurrentTool
getCustomPoolSize, isNoSpaceException, isRunning, offer
-
Methods inherited from class com.nomagic.magicreport.engine.Tool
clone, getContext, getProperties, getProperty, getProperty, notifyObservers, setContext, setProperties
-
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, setChanged
-
-
-
-
Field Detail
-
CONTEXT_NAME
public static final java.lang.String CONTEXT_NAME
Contains a context name.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ExportTool3
public ExportTool3()
Create an export tool.
-
ExportTool3
public ExportTool3(java.util.Observer observer)
Create an export tool with observer.- Parameters:
observer
- Observer
-
ExportTool3
public ExportTool3(com.nomagic.magicreport.engine.ITemplateEngine engine, java.util.Observer observer)
Create an export tool with observer.- Parameters:
engine
- engineobserver
- Observer
-
-
Method Detail
-
setRecursive
public void setRecursive(boolean isRecursive)
-
setShowAuxiliary
public void setShowAuxiliary(boolean isShowAuxiliary)
-
consume
public void consume(com.nomagic.magicreport.engine.ConcurrentTool.ConsumeObject consumeObject)
Consume a object.- Specified by:
consume
in classcom.nomagic.magicreport.engine.ConcurrentTool
- Parameters:
consumeObject
- consume object.- See Also:
ConcurrentTool.consume(ConsumeObject)
-
exportElement
public com.nomagic.magicreport.engine.ITool.Void exportElement(java.io.File exportingFile, Element exportingElement, boolean exportResources)
Export element to XML file.- Parameters:
exportingFile
- exporting fileexportingElement
- exporting elementexportResources
- true if you want to export resources of this element- Returns:
- nothing
-
exportElement
public com.nomagic.magicreport.engine.ITool.Void exportElement(java.io.File exportingFile, Element exportingElement, boolean exportResources, boolean exportLinkedFile, @CheckForNull com.nomagic.magicdraw.ui.ElementFilter filter)
-
exportElement
public com.nomagic.magicreport.engine.ITool.Void exportElement(java.io.File exportingFile, Element exportingElement, boolean exportResources, boolean exportLinkedFile)
Export element to XML file.- Parameters:
exportingFile
- exporting fileexportingElement
- exporting elementexportResources
- true if you want to export resources of this elementexportLinkedFile
- true if you want to include linked files.- Returns:
- nothing
-
exportDiagramImage
public com.nomagic.magicreport.engine.ITool.Void exportDiagramImage(DiagramPresentationElement diagramPresentation, boolean exportResources)
-
exportElementForTree
public com.nomagic.magicreport.engine.ITool.Void exportElementForTree(java.io.File exportingNodeFile, Element exportingElement, boolean exportResources, com.nomagic.magicdraw.ui.ElementFilter filter)
-
exportElementForTree
public com.nomagic.magicreport.engine.ITool.Void exportElementForTree(java.io.File exportingNodeFile, Element exportingElement, boolean exportResources)
Export element to XML file which is used for create tree.- Parameters:
exportingNodeFile
- exporting fileexportingElement
- export elementexportResources
- true if you want to export resources of this element- Returns:
- nothing
-
getResourcesLocation
protected java.lang.String getResourcesLocation()
Return location of resources directory.- Returns:
- a path to resources directory.
-
createResourcesDir
protected java.io.File createResourcesDir(java.lang.String resourcesLocation) throws java.io.IOException
Create a resource directory.- Parameters:
resourcesLocation
- resources location- Returns:
- a File pointed to resources directory
- Throws:
java.io.IOException
- if IO error occurs.
-
exportIcon
public java.lang.String exportIcon(java.lang.String type) throws java.io.IOException
- Throws:
java.io.IOException
-
exportIcon
protected java.lang.String exportIcon(BaseElement exportingElement) throws java.io.IOException
Export the icon for element. This method should not perform graphic renderer by itself. The icon exporting process should be enqueue by methodoffer(ConsumeObject)
.- Parameters:
exportingElement
- target element- Returns:
- path to icon
- Throws:
java.io.IOException
- if IO error occurs
-
exportCustomImageHolder
protected java.lang.String exportCustomImageHolder(BaseElement exportingElement) throws java.io.IOException
Export the image for the element. Image for the element will be exported from strereotype CustomImageHolder.- Parameters:
exportingElement
- target element- Returns:
- path to icon
- Throws:
java.io.IOException
- if IO error occurs
-
createAndExportElement
protected void createAndExportElement(org.codehaus.stax2.XMLStreamWriter2 document, Element exportingElement, boolean exportResources, boolean exportLinkedFile, @CheckForNull com.nomagic.magicdraw.ui.ElementFilter filter) throws java.io.IOException, javax.xml.stream.XMLStreamException
- Throws:
java.io.IOException
javax.xml.stream.XMLStreamException
-
createAndExportSmartElement
protected void createAndExportSmartElement(org.codehaus.stax2.XMLStreamWriter2 document, Element exportingElement, boolean exportResources, boolean exportLinkedFile, @CheckForNull com.nomagic.magicdraw.ui.ElementFilter filter) throws java.io.IOException, javax.xml.stream.XMLStreamException
- Throws:
java.io.IOException
javax.xml.stream.XMLStreamException
-
createAndExportElement
protected void createAndExportElement(org.codehaus.stax2.XMLStreamWriter2 document, Element exportingElement, boolean exportResources, boolean exportLinkedFile, @CheckForNull com.nomagic.magicdraw.ui.ElementFilter filter, boolean isSmart) throws java.io.IOException, javax.xml.stream.XMLStreamException
- Throws:
java.io.IOException
javax.xml.stream.XMLStreamException
-
createAttributeAndExportElement
protected void createAttributeAndExportElement(org.codehaus.stax2.XMLStreamWriter2 document, Element exportingElement, boolean exportResources, boolean exportLinkedFile, boolean skipData) throws java.io.IOException, javax.xml.stream.XMLStreamException
Create attributes for XML element represents theexportingElement
and offer the element to be created into file. Returnnull
to cancel this element exporting.- Parameters:
document
- XML documentexportingElement
- exporting elementexportResources
- true if you want to export resources of this elementexportLinkedFile
- true if you want to include linked files.skipData
- true to create only main attribute to xml document.- Throws:
java.io.IOException
- when IO error occurred.javax.xml.stream.XMLStreamException
-
getElementType
protected java.lang.String getElementType(Element element)
Return String representing element type.- Parameters:
element
- element- Returns:
- a String representing element type.
-
getElementTypeForTagName
protected java.lang.String getElementTypeForTagName(Element element)
-
createTagName
protected java.lang.String createTagName(java.lang.String tagName)
-
exportAll
public java.lang.String exportAll(boolean exportResources, boolean exportLinkedFile)
Export current opened project into file.- Parameters:
exportResources
- true if you want to export resources.exportLinkedFile
- true if you want to include linked files.- Returns:
- nothing
-
destroy
public void destroy()
Called by the engine to inform this tool is no longer use and that it should destroy any resources that it has allocated.- Overrides:
destroy
in classcom.nomagic.magicreport.engine.ConcurrentTool
- See Also:
ConcurrentTool.destroy()
-
getPropertyHumanName
public java.lang.String getPropertyHumanName(java.lang.String propertyName, java.util.Map<java.lang.String,java.lang.String> nameMap)
Get property human name of given property name. IfnameMap
is used, human name will be resolved bynameMap
then resource string.- Parameters:
propertyName
- a property namenameMap
- optional provides new name map fromDSL.getPropertyNameMap(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element)
to resolve property name from <<metaType>>- Returns:
- human name
-
getHumanName
public static java.lang.String getHumanName(java.lang.String propertyName, java.util.Map<java.lang.String,java.lang.String> nameMap)
-
isCancel
protected boolean isCancel()
-
handleIOException
protected void handleIOException(java.lang.Exception e)
-
-