| 1 |  |  package org.kuali.student.common.ui.client.util; | 
  | 2 |  |   | 
  | 3 |  |  import com.google.gwt.dom.client.Document; | 
  | 4 |  |  import com.google.gwt.dom.client.NodeList; | 
  | 5 |  |  import com.google.gwt.user.client.Window; | 
  | 6 |  |  import com.google.gwt.user.client.ui.UIObject; | 
  | 7 |  |   | 
  | 8 | 0 |  public class PrintUtils { | 
  | 9 | 0 |      private static int num = 0; | 
  | 10 |  |       | 
  | 11 |  |   | 
  | 12 |  |   | 
  | 13 |  |   | 
  | 14 |  |      public static void print(UIObject uiObject){ | 
  | 15 | 0 |              String headTag = ""; | 
  | 16 | 0 |              String styleTags = ""; | 
  | 17 | 0 |              NodeList<com.google.gwt.dom.client.Element> head = Document.get().getElementsByTagName("head"); | 
  | 18 | 0 |              if(head.getItem(0) != null){ | 
  | 19 | 0 |                      com.google.gwt.dom.client.Element e = head.getItem(0); | 
  | 20 | 0 |                      NodeList<com.google.gwt.dom.client.Element> styles = e.getElementsByTagName("style"); | 
  | 21 | 0 |                      for(int i = 0; i < styles.getLength(); i++){ | 
  | 22 | 0 |                              styleTags = styleTags + styles.getItem(i).getString(); | 
  | 23 |  |                               | 
  | 24 |  |                      } | 
  | 25 |  |              } | 
  | 26 | 0 |              headTag = "<HEAD><TITLE>Print - " + Window.getTitle() + "</TITLE>" + styleTags + "</HEAD>"; | 
  | 27 | 0 |              openPrintWindow(uiObject.getElement().getString(), headTag, num); | 
  | 28 | 0 |              num++; | 
  | 29 | 0 |      } | 
  | 30 |  |       | 
  | 31 |  |      private static native void openPrintWindow(String html, String headTag, int num) | 
  | 32 |  |   | 
  | 33 |  |   | 
  | 34 |  |   | 
  | 35 |  |   | 
  | 36 |  |   | 
  | 37 |  |   | 
  | 38 |  |   | 
  | 39 |  |   | 
  | 40 |  |   | 
  | 41 |  |   | 
  | 42 |  |   | 
  | 43 |  |   | 
  | 44 |  |  ; | 
  | 45 |  |  } |