public abstract class AbstractApplication extends AbstractBean implements Application
Application
.
AbstractApplication
supports the command line parameter
-open filename
to open views for specific URI's upon launch of
the application.
Modifier and Type | Field and Description |
---|---|
protected ResourceBundleUtil |
labels |
protected ApplicationModel |
model |
static java.lang.String |
VIEW_COUNT_PROPERTY |
propertySupport
ACTIVE_VIEW_PROPERTY, RECENT_URIS_PROPERTY
Constructor and Description |
---|
AbstractApplication()
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
add(View v)
Adds a view to this application.
|
protected void |
addAction(javax.swing.JMenu m,
javax.swing.Action a)
Adds the specified action as a menu item to the supplied menu.
|
protected void |
addAction(javax.swing.JMenu m,
View view,
java.lang.String actionID)
Adds the specified action as a menu item to the supplied menu.
|
protected void |
addMenuItem(javax.swing.JMenu m,
javax.swing.JMenuItem mi)
Adds the specified action as a menu item to the supplied menu.
|
void |
addPalette(java.awt.Window palette)
Adds a palette window to the application.
|
void |
addRecentURI(java.net.URI uri)
Appends a URI to the list of recent URIs.
|
void |
addWindow(java.awt.Window window,
View p)
Adds a (non-palette) window to the application.
|
protected View |
basicCreateView() |
void |
clearRecentURIs()
Clears the list of recent URIs.
|
void |
configure(java.lang.String[] args)
Configures the application using the provided arguments array.
|
java.awt.Container |
createContainer() |
protected javax.swing.JMenu |
createOpenRecentFileMenu(View view) |
View |
createView()
Creates a new view for this application and initializes it, by calling
View.init() . |
protected abstract javax.swing.ActionMap |
createViewActionMap(View p) |
void |
destroy()
Destroys the application and calls System.exit(0).
|
void |
dispose(View view)
This is a convenience method for removing a view and disposing it.
|
protected javax.swing.Action |
getAction(View view,
java.lang.String actionID) |
javax.swing.ActionMap |
getActionMap(View v)
Gets the action map.
|
View |
getActiveView()
Gets the active view.
|
java.lang.String |
getCopyright()
Returns the copyright of the application.
|
URIChooser |
getExportChooser(View v)
Gets an export chooser for the specified view or for the entire application.
|
URIChooser |
getImportChooser(View v)
Gets an import chooser for the specified view or for the entire application.
|
ApplicationModel |
getModel()
Returns the application model.
|
java.lang.String |
getName()
Returns the name of the application.
|
URIChooser |
getOpenChooser(View v)
Gets an open chooser for the specified view or for the entire application.
|
protected java.util.List<java.net.URI> |
getOpenURIsFromMainArgs(java.lang.String[] args)
Parses the arguments to the main method and returns a list of URI's
for which views need to be opened upon launch of the application.
|
java.util.List<java.net.URI> |
getRecentURIs()
Returns the recently opened URIs.
|
URIChooser |
getSaveChooser(View v)
Gets a save chooser for the specified view or for the entire application.
|
java.lang.String |
getVersion()
Returns the version of the application.
|
void |
init()
Initializes the application.
|
protected void |
initLabels() |
boolean |
isEnabled()
Returns the enabled state of the application.
|
void |
launch(java.lang.String[] args)
Launches the application.
|
protected void |
maybeAddSeparator(javax.swing.JMenu m)
Adds a separator to the supplied menu.
|
void |
remove(View v)
Removes a view from this application and removes it from the users
view.
|
void |
removePalette(java.awt.Window palette)
Removes a palette window from the application.
|
void |
removeWindow(java.awt.Window window)
Removes a (non-palette) window from the application.
|
void |
setActionMap(javax.swing.ActionMap m)
Sets the application-wide action map.
|
void |
setActiveView(View newValue)
Sets the active view.
|
void |
setEnabled(boolean newValue)
Sets the enabled state of the application.
|
void |
setModel(ApplicationModel newValue)
Sets the application model.
|
void |
start(java.util.List<java.net.URI> uris)
Starts the application.
|
void |
stop()
Stops the application without saving any unsaved views.
|
java.util.Collection<View> |
views()
Returns a read only collection view of the views of this application.
|
addPropertyChangeListener, addPropertyChangeListener, clone, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addPropertyChangeListener, createEditMenu, createFileMenu, createHelpMenu, createViewMenu, createWindowMenu, getComponent, hide, isSharingToolsAmongViews, removePropertyChangeListener, show
protected ResourceBundleUtil labels
protected ApplicationModel model
public static final java.lang.String VIEW_COUNT_PROPERTY
public void init()
Application
configure()
should have been invoked before the application
is inited. Alternatively an application can be configured using setter
methods.init
in interface Application
public void start(java.util.List<java.net.URI> uris)
Application
init()
must have been invoked before the application is started.start
in interface Application
uris
- Upon launch, the application may be requested to open views
for a given list of URI's.public final View createView()
Application
View.init()
.createView
in interface Application
public void setModel(ApplicationModel newValue)
Application
setModel
in interface Application
public ApplicationModel getModel()
Application
getModel
in interface Application
protected View basicCreateView()
public void setActiveView(View newValue)
newValue
- Active view, can be null.public View getActiveView()
getActiveView
in interface Application
public java.lang.String getName()
Application
getName
in interface Application
public java.lang.String getVersion()
Application
getVersion
in interface Application
public java.lang.String getCopyright()
Application
getCopyright
in interface Application
public void stop()
Application
init()
must have been invoked before the application is stopped.stop
in interface Application
public void destroy()
Application
destroy
in interface Application
public void remove(View v)
Application
remove
in interface Application
public void add(View v)
Application
add
in interface Application
protected abstract javax.swing.ActionMap createViewActionMap(View p)
public void dispose(View view)
Application
dispose
in interface Application
public java.util.Collection<View> views()
Application
views
in interface Application
public boolean isEnabled()
Application
isEnabled
in interface Application
public void setEnabled(boolean newValue)
Application
setEnabled
in interface Application
public java.awt.Container createContainer()
public void launch(java.lang.String[] args)
launch
in interface Application
args
- This implementation supports the command-line parameter "-open"
which can be followed by one or more filenames or URI's.protected java.util.List<java.net.URI> getOpenURIsFromMainArgs(java.lang.String[] args)
This implementation supports the command-line parameter "-open" which can be followed by one or more filenames or URI's.
This method is invoked from the Application.launch
method.
args
- Arguments to the main method.protected void initLabels()
public void configure(java.lang.String[] args)
Application
configure
in interface Application
public void removePalette(java.awt.Window palette)
Application
removePalette
in interface Application
public void addPalette(java.awt.Window palette)
Application
addPalette
in interface Application
public void removeWindow(java.awt.Window window)
Application
removeWindow
in interface Application
public void addWindow(java.awt.Window window, View p)
Application
addWindow
in interface Application
window
- The window.p
- The View to which this window is associated, or null
if the window is associated to the application.protected javax.swing.Action getAction(View view, java.lang.String actionID)
protected void addAction(javax.swing.JMenu m, View view, java.lang.String actionID)
protected void addAction(javax.swing.JMenu m, javax.swing.Action a)
protected void addMenuItem(javax.swing.JMenu m, javax.swing.JMenuItem mi)
protected void maybeAddSeparator(javax.swing.JMenu m)
public java.util.List<java.net.URI> getRecentURIs()
Application
getRecentURIs
in interface Application
public void clearRecentURIs()
Application
clearRecentURIs
in interface Application
public void addRecentURI(java.net.URI uri)
Application
addRecentURI
in interface Application
protected javax.swing.JMenu createOpenRecentFileMenu(View view)
public URIChooser getOpenChooser(View v)
Application
getOpenChooser
in interface Application
v
- A view or null.public URIChooser getSaveChooser(View v)
Application
getSaveChooser
in interface Application
v
- A view or null.public URIChooser getImportChooser(View v)
Application
getImportChooser
in interface Application
v
- A view or null.public URIChooser getExportChooser(View v)
Application
getExportChooser
in interface Application
v
- A view or null.public void setActionMap(javax.swing.ActionMap m)
public javax.swing.ActionMap getActionMap(View v)
getActionMap
in interface Application
v
- A view or null