Changeset 2273


Ignore:
Timestamp:
2001-04-03T21:36:37+12:00 (23 years ago)
Author:
daven
Message:

retain state of non-explicit preferences (e.g. casfolding, stemming)

Location:
trunk/java-client/org/nzdl/gsdl
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/CSFrame.java

    r2260 r2273  
    153153                case QUIT_ID:
    154154                     System.out.println("quit chosen from menu");
     155                     //save preferences not in dialog
     156                     searchPanel.savePrefs();
    155157                     dispose();       // free resources
    156158                     System.exit(0);  // exit program
  • trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/SearchPanel.java

    r2270 r2273  
    142142    searchTextFieldPanel.add(searchTextField);
    143143
     144
     145    String queryType = NzdlConstants.DEFAULT_QUERY_TYPE;
     146    System.err.println("default queryType = " + queryType);
     147    if (NzdlPreferences.getInstance().isString(NzdlConstants.QUERYTYPE)) {
     148    queryType = NzdlPreferences.getInstance().getString(NzdlConstants.QUERYTYPE);
     149    }
     150    System.err.println("queryType = " + queryType);
     151    boolean stemming = NzdlConstants.DEFAULT_STEMMING;
     152    if (NzdlPreferences.getInstance().isBoolean(NzdlConstants.STEMMING))
     153    stemming = NzdlPreferences.getInstance().getBoolean(NzdlConstants.STEMMING);
     154    boolean caseFolding = NzdlConstants.DEFAULT_CASE_FOLDING;
     155    if (NzdlPreferences.getInstance().isBoolean(NzdlConstants.CASE_FOLDING))
     156    caseFolding = NzdlPreferences.getInstance().getBoolean(NzdlConstants.CASE_FOLDING);
     157   
    144158    optionsPanel = new JPanel();
    145159
     
    148162    rankedRadioButton = new JRadioButton("ranked");
    149163    rankedRadioButton.setActionCommand(rankedRadioButton.getText());
    150     rankedRadioButton.setSelected(rankedRadioButton.getText() == NzdlConstants.DEFAULT_QUERY_TYPE);
     164    rankedRadioButton.setSelected(queryType.equals(rankedRadioButton.getText()));
    151165    rankedRadioButton.setToolTipText("Display results in a ranked list");
    152166   
    153167    booleanRadioButton = new JRadioButton("boolean");
    154168    booleanRadioButton.setActionCommand(booleanRadioButton.getText());
    155     booleanRadioButton.setSelected(booleanRadioButton.getText() == NzdlConstants.DEFAULT_QUERY_TYPE);
     169    booleanRadioButton.setSelected(queryType.equals(booleanRadioButton.getText()));
    156170    booleanRadioButton.setToolTipText("Allows the use of Boolean operators: AND(&) OR(|) and NOT(!)");
    157171    buttonGroup = new ButtonGroup();
     
    160174    queryTypePanel.add(rankedRadioButton);
    161175    queryTypePanel.add(booleanRadioButton);
    162    
    163     stemCheckBox = new JCheckBox("Stemming", true);
     176
     177    stemCheckBox = new JCheckBox("Stemming", stemming);
    164178    stemCheckBox.setToolTipText("Strip endings such as '...ing', '...ed'");
    165     caseFoldCheckBox = new JCheckBox("Match case", false);
     179    caseFoldCheckBox = new JCheckBox("Match case", caseFolding);
    166180    caseFoldCheckBox.setToolTipText("Only match when the case is the same");
    167181
     
    416430    }
    417431
    418 
    419      } //end SearchPanel
     432    /*
     433     * save prefs not in preferencesDialog
     434     */
     435    public void savePrefs() {
     436    NzdlPreferences.getInstance().setBoolean(NzdlConstants.STEMMING,stemCheckBox.isSelected());
     437    NzdlPreferences.getInstance().setBoolean(NzdlConstants.CASE_FOLDING,caseFoldCheckBox.isSelected());
     438    NzdlPreferences.getInstance().setString(NzdlConstants.QUERYTYPE,buttonGroup.getSelection().getActionCommand());
     439    } //savePrefs
     440
     441
     442} //end SearchPanel
  • trunk/java-client/org/nzdl/gsdl/util/NzdlConstants.java

    r2270 r2273  
    2727 * @author Aziz Mahoui    ([email protected])
    2828 * @author Gordon Paynter ([email protected])
     29 * @author Dave Nichols   ([email protected])
    2930 * @version $Revision$
    3031 */
     
    4142  int    DEFAULT_END_RESULTS   = 10;
    4243  int    DEFAULT_MAX_DOCS      = 200;
     44
     45    /* preferences not under explicit dialog/user control */
     46
     47    String STEMMING = "stemming";
     48    String CASE_FOLDING = "casefolding";
     49    String QUERYTYPE = "querytype";
     50
    4351
    4452  /* Preference Strings */
  • trunk/java-client/org/nzdl/gsdl/util/NzdlPreferences.java

    r2270 r2273  
    9797    getInstance().save();
    9898  }
     99
     100
     101    public static boolean isBoolean(String key) {
     102    String value = (String) getInstance()._preferences.get(key);
     103    if (value == null)
     104        return false;
     105    return true;
     106    }
     107
    99108  /**
    100109   * Get a String preference
     
    109118    return value;
    110119  }
     120
     121    public static boolean isString(String key){
     122    //String value = (String) getInstance()._preferences.get(key);
     123    if (getInstance()._preferences.get(key) == null )
     124        return false;
     125    else
     126        return true;
     127    }
     128
     129
     130
    111131  /**
    112132   * Set a String preference
Note: See TracChangeset for help on using the changeset viewer.