19 package org.turro.attach.zul;
21 import java.awt.image.BufferedImage;
22 import java.io.ByteArrayInputStream;
24 import javax.imageio.ImageIO;
25 import org.turro.attach.db.LoadContent;
26 import org.turro.attach.entity.Attachment;
27 import org.turro.elephant.util.Images;
28 import org.turro.i18n.I_;
29 import org.turro.preview.Preview;
30 import org.turro.zkoss.dialog.Windows;
31 import org.zkoss.zk.ui.event.Event;
32 import org.zkoss.zk.ui.event.EventListener;
33 import org.zkoss.zk.ui.event.Events;
34 import org.zkoss.zul.Image;
35 import org.zkoss.zul.Toolbarbutton;
41 public class PreviewButton extends Toolbarbutton implements EventListener<Event> {
46 this.attachment = attachment;
48 setTooltiptext(
I_.
get(
"Preview"));
49 addEventListener(Events.ON_CLICK,
this);
53 public void onEvent(Event event)
throws Exception {
54 Preview preview = Preview.from(
new ByteArrayInputStream(
56 File result = preview.get();
58 BufferedImage bi = ImageIO.read(result);
59 Image image =
new Image();
static byte[] getContent(Attachment attachment)
String getFileExtension()
static String getImage(String image)
static String get(String msg)
static Windows title(String title)
Windows addComponent(HtmlBasedComponent component)
Windows adaptHeight(int height)
Windows onClose(Consumer< Windows > onClose)
Windows adaptWidth(int width)