use of com.apple.eawt.ApplicationEvent in project Spark by igniterealtime.
the class ApplePlugin method initialize.
@SuppressWarnings("deprecation")
public void initialize() {
_props = new AppleProperties();
ApplePreference pref = new ApplePreference(_props);
SparkManager.getPreferenceManager().addPreference(pref);
_applebounce = new AppleBounce(_props);
_appledock = new AppleDock();
SparkManager.getNativeManager().addNativeHandler(this);
handleIdle();
// // register an application listener to show the about box
_application = Application.getApplication();
_application.setEnabledPreferencesMenu(true);
_application.addPreferencesMenuItem();
_application.addApplicationListener(new ApplicationAdapter() {
public void handlePreferences(ApplicationEvent applicationEvent) {
SparkManager.getPreferenceManager().showPreferences();
}
public void handleReOpenApplication(ApplicationEvent event) {
MainWindow mainWindow = SparkManager.getMainWindow();
if (!mainWindow.isVisible()) {
mainWindow.setState(Frame.NORMAL);
mainWindow.setVisible(true);
}
if (SparkManager.getChatManager().getChatContainer().getTotalNumberOfUnreadMessages() > 0) {
final ChatFrame frame = SparkManager.getChatManager().getChatContainer().getChatFrame();
frame.setState(Frame.NORMAL);
frame.setVisible(true);
frame.toFront();
}
}
public void handleQuit(ApplicationEvent applicationEvent) {
SparkManager.getMainWindow().shutdown();
}
});
}
use of com.apple.eawt.ApplicationEvent in project org.alloytools.alloy by AlloyTools.
the class MacUtil method registerApplicationListener.
/**
* Register a Mac OS X "ApplicationListener"; if there was a previous listener,
* it will be removed first.
*
* @param reopen - when the user clicks on the Dock icon, we'll call
* reopen.run() using SwingUtilities.invokeLater
* @param about - when the user clicks on About Alloy4, we'll call about.run()
* using SwingUtilities.invokeLater
* @param open - when a file needs to be opened, we'll call open.run(filename)
* using SwingUtilities.invokeLater
* @param quit - when the user clicks on Quit, we'll call quit.run() using
* SwingUtilities.invokeAndWait
*/
public synchronized void registerApplicationListener(final Runnable reopen, final Runnable about, final Runner open, final Runnable quit) {
if (app == null)
app = new Application();
else if (listener != null)
app.removeApplicationListener(listener);
listener = new ApplicationAdapter() {
@Override
public void handleReOpenApplication(ApplicationEvent arg) {
SwingUtilities.invokeLater(reopen);
}
@Override
public void handleAbout(ApplicationEvent arg) {
arg.setHandled(true);
SwingUtilities.invokeLater(about);
}
@Override
public void handleOpenFile(ApplicationEvent arg) {
final String filename = arg.getFilename();
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
open.run(filename);
}
});
}
@Override
public void handleQuit(ApplicationEvent arg) {
try {
if (SwingUtilities.isEventDispatchThread())
quit.run();
else
SwingUtilities.invokeAndWait(quit);
} catch (Throwable e) {
// Nothing we can do; we're already trying to quit!
}
arg.setHandled(false);
}
};
app.addApplicationListener(listener);
}
use of com.apple.eawt.ApplicationEvent in project org.alloytools.alloy by AlloyTools.
the class MacUtil method addMenus.
public void addMenus(SimpleGUI simpleGUI) {
Application.getApplication().addPreferencesMenuItem();
Application.getApplication().addAboutMenuItem();
Application.getApplication().addApplicationListener(new ApplicationAdapter() {
@Override
public void handleAbout(ApplicationEvent ae) {
simpleGUI.doAbout();
}
@Override
public void handlePreferences(ApplicationEvent ae) {
simpleGUI.doPreferences();
}
@Override
public void handleQuit(ApplicationEvent arg0) {
simpleGUI.doQuit();
}
});
}
Aggregations