| Quintiq file version 2.0 | 
| #parent: #root | 
| Method ImportFromXML ( | 
|   String xmlstring, | 
|   output String feedback_o | 
| ) as Boolean | 
| { | 
|   Description: 'Restores view setting. Called by designer during retrieve view' | 
|   TextBody: | 
|   [* | 
|     // Import supply chain view from XML | 
|     result := true; | 
|      | 
|     // Check if xmlstring is populated | 
|     if( xmlstring.Length() > 0 ) | 
|     { | 
|       xmlview := null( SupplyChainView ); | 
|        | 
|       // Try to import xmlstring | 
|       try | 
|       { | 
|         xmlview := SupplyChainView::XMLImportSupplyChainViewXML( xmlstring ); | 
|       } | 
|       onerror | 
|       { | 
|         result := false;       | 
|       } | 
|        | 
|       // Check if xmlview is null | 
|       if( not isnull( xmlview ) ) | 
|       { | 
|         // Update this with xmlview | 
|         this.Update( xmlview.SupplyChainBackground(), | 
|                      xmlview.FontSize(), | 
|                      xmlview.FontName(), | 
|                      xmlview.GridPointDistance(), | 
|                      xmlview.RelativeStockingPointSize(), | 
|                      xmlview.RelativeUnitHeight(), | 
|                      xmlview.RelativeUnitWidth(), | 
|                      xmlview.RelativeProductHeight(), | 
|                      xmlview.RelativeProductWidth(), | 
|                      xmlview.IsGridVisible(), | 
|                      xmlview.IsLaneVisible(), | 
|                      xmlview.IsUnitNodeLabelVisible(), | 
|                      xmlview.IsStockingPointNodeLabelVisible(), | 
|                      xmlview.ArrowColor(), | 
|                      xmlview.HasPersistentArrows(), | 
|                      this.OffsetX(), | 
|                      this.OffsetY() ) | 
|      | 
|         // Traverse all nodes in xmlview | 
|         traverse( xmlview, Node, xmlnode ) | 
|         { | 
|           // Executes logic according to the type of the object | 
|           ontype( xmlnode ) | 
|           { | 
|             // If xmlnode is type of UnitNode | 
|             UnitNode as unitxmlnode: | 
|             { | 
|               // Select UnitNode with the same name as xmlnode | 
|               node := select( this, UnitNode, n, n.Name() = xmlnode.Name() ); | 
|               // Check if node is null | 
|               if( not isnull( node ) ) | 
|               { | 
|                 // Update node with values from xmlnode | 
|                 node.Update( unitxmlnode.GridX(), unitxmlnode.GridY(), unitxmlnode.IsUserVisible(), unitxmlnode.NameDisplayBehavior(), | 
|                              unitxmlnode.TextColor(), unitxmlnode.BackgroundImageName() ); | 
|               } | 
|             } | 
|             // If xmlnode is type of StockingPointNode | 
|             StockingPointNode as stockingpointxmlnode: | 
|             { | 
|               // Select StockingPointNode with the same name as xmlnode | 
|               node := select( this, StockingPointNode, n, n.Name() = stockingpointxmlnode.Name() ); | 
|               // Check if node is null | 
|               if( not isnull( node ) ) | 
|               { | 
|                 // Update node with values from xmlnode | 
|                 node.Update( stockingpointxmlnode.GridX(), stockingpointxmlnode.GridY(), stockingpointxmlnode.IsUserVisible(), stockingpointxmlnode.NameDisplayBehavior(), | 
|                              stockingpointxmlnode.TextColor() ); | 
|               } | 
|             } | 
|           } | 
|         } | 
|      | 
|         //Hide newly added nodes that are not defined in the xmlstring yet | 
|         unitnodes := selectset( this, Node.astype( UnitNode ), n, | 
|                                 not exists( xmlview, Node.astype( UnitNode ), xmlnode, xmlnode.Name() = n.Name() ) ) | 
|         traverse( unitnodes, Elements, e ) | 
|         { | 
|           e.IsUserVisible ( false ); | 
|         } | 
|      | 
|         spnodes := selectset( this, Node.astype( StockingPointNode ), n, | 
|                               not exists( xmlview, Node.astype( StockingPointNode ), xmlnode, xmlnode.Name() = n.Name() ) ) | 
|         traverse( spnodes, Elements, e ) | 
|         { | 
|           e.IsUserVisible ( false ); | 
|         } | 
|      | 
|         // Delete xmlview | 
|         xmlview.Delete(); | 
|       } | 
|     } | 
|     else | 
|     { | 
|       result := false; | 
|     } | 
|      | 
|     // Return feedback if the method failed to parse xmlstring | 
|     if( not result ) | 
|     { | 
|       feedback_o := Translations::MP_SupplyChainView_ImportFromXML_InvalidFile(); | 
|     } | 
|      | 
|     return result; | 
|   *] | 
| } |