jap
Class AbstractJAPConfModule

java.lang.Object
  extended by jap.AbstractJAPConfModule
All Implemented Interfaces:
JAPHelpContext.IHelpContext
Direct Known Subclasses:
AccountSettingsPanel, JAPConfAnon, JAPConfAnonGeneral, JAPConfCert, JAPConfForwardingServer, JAPConfForwardingState, JAPConfHTTPFilter, JAPConfInfoService, JAPConfMixminion, JAPConfNetwork, JAPConfServices, JAPConfTC, JAPConfTor, JAPConfUI, JAPConfUpdate

public abstract class AbstractJAPConfModule
extends java.lang.Object
implements JAPHelpContext.IHelpContext

This is the generic implementation for a JAP configuration module.


Nested Class Summary
protected  class AbstractJAPConfModule.FontSizeObserver
          Observes changes of the font size.
private  class AbstractJAPConfModule.RootPanelAncestorListener
          Helper class for creating a onRootPanelShown call when the root panel (the whole configuration tab of this module) is coming to foreground.
 
Field Summary
private  AWTUpdateQueue AWT_UPDATE_QUEUE
           
protected  java.lang.Object LOCK_OBSERVABLE
           
private  boolean m_bObserversInitialised
           
private  javax.swing.JPanel m_rootPanel
          This stores the root panel of this configuration tab.
protected  IJAPConfSavePoint m_savePoint
          The savepoint for this module.
 
Constructor Summary
protected AbstractJAPConfModule(IJAPConfSavePoint a_moduleSavePoint)
          This is the constructor of AbstractJAPConfModule.
 
Method Summary
 void cancelPressed()
          This method is called every time the user presses the "Cancel" button.
 void createSavePoint()
          This will create a new savepoint with the current configuration.
static java.awt.GridBagConstraints createTabbedRootPanelContraints()
          Creates constraints for an equal alignment of a root panel with tabs.
 void fontSizeChanged(JAPModel.FontResize a_fontResize, javax.swing.JLabel a_dummyLabel)
          May contain some logic that is executed when the font size changes.
 java.awt.Component getHelpExtractionDisplayContext()
           
 javax.swing.JPanel getRootPanel()
          This returns the root panel for this configuration module.
abstract  java.lang.String getTabTitle()
          This method must be implemented by the children of AbstractJAPConfModule and returns the title for this configuration tab.
protected  boolean initObservers()
          All observables that are observed by this object MUST be registered here.
 boolean okPressed()
          This method is called every time the user presses the "OK" button.
protected  void onCancelPressed()
          This method can be overwritten by the children of AbstractJAPConfModule.
protected  boolean onOkPressed()
          This method can be overwritten by the children of AbstractJAPConfModule.
protected  void onResetToDefaultsPressed()
          This method can be overwritten by the children of AbstractJAPConfModule.
protected  void onRootPanelShown()
          This method can be overwritten by the children of AbstractJAPConfModule.
protected  void onUpdateValues()
          This method can be overwritten by the children of AbstractJAPConfModule.
abstract  void recreateRootPanel()
          This method must be implemented by the children of AbstractJAPConfModule.
 void resetToDefaultsPressed()
          This method is called every time the user presses the "Reset to defaults" button.
 void updateValues(boolean a_bSync)
          This method is called, if something on the configuration data has changed and the module shall update its GUI.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface gui.JAPHelpContext.IHelpContext
getHelpContext
 

Field Detail

AWT_UPDATE_QUEUE

private final AWTUpdateQueue AWT_UPDATE_QUEUE

m_rootPanel

private javax.swing.JPanel m_rootPanel
This stores the root panel of this configuration tab. All elements of the configuration tab are placed on this panel (or subpanels).


m_savePoint

protected IJAPConfSavePoint m_savePoint
The savepoint for this module. It is needed for restoring the old configuration, if the user presses "Cancel" or the default configuration, if the user presses "Reset to defaults".


m_bObserversInitialised

private boolean m_bObserversInitialised

LOCK_OBSERVABLE

protected final java.lang.Object LOCK_OBSERVABLE
Constructor Detail

AbstractJAPConfModule

protected AbstractJAPConfModule(IJAPConfSavePoint a_moduleSavePoint)
This is the constructor of AbstractJAPConfModule. It will be called by every child of this class. Every child have to do an super(a_moduleSavePoint) in the first line of its own constructor, where a_moduleSavePoint is the savepoint for this module.

Parameters:
a_moduleSavePoint - The savepoint for this module. If you supply null, there is no possibility for creating savepoints for this module. Also the default configuration for this module cannot be restored auto- matically.
Method Detail

createTabbedRootPanelContraints

public static java.awt.GridBagConstraints createTabbedRootPanelContraints()
Creates constraints for an equal alignment of a root panel with tabs.

Returns:
GridBagConstraints

getTabTitle

public abstract java.lang.String getTabTitle()
This method must be implemented by the children of AbstractJAPConfModule and returns the title for this configuration tab.

Returns:
The title for this configuration tab.

recreateRootPanel

public abstract void recreateRootPanel()
This method must be implemented by the children of AbstractJAPConfModule. It is called every time the root panel needs to be (re)created (e.g. the language has changed). This method is also called by the constructor of AbstractJAPConfModule after creating the root panel.


getRootPanel

public final javax.swing.JPanel getRootPanel()
This returns the root panel for this configuration module. The children of AbstractJAPConfModule can use this method to insert elements on the root panel. This method is also called to connect the root panel with a JTabbedPane.

Returns:
The root panel of this configuration module.

createSavePoint

public final void createSavePoint()
This will create a new savepoint with the current configuration. If the user later will press "Cancel", we can restore the current configuration. This method is called, every time, the configuration dialog is opened by the user.


okPressed

public final boolean okPressed()
This method is called every time the user presses the "OK" button. The onOkPressed() event handler is called by this method.

Returns:
true, if all values are ok and we can procceed; false otherwise

fontSizeChanged

public void fontSizeChanged(JAPModel.FontResize a_fontResize,
                            javax.swing.JLabel a_dummyLabel)
May contain some logic that is executed when the font size changes. It should also contain all fixed font sizes, e.g. for JLabels.

Parameters:
a_fontResize - the resize factor
a_dummyLabel - a label to get the current JLabel font size from

cancelPressed

public final void cancelPressed()
This method is called every time the user presses the "Cancel" button. It contains the generic implementation for restoring the original configuration from the last savepoint. Also the onCancelPressed() event handler is called by this method.


resetToDefaultsPressed

public final void resetToDefaultsPressed()
This method is called every time the user presses the "Reset to defaults" button. It contains the generic implementation for restoring the default configuration from the savepoint. Also the onResetToDefaultsPressed() event handler is called by this method.


updateValues

public final void updateValues(boolean a_bSync)
This method is called, if something on the configuration data has changed and the module shall update its GUI. The update events are queued.

Parameters:
a_bSync - if the current thread should wait until the operation is performed

onRootPanelShown

protected void onRootPanelShown()
This method can be overwritten by the children of AbstractJAPConfModule. It is called every time the root panel comes to the foreground (is set to visible).


onOkPressed

protected boolean onOkPressed()
This method can be overwritten by the children of AbstractJAPConfModule. It is called every time the user presses "OK" in the configuration dialog.


onCancelPressed

protected void onCancelPressed()
This method can be overwritten by the children of AbstractJAPConfModule. It is called every time the user presses "Cancel" in the configuration dialog after the restoring of the savepoint data (if there is a savepoint for this module).


onResetToDefaultsPressed

protected void onResetToDefaultsPressed()
This method can be overwritten by the children of AbstractJAPConfModule. It is called every time the user presses "Reset to defaults" in the configuration dialog after the restoring of the default configuration from the savepoint (if there is a savepoint for this module).


onUpdateValues

protected void onUpdateValues()
This method can be overwritten by the children of AbstractJAPConfModule. It is called every time the values of the model have changed and must be reread by the module. SHOULD NOT BE CALLED DIRECTLY in subclasses!!


initObservers

protected boolean initObservers()
All observables that are observed by this object MUST be registered here. Subsequent calls of this method should not lead to additional registrations.


getHelpExtractionDisplayContext

public java.awt.Component getHelpExtractionDisplayContext()
Specified by:
getHelpExtractionDisplayContext in interface JAPHelpContext.IHelpContext