svn-document-layout / trunk / org.gvsig.app.document.layout2.app / org.gvsig.app.document.layout2.app.mainplugin / src / main / java / org / gvsig / app / project / documents / layout / report / LayoutReportActionImpl.java @ 1600
History | View | Annotate | Download (22.4 KB)
1 |
package org.gvsig.app.project.documents.layout.report; |
---|---|
2 |
|
3 |
import java.awt.Dimension; |
4 |
import java.awt.event.ActionEvent; |
5 |
import java.awt.geom.Point2D; |
6 |
import java.io.File; |
7 |
import java.io.InputStream; |
8 |
import java.util.ArrayList; |
9 |
import java.util.List; |
10 |
import java.util.Objects; |
11 |
import javax.json.JsonNumber; |
12 |
import javax.json.JsonObject; |
13 |
import javax.swing.JComponent; |
14 |
import javax.swing.JOptionPane; |
15 |
import javax.swing.SwingUtilities; |
16 |
import org.apache.commons.io.IOUtils; |
17 |
import org.apache.commons.lang3.StringUtils; |
18 |
import org.cresques.cts.ICoordTrans; |
19 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
20 |
import org.gvsig.app.ApplicationLocator; |
21 |
import org.gvsig.app.ApplicationManager; |
22 |
import org.gvsig.app.project.documents.Document; |
23 |
import org.gvsig.app.project.documents.layout.LayoutContext; |
24 |
import org.gvsig.app.project.documents.layout.fframes.FFrameView; |
25 |
import org.gvsig.app.project.documents.layout.fframes.IFFrame; |
26 |
import org.gvsig.app.project.documents.layout.gui.LayoutPanel; |
27 |
import static org.gvsig.app.project.documents.layout.report.LayoutReportActionFactory.LAYOUT_REPORT_ACTION_NAME; |
28 |
import org.gvsig.app.project.documents.view.ViewDocument; |
29 |
import org.gvsig.app.project.documents.view.gui.IView; |
30 |
import org.gvsig.desktopopen.DesktopOpen; |
31 |
import org.gvsig.expressionevaluator.ExpressionEvaluatorLocator; |
32 |
import org.gvsig.expressionevaluator.ExpressionEvaluatorManager; |
33 |
import org.gvsig.expressionevaluator.ExpressionUtils; |
34 |
import org.gvsig.expressionevaluator.MutableSymbolTable; |
35 |
import org.gvsig.fmap.dal.DALLocator; |
36 |
import org.gvsig.fmap.dal.exception.DataException; |
37 |
import org.gvsig.fmap.dal.expressionevaluator.FeatureSymbolTable; |
38 |
import org.gvsig.fmap.dal.feature.Feature; |
39 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
40 |
import org.gvsig.fmap.dal.feature.FeatureSelection; |
41 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
42 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
43 |
import org.gvsig.fmap.dal.swing.DALSwingLocator; |
44 |
import org.gvsig.fmap.dal.swing.DataSwingManager; |
45 |
import org.gvsig.fmap.dal.swing.report.AbstractReportAction; |
46 |
import org.gvsig.fmap.dal.swing.report.ReportActionFactory; |
47 |
import org.gvsig.fmap.geom.Geometry; |
48 |
import org.gvsig.fmap.geom.GeometryLocator; |
49 |
import org.gvsig.fmap.geom.exception.CreateEnvelopeException; |
50 |
import org.gvsig.fmap.geom.primitive.Envelope; |
51 |
import org.gvsig.fmap.mapcontext.MapContext; |
52 |
import org.gvsig.fmap.mapcontext.ViewPort; |
53 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
54 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
55 |
import org.gvsig.json.Json; |
56 |
import org.gvsig.pdf.lib.api.PDFDocument; |
57 |
import org.gvsig.pdf.lib.api.PDFLocator; |
58 |
import org.gvsig.pdf.lib.api.PDFManager; |
59 |
import org.gvsig.pdf.swing.api.PDFSwingLocator; |
60 |
import org.gvsig.pdf.swing.api.PDFSwingManager; |
61 |
import org.gvsig.pdf.swing.api.PDFViewer; |
62 |
import org.gvsig.tools.ToolsLocator; |
63 |
import org.gvsig.tools.dispose.DisposeUtils; |
64 |
import org.gvsig.tools.exception.BaseException; |
65 |
import org.gvsig.tools.i18n.I18nManager; |
66 |
import org.gvsig.tools.locator.LocatorException; |
67 |
import org.gvsig.tools.persistence.PersistenceManager; |
68 |
import org.gvsig.tools.persistence.PersistentState; |
69 |
import org.gvsig.tools.resourcesstorage.ResourcesStorage; |
70 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
71 |
import org.gvsig.tools.swing.api.ToolsSwingUtils; |
72 |
import org.gvsig.tools.swing.api.task.JTaskStatus; |
73 |
import org.gvsig.tools.swing.api.threadsafedialogs.ThreadSafeDialogsManager; |
74 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
75 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager_v2; |
76 |
import org.gvsig.tools.task.SimpleTaskStatus; |
77 |
import org.gvsig.tools.util.ToolsUtilLocator; |
78 |
|
79 |
/**
|
80 |
*
|
81 |
* @author jjdelcerro
|
82 |
*/
|
83 |
@SuppressWarnings("UseSpecificCatch") |
84 |
public class LayoutReportActionImpl extends AbstractReportAction implements LayoutReportAction { |
85 |
|
86 |
public static LayoutReportActionImpl createFakeLayoutReportAction(Document doc) { |
87 |
ApplicationManager application = ApplicationLocator.getApplicationManager(); |
88 |
DataSwingManager dataSwingManager = DALSwingLocator.getDataSwingManager(); |
89 |
Feature f = null;
|
90 |
FeatureStore theStore = null;
|
91 |
ReportActionFactory theFactory = dataSwingManager.getReportActionFactory(LAYOUT_REPORT_ACTION_NAME); |
92 |
try {
|
93 |
IWindow activeView = application.getActiveWindow(ViewDocument.class); |
94 |
ViewDocument viewdoc = (ViewDocument) ((IView)activeView).getDocument(); |
95 |
FLyrVect layer = viewdoc.getMapContext().getLayers().getFirstActiveVectorLayer(); |
96 |
theStore = layer.getFeatureStore(); |
97 |
if( theStore.isFeatureSelectionEmpty() ) {
|
98 |
f = theStore.first(); |
99 |
} else {
|
100 |
f = theStore.getFeatureSelection().first(); |
101 |
} |
102 |
} catch(Throwable t) { |
103 |
LOGGER.debug("Can't retrieve test feature",t);
|
104 |
} |
105 |
LayoutReportActionImpl report = new LayoutReportActionImpl(theFactory, theStore, f);
|
106 |
report.getSymbolTable().setVar("$LAYOUT", doc);
|
107 |
report.getSymbolTable().setVar("$PAGE", 1); |
108 |
report.getSymbolTable().setVar("$PAGES", 1); |
109 |
return report;
|
110 |
} |
111 |
|
112 |
|
113 |
private final JsonObject json; |
114 |
private final FeatureStore store; |
115 |
private final FeatureQuery query; |
116 |
private FeatureSet selection;
|
117 |
private Feature current_row;
|
118 |
private MutableSymbolTable symbolTable;
|
119 |
FeatureSymbolTable fSymbolTable; |
120 |
private boolean centerToCurrentRow; |
121 |
private boolean zoomToCurrentRow; |
122 |
private double bufferSize; |
123 |
private boolean selectCurrentRow; |
124 |
private boolean useInternalPdfViewer; |
125 |
// private FeatureSet set;
|
126 |
private Iterable<Feature> set; |
127 |
private int featuresCount; |
128 |
private String viewTag; |
129 |
|
130 |
@SuppressWarnings("OverridableMethodCallInConstructor") |
131 |
private LayoutReportActionImpl(ReportActionFactory factory, FeatureStore store, Feature feature) {
|
132 |
// Fake layoutReportAction constructor
|
133 |
super(factory, null); |
134 |
try {
|
135 |
this.selection = store.createFeatureSelection();
|
136 |
((FeatureSelection)this.selection).select(feature);
|
137 |
} catch(Throwable t) { |
138 |
LOGGER.debug("Can't initialize selection",t);
|
139 |
} |
140 |
this.store = store;
|
141 |
this.query = store.createFeatureQuery(feature.createFilter());
|
142 |
this.current_row = feature;
|
143 |
this.json = Json.createObjectBuilder()
|
144 |
.add(LAYOUT_REPORT_NAME, store.getName()) |
145 |
.add(LAYOUT_REPORT_TYPE, LAYOUT_REPORT_ACTION_NAME) |
146 |
.add(LAYOUT_REPORT_LABEL, store.getName()) |
147 |
.build(); |
148 |
|
149 |
this.setReportName(this.json.getString(LAYOUT_REPORT_NAME, store.getName())); |
150 |
this.setReportLabel(this.json.getString(LAYOUT_REPORT_LABEL, this.getReportName())); |
151 |
} |
152 |
|
153 |
@SuppressWarnings("OverridableMethodCallInConstructor") |
154 |
public LayoutReportActionImpl(ReportActionFactory factory, FeatureStore store, FeatureQuery query, FeatureSet selection, final JsonObject json) { |
155 |
super(factory, null); |
156 |
this.json = json;
|
157 |
this.setReportName(this.json.getString(LAYOUT_REPORT_NAME, store.getName())); |
158 |
this.setReportLabel(this.json.getString(LAYOUT_REPORT_LABEL, this.getReportName())); |
159 |
|
160 |
this.setCenterToCurrentRow(this.json.getBoolean(LAYOUT_REPORT_CENTER_TO_CURRENT_ROW, true)); |
161 |
this.setZoomToCurrentRow(this.json.getBoolean(LAYOUT_REPORT_ZOOM_TO_CURRENT_ROW, true)); |
162 |
this.setBufferSize(0.0); |
163 |
if(this.json.containsKey(LAYOUT_REPORT_BUFFER_SIZE)){ |
164 |
JsonNumber theSize = this.json.getJsonNumber(LAYOUT_REPORT_BUFFER_SIZE);
|
165 |
if(theSize != null){ |
166 |
this.setBufferSize(theSize.doubleValue());
|
167 |
} |
168 |
} |
169 |
this.setSelectCurrentRow(this.json.getBoolean(LAYOUT_REPORT_SELECT_CURRENT_ROW, false)); |
170 |
this.setViewTag(this.json.getString(LAYOUT_REPORT_VIEW_TAG, null)); |
171 |
this.setUseInternalPdfViewer(this.json.getBoolean(LAYOUT_REPORT_USE_INTERNAL_PDF_VIEWER, true)); |
172 |
|
173 |
this.selection = selection;
|
174 |
this.store = store;
|
175 |
this.query = query;
|
176 |
this.current_row = null; |
177 |
} |
178 |
|
179 |
public Feature row() {
|
180 |
return this.current_row; |
181 |
} |
182 |
|
183 |
private Iterable<Feature> features() { |
184 |
if( this.set == null ) { |
185 |
if(this.selection == null){ |
186 |
try {
|
187 |
FeatureSet fset = store.getFeatureSet(query); |
188 |
this.featuresCount = fset.size();
|
189 |
this.set = fset;
|
190 |
} catch (DataException ex) {
|
191 |
throw new RuntimeException("Can't create dynamic-text report.", ex); |
192 |
} |
193 |
} else {
|
194 |
this.featuresCount = this.selection.size(); |
195 |
if(this.selection instanceof FeatureSelection){ |
196 |
this.set = this.store.getFeaturesIterable(((FeatureSelection)this.selection).referenceIterator()); |
197 |
} else {
|
198 |
this.set = this.selection; |
199 |
DisposeUtils.bind(this.set);
|
200 |
} |
201 |
} |
202 |
} |
203 |
return this.set; |
204 |
} |
205 |
|
206 |
|
207 |
@Override
|
208 |
public void actionPerformed(ActionEvent e) { |
209 |
if (!this.isEnabled()) { |
210 |
return;
|
211 |
} |
212 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
213 |
final WindowManager_v2 windowManager = (WindowManager_v2) ToolsSwingLocator.getWindowManager();
|
214 |
final JTaskStatus taskStatusPanel = ToolsSwingLocator.getTaskStatusSwingManager().createJTaskStatus();
|
215 |
final LayoutReportAction report = this; |
216 |
|
217 |
SimpleTaskStatus theStatus = this.getStatus();
|
218 |
theStatus.setIndeterminate(); |
219 |
taskStatusPanel.setShowRemoveTaskButton(false);
|
220 |
taskStatusPanel.bind(theStatus); |
221 |
ToolsSwingUtils.ensureRowsCols(taskStatusPanel, 4, 100, 5, 200); |
222 |
|
223 |
windowManager.showWindow( |
224 |
taskStatusPanel.asJComponent(), |
225 |
i18n.getTranslation("_Creating_report")+" '" + this.getReportLabel() + "'...", |
226 |
WindowManager.MODE.TOOL |
227 |
); |
228 |
|
229 |
Thread task = new Thread(() -> { |
230 |
List<File> singlePdfFiles = new ArrayList(); |
231 |
Iterable<Feature> features = null; |
232 |
try {
|
233 |
String title = this.getReportLabel(); |
234 |
String creator = "gvSIG-desktop"; |
235 |
String subject = "Layout report"; |
236 |
|
237 |
File pdfFile = ToolsLocator.getFoldersManager().getUniqueTemporaryFile("report.pdf"); |
238 |
int pag = 0; |
239 |
features = features(); |
240 |
theStatus.setRangeOfValues(1, featuresCount);
|
241 |
theStatus.message(i18n.getTranslation("_Building_pages"));
|
242 |
for (Feature feature : features) {
|
243 |
if( theStatus.isCancellationRequested() ) {
|
244 |
theStatus.cancel(); |
245 |
return;
|
246 |
} |
247 |
File f = printReport(feature, ++pag);
|
248 |
singlePdfFiles.add(f); |
249 |
theStatus.incrementCurrentValue(); |
250 |
} |
251 |
|
252 |
theStatus.message(i18n.getTranslation("_Building_pdf"));
|
253 |
PDFManager pdfManager = PDFLocator.getPDFManager(); |
254 |
pdfManager.merge(singlePdfFiles, pdfFile, title, creator, subject, theStatus); |
255 |
|
256 |
if (this.isUseInternalPdfViewer()) { |
257 |
this.showEmbedded(pdfFile);
|
258 |
} else {
|
259 |
this.showExternal(pdfFile);
|
260 |
} |
261 |
|
262 |
theStatus.terminate(); |
263 |
SwingUtilities.invokeLater(() -> {
|
264 |
taskStatusPanel.setVisible(false);
|
265 |
}); |
266 |
|
267 |
} catch (Throwable t) { |
268 |
LOGGER.warn("Can't create layout report.", t);
|
269 |
theStatus.abort(); |
270 |
} finally {
|
271 |
for (File singlePdfFile : singlePdfFiles) { |
272 |
singlePdfFile.delete(); |
273 |
} |
274 |
DisposeUtils.disposeQuietly(features); |
275 |
|
276 |
} |
277 |
}, "Report_" + report.getReportName());
|
278 |
task.start(); |
279 |
|
280 |
} |
281 |
|
282 |
private File printReport(Feature feature, int page) throws Exception { |
283 |
this.current_row = feature;
|
284 |
final LayoutPanel layout = this.loadTemplate(); |
285 |
final LayoutContext context = layout.getLayoutContext();
|
286 |
final Document document = layout.getDocument(); |
287 |
|
288 |
this.getSymbolTable();
|
289 |
fSymbolTable.setFeature(current_row); |
290 |
this.symbolTable.setVar("$LAYOUT", document); |
291 |
this.symbolTable.setVar("$PAGE", page); |
292 |
this.symbolTable.setVar("$PAGES", this.featuresCount); |
293 |
|
294 |
|
295 |
File pdfFile = null; |
296 |
Object previous_report = document.getProperty("$REPORT"); |
297 |
try {
|
298 |
document.setProperty("$REPORT", this); |
299 |
/*
|
300 |
TODO: Aqui podriamos consultar en el json para ver si hacemos:
|
301 |
x zoom al envelope de la geometria de current_row,
|
302 |
x si le aplicamos un buffer antes a ese envelop,
|
303 |
X si la seleccionamos...
|
304 |
- asi como con que vista tenemos que hacerlo. ????
|
305 |
*/
|
306 |
int count = 1; |
307 |
MapContext mapContext = null;
|
308 |
MapContext mapContextCandidate = null;
|
309 |
for (IFFrame frame : context.getAllFFrames()) {
|
310 |
if (frame instanceof FFrameView) { |
311 |
if(mapContextCandidate == null){ |
312 |
mapContextCandidate = ((FFrameView) frame).getMapContext(); |
313 |
} |
314 |
String frameTag = frame.getTag();
|
315 |
String countTag = "#"+count; |
316 |
if(StringUtils.equalsIgnoreCase(this.getViewTag(), frameTag) || |
317 |
StringUtils.equalsIgnoreCase(this.getViewTag(), countTag)){
|
318 |
mapContext = ((FFrameView) frame).getMapContext(); |
319 |
break;
|
320 |
} |
321 |
} |
322 |
} |
323 |
if(mapContext == null){ |
324 |
mapContext = mapContextCandidate; |
325 |
}; |
326 |
|
327 |
FeatureStore storeInLayout = this.store;
|
328 |
if (mapContext != null) { |
329 |
ICoordTrans ct = null;
|
330 |
Geometry geom = this.current_row.getDefaultGeometry().cloneGeometry();
|
331 |
for (FLayer layer : mapContext.getLayers().getLayers(null)) { |
332 |
if (layer instanceof FLyrVect) { |
333 |
FeatureStore layerStore = ((FLyrVect) layer).getFeatureStore(); |
334 |
if (layerStore != null) { |
335 |
if (layerStore.getParameters().isTheSameStore(this.store.getParameters())) { |
336 |
storeInLayout = layerStore; |
337 |
ct = ((FLyrVect) layer).getCoordTrans(); |
338 |
break;
|
339 |
} |
340 |
} |
341 |
} |
342 |
} |
343 |
if(ct!=null && ct.getPOrig().equals(geom.getProjection())){ |
344 |
geom.reProject(ct); |
345 |
} else if(!geom.getProjection().equals(mapContext.getProjection())){ |
346 |
ct = geom.getProjection().getCT(mapContext.getProjection()); |
347 |
geom.reProject(ct); |
348 |
} |
349 |
if (isZoomToCurrentRow()) {
|
350 |
|
351 |
Envelope envelope = geom |
352 |
.getEnvelope().getGeometry().buffer(getBufferSize()).getEnvelope(); |
353 |
mapContext.getViewPort().setEnvelope(envelope); |
354 |
|
355 |
} else if (isCenterToCurrentRow()) { |
356 |
|
357 |
Envelope envelope = geom |
358 |
.getEnvelope().getGeometry().buffer(getBufferSize()).getEnvelope(); |
359 |
center(mapContext, envelope); |
360 |
|
361 |
} else {
|
362 |
//DO NOTHING ??
|
363 |
} |
364 |
} |
365 |
storeInLayout.getFeatureSelection().deselectAll(); |
366 |
if (isSelectCurrentRow()) {
|
367 |
storeInLayout.getFeatureSelection().select(current_row.getReference()); |
368 |
} |
369 |
|
370 |
context.fullRefresh(); |
371 |
layout.getLayoutControl().getLayoutDraw().initialize(); |
372 |
|
373 |
pdfFile = ToolsLocator.getFoldersManager().getUniqueTemporaryFile("report.pdf");
|
374 |
layout.layoutToPDF(pdfFile); |
375 |
} finally {
|
376 |
document.setProperty("$REPORT", previous_report);
|
377 |
} |
378 |
|
379 |
return pdfFile;
|
380 |
} |
381 |
|
382 |
private void center(MapContext mapContext, Envelope envelope) throws LocatorException, CreateEnvelopeException { |
383 |
ViewPort viewPort = mapContext.getViewPort(); |
384 |
Envelope oldExtent = viewPort.getAdjustedEnvelope(); |
385 |
double oldCenterX = oldExtent.getCenter(0); |
386 |
double oldCenterY = oldExtent.getCenter(1); |
387 |
double centerX = envelope.getCenter(0); |
388 |
double centerY = envelope.getCenter(1); |
389 |
Point2D.Double center = new Point2D.Double(centerX, centerY); |
390 |
double movX = centerX - oldCenterX;
|
391 |
double movY = centerY - oldCenterY;
|
392 |
|
393 |
double minx = oldExtent.getMinimum(0) + movX; |
394 |
double miny = oldExtent.getMinimum(1) + movY; |
395 |
double maxX = oldExtent.getMaximum(0) + movX; |
396 |
double maxY = oldExtent.getMaximum(1) + movY; |
397 |
Envelope extent = GeometryLocator.getGeometryManager().createEnvelope( |
398 |
minx, miny, |
399 |
maxX, maxY, |
400 |
Geometry.SUBTYPES.GEOM2D); |
401 |
viewPort.setEnvelope(extent); |
402 |
} |
403 |
|
404 |
private void showEmbedded(File pdfFile) { |
405 |
if (!SwingUtilities.isEventDispatchThread()) { |
406 |
SwingUtilities.invokeLater(() -> {
|
407 |
showEmbedded(pdfFile); |
408 |
}); |
409 |
return;
|
410 |
} |
411 |
try {
|
412 |
final WindowManager windowManager = ToolsSwingLocator.getWindowManager();
|
413 |
final PDFSwingManager pdfSwingManager = PDFSwingLocator.getPDFSwingManager();
|
414 |
final PDFManager pdfManager = PDFLocator.getPDFManager();
|
415 |
|
416 |
final PDFDocument pdfdoc = pdfManager.createPDFDocument(pdfFile);
|
417 |
PDFViewer viewer = pdfSwingManager.createPDFViewer(); |
418 |
viewer.put(pdfdoc); |
419 |
viewer.setMode(PDFViewer.MODE_LIGHT); |
420 |
|
421 |
JComponent comp = viewer.asJComponent();
|
422 |
Dimension size = ToolsSwingUtils.ensureRowsCols(comp.getPreferredSize(), 20, 100, 40, 150); |
423 |
comp.setSize(size); |
424 |
|
425 |
String title = "Report: " + this.getLabel(); |
426 |
windowManager.showWindow( |
427 |
comp, |
428 |
title, |
429 |
WindowManager.MODE.WINDOW |
430 |
); |
431 |
} catch (Exception ex) { |
432 |
LOGGER.warn("Can't show pdf file '" + Objects.toString(pdfFile) + "'", ex); |
433 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
434 |
ThreadSafeDialogsManager dialogs = ToolsSwingLocator.getThreadSafeDialogsManager(); |
435 |
dialogs.messageDialog( |
436 |
i18n.getTranslation("_Cant_show_pdf_file")+" (" + Objects.toString(pdfFile) + ")\n\n"+BaseException.getMessageStack(ex, 0), |
437 |
"Creating report '" + this.getReportLabel() + "'", |
438 |
JOptionPane.WARNING_MESSAGE
|
439 |
); |
440 |
} |
441 |
} |
442 |
|
443 |
private void showExternal(File pdfFile) { |
444 |
if (!SwingUtilities.isEventDispatchThread()) { |
445 |
SwingUtilities.invokeLater(() -> {
|
446 |
showExternal(pdfFile); |
447 |
}); |
448 |
return;
|
449 |
} |
450 |
DesktopOpen desktop = ToolsUtilLocator.getToolsUtilManager().createDesktopOpen(); |
451 |
desktop.open(pdfFile); |
452 |
} |
453 |
|
454 |
private LayoutPanel loadTemplate() throws Exception { |
455 |
ResourcesStorage resources = store.getResourcesStorage(); |
456 |
if (resources == null) { |
457 |
return null; |
458 |
} |
459 |
String templateName = this.json.getString(LAYOUT_REPORT_TEMPLATE_NAME, LAYOUT_REPORT_DEFAULT_TEMPLATE_NAME); // "1.layout"... |
460 |
ResourcesStorage.Resource resource = resources.getResource(templateName); |
461 |
InputStream is = null; |
462 |
try {
|
463 |
is = resource.asInputStream(); |
464 |
PersistenceManager persistenceManager = ToolsLocator.getPersistenceManager(); |
465 |
PersistentState persistentState = persistenceManager.loadState(is); |
466 |
|
467 |
LayoutPanel layout = (LayoutPanel) persistenceManager.create(persistentState); |
468 |
|
469 |
return layout;
|
470 |
} finally {
|
471 |
IOUtils.closeQuietly(is); |
472 |
} |
473 |
} |
474 |
|
475 |
public MutableSymbolTable getSymbolTable() {
|
476 |
if( this.symbolTable == null ) { |
477 |
this.symbolTable = ExpressionUtils.createSymbolTable();
|
478 |
fSymbolTable = DALLocator.getDataManager().createFeatureSymbolTable(); |
479 |
fSymbolTable.setFeature(current_row); |
480 |
this.symbolTable.addSymbolTable(fSymbolTable);
|
481 |
this.symbolTable.setVar("$REPORT", this); |
482 |
} |
483 |
return this.symbolTable; |
484 |
} |
485 |
|
486 |
@Override
|
487 |
public String evaluateDynamicText(String s) { |
488 |
ExpressionEvaluatorManager manager = ExpressionEvaluatorLocator.getExpressionEvaluatorManager(); |
489 |
if( !manager.isDynamicText(s) ) {
|
490 |
return s;
|
491 |
} |
492 |
String x = manager.evaluateDynamicText(
|
493 |
this.getSymbolTable(),
|
494 |
s, |
495 |
null,
|
496 |
this.store.getResourcesStorage()
|
497 |
); |
498 |
return x;
|
499 |
} |
500 |
|
501 |
@Override
|
502 |
public boolean isCenterToCurrentRow() { |
503 |
return this.centerToCurrentRow; |
504 |
} |
505 |
|
506 |
@Override
|
507 |
public void setCenterToCurrentRow(boolean centerToCurrentRow) { |
508 |
this.centerToCurrentRow = centerToCurrentRow;
|
509 |
} |
510 |
|
511 |
@Override
|
512 |
public boolean isZoomToCurrentRow() { |
513 |
return this.zoomToCurrentRow; |
514 |
} |
515 |
|
516 |
@Override
|
517 |
public void setZoomToCurrentRow(boolean zoomToCurrentRow) { |
518 |
this.zoomToCurrentRow = zoomToCurrentRow;
|
519 |
} |
520 |
|
521 |
@Override
|
522 |
public double getBufferSize() { |
523 |
return bufferSize;
|
524 |
} |
525 |
|
526 |
@Override
|
527 |
public void setBufferSize(double bufferSize) { |
528 |
this.bufferSize = bufferSize;
|
529 |
} |
530 |
|
531 |
@Override
|
532 |
public boolean isSelectCurrentRow() { |
533 |
return selectCurrentRow;
|
534 |
} |
535 |
|
536 |
@Override
|
537 |
public void setSelectCurrentRow(boolean selectCurrentRow) { |
538 |
this.selectCurrentRow = selectCurrentRow;
|
539 |
} |
540 |
|
541 |
@Override
|
542 |
public String getViewTag() { |
543 |
return viewTag;
|
544 |
} |
545 |
|
546 |
@Override
|
547 |
public void setViewTag(String viewTag) { |
548 |
this.viewTag = viewTag;
|
549 |
} |
550 |
|
551 |
public boolean isUseInternalPdfViewer() { |
552 |
return useInternalPdfViewer;
|
553 |
} |
554 |
|
555 |
@Override
|
556 |
public void setUseInternalPdfViewer(boolean useInternalPdfViewer) { |
557 |
this.useInternalPdfViewer = useInternalPdfViewer;
|
558 |
} |
559 |
|
560 |
} |