org.openpermis.editor.policy
Class MacAdapter

java.lang.Object
  extended by org.openpermis.editor.policy.MacAdapter

public final class MacAdapter
extends Object

Adapter that maps Mac OS X specific system functions to Swing actions.

Since:
0.1.0

Nested Class Summary
static class MacAdapter.EventHandlerAdapter
          Adapter for EAWT event handlers.
static class MacAdapter.NopAction
          Action that does nothing.
 
Field Summary
private  Object application
          The EAWT application instance.
private static org.slf4j.Logger LOGGER
          The logger object of this class.
 
Constructor Summary
MacAdapter()
          Creates a new mac adapter that is only active if running on a mac.
 
Method Summary
private  Object createApplicationInstance()
          Creates an instance of an apple application object.
private  Action getAction(Action action)
          Returns an action for use when registering handlers.
static void initialize(String name)
          Sets the Mac OS X application name and enables the application menu bar.
private  boolean isActive()
          Checks if the adapter is active.
static boolean isMac()
          Checks if the application is running on Mac OS X.
private  void register(MacAdapter.EventHandlerAdapter adapter)
          Registers an EAWT handler for the specified application method and action to execute.
 void registerAboutAction(Action action)
          Registers an action for the application about menu item.
 void registerOpenFileAction(Action action)
          Registers an action for events that prompt the application to open a file.
 void registerPreferencesAction(Action action)
          Registers an action for the application preferences menu item.
 void registerQuitAction(Action action)
          Registers an action for the application quit command.
 void setDockImage(Image image)
          Sets the image displayed on the dock.
private  void setEnabled(String method, boolean enabled)
          Enables or disables an application feature.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGER

private static final org.slf4j.Logger LOGGER
The logger object of this class.

Since:
0.1.0

application

private final Object application
The EAWT application instance.

See Also:
createApplicationInstance()
Since:
0.1.0
Constructor Detail

MacAdapter

public MacAdapter()
Creates a new mac adapter that is only active if running on a mac.

Since:
0.1.0
Method Detail

isMac

public static boolean isMac()
Checks if the application is running on Mac OS X.

Returns:
true if the application is running on Mac OS X, false otherwise.
Since:
0.1.0

initialize

public static void initialize(String name)
Sets the Mac OS X application name and enables the application menu bar.

Does nothing if the application is not running on Mac OS X.

Notes:
Has to be called prior to initializing AWT.
Parameters:
name - the application name to set.
Since:
0.1.0

createApplicationInstance

private Object createApplicationInstance()
Creates an instance of an apple application object.

Returns:
the application instance requested or null if we are not running on Mac OS X or the current OS does not support Apple EAWT.
Since:
0.1.0

isActive

private boolean isActive()
Checks if the adapter is active.

Returns:
true if the adapter is active, false otherwise.
Since:
0.1.0

setEnabled

private void setEnabled(String method,
                        boolean enabled)
Enables or disables an application feature.

Parameters:
method - the method to call to enable or disable the feature.
enabled - true to enable the feature, false to disable it.
Since:
0.1.0

register

private void register(MacAdapter.EventHandlerAdapter adapter)
Registers an EAWT handler for the specified application method and action to execute.

Parameters:
adapter - the adapter to register for EAWT events.
Since:
0.1.0

getAction

private final Action getAction(Action action)
Returns an action for use when registering handlers.

Parameters:
action - the preferred action to execute.
Returns:
the action to use for registering handlers, never null.
Since:
0.1.0

registerQuitAction

public void registerQuitAction(Action action)
Registers an action for the application quit command.

Parameters:
action - the action to execute, null to disable handling.
Since:
0.1.0

registerAboutAction

public void registerAboutAction(Action action)
Registers an action for the application about menu item.

Parameters:
action - the action to execute, null to disable handling.
Since:
0.1.0

registerPreferencesAction

public void registerPreferencesAction(Action action)
Registers an action for the application preferences menu item.

Parameters:
action - the action to execute, null to disable handling.
Since:
0.1.0

registerOpenFileAction

public void registerOpenFileAction(Action action)
Registers an action for events that prompt the application to open a file.

The file to be opened is passed in to the action handler as source of the action event in form of a String.

Parameters:
action - the action to register.
Since:
0.1.0

setDockImage

public void setDockImage(Image image)
Sets the image displayed on the dock.

Parameters:
image - the image to use as dock image.
Since:
0.1.0


PERMIS Role Based Access Control 0.3.0 (Build 14)
2009/05/08 09:06:48
Copyright (c) 2002-2007 Ergon Informatik AG