Class ExportTool2

  • All Implemented Interfaces:
    com.nomagic.magicreport.engine.ITool, com.nomagic.magicreport.IVariable, java.io.Serializable, java.lang.Cloneable

    @OpenApiAll
    public class ExportTool2
    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
    • Nested Class Summary

      • Nested classes/interfaces inherited from class com.nomagic.magicreport.engine.ConcurrentTool

        com.nomagic.magicreport.engine.ConcurrentTool.ConsumeObject
      • Nested classes/interfaces inherited from interface com.nomagic.magicreport.engine.ITool

        com.nomagic.magicreport.engine.ITool.HTMLString, com.nomagic.magicreport.engine.ITool.RetainedString, com.nomagic.magicreport.engine.ITool.Void
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String CONTEXT_NAME
      Contains a context name.
      • Fields inherited from class com.nomagic.magicreport.engine.Tool

        context, properties
      • Fields inherited from interface com.nomagic.magicreport.engine.ITool

        VOID
    • Constructor Summary

      Constructors 
      Constructor Description
      ExportTool2()
      Create an export tool.
      ExportTool2​(com.nomagic.magicreport.engine.ITemplateEngine engine, java.util.Observer observer)
      Create an export tool with observer.
      ExportTool2​(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 org.w3c.dom.Element createAndExportElement​(org.w3c.dom.Document document, Element exportingElement, boolean exportResources, boolean exportLinkedFile, com.nomagic.magicdraw.ui.ElementFilter filter)  
      protected org.w3c.dom.Element createAndExportElement​(org.w3c.dom.Document document, Element exportingElement, boolean exportResources, boolean exportLinkedFile, com.nomagic.magicdraw.ui.ElementFilter filter, boolean isSmart)  
      protected org.w3c.dom.Element createAndExportSmartElement​(org.w3c.dom.Document document, Element exportingElement, boolean exportResources, boolean exportLinkedFile, com.nomagic.magicdraw.ui.ElementFilter filter)  
      protected org.w3c.dom.Element createAttributeAndExportElement​(org.w3c.dom.Document document, Element exportingElement, boolean exportResources, boolean exportLinkedFile, boolean skipData)
      Create attributes for XML element represents the exportingElement and offer the element to be created into file.
      protected java.io.File createResourcesDir​(java.lang.String resourcesLocation)
      Create a resource directory.
      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.
      protected java.lang.String getElementType​(Element element)
      Return String representing element type.
      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
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface com.nomagic.magicreport.engine.ITool

        clearTool
    • Field Detail

      • CONTEXT_NAME

        public static final java.lang.String CONTEXT_NAME
        Contains a context name.
        See Also:
        Constant Field Values
    • Constructor Detail

      • ExportTool2

        public ExportTool2()
        Create an export tool.
      • ExportTool2

        public ExportTool2​(java.util.Observer observer)
        Create an export tool with observer.
        Parameters:
        observer - Observer
      • ExportTool2

        public ExportTool2​(com.nomagic.magicreport.engine.ITemplateEngine engine,
                           java.util.Observer observer)
        Create an export tool with observer.
        Parameters:
        engine - engine
        observer - 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 class com.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 file
        exportingElement - exporting element
        exportResources - 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 file
        exportingElement - exporting element
        exportResources - true if you want to export resources of this element
        exportLinkedFile - 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 file
        exportingElement - export element
        exportResources - 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

        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 method offer(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 org.w3c.dom.Element createAndExportElement​(org.w3c.dom.Document document,
                                                             Element exportingElement,
                                                             boolean exportResources,
                                                             boolean exportLinkedFile,
                                                             @CheckForNull
                                                             com.nomagic.magicdraw.ui.ElementFilter filter)
                                                      throws java.io.IOException
        Throws:
        java.io.IOException
      • createAndExportSmartElement

        protected org.w3c.dom.Element createAndExportSmartElement​(org.w3c.dom.Document document,
                                                                  Element exportingElement,
                                                                  boolean exportResources,
                                                                  boolean exportLinkedFile,
                                                                  @CheckForNull
                                                                  com.nomagic.magicdraw.ui.ElementFilter filter)
                                                           throws java.io.IOException
        Throws:
        java.io.IOException
      • createAndExportElement

        protected org.w3c.dom.Element createAndExportElement​(org.w3c.dom.Document document,
                                                             Element exportingElement,
                                                             boolean exportResources,
                                                             boolean exportLinkedFile,
                                                             @CheckForNull
                                                             com.nomagic.magicdraw.ui.ElementFilter filter,
                                                             boolean isSmart)
                                                      throws java.io.IOException
        Throws:
        java.io.IOException
      • createAttributeAndExportElement

        protected org.w3c.dom.Element createAttributeAndExportElement​(org.w3c.dom.Document document,
                                                                      Element exportingElement,
                                                                      boolean exportResources,
                                                                      boolean exportLinkedFile,
                                                                      boolean skipData)
                                                               throws java.io.IOException
        Create attributes for XML element represents the exportingElement and offer the element to be created into file. Return null to cancel this element exporting.
        Parameters:
        document - XML document
        exportingElement - exporting element
        exportResources - true if you want to export resources of this element
        exportLinkedFile - true if you want to include linked files.
        skipData - true to create only main attribute to xml document.
        Returns:
        XML element for creating containment tree.
        Throws:
        java.io.IOException - when IO error occurred.
      • getElementType

        protected java.lang.String getElementType​(Element element)
        Return String representing element type.
        Parameters:
        element - element
        Returns:
        a String representing element type.
      • 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 class com.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. If nameMap is used, human name will be resolved by nameMap then resource string.
        Parameters:
        propertyName - a property name
        nameMap - optional provides new name map from DSL.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)