com.tensegrity.skeleton.swt.commands
Class SwtPreferenceHelper

java.lang.Object
  extended bycom.tensegrity.skeleton.swt.commands.SwtPreferenceHelper
All Implemented Interfaces:
PreferenceHelp

public class SwtPreferenceHelper
extends java.lang.Object
implements PreferenceHelp

Helper class providing utility methods for setting the preferences within applications based on the SWT windowing toolkit.

These methods are typically needed twice:

The SwtPreferenceHelper class also provides some settings like last used directory necessary for file dialogs. See getCurrentDirectory().

Version:
$Id: SwtPreferenceHelper.java,v 1.15 2006/03/24 15:40:39 BurkhardWick Exp $
Author:
S�bastien Guyon

Constructor Summary
SwtPreferenceHelper(ApplicationFrame frame)
          Constructor specifying the ApplicationFrame.
 
Method Summary
 void applyGridSettings()
          Applies the settings given by the preferences to the CompositeViewGrid object of the view.
 void applyGridSettings(GraphDocument document)
          Applies the grid settings stored into the ApplicationFrame's preferences to the passed GraphDocument.
 void applyRulerSettings()
          Applies the settings given by the preferences to the CompositeViewRuler object of the view.
 void applyRulerSettings(GraphDocument document)
          Applies the ruler settings stored into the ApplicationFrame's preferences to the passed GraphDocument.
 void changeNavigatorPanelRendererAttribute(java.lang.String name, boolean value)
          Sets an attribute on the AttributeSet that is returned by the NavigatorPanel class statically and which can be used to adjust the RendererConfigurationC that is used by all NavigatorPanels.
 void changeSwtGraphPanelRendererAttribute(java.lang.String name, boolean value)
          Sets an attribute on the AttributeSet that is returned by the SwingGraphPanel class statically and which can be used to adjust the RendererConfigurationC that is used by all SwingGraphPanels during user-interaction.
protected  ApplicationFrame getApplicationFrame()
          Returns the instance of ApplicationFrame.
 java.io.File getCurrentDirectory()
          Returns the current directory of this application.
 void initCurrentDirectory()
          Initializes the currently used directory.
 void initFrameSizeAndPosition()
          Initializes the size and the position of the top level frame to the values found in the preferences.
 void initToolbarVisibilties()
          Called at Application start to initialize the visibilities of the Toolbar.
 void navigatorPanelSetUpdateDuringActing(boolean update)
          Sets the setUpdateDuringActing() property on the SwtNavigator.
 void setCurrentDirectory(java.io.File directory)
          Sets the currently used directory.
 void setLanguage(java.lang.String value)
          Sets the used language to the one specified by value.
 void setLookAndFeel(java.lang.String laf)
          Deprecated. Setting a new look and feel is not relevant for SWT based applications, therefore this method is deprecated and throws a RuntimeException.
 void setSubMenuRecentlyUsed(org.eclipse.swt.widgets.Menu menu)
          Sets the Sub-Menu for the recenlty used files to the given Menu.
 void setTooltipsEnabled(boolean b)
          Enables the tooltips if b is true.
protected  void updateNavigatorContainer()
          Updates the navigator container.
 void updateRecentlyUsedFilesMenu(ApplicationFrame applicationFrame)
          Updates the menu of recently used files.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SwtPreferenceHelper

public SwtPreferenceHelper(ApplicationFrame frame)
Constructor specifying the ApplicationFrame.

Parameters:
frame - the ApplicationFrame of the application.
Method Detail

setLanguage

public void setLanguage(java.lang.String value)
Sets the used language to the one specified by value.

Specified by:
setLanguage in interface PreferenceHelp
Parameters:
value - a string defining the language to be used.

setLookAndFeel

public void setLookAndFeel(java.lang.String laf)
Deprecated. Setting a new look and feel is not relevant for SWT based applications, therefore this method is deprecated and throws a RuntimeException.

Sets the look and feel to the one specified by value.

Specified by:
setLookAndFeel in interface PreferenceHelp
Parameters:
laf - a string defining the look and feel to be used.

setTooltipsEnabled

public void setTooltipsEnabled(boolean b)
Enables the tooltips if b is true.

Specified by:
setTooltipsEnabled in interface PreferenceHelp
Parameters:
b - true, if tooltips should be displayed.

setSubMenuRecentlyUsed

public void setSubMenuRecentlyUsed(org.eclipse.swt.widgets.Menu menu)
Sets the Sub-Menu for the recenlty used files to the given Menu.

Parameters:
menu - the Menu to set.

updateRecentlyUsedFilesMenu

public void updateRecentlyUsedFilesMenu(ApplicationFrame applicationFrame)
Updates the menu of recently used files.

Parameters:
applicationFrame - the ApplicationFrame.

getCurrentDirectory

public java.io.File getCurrentDirectory()
Returns the current directory of this application.

Specified by:
getCurrentDirectory in interface PreferenceHelp
Returns:
the current directory of this application.

setCurrentDirectory

public void setCurrentDirectory(java.io.File directory)
Sets the currently used directory.

Specified by:
setCurrentDirectory in interface PreferenceHelp
Parameters:
directory - the directory to set.

initFrameSizeAndPosition

public void initFrameSizeAndPosition()
Initializes the size and the position of the top level frame to the values found in the preferences.

Specified by:
initFrameSizeAndPosition in interface PreferenceHelp

initCurrentDirectory

public void initCurrentDirectory()
Initializes the currently used directory.

Specified by:
initCurrentDirectory in interface PreferenceHelp

changeSwtGraphPanelRendererAttribute

public void changeSwtGraphPanelRendererAttribute(java.lang.String name,
                                                 boolean value)
Sets an attribute on the AttributeSet that is returned by the SwingGraphPanel class statically and which can be used to adjust the RendererConfigurationC that is used by all SwingGraphPanels during user-interaction.

Parameters:
name - of the renderer-configuration item to change.
value - boolean-value to change the renderer-configuration item to.

updateNavigatorContainer

protected void updateNavigatorContainer()
Updates the navigator container.

See Also:
SwtNavigatorContainer.update(Observable, Object)

navigatorPanelSetUpdateDuringActing

public void navigatorPanelSetUpdateDuringActing(boolean update)
Sets the setUpdateDuringActing() property on the SwtNavigator.

Parameters:
update - true if the SwtNavigator should be updated while dragging, false otherwise.

changeNavigatorPanelRendererAttribute

public void changeNavigatorPanelRendererAttribute(java.lang.String name,
                                                  boolean value)
Sets an attribute on the AttributeSet that is returned by the NavigatorPanel class statically and which can be used to adjust the RendererConfigurationC that is used by all NavigatorPanels.

Parameters:
name - of the renderer-configuration item to change.
value - boolean-value to change the renderer-configuration item to.

applyRulerSettings

public void applyRulerSettings()
Applies the settings given by the preferences to the CompositeViewRuler object of the view.

Specified by:
applyRulerSettings in interface PreferenceHelp

applyGridSettings

public void applyGridSettings()
Applies the settings given by the preferences to the CompositeViewGrid object of the view.

Specified by:
applyGridSettings in interface PreferenceHelp

applyRulerSettings

public void applyRulerSettings(GraphDocument document)
Applies the ruler settings stored into the ApplicationFrame's preferences to the passed GraphDocument. Note that if no Preferences are retrieved some default values are used.

Specified by:
applyRulerSettings in interface PreferenceHelp
Parameters:
document - the GraphDocument for which the ruler has to be setup.

applyGridSettings

public void applyGridSettings(GraphDocument document)
Applies the grid settings stored into the ApplicationFrame's preferences to the passed GraphDocument. Note that if no Preferences are retrieved some default values are used.

Specified by:
applyGridSettings in interface PreferenceHelp
Parameters:
document - the GraphDocument for which the grid has to be setup.

initToolbarVisibilties

public void initToolbarVisibilties()
Called at Application start to initialize the visibilities of the Toolbar. They are set to their last state.

Specified by:
initToolbarVisibilties in interface PreferenceHelp

getApplicationFrame

protected ApplicationFrame getApplicationFrame()
Returns the instance of ApplicationFrame. This ApplicationFrame represents the enclosing application for this preference helper.

Returns:
the instance of the currently enclosing ApplicationFrame.


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.