previewproxybase.java
来自「swing编写的库存管理程序。毕业设计类」· Java 代码 · 共 2,255 行 · 第 1/5 页
JAVA
2,255 行
/**
* Checks, wether the preview frame was finally closed. Closing the
* frame does not just mean to make it invisible, it also kills all
* worker threads. Once the preview is closed, it is not possible to
* reactivate it again.
*
* @return true, if the preview is closed, false otherwise
*/
public boolean isClosed()
{
return closed;
}
/**
* Shuts down the preview component. Once the component is closed, it
* cannot be reactivated anymore. Calling this method will abort all
* worker threads, will close the progress dialog and dispose all
* components.
*/
public void close()
{
closed = true;
exportWorkerPool.finishAll();
repaginationWorker.finish();
if (progressDialog.isVisible())
{
progressDialog.setVisible(false);
progressDialog.dispose();
}
closeToolbar();
dispose();
}
/**
* Called by the garbage collector on an object when garbage collection
* determines that there are no more references to the object.
* A subclass overrides the <code>finalize</code> method to dispose of
* system resources or to perform other cleanup.
*
* @throws Throwable the <code>Exception</code> raised by this method
*/
public void finalize() throws Throwable
{
if (isClosed() == false)
{
close();
}
super.finalize();
exportWorkerPool.finishAll();
repaginationWorker.finish();
}
/**
* Returns the 'About' action.
*
* @return the 'About' action.
*/
public Action getAboutAction()
{
return baseActionMap.get(ABOUT_ACTION_KEY);
}
/**
* Sets the 'About' action.
*
* @param aboutAction the 'About' action.
*/
public void setAboutAction(final Action aboutAction)
{
baseActionMap.put(ABOUT_ACTION_KEY, aboutAction);
}
/**
* Returns the 'Close' action.
*
* @return the 'Close' action.
*/
public Action getCloseAction()
{
return baseActionMap.get(CLOSE_ACTION_KEY);
}
/**
* Sets the 'Close' action.
*
* @param closeAction the 'Close' action.
*/
public void setCloseAction(final Action closeAction)
{
baseActionMap.put(CLOSE_ACTION_KEY, closeAction);
}
/**
* Returns the 'First Page' action.
*
* @return the 'First Page' action.
*/
public Action getFirstPageAction()
{
return navigationActionMap.get(FIRSTPAGE_ACTION_KEY);
}
/**
* Sets the 'First Page' action.
*
* @param firstPageAction the 'First Page' action.
*/
public void setFirstPageAction(final Action firstPageAction)
{
navigationActionMap.put(FIRSTPAGE_ACTION_KEY, firstPageAction);
}
/**
* Returns the 'Last Page' action.
*
* @return the 'Last Page' action.
*/
public Action getLastPageAction()
{
return navigationActionMap.get(LASTPAGE_ACTION_KEY);
}
/**
* Sets the 'Last Page' action.
*
* @param lastPageAction the 'Last Page' action.
*/
public void setLastPageAction(final Action lastPageAction)
{
navigationActionMap.put (LASTPAGE_ACTION_KEY, lastPageAction);
}
/**
* Returns the 'Next Page' action.
*
* @return the 'Next Page' action.
*/
public Action getNextPageAction()
{
return navigationActionMap.get (NEXT_PAGE_ACTION_KEY);
}
/**
* Sets the 'Next Page' action.
*
* @param nextPageAction the 'Next Page' action.
*/
public void setNextPageAction(final Action nextPageAction)
{
navigationActionMap.put(NEXT_PAGE_ACTION_KEY, nextPageAction);
}
/**
* Returns the 'Previous Page' action.
*
* @return the 'Previous Page' action.
*/
public Action getPreviousPageAction()
{
return navigationActionMap.get (PREV_PAGE_ACTION_KEY);
}
/**
* Sets the 'Previous Page' action.
*
* @param previousPageAction the 'Previous Page' action.
*/
public void setPreviousPageAction(final Action previousPageAction)
{
navigationActionMap.put (PREV_PAGE_ACTION_KEY, previousPageAction);
}
/**
* Returns the 'Zoom In' action.
*
* @return the 'Zoom In' action.
*/
public Action getZoomInAction()
{
return zoomActionMap.get (ZOOM_IN_ACTION_KEY);
}
/**
* Sets the 'Zoom In' action.
*
* @param zoomInAction the 'Zoom In' action.
*/
public void setZoomInAction(final Action zoomInAction)
{
zoomActionMap.put (ZOOM_IN_ACTION_KEY, zoomInAction);
}
/**
* Returns the 'Zoom Out' action.
*
* @return the 'Zoom Out' action.
*/
public Action getZoomOutAction()
{
return zoomActionMap.get (ZOOM_OUT_ACTION_KEY);
}
/**
* Sets the 'Zoom Out' action.
*
* @param zoomOutAction the 'Zoom Out' action.
*/
public void setZoomOutAction(final Action zoomOutAction)
{
zoomActionMap.put (ZOOM_OUT_ACTION_KEY, zoomOutAction);
}
/**
* Returns the 'Goto' action.
*
* @return the 'Goto' action.
*/
public Action getGotoAction()
{
return navigationActionMap.get (GOTO_ACTION_KEY);
}
/**
* Sets the 'Goto' action.
*
* @param gotoAction the 'Goto' action.
*/
public void setGotoAction(final Action gotoAction)
{
navigationActionMap.put (GOTO_ACTION_KEY, gotoAction);
}
/**
* Updates the pageformat of the ReportPane.
*
* @param pf the new page format object.
*/
public void updatePageFormat(final PageFormat pf)
throws ReportProcessingException
{
if (pf == null)
{
throw new NullPointerException("The given pageformat is null.");
}
JFreeReport report = getReport();
report.setDefaultPageFormat(pf);
setReport(report);
}
/**
* Paginates the report.
*/
protected void performPagination()
{
setLockInterface(true);
setStatusText(getResources().getString("statusline.repaginate"));
progressDialog.setTitle(getResources().getString("statusline.repaginate"));
progressDialog.setMessage(getResources().getString("statusline.repaginate"));
progressDialog.pack();
final Worker worker = getRepaginationWorker();
//Log.debug ("Worker is unavailable (preSync) ... " + worker.isAvailable());
synchronized (worker)
{
while (worker.isAvailable() == false)
{
// wait until the worker is done with his current job
//Log.debug ("Worker is unavailable ... ");
try
{
worker.wait();
}
catch (InterruptedException ie)
{
// ignored
}
}
getRepaginationWorker().setWorkload(new Runnable()
{
public void run()
{
final ReportPane reportPane = getReportPane();
ReportProgressDialog progressDialog = getProgressDialog();
try
{
final long startTime = System.currentTimeMillis();
reportPane.addRepaginationListener(progressDialog);
RefineryUtilities.positionFrameRandomly(progressDialog);
progressDialog.setVisible(true);
reportPane.setHandleInterruptedState(true);
reportPane.setVisible(false);
reportPane.repaginate();
reportPane.setVisible(true);
reportPane.setHandleInterruptedState(false);
progressDialog.setVisible(false);
reportPane.removeRepaginationListener(progressDialog);
setLockInterface(false);
/*
Log.debug ("Pagination done: " +
((System.currentTimeMillis() - startTime) / 1000) + " seconds.");
*/
}
catch (ReportInterruptedException re)
{
progressDialog.setVisible(false);
reportPane.removeRepaginationListener(progressDialog);
Log.info ("Repagination aborted [ReportInterruptedException]");
}
catch (Exception e)
{
progressDialog.setVisible(false);
reportPane.removeRepaginationListener(progressDialog);
Log.warn("Failed to repaginate", e);
reportPane.setError(e);
}
}
});
}
//Log.debug ("Worker is on the way... ");
}
/**
* Checks, whether the interface is locked. A locked interface has all
* actions disabled and waits for a certain task to be completed. The only
* actions that are always enabled are teh help and the exit actions.
*
* @return true, if the interface is in the locked state, or false otherwise.
*/
public boolean isLockInterface()
{
return lockInterface;
}
/**
* Defines, whether the interface is locked. A locked interface has all
* actions disabled and waits for a certain task to be completed. The only
* actions that are always enabled are teh help and the exit actions.
*
* @param lockInterface set to true, if the interface should be set into the
* locked state, or false otherwise.
*/
public void setLockInterface(final boolean lockInterface)
{
this.lockInterface = lockInterface;
if (lockInterface == true)
{
disableButtons();
}
else
{
validateButtons();
}
}
/**
* Adds a repagination listener to this component. The listener will be
* informed about the pagination progress.
*
* @param listener the listener to be added.
*/
public void addRepaginationListener(final RepaginationListener listener)
{
reportPane.addRepaginationListener(listener);
}
/**
* Removes the specified repagination listener from this component.
*
* @param listener the listener to be removed.
*/
public void removeRepaginationListener(final RepaginationListener listener)
{
reportPane.removeRepaginationListener(listener);
}
public void setReport (JFreeReport report) throws ReportProcessingException
{
ReportPane oldPane = this.reportPane;
if (reportPane != null)
{
freeResources();
reportPane.removeRepaginationListener(progressDialog);
reportPane.removePropertyChangeListener(reportPanePropertyChangeListener);
reportPaneHolder.remove(reportPane);
reportPane = null;
}
setLargeIconsEnabled
(report.getReportConfiguration().getConfigProperty
(LARGE_ICONS_ENABLED_PROPERTY, "true").equals("true"));
setToolbarFloatable
(report.getReportConfiguration().getConfigProperty
(TOOLBAR_FLOATABLE_PROPERTY, "true").equals("true"));
proxy.setTitle(report.getName() + " - " + getResources().getString("preview-frame.title"));
// set up the content with a toolbar and a report pane
baseActionMap.put(CLOSE_ACTION_KEY, proxy.createDefaultCloseAction());
this.zoomIndex = DEFAULT_ZOOM_INDEX;
// we have an old toolbar floating around ... lets remove it
if (toolbar != null)
{
closeToolbar();
remove(toolbar);
}
if (isPropertySet(CREATE_TOOLBAR_PROPERTY, true))
{
toolbar = createToolBar ();
toolbar.setFloatable(isToolbarFloatable());
toolbar.addPropertyChangeListener(new ToolbarPropertyChangeListener());
add(toolbar, BorderLayout.NORTH);
}
reportPane = createReportPane(report);
reportPane.addPropertyChangeListener(reportPanePropertyChangeListener);
reportPane.setVisible(false); // initially hidden
reportPaneHolder.add(reportPane);
buildExportPlugins(report);
reinitialize();
applyDefinedDimension(report);
firePropertyChange(REPORT_PANE_PROPERTY, oldPane, reportPane);
performPagination();
// inform all listeners, that we have a new reportpane
Log.info("setReport(..): started pagination ...");
}
public JFreeReport getReport ()
{
return reportPane.getReport();
}
public void refresh () throws ReportProcessingException
{
JFreeReport report = reportPane.getReport();
setReport(report);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?