public Object execute(ExecutionEvent event) throws ExecutionException {
PrintDialog printDialog = new PrintDialog(HandlerUtil.getActiveShell(event));
PrinterData printerData = printDialog.open();
if(printerData != null ) {
Printer printer = new Printer(printerData);
if(printer.startJob("Text")) {
GC gc = new GC(printer);
View view = (View) HandlerUtil.getActivePart(event);
SieveResult sr = view.getSieveData().getSeiveResult();
SingleSieve[] s = sr.getSieves();
if(printer.startPage()) {
gc.drawString("Total mass = " + Double.toString(sr.getTotal()) + " gr", 100, 100 );
gc.drawLine(85, 135, 600, 135);
gc.drawLine(85, 185, 600, 185);
gc.drawLine(85, s.length * 50 + 185, 600, s.length * 50 + 185);
gc.drawString("Sieve NO.", 100, 150 );
gc.drawString("Size( mm )", 200, 150 );
gc.drawString("Remind", 300, 150 );
gc.drawString("% Reminded", 400, 150 );
gc.drawString("% Finer", 500, 150);
for( int i = 0; i < s.length; i++ ) {
gc.drawString(s[i].getNo(), 100, 150 + ( i + 1 ) * 50);
gc.drawString("" + s[i].getSize(), 200, 150 + ( i + 1 ) * 50);
gc.drawString("" + s[i].getReminded(), 300, 150 + ( i + 1 ) * 50);
gc.drawString("" + s[i].getPercentReminded(), 400, 150 + ( i + 1 ) * 50);
gc.drawString("" + s[i].getPercentFiner(), 500, 150 + ( i + 1 ) * 50);
}
printer.endPage();
}
gc.dispose();
printer.endJob();
}
printer.dispose();
}
return null;
}