/*
 * #%L
 * carewebframework
 * %%
 * Copyright (C) 2008 - 2016 Regenstrief Institute, Inc.
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 * This Source Code Form is also subject to the terms of the Health-Related
 * Additional Disclaimer of Warranty and Limitation of Liability available at
 *
 *      http://www.carewebframework.org/licensing/disclaimer.
 *
 * #L%
 */
package org.carewebframework.ui.xml;

import java.util.HashMap;
import java.util.Map;

import org.carewebframework.ui.dialog.PopupDialog;
import org.carewebframework.web.component.BaseComponent;
import org.w3c.dom.Document;

/**
 * Static utility class for XML viewing functions.
 */
public class XMLViewer {
    
    /**
     * Show the dialog, loading the specified document.
     * 
     * @param document The XML document.
     */
    public static void showXML(Document document) {
        Map<String, Object> args = new HashMap<>();
        args.put("document", document);
        PopupDialog.show(XMLConstants.VIEW_DIALOG, args, true, true, true, null);
    }
    
    /**
     * Display the CWF markup for the component tree rooted at root.
     * 
     * @param root Root component of tree.
     */
    public static void showCWF(BaseComponent root) {
        showCWF(root, XMLConstants.EXCLUDED_PROPERTIES);
        
    }
    
    /**
     * Display the CWF markup for the component tree rooted at root.
     * 
     * @param root Root component of tree.
     * @param excludedProperties Excluded properties.
     */
    public static void showCWF(BaseComponent root, String... excludedProperties) {
        showXML(CWF2XML.toDocument(root, excludedProperties));
        
    }
    
    /**
     * Enforce static class.
     */
    private XMLViewer() {
    }
}

@@ -272,17 +272,16 @@
 se at%0A *
- 
 %0A *     
@@ -326,17 +326,16 @@
 E-2.0%0A *
- 
 %0A * Unle
@@ -650,17 +650,16 @@
 ense.%0A *
- 
 %0A * This
@@ -1079,16 +1079,66 @@
 ponent;%0A
+import org.carewebframework.web.component.Window;%0A
 import o
@@ -1243,20 +1243,16 @@
 iewer %7B%0A
-    
 %0A    /**
@@ -1306,33 +1306,32 @@
 document.%0A     *
- 
 %0A     * @param d
@@ -1352,24 +1352,51 @@
 L document.%0A
+     * @return The dialog.%0A
      */%0A    
@@ -1405,28 +1405,30 @@
 blic static 
-void
+Window
  showXML(Doc
@@ -1545,16 +1545,23 @@
         
+return 
 PopupDia
@@ -1628,28 +1628,24 @@
 ull);%0A    %7D%0A
-    
 %0A    /**%0A   
@@ -1708,33 +1708,32 @@
  at root.%0A     *
- 
 %0A     * @param r
@@ -1756,24 +1756,51 @@
 nt of tree.%0A
+     * @return The dialog.%0A
      */%0A    
@@ -1805,36 +1805,38 @@
   public static 
-void
+Window
  showCWF(BaseCom
@@ -1854,24 +1854,31 @@
 ) %7B%0A        
+return 
 showCWF(root
@@ -1914,35 +1914,23 @@
 RTIES);%0A
-        
 %0A    %7D%0A
-    
 %0A    /**
@@ -2005,17 +2005,16 @@
 .%0A     *
- 
 %0A     * 
@@ -2103,16 +2103,43 @@
 erties.%0A
+     * @return The dialog.%0A
      */%0A
@@ -2160,12 +2160,14 @@
 tic 
-void
+Window
  sho
@@ -2231,16 +2231,23 @@
         
+return 
 showXML(
@@ -2297,27 +2297,15 @@
 ));%0A
-        
 %0A    %7D%0A
-    
 %0A   

Return window instance from XMLViewer methods.