5 |
5 |
*
|
6 |
6 |
* Servoy - Smart Technology For Smart Clients.
|
7 |
7 |
* Copyright \ufffd 1997-2012 Servoy BV http://www.servoy.com
|
8 |
|
*
|
|
8 |
*
|
9 |
9 |
* This library is free software; you can redistribute it and/or
|
10 |
10 |
* modify it under the terms of the GNU Lesser General Public
|
11 |
11 |
* License as published by the Free Software Foundation; either
|
12 |
12 |
* version 2.1 of the License, or (at your option) any later version.
|
13 |
|
*
|
|
13 |
*
|
14 |
14 |
* This library is distributed in the hope that it will be useful,
|
15 |
15 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
17 |
17 |
* Lesser General Public License for more details.
|
18 |
|
*
|
|
18 |
*
|
19 |
19 |
* You should have received a copy of the GNU Lesser General Public
|
20 |
20 |
* License along with this library; if not, write to the Free Software
|
21 |
21 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
22 |
|
*
|
|
22 |
*
|
23 |
23 |
* Servoy B.V.
|
24 |
24 |
* De Brand 26
|
25 |
25 |
* 3823 LJ Amersfoort
|
... | ... | |
54 |
54 |
import com.servoy.j2db.util.ComponentFactoryHelper;
|
55 |
55 |
import com.servoy.j2db.util.Debug;
|
56 |
56 |
import com.servoy.j2db.util.PersistHelper;
|
57 |
|
import com.servoy.plugins.jasperreports.IJasperReportsService;
|
58 |
57 |
import com.servoy.plugins.jasperreports.JR_SVY_VIEWER_DISPLAY_MODE;
|
59 |
58 |
import com.servoy.plugins.jasperreports.JasperReportsPlugin;
|
60 |
59 |
import com.servoy.plugins.jasperreports.JasperReportsProvider;
|
61 |
60 |
|
62 |
61 |
/**
|
63 |
62 |
* JasperReportsServoyViewer: the real bean component.
|
64 |
|
*
|
|
63 |
*
|
65 |
64 |
* Implements all necessary scripting functions and all get/set methods for indicated properties.
|
66 |
|
*
|
|
65 |
*
|
67 |
66 |
* @author acostache
|
68 |
67 |
*
|
69 |
68 |
*/
|
... | ... | |
71 |
70 |
public class JasperReportsServoyViewer extends JPanel implements IScriptable, IServoyAwareBean
|
72 |
71 |
{
|
73 |
72 |
private static final long serialVersionUID = 1L;
|
74 |
|
private IJasperReportsService service = null;
|
75 |
73 |
private JasperReportsPlugin jasper = null;
|
76 |
74 |
private JasperReportsProvider provider = null;
|
77 |
75 |
protected String currentDisplayMode = null;
|
78 |
76 |
private String[] beanViewerExportFormats = null;
|
79 |
|
|
|
77 |
|
80 |
78 |
public JasperReportsServoyViewer()
|
81 |
79 |
{
|
82 |
80 |
setLayout(new BorderLayout());
|
83 |
81 |
setPreferredSize(new Dimension(700,550));
|
84 |
82 |
}
|
85 |
|
|
|
83 |
|
86 |
84 |
public boolean isReadOnly() {
|
87 |
85 |
return false;
|
88 |
86 |
}
|
... | ... | |
96 |
94 |
|
97 |
95 |
public void initialize(IClientPluginAccess app) {
|
98 |
96 |
try {
|
99 |
|
service = (IJasperReportsService) app.getServerService("servoy.IJasperReportService");
|
100 |
97 |
jasper = (JasperReportsPlugin)app.getPluginManager().getPlugin(IClientPlugin.class,"jasperPluginRMI");
|
101 |
98 |
provider = (JasperReportsProvider)jasper.getScriptObject();
|
102 |
99 |
} catch (Exception e) {
|
... | ... | |
106 |
103 |
|
107 |
104 |
public void setSelectedRecord(IRecord arg0) {
|
108 |
105 |
}
|
109 |
|
|
|
106 |
|
110 |
107 |
/*
|
111 |
108 |
* (non-Javadoc)
|
112 |
109 |
* @see com.servoy.j2db.scripting.IScriptObject#getAllReturnedTypes()
|
... | ... | |
182 |
179 |
public void setSize(int width, int height) {
|
183 |
180 |
super.setSize(width, height);
|
184 |
181 |
}
|
185 |
|
|
|
182 |
|
186 |
183 |
public void js_setName(String name) {
|
187 |
184 |
setName(name);
|
188 |
185 |
}
|
189 |
|
|
|
186 |
|
190 |
187 |
/**
|
191 |
188 |
* Gets or sets the name of the Bean.
|
192 |
|
*
|
|
189 |
*
|
193 |
190 |
* @sample
|
194 |
191 |
* var beanName = %%elementName%%.name;
|
195 |
|
*
|
|
192 |
*
|
196 |
193 |
* @return the name of the Bean
|
197 |
194 |
*/
|
198 |
195 |
public String js_getName() {
|
199 |
196 |
return getName();
|
200 |
197 |
}
|
201 |
|
|
|
198 |
|
202 |
199 |
public void js_setBackground(String background) {
|
203 |
200 |
setBackground(PersistHelper.createColor(background));
|
204 |
201 |
}
|
205 |
202 |
|
206 |
203 |
/**
|
207 |
204 |
* Sets or gets the background color of the Bean.
|
208 |
|
*
|
|
205 |
*
|
209 |
206 |
* @sample
|
210 |
207 |
* %%elementName%%.background='#00ff00';
|
211 |
|
*
|
|
208 |
*
|
212 |
209 |
* @return the border color of the bean
|
213 |
210 |
*/
|
214 |
211 |
public String js_getBackground() {
|
215 |
212 |
return (getBackground() == null) ? null : PersistHelper.createColorString(getBackground());
|
216 |
213 |
}
|
217 |
|
|
|
214 |
|
218 |
215 |
public void js_setBorder(String border) {
|
219 |
216 |
setBorder(ComponentFactoryHelper.createBorder(border));
|
220 |
217 |
}
|
221 |
|
|
|
218 |
|
222 |
219 |
/**
|
223 |
220 |
* Sets or gets the border type, width and color.
|
224 |
|
*
|
|
221 |
*
|
225 |
222 |
* @sample
|
226 |
223 |
* %%elementName%%.border='LineBorder,4,#000000';
|
227 |
|
*
|
|
224 |
*
|
228 |
225 |
* @return border type, width and color
|
229 |
226 |
*/
|
230 |
227 |
public String js_getBorder() {
|
231 |
228 |
return ComponentFactoryHelper.createBorderString(getBorder());
|
232 |
229 |
}
|
233 |
|
|
|
230 |
|
234 |
231 |
/**
|
235 |
232 |
* Sets or gets the display mode of the viewer in the Bean.
|
236 |
|
*
|
|
233 |
*
|
237 |
234 |
* @sample
|
238 |
235 |
* %%elementName%%.displayMode = JR_SVY_VIEWER_DISPLAY_MODE.FIT_WIDTH;
|
239 |
236 |
* %%elementName%%.showReport(myDataSource,"myReport.jrxml",null);
|
240 |
|
*
|
|
237 |
*
|
241 |
238 |
* @return the display mode of the viewer
|
242 |
239 |
*/
|
243 |
240 |
public String js_getDisplayMode() {
|
244 |
241 |
//make a pretty name for the display mode type
|
245 |
242 |
String disp = "";
|
246 |
|
for (String d : currentDisplayMode.split("_"))
|
247 |
|
{
|
|
243 |
for (String d : currentDisplayMode.split("_"))
|
|
244 |
{
|
248 |
245 |
d = d.substring(0, 1).toUpperCase() + d.substring(1);
|
249 |
246 |
disp = disp + d + " ";
|
250 |
247 |
}
|
251 |
248 |
return disp.substring(0, disp.length() - 1);
|
252 |
249 |
}
|
253 |
|
|
|
250 |
|
254 |
251 |
public void js_setDisplayMode(String displayMode) {
|
255 |
252 |
this.currentDisplayMode = displayMode;
|
256 |
253 |
}
|
257 |
|
|
|
254 |
|
258 |
255 |
public void js_setFont(String fontString) {
|
259 |
256 |
if (fontString != null) {
|
260 |
257 |
setFont(PersistHelper.createFont(fontString));
|
261 |
258 |
}
|
262 |
259 |
}
|
263 |
|
|
|
260 |
|
264 |
261 |
/**
|
265 |
262 |
* Sets or gets the font type of the Bean's viewer.
|
266 |
|
*
|
|
263 |
*
|
267 |
264 |
* @sample
|
268 |
265 |
* %%elementName%%.font='Tahoma,0,14';
|
269 |
|
*
|
|
266 |
*
|
270 |
267 |
* @return the font type used in the viewer
|
271 |
268 |
*/
|
272 |
269 |
public String js_getFont() {
|
... | ... | |
276 |
273 |
public void js_setForeground(String foregroundString) {
|
277 |
274 |
setForeground(PersistHelper.createColor(foregroundString));
|
278 |
275 |
}
|
279 |
|
|
|
276 |
|
280 |
277 |
/**
|
281 |
278 |
* Sets or gets the foreground color.
|
282 |
|
*
|
|
279 |
*
|
283 |
280 |
* @sample
|
284 |
281 |
* %%elementName%%.foreground='#000000';
|
285 |
|
*
|
|
282 |
*
|
286 |
283 |
* @return the foreground color
|
287 |
284 |
*/
|
288 |
285 |
public String js_getForeground() {
|
289 |
|
return (getForeground() == null) ? null :
|
|
286 |
return (getForeground() == null) ? null :
|
290 |
287 |
PersistHelper.createColorString(getForeground());
|
291 |
288 |
}
|
292 |
|
|
|
289 |
|
293 |
290 |
public void js_setLocation(int x, int y) {
|
294 |
291 |
setLocation(x,y);
|
295 |
292 |
}
|
296 |
|
|
|
293 |
|
297 |
294 |
/**
|
298 |
295 |
* Gets the x-coordinate of the Bean's top-left corner location.
|
299 |
|
*
|
|
296 |
*
|
300 |
297 |
* @sample
|
301 |
298 |
* var x = %%elementName%%.getLocationX();
|
302 |
|
*
|
|
299 |
*
|
303 |
300 |
* @return the x-coordinate of the Bean's top-left corner location
|
304 |
301 |
*/
|
305 |
302 |
public int js_getLocationX() {
|
... | ... | |
308 |
305 |
|
309 |
306 |
/**
|
310 |
307 |
* Gets the y-coordinate of the Bean's top-left corner location.
|
311 |
|
*
|
|
308 |
*
|
312 |
309 |
* @sample
|
313 |
310 |
* var y = %%elementName%%.getLocationY();
|
314 |
|
*
|
|
311 |
*
|
315 |
312 |
* @return the y-coordinate of the Bean's top-left corner location
|
316 |
313 |
*/
|
317 |
314 |
public int js_getLocationY() {
|
318 |
315 |
return getLocation().y;
|
319 |
316 |
}
|
320 |
|
|
|
317 |
|
321 |
318 |
/**
|
322 |
319 |
* Sets the size of the Bean.
|
323 |
|
*
|
|
320 |
*
|
324 |
321 |
* @sample
|
325 |
322 |
* %%elementName%%.setSize(800,600);
|
326 |
|
*
|
|
323 |
*
|
327 |
324 |
* @param width the width of the bean
|
328 |
325 |
* @param height the height of the bean
|
329 |
326 |
*/
|
330 |
327 |
public void js_setSize(int width, int height) {
|
331 |
328 |
setSize(width,height);
|
332 |
329 |
}
|
333 |
|
|
|
330 |
|
334 |
331 |
/**
|
335 |
332 |
* Gets the width of the Bean.
|
336 |
|
*
|
|
333 |
*
|
337 |
334 |
* @sample
|
338 |
335 |
* var w = %%elementName%%.getWidth();
|
339 |
|
*
|
|
336 |
*
|
340 |
337 |
* @return the width of the Bean
|
341 |
338 |
*/
|
342 |
339 |
public int js_getWidth() {
|
343 |
340 |
return getSize().width;
|
344 |
341 |
}
|
345 |
|
|
|
342 |
|
346 |
343 |
/**
|
347 |
344 |
* Gets the height of the Bean.
|
348 |
|
*
|
|
345 |
*
|
349 |
346 |
* @sample
|
350 |
347 |
* var h = %%elementName%%.getHeight();
|
351 |
|
*
|
|
348 |
*
|
352 |
349 |
* @return the height of the Bean
|
353 |
350 |
*/
|
354 |
351 |
public int js_getHeight() {
|
355 |
352 |
return getSize().height;
|
356 |
353 |
}
|
357 |
|
|
|
354 |
|
358 |
355 |
public void js_setTransparent(boolean transparent) {
|
359 |
356 |
setTransparent(true);
|
360 |
357 |
}
|
361 |
|
|
|
358 |
|
362 |
359 |
public boolean js_getTransparent() {
|
363 |
360 |
return isTransparent();
|
364 |
361 |
}
|
365 |
|
|
|
362 |
|
366 |
363 |
/**
|
367 |
364 |
* @deprecated
|
368 |
365 |
*/
|
... | ... | |
370 |
367 |
public void js_setReportsDirectory(String reportsDirectory) throws Exception {
|
371 |
368 |
provider.js_setReportDirectory(reportsDirectory);
|
372 |
369 |
}
|
373 |
|
|
|
370 |
|
374 |
371 |
/**
|
375 |
372 |
* @deprecated replaced by the relativeReportsDirectory property
|
376 |
373 |
*/
|
... | ... | |
378 |
375 |
public String js_getReportsDirectory() throws Exception {
|
379 |
376 |
return provider.js_getReportDirectory();
|
380 |
377 |
}
|
381 |
|
|
|
378 |
|
382 |
379 |
public void js_setRelativeReportsDirectory(String relativeReportsDirectory) throws Exception {
|
383 |
380 |
provider.js_setRelativeReportsDirectory(relativeReportsDirectory);
|
384 |
381 |
}
|
385 |
|
|
|
382 |
|
386 |
383 |
/**
|
387 |
384 |
* Property for retrieving and setting the path to the reports directory, set by the current client, relative to the server reports directory
|
388 |
385 |
* of the Servoy JasperReports plugin.
|
389 |
|
*
|
|
386 |
*
|
390 |
387 |
* Please refer to the same property of the Servoy JasperReports plugin for more details.
|
391 |
|
*
|
|
388 |
*
|
392 |
389 |
* @sample
|
393 |
390 |
* %%elementName%%.relativeReportsDirectory = 'relativePath/to/serverReportsDirectory';
|
394 |
|
*
|
|
391 |
*
|
395 |
392 |
* @return the location of the client set reports directory, relative to the server set path
|
396 |
|
*
|
|
393 |
*
|
397 |
394 |
* @throws Exception
|
398 |
395 |
*/
|
399 |
396 |
public String js_getRelativeReportsDirectory() throws Exception {
|
... | ... | |
403 |
400 |
public void js_setRelativeExtraDirectories(String relativeExtraDirectories) throws Exception {
|
404 |
401 |
provider.js_setRelativeExtraDirectories(relativeExtraDirectories);
|
405 |
402 |
}
|
406 |
|
|
|
403 |
|
407 |
404 |
/**
|
408 |
405 |
* Get or set the relative path or comma separated paths to the extra resource directories of the Servoy JasperReports plugin.
|
409 |
406 |
* The paths are set per client and are relative to the server corresponding directories setting.
|
410 |
|
*
|
|
407 |
*
|
411 |
408 |
* Please refer to the same property of the Servoy JasperReports plugin for more details.
|
412 |
|
*
|
|
409 |
*
|
413 |
410 |
* @sample
|
414 |
411 |
* %%elementName%%.extraDirectories='relative/path/to/client/extraDirectory1';
|
415 |
|
*
|
|
412 |
*
|
416 |
413 |
* @return the relative path or paths to the client set extra directory/directories
|
417 |
|
*
|
|
414 |
*
|
418 |
415 |
* @throws Exception
|
419 |
416 |
*/
|
420 |
417 |
public String js_getRelativeExtraDirectories() throws Exception {
|
421 |
418 |
return provider.js_getRelativeExtraDirectories();
|
422 |
419 |
}
|
423 |
|
|
424 |
|
|
|
420 |
|
|
421 |
|
425 |
422 |
/**
|
426 |
423 |
* @deprecated
|
427 |
424 |
*/
|
... | ... | |
429 |
426 |
public void js_setExtraDirectories(String extraDirectories) throws Exception {
|
430 |
427 |
provider.js_setExtraDirectories(extraDirectories);
|
431 |
428 |
}
|
432 |
|
|
|
429 |
|
433 |
430 |
/**
|
434 |
431 |
* @deprecated replaced by the relativeExtraDirectories property
|
435 |
432 |
*/
|
... | ... | |
437 |
434 |
public String js_getExtraDirectories() throws Exception {
|
438 |
435 |
return provider.js_getExtraDirectories();
|
439 |
436 |
}
|
440 |
|
|
|
437 |
|
441 |
438 |
/**
|
442 |
439 |
* @clonedesc js_showReport(Object, String, Object, String, Boolean)
|
443 |
440 |
* @sampleas js_showReport(Object, String, Object, String, Boolean)
|
444 |
|
*
|
|
441 |
*
|
445 |
442 |
* @param source the datasource (the server name, foundset or dataset) to run the report on
|
446 |
443 |
* @param report the report file to export and preview (relative to the reports directory)
|
447 |
444 |
* @param parameters the map of parameters to be used when previewing the report
|
448 |
|
*
|
|
445 |
*
|
449 |
446 |
* @throws Exception
|
450 |
447 |
*/
|
451 |
448 |
public void js_showReport(Object source, String report, Object parameters) throws Exception {
|
... | ... | |
455 |
452 |
/**
|
456 |
453 |
* @clonedesc js_showReport(Object, String, Object, String, Boolean)
|
457 |
454 |
* @sampleas js_showReport(Object, String, Object, String, Boolean)
|
458 |
|
*
|
|
455 |
*
|
459 |
456 |
* @param source the datasource (the server name, foundset or dataset) to run the report on
|
460 |
457 |
* @param report the report file to export and preview (relative to the reports directory)
|
461 |
458 |
* @param parameters the map of parameters to be used when previewing the report
|
462 |
459 |
* @param localeString the string which specifies the locale
|
463 |
|
*
|
|
460 |
*
|
464 |
461 |
* @throws Exception
|
465 |
462 |
*/
|
466 |
463 |
public void js_showReport(Object source, String report, Object parameters, String localeString)
|
467 |
464 |
throws Exception {
|
468 |
465 |
js_showReport(source, report, parameters,localeString, Boolean.valueOf(false));
|
469 |
466 |
}
|
470 |
|
|
|
467 |
|
471 |
468 |
/**
|
472 |
469 |
* Shows the indicated report in a JasperReports Viewer (in the Bean).
|
473 |
|
*
|
|
470 |
*
|
474 |
471 |
* @sample
|
475 |
472 |
* var params = new Object();
|
476 |
473 |
* params.SUBREPORT_DIR = "./Subreport_Tests/";
|
477 |
474 |
* var report = %%elementName%%.showReport(customers_to_orders,"/Subreport_Tests/main_report_fs.jrxml",params);
|
478 |
|
*
|
|
475 |
*
|
479 |
476 |
* @param source the datasource (the server name, foundset or dataset) to run the report on
|
480 |
477 |
* @param report the report file to export and preview (relative to the reports directory)
|
481 |
478 |
* @param parameters the map of parameters to be used when previewing the report
|
482 |
479 |
* @param localeString the string which specifies the locale
|
483 |
480 |
* @param moveTableOfContent true in order to move the table of contents, false otherwise
|
484 |
|
*
|
|
481 |
*
|
485 |
482 |
* @throws Exception
|
486 |
483 |
*/
|
487 |
484 |
public void js_showReport(Object source, String report, Object parameters, String localeString,
|
488 |
485 |
Boolean moveTableOfContent) throws Exception{
|
489 |
486 |
showReport(source, report, parameters, localeString, moveTableOfContent);
|
490 |
487 |
}
|
491 |
|
|
|
488 |
|
492 |
489 |
public void js_setBeanViewerExportFormats(String[] saveContribs) throws Exception {
|
493 |
490 |
beanViewerExportFormats = saveContribs;
|
494 |
491 |
}
|
495 |
|
|
|
492 |
|
496 |
493 |
/**
|
497 |
494 |
* Gets or gets the file save/export formats of the Bean's viewer.
|
498 |
|
*
|
|
495 |
*
|
499 |
496 |
* @sample
|
500 |
497 |
* //also see plugins.jasperPluginRMI.viewerExportFormats
|
501 |
498 |
* %%elementName%%.beanViewerExportFormats=[OUTPUT_FORMAT.PDF, OUTPUT_FORMAT.XLS];
|
502 |
|
*
|
|
499 |
*
|
503 |
500 |
* @return the file save/export formats of the viewer
|
504 |
|
*
|
|
501 |
*
|
505 |
502 |
* @throws Exception
|
506 |
503 |
*/
|
507 |
504 |
public String[] js_getBeanViewerExportFormats() throws Exception {
|
508 |
505 |
return beanViewerExportFormats;
|
509 |
506 |
}
|
510 |
|
|
|
507 |
|
511 |
508 |
protected JRViewerWrapper jrv;
|
512 |
509 |
private class JRViewerWrapper extends JRViewer
|
513 |
510 |
{
|
... | ... | |
517 |
514 |
{
|
518 |
515 |
super(jp);
|
519 |
516 |
}
|
520 |
|
|
|
517 |
|
521 |
518 |
public void btnFitPagePressed()
|
522 |
519 |
{
|
523 |
520 |
btnFitPage.setSelected(true);
|
... | ... | |
525 |
522 |
btnFitWidth.setSelected(false);
|
526 |
523 |
cmbZoom.setSelectedIndex(-1);
|
527 |
524 |
}
|
528 |
|
|
|
525 |
|
529 |
526 |
public boolean isBtnFitPagePressed()
|
530 |
527 |
{
|
531 |
528 |
return btnFitPage.isSelected();
|
532 |
529 |
}
|
533 |
|
|
|
530 |
|
534 |
531 |
public void selectBtnFitPage()
|
535 |
532 |
{
|
536 |
533 |
btnFitPage.setSelected(true);
|
537 |
534 |
}
|
538 |
|
|
539 |
|
|
|
535 |
|
|
536 |
|
540 |
537 |
public void btnFitWidthPressed()
|
541 |
538 |
{
|
542 |
539 |
btnFitWidth.setSelected(true);
|
... | ... | |
544 |
541 |
btnActualSize.setSelected(false);
|
545 |
542 |
cmbZoom.setSelectedIndex(-1);
|
546 |
543 |
}
|
547 |
|
|
|
544 |
|
548 |
545 |
public boolean isBtnFitWidthPressed()
|
549 |
546 |
{
|
550 |
547 |
return btnFitWidth.isSelected();
|
551 |
548 |
}
|
552 |
|
|
|
549 |
|
553 |
550 |
public void selectBtnFitWidth()
|
554 |
551 |
{
|
555 |
552 |
btnFitWidth.setSelected(true);
|
556 |
553 |
}
|
557 |
|
|
|
554 |
|
558 |
555 |
public void btnActualSizePressed()
|
559 |
556 |
{
|
560 |
557 |
btnActualSize.setSelected(true);
|
... | ... | |
563 |
560 |
cmbZoom.setSelectedIndex(-1);
|
564 |
561 |
setZoomRatio(1);
|
565 |
562 |
}
|
566 |
|
|
|
563 |
|
567 |
564 |
public boolean isBtnActualSizePressed()
|
568 |
565 |
{
|
569 |
566 |
return btnActualSize.isSelected();
|
570 |
567 |
}
|
571 |
|
|
|
568 |
|
572 |
569 |
public void selectBtnActualSize()
|
573 |
570 |
{
|
574 |
571 |
btnActualSize.setSelected(true);
|
575 |
572 |
}
|
576 |
573 |
}
|
577 |
|
|
|
574 |
|
578 |
575 |
// main functionality
|
579 |
576 |
public void showReport(Object source, String report, Object parameters, String localeString,
|
580 |
577 |
Boolean moveTableOfContent) throws Exception{
|
581 |
|
|
|
578 |
|
582 |
579 |
byte[] jasperPrintAsByteArray = provider.runReportForBean(source, report, null, "view", parameters, localeString, moveTableOfContent);
|
583 |
580 |
InputStream jasperPrintAsStream = new ByteArrayInputStream(jasperPrintAsByteArray);
|
584 |
581 |
JasperPrint jp = (JasperPrint) JRLoader.loadObject(jasperPrintAsStream);
|
585 |
582 |
jrv = new JRViewerWrapper(jp);
|
586 |
583 |
if (getComponents().length > 0) removeAll();
|
587 |
584 |
add(jrv, BorderLayout.CENTER);
|
588 |
|
|
|
585 |
|
589 |
586 |
jrv.addComponentListener(new ComponentListener() {
|
590 |
|
public void componentResized(ComponentEvent e) {
|
|
587 |
public void componentResized(ComponentEvent e) {
|
591 |
588 |
// no buttons selected (yet)
|
592 |
589 |
if (!jrv.isBtnActualSizePressed() && !jrv.isBtnFitPagePressed() && !jrv.isBtnFitWidthPressed())
|
593 |
|
{
|
|
590 |
{
|
594 |
591 |
if (JR_SVY_VIEWER_DISPLAY_MODE.FIT_PAGE.equals(currentDisplayMode)) jrv.selectBtnFitPage();
|
595 |
592 |
else if (JR_SVY_VIEWER_DISPLAY_MODE.FIT_WIDTH.equals(currentDisplayMode)) jrv.selectBtnFitWidth();
|
596 |
593 |
else if (JR_SVY_VIEWER_DISPLAY_MODE.ACTUAL_PAGE_SIZE.equals(currentDisplayMode)) jrv.selectBtnActualSize();
|
597 |
594 |
}
|
598 |
595 |
|
599 |
596 |
// if display mode set via scripting && button has been pressed, we resize accordingly
|
600 |
|
// else we resize with respect to the button pressed (we let the viewer do its job alone)
|
|
597 |
// else we resize with respect to the button pressed (we let the viewer do its job alone)
|
601 |
598 |
if (JR_SVY_VIEWER_DISPLAY_MODE.FIT_PAGE.equals(currentDisplayMode) && jrv.isBtnFitPagePressed())
|
602 |
599 |
{
|
603 |
600 |
jrv.setFitPageZoomRatio();
|
... | ... | |
622 |
619 |
|
623 |
620 |
public void componentHidden(ComponentEvent e) {
|
624 |
621 |
}});
|
625 |
|
|
|
622 |
|
626 |
623 |
if (beanViewerExportFormats != null)
|
627 |
624 |
JasperReportsProvider.setViewerSaveContributors(jrv, beanViewerExportFormats);
|
628 |
|
|
|
625 |
|
629 |
626 |
this.validate();
|
630 |
627 |
}
|
631 |
628 |
|
632 |
629 |
/**
|
633 |
630 |
* This is a readonly property which returns the bean version.
|
634 |
631 |
* The bean version indicates which version of the Servoy JasperReports plugin the bean should be used with.
|
635 |
|
*
|
|
632 |
*
|
636 |
633 |
* @sample
|
637 |
634 |
* application.output(%%elementName%%.beanVersion);
|
638 |
|
*
|
|
635 |
*
|
639 |
636 |
* @return the version of the bean; this should be in sync with the version of the plugin used
|
640 |
637 |
*/
|
641 |
638 |
public String js_getBeanVersion()
|
642 |
639 |
{
|
643 |
|
return "Bean version: " + provider.js_getPluginVersion() + ".\nThis version number indicates the bean should be used together with the Servoy JasperReports plugin version " + provider.js_getPluginVersion() + ".";
|
|
640 |
return "Bean version: " + provider.js_getPluginVersion() + ".\nThis version number indicates the bean should be used together with the Servoy JasperReports plugin version " + provider.js_getPluginVersion() + ".";
|
644 |
641 |
}
|
645 |
|
|
|
642 |
|
646 |
643 |
public void js_setBeanVersion(String version)
|
647 |
644 |
{
|
648 |
645 |
//do nothing
|