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 
      Modifier and Type Class Description
      private class  ExportTool2.ConcurrentHashSet<T>  
      private static class  ExportTool2.ElementComparator<T>  
      private static class  ExportTool2.NameComparator<T>  
      private static class  ExportTool2.NodeComparator<T>  
      private static class  ExportTool2.SymbolElement  
      • 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
    • 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
      private void appendPropertyCollection​(java.util.Collection<?> propertyCollection, org.w3c.dom.Document document, java.util.List<org.w3c.dom.Element> childList, org.w3c.dom.Element fieldElement, boolean exportResources)  
      private int calculatePercentage​(long current, long total)  
      private void collectAnchorShapeBounds​(javax.swing.text.View view, java.awt.Shape container, java.util.Set<ExportTool2.SymbolElement> shapeList, javax.swing.text.Element element, com.nomagic.magicdraw.uml.symbols.DiagramObjectViewContainer diagramContainer)  
      private java.util.Set<java.lang.String> collectElementPropertiesNames​(Element element, java.lang.String mode)
      Creates and collects groups nodes user friendly names that appears in element's specification dialog tree at specific view mode (Standard/Expert/All)
      private void collectElements()  
      private void collectElements​(Element exportingElement)  
      private void collectOwnedElements​(Element exportingElement, boolean isRecursive)  
      private boolean collectOwner​(Element exportingElement, java.util.Set<java.lang.String> parents, java.util.Set<Diagram> diagrams, java.util.Set<java.lang.String> notAccepts)  
      void consume​(com.nomagic.magicreport.engine.ConcurrentTool.ConsumeObject consumeObject)
      Consume a object.
      private java.lang.String convertModelLinkToFileURL​(Element propertyValue)  
      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)  
      private void createAreaMapForDiagramPresentation​(org.w3c.dom.Document document, com.nomagic.magicdraw.uml.symbols.DiagramObjectViewContainer diagramContainer, java.util.Collection<PresentationElement> presentationElements, org.w3c.dom.Element mapElement, double scale, java.io.FileWriter writer)  
      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.
      private java.lang.String createDiagramTypeName​(java.lang.String name)
      Append 's' after diagram type name.
      private org.w3c.dom.Element createElementAttributeData​(org.w3c.dom.Document document, java.lang.String tagName, Element exportingElement, boolean exportResources)  
      private org.w3c.dom.Element createElementAttributeData​(org.w3c.dom.Document document, java.lang.String tagName, Element exportingElement, boolean exportResources, boolean skipData)  
      private com.nomagic.magicdraw.ui.ElementFilter createElementFilter​(Project project)  
      private org.w3c.dom.Element createElementForTree​(org.w3c.dom.Document document, Element exportingElement, boolean exportResources)
      Create XML element for element which is used to create tree.
      private java.lang.String createHexaID​(java.lang.String elementID)  
      private java.io.File createOutputByID​(java.lang.String prefix, java.lang.String elementID, java.lang.String subfix, boolean forceRenew)  
      private java.io.File createOutputFile​(java.lang.String filename)  
      private java.io.File createOutputFromDefault​(java.lang.String filename, boolean forceRenew)  
      private java.lang.String createReferneceDiagramType​(java.lang.String name)  
      private java.io.File createResourcesDir()
      Create a resource directory.
      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.
      private void ensureParentDirExists​(java.io.File parentFile)  
      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.
      private void exportDiagram​(Diagram diagram, Project project, org.w3c.dom.Document document, org.w3c.dom.Element xmlElement, java.lang.String[] mainData, boolean exportResources, java.util.List<org.w3c.dom.Element> nodeList, boolean exportLinkedFile)
      Export area mapping of elements in the diagram.
      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)  
      private void exportElement​(org.w3c.dom.Element parentElement, Element exportingElement, boolean exportResources, boolean exportLinkedFile, boolean skipData)
      Export xml element for data.xml
      private void exportElementForDiagramTree()  
      private com.nomagic.magicreport.engine.ITool.Void exportElementForDiagramTypeTree​(java.util.Map<java.lang.String,​java.util.List<Diagram>> diagramTypeMap)  
      private com.nomagic.magicreport.engine.ITool.Void exportElementForRootDiagramTree​(java.util.Map<java.lang.String,​java.util.List<Diagram>> diagramTypeMap)  
      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.
      private java.lang.String exportIconForHTMLDocument​(Project project, java.lang.String text)
      For html, it may contain some attributes that refer to element icon.
      Ex.
      private org.w3c.dom.Element exportImageMap​(org.w3c.dom.Document document, java.lang.String[] mainData, DiagramPresentationElement diagramPresentation, boolean exportLinkedFile)  
      private void exportRootTreeAndProfile​(org.w3c.dom.Element rootElement, org.w3c.dom.Document document, java.lang.String resourcesLocation, Package dataModel, Project project, boolean exportResources, boolean exportLinkedFile)  
      private Element findRootOwner​(Element element)  
      private java.lang.String formatObject​(java.lang.Object object)  
      private com.nomagic.magicdraw.ui.ElementFilter getAuxiliaryResourceFilter()  
      private java.lang.String getBlankField()  
      private java.util.Set<ExportTool2.SymbolElement> getContentShapeAnchorBounds​(com.nomagic.magicdraw.uml.symbols.shapes.TextObject textObject, com.nomagic.magicdraw.uml.symbols.DiagramObjectViewContainer diagramContainer)
      Collect all anchor element from content shape.
      private java.lang.String getElementPropertyString​(Element exportingElement, java.lang.String propertyName)  
      private java.util.Collection<Element> getElementScope()  
      protected java.lang.String getElementType​(Element element)
      Return String representing element type.
      private boolean getExportConfig​(java.lang.String config)  
      private int getExportImageSize()  
      private java.lang.String getFormattedNumber​(long num)  
      private com.nomagic.magicreport.format.HTMLFormatter getHTMLFormatter()  
      static java.lang.String getHumanName​(java.lang.String propertyName, java.util.Map<java.lang.String,​java.lang.String> nameMap)  
      private java.lang.String getModeString​(java.util.Set<java.lang.String>[] propertiesModes, java.lang.String propertyName)  
      private java.util.Collection<Package> getPackageScope()  
      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)  
      private boolean hasActiveHyperlink​(Element exportingElement)  
      private boolean hasChildElement​(Element exportingElement)  
      private void increaseProgressBar​(Element exportingElement, java.lang.String id, java.lang.String text)  
      private void initialScopeAndVariable()  
      private void initialScopeAndVariable​(boolean alwaysInit)  
      protected boolean isCancel()  
      private boolean isCreateSpecificationIcon​(Element exportingElement)  
      private static boolean isExportableElement​(Element element)
      Fixed https://jira.nomagic.com/browse/MGRP-3170s 1) Applied Stereotype Instances and Slots that are tagged values should not be exported, since they are not part of actual model 2) Documentation comments should not be exported in a separate file - it is enough to print info in its owner 3) Should not export not user-created ValueSpecifications, like ones that are created when setting multiplicity property value
      private boolean isExportableSpecElement​(Element element)
      Check element that can be created as xml file for specification panel
      private boolean isExportableTreeElement​(Element element)
      Check element that can be created as xml file for containment tree
      private boolean isHiddenElement​(Element exportingElement, com.nomagic.magicdraw.ui.ElementFilter filter)  
      private boolean isNotAcceptAuxiliary​(BaseElement testPackage)  
      private boolean isSkipExportAll()  
      private void offerElementToConsumeObject​(Element exportingElement, boolean exportResources, boolean exportLinkedFile)
      Export element to XML file.
      private void setModeString​(org.w3c.dom.Element xmlElement, java.util.Set<java.lang.String>[] propertiesModes, java.lang.String propertyName)  
      void setRecursive​(boolean isRecursive)  
      void setShowAuxiliary​(boolean isShowAuxiliary)  
      private void write​(org.w3c.dom.Node node, java.lang.StringBuilder builder)  
      • Methods inherited from class com.nomagic.magicreport.engine.ConcurrentTool

        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
    • Field Detail

      • CONTEXT_NAME

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

        private static final org.apache.logging.log4j.Logger log
      • EXPORT_ALL_ELEMENT

        private static final java.lang.String EXPORT_ALL_ELEMENT
        export all elements. true to export all xml file for containment tree and specification panel.
        See Also:
        Constant Field Values
      • EXPORT_ALL_TREE_ELEMENT

        private static final java.lang.String EXPORT_ALL_TREE_ELEMENT
        See Also:
        Constant Field Values
      • SKIP_EXPORT_ALL_SPEC_ELEMENT

        private static final java.lang.String SKIP_EXPORT_ALL_SPEC_ELEMENT
        See Also:
        Constant Field Values
      • formatter

        private final java.text.DecimalFormat formatter
      • resourcesDir

        private java.io.File resourcesDir
      • dummyULId

        private int dummyULId
      • imageScale

        private int imageScale
      • reflection

        private com.nomagic.uml2.ext.jmi.reflect.ModelReflection reflection
      • exportConfig

        private java.util.Map<java.lang.String,​java.lang.Boolean> exportConfig
      • elementsToBeExport

        private final java.util.Set<java.lang.String> elementsToBeExport
      • exportedDiagramSet

        private final java.util.Set<Diagram> exportedDiagramSet
      • exportedIconSet

        private final java.util.Set<java.lang.String> exportedIconSet
      • existingFilePaths

        private final java.util.Set<java.lang.String> existingFilePaths
      • fileExportedCount

        private long fileExportedCount
      • filesToBeExportedCount

        private long filesToBeExportedCount
      • currentPercentage

        private int currentPercentage
      • skipProgressbar

        private java.lang.Boolean skipProgressbar
      • elementFileCount

        private long elementFileCount
      • useHexadecimalName

        private java.lang.Boolean useHexadecimalName
      • hexadecimalMap

        private final java.util.Map<java.lang.String,​java.lang.String> hexadecimalMap
      • packageScope

        private java.util.Collection<Package> packageScope
      • elementScope

        private java.util.Collection<Element> elementScope
      • auxiliaryFilter

        private com.nomagic.magicdraw.ui.ElementFilter auxiliaryFilter
      • filter

        private com.nomagic.magicdraw.ui.ElementFilter filter
      • isShowAuxiliary

        private boolean isShowAuxiliary
      • globalEngine

        private com.nomagic.magicreport.engine.ITemplateEngine globalEngine
      • htmlFormatter

        private com.nomagic.magicreport.format.HTMLFormatter htmlFormatter
      • blankFieldValue

        private java.lang.String blankFieldValue
      • defaultOutputDirectory

        private java.io.File defaultOutputDirectory
      • isRecursive

        private boolean isRecursive
      • isSkipExportAll

        private boolean isSkipExportAll
      • documentBuilder

        private javax.xml.parsers.DocumentBuilder documentBuilder
      • transformer

        private javax.xml.transform.Transformer transformer
      • task

        private com.nomagic.magicdraw.magicreport.ObserverTask task
      • nodeComparator

        private final java.util.Comparator<org.w3c.dom.Element> nodeComparator
      • elementComparator

        private final java.util.Comparator<BaseElement> elementComparator
      • nameComparator

        private final java.util.Comparator<org.w3c.dom.Element> nameComparator
    • 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)
      • increaseProgressBar

        private void increaseProgressBar​(Element exportingElement,
                                         java.lang.String id,
                                         java.lang.String text)
      • getFormattedNumber

        private java.lang.String getFormattedNumber​(long num)
      • calculatePercentage

        private int calculatePercentage​(long current,
                                        long total)
      • getBlankField

        private java.lang.String getBlankField()
      • formatObject

        private java.lang.String formatObject​(@CheckForNull
                                              java.lang.Object object)
      • getPackageScope

        private java.util.Collection<Package> getPackageScope()
      • getElementScope

        private java.util.Collection<Element> getElementScope()
      • getAuxiliaryResourceFilter

        private com.nomagic.magicdraw.ui.ElementFilter getAuxiliaryResourceFilter()
      • getExportImageSize

        private int getExportImageSize()
      • isSkipExportAll

        private boolean isSkipExportAll()
      • isNotAcceptAuxiliary

        private boolean isNotAcceptAuxiliary​(BaseElement testPackage)
      • collectElementPropertiesNames

        private java.util.Set<java.lang.String> collectElementPropertiesNames​(Element element,
                                                                              java.lang.String mode)
        Creates and collects groups nodes user friendly names that appears in element's specification dialog tree at specific view mode (Standard/Expert/All)
        Parameters:
        element - element
        mode - view mode from PropertiesModeHelper.MODES
        Returns:
        Collection of String group nodes names
        See Also:
        PropertiesMode
      • appendPropertyCollection

        private void appendPropertyCollection​(java.util.Collection<?> propertyCollection,
                                              org.w3c.dom.Document document,
                                              java.util.List<org.w3c.dom.Element> childList,
                                              org.w3c.dom.Element fieldElement,
                                              boolean exportResources)
                                       throws java.io.IOException
        Throws:
        java.io.IOException
      • getModeString

        private java.lang.String getModeString​(java.util.Set<java.lang.String>[] propertiesModes,
                                               java.lang.String propertyName)
      • setModeString

        private void setModeString​(org.w3c.dom.Element xmlElement,
                                   java.util.Set<java.lang.String>[] propertiesModes,
                                   java.lang.String propertyName)
      • 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
      • exportImageMap

        private org.w3c.dom.Element exportImageMap​(org.w3c.dom.Document document,
                                                   java.lang.String[] mainData,
                                                   DiagramPresentationElement diagramPresentation,
                                                   boolean exportLinkedFile)
      • createAreaMapForDiagramPresentation

        private void createAreaMapForDiagramPresentation​(org.w3c.dom.Document document,
                                                         com.nomagic.magicdraw.uml.symbols.DiagramObjectViewContainer diagramContainer,
                                                         java.util.Collection<PresentationElement> presentationElements,
                                                         org.w3c.dom.Element mapElement,
                                                         double scale,
                                                         java.io.FileWriter writer)
                                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • ensureParentDirExists

        private void ensureParentDirExists​(java.io.File parentFile)
      • convertModelLinkToFileURL

        @CheckForNull
        private java.lang.String convertModelLinkToFileURL​(Element propertyValue)
                                                    throws java.io.IOException
        Throws:
        java.io.IOException
      • exportDiagram

        private void exportDiagram​(Diagram diagram,
                                   Project project,
                                   org.w3c.dom.Document document,
                                   org.w3c.dom.Element xmlElement,
                                   java.lang.String[] mainData,
                                   boolean exportResources,
                                   java.util.List<org.w3c.dom.Element> nodeList,
                                   boolean exportLinkedFile)
        Export area mapping of elements in the diagram.
      • exportDiagramImage

        public com.nomagic.magicreport.engine.ITool.Void exportDiagramImage​(DiagramPresentationElement diagramPresentation,
                                                                            boolean exportResources)
      • getHTMLFormatter

        private com.nomagic.magicreport.format.HTMLFormatter getHTMLFormatter()
      • 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
      • write

        private void write​(org.w3c.dom.Node node,
                           java.lang.StringBuilder builder)
      • createElementForTree

        private org.w3c.dom.Element createElementForTree​(org.w3c.dom.Document document,
                                                         Element exportingElement,
                                                         boolean exportResources)
                                                  throws java.io.IOException
        Create XML element for element which is used to create tree.
        Throws:
        java.io.IOException
      • getElementPropertyString

        @CheckForNull
        private java.lang.String getElementPropertyString​(Element exportingElement,
                                                          java.lang.String propertyName)
      • hasActiveHyperlink

        private boolean hasActiveHyperlink​(Element exportingElement)
      • isCreateSpecificationIcon

        private boolean isCreateSpecificationIcon​(Element exportingElement)
      • isHiddenElement

        private boolean isHiddenElement​(Element exportingElement,
                                        com.nomagic.magicdraw.ui.ElementFilter filter)
      • hasChildElement

        private boolean hasChildElement​(Element exportingElement)
      • 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.
      • createResourcesDir

        private java.io.File createResourcesDir()
                                         throws java.io.IOException
        Create a resource directory.
        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
      • offerElementToConsumeObject

        private void offerElementToConsumeObject​(Element exportingElement,
                                                 boolean exportResources,
                                                 boolean exportLinkedFile)
        Export element to XML file. Use element id as file name.
        Parameters:
        exportingElement - exporting element
      • createElementAttributeData

        private org.w3c.dom.Element createElementAttributeData​(org.w3c.dom.Document document,
                                                               java.lang.String tagName,
                                                               Element exportingElement,
                                                               boolean exportResources)
                                                        throws java.io.IOException
        Throws:
        java.io.IOException
      • createElementAttributeData

        private org.w3c.dom.Element createElementAttributeData​(org.w3c.dom.Document document,
                                                               java.lang.String tagName,
                                                               Element exportingElement,
                                                               boolean exportResources,
                                                               boolean skipData)
                                                        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)
                                                      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.
      • exportElement

        private void exportElement​(org.w3c.dom.Element parentElement,
                                   Element exportingElement,
                                   boolean exportResources,
                                   boolean exportLinkedFile,
                                   boolean skipData)
                            throws java.io.IOException
        Export xml element for data.xml
        Parameters:
        parentElement - dom parent
        exportingElement - element to be exported
        exportResources - true to export sources (icon, image)
        exportLinkedFile - true to export link file
        skipData - true to create only main data
        Throws:
        java.io.IOException
      • createOutputByID

        private java.io.File createOutputByID​(java.lang.String prefix,
                                              java.lang.String elementID,
                                              java.lang.String subfix,
                                              boolean forceRenew)
      • createHexaID

        private java.lang.String createHexaID​(java.lang.String elementID)
      • createOutputFromDefault

        private java.io.File createOutputFromDefault​(java.lang.String filename,
                                                     boolean forceRenew)
      • createOutputFile

        private java.io.File createOutputFile​(java.lang.String filename)
      • initialScopeAndVariable

        private void initialScopeAndVariable()
      • initialScopeAndVariable

        private void initialScopeAndVariable​(boolean alwaysInit)
      • collectElements

        private void collectElements()
      • collectOwner

        private boolean collectOwner​(Element exportingElement,
                                     java.util.Set<java.lang.String> parents,
                                     java.util.Set<Diagram> diagrams,
                                     java.util.Set<java.lang.String> notAccepts)
      • collectElements

        private void collectElements​(Element exportingElement)
      • collectOwnedElements

        private void collectOwnedElements​(Element exportingElement,
                                          boolean isRecursive)
      • 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
      • exportRootTreeAndProfile

        private void exportRootTreeAndProfile​(org.w3c.dom.Element rootElement,
                                              org.w3c.dom.Document document,
                                              java.lang.String resourcesLocation,
                                              Package dataModel,
                                              Project project,
                                              boolean exportResources,
                                              boolean exportLinkedFile)
      • createElementFilter

        private com.nomagic.magicdraw.ui.ElementFilter createElementFilter​(Project project)
      • 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()
      • collectAnchorShapeBounds

        private void collectAnchorShapeBounds​(javax.swing.text.View view,
                                              java.awt.Shape container,
                                              java.util.Set<ExportTool2.SymbolElement> shapeList,
                                              javax.swing.text.Element element,
                                              com.nomagic.magicdraw.uml.symbols.DiagramObjectViewContainer diagramContainer)
      • getContentShapeAnchorBounds

        private java.util.Set<ExportTool2.SymbolElement> getContentShapeAnchorBounds​(com.nomagic.magicdraw.uml.symbols.shapes.TextObject textObject,
                                                                                     com.nomagic.magicdraw.uml.symbols.DiagramObjectViewContainer diagramContainer)
        Collect all anchor element from content shape.
        Returns:
        a list containing anchor shape
      • 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 DSLManager.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)
      • exportElementForDiagramTree

        private void exportElementForDiagramTree()
      • createReferneceDiagramType

        private java.lang.String createReferneceDiagramType​(java.lang.String name)
      • createDiagramTypeName

        private java.lang.String createDiagramTypeName​(java.lang.String name)
        Append 's' after diagram type name.
      • exportElementForRootDiagramTree

        private com.nomagic.magicreport.engine.ITool.Void exportElementForRootDiagramTree​(java.util.Map<java.lang.String,​java.util.List<Diagram>> diagramTypeMap)
      • exportElementForDiagramTypeTree

        private com.nomagic.magicreport.engine.ITool.Void exportElementForDiagramTypeTree​(java.util.Map<java.lang.String,​java.util.List<Diagram>> diagramTypeMap)
      • getExportConfig

        private boolean getExportConfig​(java.lang.String config)
      • isExportableTreeElement

        private boolean isExportableTreeElement​(Element element)
        Check element that can be created as xml file for containment tree
        Parameters:
        element - specific element
        Returns:
        true if it can be created as xml file; otherwise, false.
      • isExportableSpecElement

        private boolean isExportableSpecElement​(Element element)
        Check element that can be created as xml file for specification panel
        Parameters:
        element - specific element
        Returns:
        true if it can be created as xml file; otherwise, false.
      • isExportableElement

        private static boolean isExportableElement​(Element element)
        Fixed https://jira.nomagic.com/browse/MGRP-3170s 1) Applied Stereotype Instances and Slots that are tagged values should not be exported, since they are not part of actual model 2) Documentation comments should not be exported in a separate file - it is enough to print info in its owner 3) Should not export not user-created ValueSpecifications, like ones that are created when setting multiplicity property value
      • exportIconForHTMLDocument

        private java.lang.String exportIconForHTMLDocument​(Project project,
                                                           java.lang.String text)
        For html, it may contain some attributes that refer to element icon.
        Ex. This icon should be exported and the value of "src" attribute should be changed to the url of exported icon.
        Parameters:
        project - current project
        text - html text
        Returns:
        updated text
      • isCancel

        protected boolean isCancel()
      • handleIOException

        protected void handleIOException​(java.lang.Exception e)