|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgr.zeus.ui.SingleAppInstance
public final class SingleAppInstance
This helper component provides a simple solution to the multiple applications
instances problem. Just invoke onInit()
at your application's
startup and onExit()
at your application's shutdown and that's
all there is to it. SingleAppInstance
creates and locks a file
within the startup directory so if anyone is to execute your application
again the second onInit()
call fails with a message.
The onExit()
method unlocks and deletes the file.
If m_reportPopup
is true, a popup window is displayed for the
user to take action, else the user is informed via stderr
.
If you wish to change the look and feel of the popup window invoke
SingleAppInstance
after setting the look and feel inside your
application. If you wish to translate the messages for this component create
a new property file for your locale and place it inside
/gr/zeus/
where the default
"singleappinstance.properties" resides.
Method Summary | |
---|---|
static SingleAppInstance |
getInstance()
This method returns the single instance of this class. |
static SingleAppInstance |
getInstance(java.lang.String filename)
This method returns the single instance of this class. |
boolean |
getReportPopup()
Gets whether to report via a popup or via stderr . |
void |
onExit()
Release the file lock and delete the file. |
void |
onInit()
Creates a file and obtains a lock. |
void |
setReportPopup(boolean f)
Sets whether to report via a popup or via stderr . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static SingleAppInstance getInstance()
public static SingleAppInstance getInstance(java.lang.String filename)
filename
- The filename to create and lock, should be unique and
within current folder.
public void onInit()
System.exit()
. Should be invoked ONCE
inside main()
in your application.
public void onExit()
System.exit()
on your application.
public boolean getReportPopup()
stderr
.
true
, a popup window is displayed,
else the user is informed via stderr
.public void setReportPopup(boolean f)
stderr
.
f
- If true
, via a popup window,
else via stderr
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |