public class NewAction extends LengthyAction implements NewDocumentService
Modifier and Type | Class and Description |
---|---|
protected static class |
NewAction.ChooserPane |
protected static class |
NewAction.TemplateRenderer |
protected static class |
NewAction.TemplateTree |
Modifier and Type | Field and Description |
---|---|
protected static IconResource |
collapsedIcon |
protected URL |
copyURL |
protected boolean |
createOnly |
protected static IconResource |
documentIcon |
protected static IconResource |
expandedIcon |
protected URL |
inURL |
protected static IconResource |
newIcon |
protected boolean |
selectCopyURL |
app, id, MODIFIERS_TOOLTIP_KEY, NO_MNEMONIC, SELECTED_ICON_KEY, UNSELECTED_ICON_KEY
changeSupport, enabled
PART_ID
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
Constructor and Description |
---|
NewAction() |
Modifier and Type | Method and Description |
---|---|
protected NewAction.ChooserPane |
createChooserPane(Configuration[] configurations) |
protected CommandResult |
doExec(URL templateURL,
URL saveURL,
boolean createSaveFile,
boolean onlyCreate) |
protected void |
exec()
Second step of
LengthyAction.doIt() . |
protected URL |
findTemplate(String categoryName,
String templateName,
URL saveURL,
boolean reportError) |
protected static TemplateInfo.Entry[] |
getAllTemplateEntries(Configuration[] configs) |
protected static void |
getAllTemplateEntries(Configuration[] configs,
List<TemplateInfo.Entry> all) |
protected static boolean |
hasCategory(TemplateInfo.Entry entry,
String categoryName) |
protected boolean |
init()
First step of
LengthyAction.doIt() . |
URL |
newDocument(String categoryName,
String templateName,
URL saveURL,
boolean createSaveFile)
Create a new document.
|
URL |
newDocument(URL templateURL,
URL saveURL,
boolean createSaveFile)
Create a new document.
|
protected URL[] |
promptUser(URL inURL,
String showCategory,
boolean selectCopyURL) |
static URL |
selectTemplate(App app,
String title)
Displays a dialog box allowing to choose a document template.
|
void |
updateEnabled()
This action should enable or disable itself using standard method
setEnabled(boolean).
|
doIt, finish
actionPerformed, activeEditorChanged, applyPreferences, destroyApp, editingContextChanged, flushPreferences, getAccelerator, getApp, getDialogTitle, getIcon, getId, getLabel, getMnemonic, getMnemonicIndex, getModifiersToolTip, getSelectedIcon, getToolTip, getUnselectedIcon, hasListeners, initApp, isEditingContextSensitive, isSelected, namespacePrefixesChanged, saveStateChanged, setAccelerator, setDisabledIcons, setIcon, setLabel, setMnemonic, setMnemonicIndex, setModifiersToolTip, setSelected, setSelectedIcon, setToolTip, setUnselectedIcon, undoStateChanged, validityStateChanged, wasCtrlClick, wasRightClick, wasShiftClick
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
protected URL inURL
protected URL copyURL
protected boolean selectCopyURL
protected boolean createOnly
protected static IconResource newIcon
protected static IconResource expandedIcon
protected static IconResource collapsedIcon
protected static IconResource documentIcon
protected boolean init()
LengthyAction
LengthyAction.doIt()
. Possibly an interactive one. It is
possible to prompt the user during this step and therefore, the user
can cancel the execution of the action (before it actually starts).init
in class LengthyAction
true
if execution should proceed;
false
if execution has been canceledprotected void exec()
LengthyAction
LengthyAction.doIt()
. Actual execution of the action. A busy
cursor is displayed during this step.exec
in class LengthyAction
protected CommandResult doExec(URL templateURL, URL saveURL, boolean createSaveFile, boolean onlyCreate)
public void updateEnabled()
AppAction
This method is invoked:
updateEnabled
in class AppAction
AppAction.activeEditorChanged()
,
AppAction.editingContextChanged()
protected NewAction.ChooserPane createChooserPane(Configuration[] configurations)
public static URL selectTemplate(App app, String title)
This convenience method is used by the Folder to create a copy of user-selected document template in current folder.
app
- App used to obtain the configurations and to position
the dialog boxtitle
- title of the dialog boxnull
if the user has canceled this actionprotected static TemplateInfo.Entry[] getAllTemplateEntries(Configuration[] configs)
protected static void getAllTemplateEntries(Configuration[] configs, List<TemplateInfo.Entry> all)
public URL newDocument(String categoryName, String templateName, URL saveURL, boolean createSaveFile)
NewDocumentService
If category is null, then saveURL cannot be null. In this ``saveURL'' mode, the document template used to create the new document is:
newDocument
in interface NewDocumentService
categoryName
- category of the document template.
Note that by default, the category of a document template is the name of the configuration containing it.
May be null
in which case, this method works in
``saveURL'' mode. See above.
templateName
- name of a document template.
May be null
in which case the first document template
of the category is automatically selected.saveURL
- the URL of the newly created document.
May be null
in which case an "untitled" URL
is automatically computed.createSaveFile
- if true
and saveURL is not
null
, the newly created document is immediately saved
at specified locationnull
otherwise (e.g. specified category or template
are not found)protected URL findTemplate(String categoryName, String templateName, URL saveURL, boolean reportError)
protected static final boolean hasCategory(TemplateInfo.Entry entry, String categoryName)
public URL newDocument(URL templateURL, URL saveURL, boolean createSaveFile)
NewDocumentService
newDocument
in interface NewDocumentService
templateURL
- URL of the document templatesaveURL
- the URL of the newly created document.
May be null
in which case an "untitled" URL
is automatically computed.createSaveFile
- if true
and saveURL is not
null
, the newly created document is immediately saved
at specified locationnull
otherwise (e.g. specified template cannot be opened)