BrightSide Workbench Full Report + Source Code
PreviewHtml.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2013 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 package org.turro.zkoss.dialog;
20 
21 import org.turro.elephant.zkoss.Modal;
22 import org.turro.i18n.I_;
23 import org.turro.zul.frame.Framework;
24 import org.zkoss.zul.Html;
25 import org.zkoss.zul.Style;
26 import org.zkoss.zul.Window;
27 
32 public class PreviewHtml extends Window {
33 
34  private Html html;
35 
36  public void setPublication(String publication) {
37  addDefaults();
38  html.setContent(publication);
39  }
40 
41  private void addDefaults() {
42  appendChild(new Style("/_internal/css/default.css"));
43  appendChild(new Style("/_internal/css/default-site.css"));
44  html = new Html();
45  html.setWidth("100%");
46  html.setHeight("100%");
47  appendChild(html);
48  setContentStyle("overflow:auto");
49  }
50 
51  public static void preview(String html) throws InterruptedException {
52  Framework frame = Framework.getCurrent();
53  if(html != null) {
54  PreviewHtml ph = new PreviewHtml();
55  ph.setPage(frame.getPage());
56  ph.setMode("modal");
57  ph.setBorder("normal");
58  ph.setTitle(I_.get("Preview"));
59  ph.setClosable(true);
60  ph.setSizable(true);
61  ph.setMaximizable(true);
62  ph.setWidth("700px");
63  ph.setHeight("600px");
64  ph.setPublication(html);
65  ph.setMaximized(false);
66  Modal.doModal(ph, null);
67  }
68  }
69 
70 }
static int doModal(String file)
Definition: Modal.java:38
static String get(String msg)
Definition: I_.java:41
static void preview(String html)
void setPublication(String publication)
static Framework getCurrent()
Definition: Framework.java:203