|
Holger's Java API |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.swing.AbstractAction
com.antelmann.util.gui.MyAbstractAction
@Licensed public abstract class MyAbstractAction
a base class for actions that provides some convenience for implementing actions
| Field Summary | |
|---|---|
protected ValueRetriever<? extends Component> |
parentRetriever
|
protected ValueRetriever<? extends User> |
userRetriever
|
| Fields inherited from class javax.swing.AbstractAction |
|---|
changeSupport, enabled |
| Fields inherited from interface javax.swing.Action |
|---|
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 Summary | |
|---|---|
MyAbstractAction()
|
|
MyAbstractAction(Icon icon)
|
|
MyAbstractAction(String name)
|
|
MyAbstractAction(String name,
String description,
Icon icon)
|
|
MyAbstractAction(String name,
String description,
Icon icon,
Component parent)
|
|
MyAbstractAction(String name,
String description,
Icon icon,
Component parent,
Logger logger)
|
|
MyAbstractAction(String name,
String description,
Icon icon,
Component parent,
Logger logger,
ValueRetriever<User> userRetriever,
boolean requiresLicense)
|
|
| Method Summary | ||
|---|---|---|
void |
actionPerformed(ActionEvent ev)
initializes the parent component - if applicable - and calls performAction; if the parent was null, it is going to be reset at the end again, so that it gets dynamically reset on each call. |
|
boolean |
add(InterfaceMonitor im)
|
|
boolean |
addRequiredAccessRight(Object right)
returns true only if the given right was actually added; false if the right was already present |
|
void |
addRequiredAccessRights(Object... rights)
|
|
void |
checkAccess(User user)
checks the current user from the retriever for being able to access all required rights in order to access this action; this method is called upon actionPerformed(ActionEvent). |
|
static
|
createListRetriever(List<T> list,
String listDescription)
|
|
static
|
createReferenceRetriever(ValueRetriever<T> retriever)
|
|
static
|
createStubRetriever(T entry)
|
|
static
|
createStubRetriever(ValueRetriever<T> retriever)
|
|
protected Component |
determineParentComponent(ActionEvent ev)
called by actionPerformed(ActionEvent) to allow the initialization of the parent component before performAction(ActionEvent) is called |
|
protected void |
doh(Throwable ex)
|
|
protected void |
doh(Throwable ex,
Component parent)
handles an Exception the common way by logging it and then displaying it to the user |
|
|
execute(Callable<T> call,
Handler<? super T,?> handler)
executes the given call in a new thread (as a background task) and then performs the handler with the value from the call in the event thread again |
|
Thread |
execute(Task<?> backgroundTask,
Task<?> finishingTaskInEventThread)
executes the first given task in the background and then the second later in the event thread again. |
|
static Component |
findParent(EventObject ev)
|
|
Object |
getFormValue(Form form,
Object defaultValue)
|
|
Object |
getFormValue(Form form,
ValueRetriever<?> retriever)
|
|
String |
getHelpText()
|
|
InterfaceMonitor[] |
getInterfaceMonitors()
|
|
Logger |
getLogger()
acess to the (non-null) Logger suitable for logging entries in the context of this instance |
|
Component |
getParent()
|
|
ValueRetriever<? extends Component> |
getParentRetriever()
|
|
protected Set<Object> |
getRequiredUserRights()
|
|
Filter<? super User> |
getUserAccessFilter()
|
|
ValueRetriever<? extends User> |
getUserRetriever()
|
|
boolean |
isAccessibleBy(User user)
utilizes checkAccess(User) to answer the question
(while temporarily disabling password requirements) |
|
protected abstract void |
performAction(ActionEvent ev,
Component parent)
|
|
boolean |
remove(InterfaceMonitor im)
|
|
boolean |
requiresLicense()
|
|
boolean |
requiresPassword()
returns whether this action requires to re-enter the login password to be able to continue (false by default), which is only applicable if a userRetriever is set to a non-null value. |
|
String |
runCommand(boolean captureOutput,
String... command)
convenience method to simply run a given command on the command line |
|
Thread |
runInBackground(Task<?> task)
returns the started thread |
|
void |
setDisjunctAccessFilter(Object... accessRights)
sets a special user access filter |
|
void |
setHelpText(String helpText)
|
|
void |
setMnemonicKey(int mnemonicKey)
see KeyEvent |
|
void |
setParent(Component parent)
|
|
void |
setParentRetriever(ValueRetriever<? extends Component> parentRetriever)
|
|
void |
setRequiresLicense(boolean flag)
|
|
void |
setRequiresPassword(boolean requiresPassword)
allows to enforce that the user currently logged in needs to re-enter his/her password to be able to continue. |
|
void |
setUserAccessFilter(Filter<? super User> userAccessFilter)
allows to specify a filter for users that is checked when checkAccess(User) is called if set to a non-null value |
|
void |
setUserRetriever(ValueRetriever<? extends User> userRetriever)
|
|
| Methods inherited from class javax.swing.AbstractAction |
|---|
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected ValueRetriever<? extends User> userRetriever
protected ValueRetriever<? extends Component> parentRetriever
| Constructor Detail |
|---|
public MyAbstractAction()
public MyAbstractAction(String name)
public MyAbstractAction(Icon icon)
public MyAbstractAction(String name,
String description,
Icon icon)
public MyAbstractAction(String name,
String description,
Icon icon,
Component parent)
public MyAbstractAction(String name,
String description,
Icon icon,
Component parent,
Logger logger)
public MyAbstractAction(String name,
String description,
Icon icon,
Component parent,
Logger logger,
ValueRetriever<User> userRetriever,
boolean requiresLicense)
| Method Detail |
|---|
protected abstract void performAction(ActionEvent ev,
Component parent)
throws Exception
Exceptionpublic Filter<? super User> getUserAccessFilter()
setUserAccessFilter(Filter)public void setUserAccessFilter(Filter<? super User> userAccessFilter)
checkAccess(User) is called if set to a non-null value
checkAccess(User),
UserFilterpublic void setDisjunctAccessFilter(Object... accessRights)
setUserAccessFilter(Filter)public void setMnemonicKey(int mnemonicKey)
KeyEvent
public void setHelpText(String helpText)
public String getHelpText()
public ValueRetriever<? extends User> getUserRetriever()
public void setUserRetriever(ValueRetriever<? extends User> userRetriever)
public boolean requiresPassword()
setRequiresPassword(boolean),
setUserRetriever(ValueRetriever)public Logger getLogger()
LoggerProvider
getLogger in interface LoggerProviderpublic boolean requiresLicense()
public void setRequiresLicense(boolean flag)
protected Set<Object> getRequiredUserRights()
public void setRequiresPassword(boolean requiresPassword)
Database is associated with this instance.
checkAccess(User)public static <T extends DBEntry> ValueRetriever<Stub<T>> createStubRetriever(T entry)
public static <T extends DBEntry> ValueRetriever<Stub<T>> createStubRetriever(ValueRetriever<T> retriever)
public static <T extends DBEntry> ValueRetriever<DBReference> createReferenceRetriever(ValueRetriever<T> retriever)
public static <T> ListRetriever<T> createListRetriever(List<T> list,
String listDescription)
public boolean isAccessibleBy(User user)
checkAccess(User) to answer the question
(while temporarily disabling password requirements)
public void checkAccess(User user)
throws AccessControlException
actionPerformed(ActionEvent).
When overriding this method it is a good idea to call this method through super.checkAccess(user)
to have the usual stuff checked automatically and then to your own checks.
AccessControlException - if the check fails (which also happens if no user was given)public void addRequiredAccessRights(Object... rights)
public boolean addRequiredAccessRight(Object right)
public ValueRetriever<? extends Component> getParentRetriever()
public void setParentRetriever(ValueRetriever<? extends Component> parentRetriever)
protected Component determineParentComponent(ActionEvent ev)
public static Component findParent(EventObject ev)
public void setParent(Component parent)
public Component getParent()
public String runCommand(boolean captureOutput,
String... command)
throws IOException,
InterruptedException
command - the command to be runcaptureOutput - if true, the output of the command is captured and returned
IOException
InterruptedException
public <T> void execute(Callable<T> call,
Handler<? super T,?> handler)
call - handler - public Thread runInBackground(Task<?> task)
public Thread execute(Task<?> backgroundTask,
Task<?> finishingTaskInEventThread)
@Licensed public void actionPerformed(ActionEvent ev)
performAction(ActionEvent, Component) is executed, this method
calls checkAccess(User) and will show a warning as well as terminate if the
access check fails (only if there was a database configured with this instance, though).
Exceptions are handled by calling doh(Exception).
actionPerformed in interface ActionListener
public Object getFormValue(Form form,
Object defaultValue)
throws IOException
IOException
public Object getFormValue(Form form,
ValueRetriever<?> retriever)
throws IOException
IOExceptionFormHelper.getFormValue(Form, ValueRetriever, String)public boolean add(InterfaceMonitor im)
public boolean remove(InterfaceMonitor im)
public InterfaceMonitor[] getInterfaceMonitors()
protected void doh(Throwable ex)
protected void doh(Throwable ex,
Component parent)
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||