use of net.sf.jasperreports.engine.JasperPrint in project VaadinUtils by rlsutton1.
the class JasperManager method fillReport.
// /**
// * Binds a value to a report parameter.
// *
// * Essentially a report can have a no. of named parameters which are used
// to
// * filter the report or display on the report. This method allows you to
// * pass in a map (name, value) of parameter value at runtime.
// *
// * @param parameters
// * a map of name/value pairs to bind to report parameters of the
// * given names.
// */
//
// private void bindParameters(Map<String, Object> parameters)
// {
// for (String parameterName : parameters.keySet())
// {
// Preconditions.checkArgument(paramExists(parameterName),
// "The passed Jasper Report parameter: "
// + parameterName + " does not existing on the Report");
//
// boundParams.put(parameterName, parameters.get(parameterName));
// }
// }
private JasperPrint fillReport(OutputFormat outputFormat) throws JRException, InterruptedException {
Connection connection = reportProperties.getConnection();
fillHandle = CustomAsynchronousFillHandle.createCustomHandle(jasperReport, boundParams, connection);
fillHandle.setDataProvider(reportProperties, outputFormat);
fillHandle.addFillListener(new FillListener() {
@Override
public void pageUpdated(JasperPrint jasperPrint, int pageIndex) {
queueEntry.setStatus("Filling page " + pageIndex);
}
@Override
public void pageGenerated(JasperPrint jasperPrint, int pageIndex) {
queueEntry.setStatus("Generating page " + pageIndex);
}
});
AsyncJasperPrintAccessor asyncAccessor = new AsyncJasperPrintAccessor(fillHandle);
if (!stop) {
fillHandle.startFill();
}
// boundParams, connection);
while (asyncAccessor.getReportStatus().getStatus() == ReportExecutionStatus.Status.RUNNING) {
Thread.sleep(100);
}
return asyncAccessor.getFinalJasperPrint();
}
use of net.sf.jasperreports.engine.JasperPrint in project archi by archimatetool.
the class JasperReportsExporter method export.
/**
* Export the model to Jasper Reports
* @param monitor Progress Monitor. Can be null
* @throws IOException
* @throws JRException
*/
public void export(IProgressMonitor monitor) throws IOException, JRException {
progressMonitor = monitor;
if (progressMonitor != null) {
progressMonitor.beginTask(Messages.JasperReportsExporter_0, -1);
}
// Temp Folder to store assets
// $NON-NLS-1$
File tmpFolder = new File(fExportFolder, "tmp");
tmpFolder.mkdirs();
try {
writeDiagrams(tmpFolder);
JasperPrint jasperPrint = createJasperPrint(tmpFolder);
if ((fExportOptions & EXPORT_HTML) != 0) {
setProgressSubTask(Messages.JasperReportsExporter_3);
// $NON-NLS-1$
exportHTML(jasperPrint, new File(fExportFolder, fExportFileName + ".html"));
}
if ((fExportOptions & EXPORT_PDF) != 0) {
setProgressSubTask(Messages.JasperReportsExporter_4);
// $NON-NLS-1$
exportPDF(jasperPrint, new File(fExportFolder, fExportFileName + ".pdf"));
}
if ((fExportOptions & EXPORT_DOCX) != 0) {
setProgressSubTask(Messages.JasperReportsExporter_5);
// $NON-NLS-1$
exportDOCX(jasperPrint, new File(fExportFolder, fExportFileName + ".docx"));
}
if ((fExportOptions & EXPORT_PPT) != 0) {
setProgressSubTask(Messages.JasperReportsExporter_6);
// $NON-NLS-1$
exportPPT(jasperPrint, new File(fExportFolder, fExportFileName + ".pptx"));
}
if ((fExportOptions & EXPORT_RTF) != 0) {
setProgressSubTask(Messages.JasperReportsExporter_7);
// $NON-NLS-1$
exportRTF(jasperPrint, new File(fExportFolder, fExportFileName + ".rtf"));
}
if ((fExportOptions & EXPORT_ODT) != 0) {
setProgressSubTask(Messages.JasperReportsExporter_8);
// $NON-NLS-1$
exportODT(jasperPrint, new File(fExportFolder, fExportFileName + ".odt"));
}
} finally {
if (DELETE_TEMP_FILES) {
setProgressSubTask(Messages.JasperReportsExporter_9);
FileUtils.deleteFolder(tmpFolder);
}
}
}
use of net.sf.jasperreports.engine.JasperPrint in project dwoss by gg-net.
the class DocumentPrintAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
Ui.exec(() -> {
// TODO: This is a very special case, there the Ui needs the result on construction. So the consumer pattern cannot be used.
// This meeans, for now no progress display.
JasperPrint print = Dl.remote().lookup(DocumentSupporter.class).render(document, type);
CustomerMetaData customer = Dl.remote().lookup(CustomerService.class).asCustomerMetaData(customerId);
boolean mailAvailable = customer.getEmail() != null && !customer.getEmail().trim().isEmpty();
Ui.exec(() -> {
Ui.build().parent(controller.getView()).swing().eval(() -> new JRViewerCask(print, document, type, mailAvailable)).opt().filter(c -> c.isCorrectlyBriefed()).ifPresent(c -> Ui.progress().call(() -> {
CustomerDocument customerDocument = new CustomerDocument(customer.getFlags(), document, customer.getShippingCondition(), customer.getPaymentMethod());
for (StateTransition<CustomerDocument> stateTransition : Dl.remote().lookup(RedTapeWorker.class).getPossibleTransitions(customerDocument)) {
RedTapeStateTransition redTapeStateTransition = (RedTapeStateTransition) stateTransition;
for (RedTapeStateTransition.Hint hint : redTapeStateTransition.getHints()) {
if (hint == RedTapeStateTransition.Hint.SENDED_INFORMATION) {
this.document = Optional.of(Dl.remote().lookup(RedTapeWorker.class).stateChange(customerDocument, redTapeStateTransition, Lookup.getDefault().lookup(Guardian.class).getUsername())).filter(Ui.failure()::handle).map(Reply::getPayload).orElse(document);
}
}
}
controller.reloadSelectionOnStateChange(Dl.remote().lookup(DocumentSupporter.class).briefed(document, Dl.local().lookup(Guardian.class).getUsername()));
return null;
}));
});
});
}
use of net.sf.jasperreports.engine.JasperPrint in project dwoss by gg-net.
the class RedTapeController method openDocument.
/**
* This method is called if a chosen Document will be printed and/or sent per E-Mail.
* This Method become a Document and will open a JasperViewer that contains also a Send Button for sending E-Mail
* <p/>
* @param document
*/
public void openDocument(Document document, boolean printAsReservation) {
JasperPrint print = Dl.remote().lookup(DocumentSupporter.class).render(document, (printAsReservation ? DocumentViewType.RESERVATION : DocumentViewType.DEFAULT));
JDialog d = new JDialog(parent(), "Dokument drucken/versenden");
d.setSize(800, 1000);
d.setModalityType(Dialog.ModalityType.DOCUMENT_MODAL);
d.setLocationRelativeTo(view);
d.getContentPane().setLayout(new BorderLayout());
boolean canEmaild = model.getPurchaseCustomer().getEmail() != null && model.getPurchaseCustomer().getEmail().trim().isEmpty();
JRViewerCask jrViewerCask = new JRViewerCask(print, document, (printAsReservation ? DocumentViewType.RESERVATION : DocumentViewType.DEFAULT), canEmaild);
d.getContentPane().add(jrViewerCask, BorderLayout.CENTER);
d.setVisible(true);
if (jrViewerCask.isCorrectlyBriefed()) {
reloadSelectionOnStateChange(Dl.remote().lookup(DocumentSupporter.class).briefed(document, Dl.local().lookup(Guardian.class).getUsername()));
}
}
use of net.sf.jasperreports.engine.JasperPrint in project dwoss by gg-net.
the class DocumentSupporterIT method testCreate.
/**
* Test of create method, of class RedTapeOperation.
*/
@Test
public void testCreate() {
Dossier dos = new Dossier();
dos.setPaymentMethod(PaymentMethod.ADVANCE_PAYMENT);
dos.setDispatch(true);
dos.setCustomerId(1);
Document doc = new Document();
doc.setType(DocumentType.ORDER);
doc.setActive(true);
doc.setDirective(Document.Directive.WAIT_FOR_MONEY);
doc.setHistory(new DocumentHistory("JUnit", "Automatische Erstellung eines leeren Dokuments"));
Address a = new Address("Herr Muh\nMuhstrasse 7\n12345 Muhstadt");
doc.setInvoiceAddress(a);
doc.setShippingAddress(a);
dos.add(doc);
doc.append(NaivBuilderUtil.comment());
doc.append(NaivBuilderUtil.service());
doc.append(NaivBuilderUtil.shippingcost());
JasperPrint print = documentSupporter.render(doc, DocumentViewType.DEFAULT);
assertNotNull("A JasperPrint should not be null", print);
}
Aggregations