public class Save extends ViewerWidget implements DocumentPanelListener, PropertyChangeListener
Create a button that will allow the PDF to be saved to disk. If the PDF was originally
loaded from a File, the user will not be prompted for a filename, otherwise this feature
functions like SaveAs
.
promptOnOverwrite | true to prompt before overwriting files, false otherwise (the default) |
---|---|
disableUnlessDirty | true to disable this feature until the PDF has been marked as "dirty" (ie it has been altered), false to always enable this feature (the defualt) |
This code is copyright the Big Faceless Organization. You're welcome to use, modify and distribute it in any form in your own projects, provided those projects continue to make use of the Big Faceless PDF library.
Modifier and Type | Class and Description |
---|---|
protected static class |
Save.SaveFileChooser
Extends the abomination that is JFileChooser to allow an options panel in the main dialog.
|
Constructor and Description |
---|
Save() |
Modifier and Type | Method and Description |
---|---|
void |
action(ViewerEvent event)
The method that's run when this feature is activated.
|
ActionListener |
createActionListener()
Return an ActionListener that will be called when this Widget is activated.
|
void |
documentUpdated(DocumentPanelEvent event)
Called when an
DocumentPanelEvent is raised |
void |
initialize(PDFViewer viewer)
Called when the feature is first added to a viewer
|
boolean |
isEnabledByDefault()
Return true if this feature is enabled by default (the default).
|
boolean |
isPromptOnOverwrite()
Indicates whether this feature should prompt before overwriting a file
|
void |
propertyChange(PropertyChangeEvent event) |
static void |
save(ViewerEvent event,
Exporter initialexporter,
String initialpath,
boolean displayprompt,
boolean overwriteprompt)
/**
Save the Document
|
void |
setDisableUnlessDirty(boolean value)
Set whether this feature should be disabled unless the PDF is marked as "dirty",
i.e. it has been changed since it was loaded.
|
void |
setPromptOnOverwrite(boolean prompt)
Set whether this feature should prompt before overwriting a file
|
getComponent, getIcon, getViewer, isButtonEnabledByDefault, isDocumentRequired, isMenuEnabledByDefault, setButton, setComponent, setDocumentRequired, setMenu, setMenu, setToolBarEnabled, setToolBarEnabledAlways, setToolBarFloatable, setToolBarFloating, toString
getAllEnabledFeatures, getAllFeatures, getCustomJavaScript, getFeatureProperty, getFeatureURLProperty, getName, setFeatureName, teardown
public void action(ViewerEvent event)
ViewerWidget
ActionListener
returned by the default implementation of
ViewerWidget.createActionListener()
, and by default is a no-op.action
in class ViewerWidget
public ActionListener createActionListener()
ViewerWidget
createActionListener
in class ViewerWidget
Quit.createActionListener()
public boolean isEnabledByDefault()
ViewerFeature
ViewerFeature.getAllEnabledFeatures()
and by the PDFViewerApplet
and PDFTool
isEnabledByDefault
in class ViewerFeature
public void initialize(PDFViewer viewer)
ViewerFeature
initialize
in class ViewerWidget
public void documentUpdated(DocumentPanelEvent event)
DocumentPanelListener
DocumentPanelEvent
is raiseddocumentUpdated
in interface DocumentPanelListener
public void propertyChange(PropertyChangeEvent event)
propertyChange
in interface PropertyChangeListener
public void setPromptOnOverwrite(boolean prompt)
prompt
- whether to prompt before overwriting a file (detault is false)public boolean isPromptOnOverwrite()
public void setDisableUnlessDirty(boolean value)
value
- whether to disable this feature unless the PDF is marked as dirty.public static void save(ViewerEvent event, Exporter initialexporter, String initialpath, boolean displayprompt, boolean overwriteprompt)
event
- the ViewerEvent that launched this actioninitialexporter
- the Exporter
to choose by default, or null to default
to a PDFExporter
initialpath
- the Path to display by default, or null
to use the same
path as the source filedisplayprompt
- whether to prompt the user for a filename. We will always prompt anyway if the document has not yet been saved.overwriteprompt
- whether to prompt the user if we are about to overwrite a filename.Copyright © 2001-2017 Big Faceless Organization