unified the dictionary settings - all in DictionarySettings now, will add synchronization soon for potential delayed loading
This commit is contained in:
parent
de3e9a1dd0
commit
f0576e5c94
5 changed files with 56 additions and 55 deletions
|
@ -14,10 +14,10 @@ public class DictionarySettings
|
|||
|
||||
public DictionarySettings ()
|
||||
{
|
||||
boolean dictionaryValid = false ;
|
||||
boolean dictionaryEnabled = false ;
|
||||
boolean dictionaryLocal = false ;
|
||||
String dictionaryPath = "" ;
|
||||
dictionaryValid = false ;
|
||||
dictionaryEnabled = false ;
|
||||
dictionaryLocal = false ;
|
||||
dictionaryPath = "" ;
|
||||
}
|
||||
|
||||
public DictionarySettings ( boolean valid, boolean enabled, boolean local, String pathOrUrl )
|
||||
|
@ -36,6 +36,14 @@ public class DictionarySettings
|
|||
dictionaryPath = pathOrUrl ;
|
||||
}
|
||||
|
||||
public static DictionarySettings cloneDs ( DictionarySettings ds )
|
||||
{
|
||||
return new DictionarySettings ( ds.dictionaryValid,
|
||||
ds.dictionaryEnabled,
|
||||
ds.dictionaryLocal,
|
||||
ds.dictionaryPath ) ;
|
||||
}
|
||||
|
||||
public boolean equal ( DictionarySettings ds )
|
||||
{
|
||||
return ( ds.isEnabled () == this.isEnabled () &&
|
||||
|
|
|
@ -252,9 +252,10 @@ public class DuffPane extends TibetanPane
|
|||
* The current dictionary information
|
||||
* @TODO these three fields should be one class
|
||||
*/
|
||||
private boolean dictionaryEnabled = false ;
|
||||
private boolean dictionaryLocal = false ;
|
||||
private String dictionaryPath ;
|
||||
//private boolean dictionaryEnabled = false ;
|
||||
//private boolean dictionaryLocal = false ;
|
||||
//private String dictionaryPath ;
|
||||
private DictionarySettings dictionarySettings = null ;
|
||||
|
||||
private Hashtable actions;
|
||||
|
||||
|
@ -448,9 +449,9 @@ public class DuffPane extends TibetanPane
|
|||
"Serif");
|
||||
romanFontSize = defaultRomanFontSize();
|
||||
|
||||
dictionaryEnabled = defaultDictionarySettingsEnabled () ;
|
||||
dictionaryLocal = defaultDictionarySettingsLocal () ;
|
||||
dictionaryPath = defaultDictionarySettingsPath () ;
|
||||
dictionarySettings = new DictionarySettings ( defaultDictionarySettingsEnabled (),
|
||||
defaultDictionarySettingsLocal (),
|
||||
defaultDictionarySettingsPath () ) ;
|
||||
onDictionarySettingsChanged () ;
|
||||
|
||||
newDocument();
|
||||
|
@ -835,19 +836,9 @@ public class DuffPane extends TibetanPane
|
|||
/**
|
||||
* //MP add comment
|
||||
*/
|
||||
public boolean getDictionarySettingsEnabled ()
|
||||
public DictionarySettings getDictionarySettings ()
|
||||
{
|
||||
return dictionaryEnabled ;
|
||||
}
|
||||
|
||||
public boolean getDictionarySettingsLocal ()
|
||||
{
|
||||
return dictionaryLocal ;
|
||||
}
|
||||
|
||||
public String getDictionarySettingsPath ()
|
||||
{
|
||||
return dictionaryPath ;
|
||||
return dictionarySettings ;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -867,9 +858,9 @@ public class DuffPane extends TibetanPane
|
|||
*/
|
||||
public void setDictionarySettings ( boolean enabled, boolean local, String path )
|
||||
{
|
||||
dictionaryEnabled = enabled ;
|
||||
dictionaryLocal = local ;
|
||||
dictionaryPath = path ;
|
||||
dictionarySettings.setEnabled ( enabled ) ;
|
||||
dictionarySettings.setLocal ( local ) ;
|
||||
dictionarySettings.setPathOrUrl ( path ) ;
|
||||
|
||||
onDictionarySettingsChanged () ;
|
||||
}
|
||||
|
@ -1961,7 +1952,7 @@ public void paste(int offset)
|
|||
public void onDictionarySettingsChanged ()
|
||||
{
|
||||
GlobalResourceHolder.getListener ().update ( getObservable (),
|
||||
(Object)new Integer ( GlobalResourceHolder.Listener.DICTIONARY_SETTINGS ) ) ;
|
||||
dictionarySettings ) ;
|
||||
|
||||
if ( null == buttonToggleDict || null == buttonLookupDict )
|
||||
return ;
|
||||
|
@ -2088,11 +2079,15 @@ public void paste(int offset)
|
|||
{
|
||||
public void keyPressed ( KeyEvent ke )
|
||||
{
|
||||
if ( KeyEvent.VK_F12 == ke.getKeyCode () )
|
||||
boolean dictEnabled = buttonLookupDict.isEnabled () &&
|
||||
buttonToggleDict.isEnabled () ;
|
||||
|
||||
|
||||
if ( dictEnabled && KeyEvent.VK_F12 == ke.getKeyCode () )
|
||||
{
|
||||
toggleDictionaryFrame () ;
|
||||
}
|
||||
else if ( KeyEvent.VK_F11 == ke.getKeyCode () )
|
||||
else if ( dictEnabled && KeyEvent.VK_F11 == ke.getKeyCode () )
|
||||
{
|
||||
lookupDictionary () ;
|
||||
}
|
||||
|
|
|
@ -53,32 +53,25 @@ public class GlobalResourceHolder
|
|||
*/
|
||||
public void update ( Observable o, Object arg )
|
||||
{
|
||||
onSettingsChange ( ((Integer)arg).intValue () ) ;
|
||||
onSettingsChange ( arg ) ;
|
||||
}
|
||||
|
||||
/**
|
||||
* onSettingsChange
|
||||
*
|
||||
*/
|
||||
public void onSettingsChange ( int setting )
|
||||
public void onSettingsChange ( Object arg )
|
||||
{
|
||||
if ( null == GlobalResourceHolder.settingsServiceProvider )
|
||||
return ;
|
||||
if ( DICTIONARY_SETTINGS == setting )
|
||||
if ( arg instanceof DictionarySettings )
|
||||
{
|
||||
//
|
||||
// compare with the current settings
|
||||
//
|
||||
boolean newDictionaryEnabled = GlobalResourceHolder.
|
||||
settingsServiceProvider.getDictionarySettingsEnabled () ;
|
||||
boolean newDictionaryLocal = GlobalResourceHolder.
|
||||
settingsServiceProvider.getDictionarySettingsLocal () ;
|
||||
String newDictionaryPath = GlobalResourceHolder.
|
||||
settingsServiceProvider.getDictionarySettingsPath () ;
|
||||
|
||||
DictionarySettings newSettings = new DictionarySettings ( newDictionaryEnabled,
|
||||
newDictionaryLocal,
|
||||
newDictionaryPath ) ;
|
||||
DictionarySettings newSettings =
|
||||
DictionarySettings.cloneDs ( GlobalResourceHolder.
|
||||
settingsServiceProvider.getDictionarySettings () ) ;
|
||||
|
||||
if ( ! newSettings.equal ( GlobalResourceHolder.dictionarySettings ) )
|
||||
{
|
||||
|
|
|
@ -80,9 +80,10 @@ public class PreferenceWindow implements ActionListener, ItemListener
|
|||
GraphicsEnvironment genv = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||
String[] fontNames = genv.getAvailableFontFamilyNames();
|
||||
|
||||
valDictionaryEnabled = dp.getDictionarySettingsEnabled () ;
|
||||
valDictionaryLocal = dp.getDictionarySettingsLocal () ;
|
||||
valDictionaryPath = dp.getDictionarySettingsPath () ;
|
||||
DictionarySettings ds = dp.getDictionarySettings () ;
|
||||
valDictionaryEnabled = ds.isEnabled () ;
|
||||
valDictionaryLocal = ds.isLocal () ;
|
||||
valDictionaryPath = ds.getPathOrUrl () ;
|
||||
|
||||
|
||||
JPanel tibetanPanel;
|
||||
|
@ -355,9 +356,10 @@ public class PreferenceWindow implements ActionListener, ItemListener
|
|||
/** This returns only when the user has closed the dialog */
|
||||
public void show()
|
||||
{
|
||||
valDictionaryEnabled = dp.getDictionarySettingsEnabled () ;
|
||||
valDictionaryLocal = dp.getDictionarySettingsLocal () ;
|
||||
valDictionaryPath = dp.getDictionarySettingsPath () ;
|
||||
DictionarySettings ds = dp.getDictionarySettings () ;
|
||||
valDictionaryEnabled = ds.isEnabled () ;
|
||||
valDictionaryLocal = ds.isLocal () ;
|
||||
valDictionaryPath = ds.getPathOrUrl () ;
|
||||
updateDictionaryGui () ;
|
||||
|
||||
pane.setOptionType ( JOptionPane.OK_CANCEL_OPTION ) ;
|
||||
|
|
|
@ -26,9 +26,12 @@ import java.util.Observable ;
|
|||
* @author Edward Garrett, Tibetan and Himalayan Digital Library */
|
||||
public interface SettingsServiceProvider
|
||||
{
|
||||
/*
|
||||
boolean getDictionarySettingsEnabled () ;
|
||||
boolean getDictionarySettingsLocal () ;
|
||||
String getDictionarySettingsPath () ;
|
||||
*/
|
||||
|
||||
DictionarySettings getDictionarySettings () ;
|
||||
Observable getObservable () ;
|
||||
} // interface SettingsServiceProvider
|
||||
|
|
Loading…
Reference in a new issue