edu.rice.cs.drjava.platform
Class DefaultPlatform

java.lang.Object
  extended by edu.rice.cs.drjava.platform.DefaultPlatform
All Implemented Interfaces:
PlatformSupport

 class DefaultPlatform
extends Object
implements PlatformSupport

Default platform-neutral implementation of PlatformSupport. Most implementations will extend this class to inherit default behaviors.

Version:
$Id: DefaultPlatform.java 5436 2011-08-02 06:58:19Z mgricken $

Field Summary
static DefaultPlatform ONLY
          Singleton instance.
 
Constructor Summary
protected DefaultPlatform()
          Private constructor for singleton pattern.
 
Method Summary
private  boolean _javadocMainHasExecuteMethod(Class<?> main)
          Returns true if the given class object for com.sun.tools.javadoc.Main has an execute(String[]) method.
 void afterUISetup(Action about, Action prefs, Action quit)
          Hook for performing general UI setup.
 boolean areDrJavaFileExtensionsRegistered()
           
 void beforeUISetup()
          Hook for performing general UI setup.
 boolean canRegisterFileExtensions()
           
 String getJavaSpecVersion()
          Returns the current Java specification version.
 boolean isJavaFileExtensionRegistered()
           
 boolean isMacPlatform()
          Returns whether this is a Mac OS X platform.
 boolean isUsingSystemLAF()
          Utility method to determine if the current Swing look and feel is the platform-specific look and feel for the client platform.
 boolean isWindowsPlatform()
          Returns whether this is a Windows platform.
 boolean openURL(URL address)
          Utility method for opening a URL in a browser in a platform-specific way.
 boolean registerDrJavaFileExtensions()
          Register .drjava and .djapp file extensions.
 boolean registerJavaFileExtension()
          Register .java file extension.
 void setMnemonic(AbstractButton obj, char mnemonic)
          Set the keyboard mnemonic for the component in a way that is consistent with the current platform.
 void setMnemonic(AbstractButton obj, int mnemonic)
          Set the keyboard mnemonic for the component in a way that is consistent with the current platform.
 void setMnemonic(ButtonModel obj, int mnemonic)
          Set the keyboard mnemonic for the component in a way that is consistent with the current platform.
 void setMnemonicAt(JTabbedPane obj, int tabIndex, int mnemonic)
          Set the keyboard mnemonic for the component in a way that is consistent with the current platform.
 boolean unregisterDrJavaFileExtensions()
          Unregister .drjava and .djapp file extensions.
 boolean unregisterJavaFileExtension()
          Unregister .java file extension.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ONLY

public static DefaultPlatform ONLY
Singleton instance.

Constructor Detail

DefaultPlatform

protected DefaultPlatform()
Private constructor for singleton pattern.

Method Detail

isUsingSystemLAF

public boolean isUsingSystemLAF()
Utility method to determine if the current Swing look and feel is the platform-specific look and feel for the client platform.

Specified by:
isUsingSystemLAF in interface PlatformSupport
Returns:
true if current Swing look and feel is the system look and feel

beforeUISetup

public void beforeUISetup()
Hook for performing general UI setup. Called before all other UI setup is done. The default implementation does nothing.

Specified by:
beforeUISetup in interface PlatformSupport

afterUISetup

public void afterUISetup(Action about,
                         Action prefs,
                         Action quit)
Hook for performing general UI setup. Called after all other UI setup is done. The default implementation does nothing.

Specified by:
afterUISetup in interface PlatformSupport
Parameters:
about - the Action associated with openning the About dialog
prefs - the Action associated with openning the Preferences dialog
quit - the Action associated with quitting the DrJava application

isMacPlatform

public boolean isMacPlatform()
Returns whether this is a Mac OS X platform.

Specified by:
isMacPlatform in interface PlatformSupport

isWindowsPlatform

public boolean isWindowsPlatform()
Returns whether this is a Windows platform.

Specified by:
isWindowsPlatform in interface PlatformSupport

getJavaSpecVersion

public String getJavaSpecVersion()
Returns the current Java specification version.

Specified by:
getJavaSpecVersion in interface PlatformSupport

_javadocMainHasExecuteMethod

private boolean _javadocMainHasExecuteMethod(Class<?> main)
Returns true if the given class object for com.sun.tools.javadoc.Main has an execute(String[]) method. If so, that means we have a 1.4 version of tools.jar.

Parameters:
main - Class object for com.sun.tools.javadoc.Main

openURL

public boolean openURL(URL address)
Utility method for opening a URL in a browser in a platform-specific way. The default implementation uses Runtime.exec to execute a command specified in Preferences. Platform implementations should attempt the default method first, then try to use a "default browser", if such a thing exists on the specific platform.

Specified by:
openURL in interface PlatformSupport
Parameters:
address - the URL to open
Returns:
true if the URL was successfully handled, false otherwise

setMnemonic

public void setMnemonic(AbstractButton obj,
                        int mnemonic)
Set the keyboard mnemonic for the component in a way that is consistent with the current platform.

Specified by:
setMnemonic in interface PlatformSupport
Parameters:
obj - the component whose mnemonic should be set
mnemonic - the key code which represents the mnemonic
See Also:
AbstractButton.setMnemonic(int), KeyEvent

setMnemonic

public void setMnemonic(AbstractButton obj,
                        char mnemonic)
Set the keyboard mnemonic for the component in a way that is consistent with the current platform.

Specified by:
setMnemonic in interface PlatformSupport
Parameters:
obj - the component whose mnemonic should be set
mnemonic - a char specifying the mnemonic value
See Also:
AbstractButton.setMnemonic(char)

setMnemonic

public void setMnemonic(ButtonModel obj,
                        int mnemonic)
Set the keyboard mnemonic for the component in a way that is consistent with the current platform.

Specified by:
setMnemonic in interface PlatformSupport
Parameters:
obj - the component whose mnemonic should be set
mnemonic - the key code which represents the mnemonic
See Also:
ButtonModel.setMnemonic(int), KeyEvent

setMnemonicAt

public void setMnemonicAt(JTabbedPane obj,
                          int tabIndex,
                          int mnemonic)
Set the keyboard mnemonic for the component in a way that is consistent with the current platform.

Specified by:
setMnemonicAt in interface PlatformSupport
Parameters:
obj - the component whose mnemonic should be set
tabIndex - the index of the tab that the mnemonic refers to
mnemonic - the key code which represents the mnemonic
See Also:
JTabbedPane.setMnemonicAt(int,int), KeyEvent

canRegisterFileExtensions

public boolean canRegisterFileExtensions()
Specified by:
canRegisterFileExtensions in interface PlatformSupport
Returns:
true if file extensions can be registered and unregistered.

registerDrJavaFileExtensions

public boolean registerDrJavaFileExtensions()
Register .drjava and .djapp file extensions.

Specified by:
registerDrJavaFileExtensions in interface PlatformSupport
Returns:
true if registering succeeded

unregisterDrJavaFileExtensions

public boolean unregisterDrJavaFileExtensions()
Unregister .drjava and .djapp file extensions.

Specified by:
unregisterDrJavaFileExtensions in interface PlatformSupport
Returns:
true if unregistering succeeded

areDrJavaFileExtensionsRegistered

public boolean areDrJavaFileExtensionsRegistered()
Specified by:
areDrJavaFileExtensionsRegistered in interface PlatformSupport
Returns:
true if .drjava and .djapp file extensions are registered.

registerJavaFileExtension

public boolean registerJavaFileExtension()
Register .java file extension.

Specified by:
registerJavaFileExtension in interface PlatformSupport
Returns:
true if registering succeeded

unregisterJavaFileExtension

public boolean unregisterJavaFileExtension()
Unregister .java file extension.

Specified by:
unregisterJavaFileExtension in interface PlatformSupport
Returns:
true if unregistering succeeded

isJavaFileExtensionRegistered

public boolean isJavaFileExtensionRegistered()
Specified by:
isJavaFileExtensionRegistered in interface PlatformSupport
Returns:
true if .java file extension is registered.