Changeset 2198


Ignore:
Timestamp:
2001-03-20T10:35:58+12:00 (23 years ago)
Author:
daven
Message:

tidying and error trapping for caret setting in empty documents

File:
1 edited

Legend:

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

    r2195 r2198  
    130130    searchTextFieldPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
    131131    searchTextFieldPanel.add(searchTextField);
    132    
     132
    133133    searchButtonPanel = new JPanel();
    134134    searchButtonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
    135135    searchButtonPanel.add(searchButton);
    136    
     136
    137137    queryFormulationPanel = new JPanel();
    138138    queryFormulationPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
     
    142142    queryFormulationPanel.add(searchTextFieldPanel);
    143143    queryFormulationPanel.add(searchButtonPanel);
    144    
     144
    145145    resultsPanel = new JPanel();
    146146    resultsPanel.setLayout(new BorderLayout());
     
    154154    resultsPanel.add(scrollResultsPane, BorderLayout.CENTER);
    155155    csModel.addResult(Result.INITIAL_FAKE_RESULT);
    156    
     156
    157157    dataPanel = new JPanel();
    158158    dataPanel.setLayout(new BorderLayout());
     
    170170                           }
    171171    }; // end custom JTextPane
     172
    172173    documentPane.setEditable(false);
    173174    documentPane.setFont(docFont);
     
    178179    scrollDataPane.setPreferredSize(new Dimension(300, 300));
    179180    dataPanel.add(scrollDataPane, BorderLayout.CENTER);
    180    
     181
    181182    parent.getRootPane().setDefaultButton(searchButton);
    182183
     
    193194
    194195  public void actionPerformed(ActionEvent e) {
    195     if (e.getSource() == searchButton ) { //assume only searchButton generates events
    196     // cursor not set when RETURN pressed, only when button clicked ?
     196    if (e.getSource() == searchButton ) {
     197      // cursor not set when RETURN pressed, only when button clicked ?
    197198      windowParent.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    198       //System.err.println("set wait cursor..");
    199199      String queryString = searchTextField.getText();
    200200      String collectionName = collectionList.getSelectedItem().toString();
     
    215215      // System.err.println("Size of docIDs = " + docIDs.size());
    216216      // paired collection of docIDs and Titles - but as Sets!
    217       Map titleMetaData = csModel.getNzdlService().getMetaData( collectionName, docIDs, "Title" );
     217      Map titleMetaData = nzdl.getMetaData( collectionName, docIDs, "Title" );
    218218      // created a paired collection of docIDs and Titles - as simple Strings!
    219219      HashMap titleMap = new HashMap();
     
    233233      if (docIDs.size() == 0 ) { // give some feedback for 0 results
    234234    csModel.addResult(Result.FAKE_RESULT);
    235     //documentPane.setText("");
    236235    documentPane.setStyledDocument(blankDoc);
    237236      }
     
    274273      if (e.getValueIsAdjusting()) { return; }
    275274      Result result =  (Result) resultsList.getSelectedValue();
    276       // System.err.println("result = " + result);
    277       // System.err.println("fake result = " + Result.FAKE_RESULT);
    278275      if ((result == Result.FAKE_RESULT) || (result == Result.INITIAL_FAKE_RESULT)) {
    279       //documentPane.setText("");
    280276      documentPane.setStyledDocument( blankDoc );
    281277      System.err.println("clicked on fake result");
     
    292288        defaultStyledDoc.remove(0, defaultStyledDoc.getLength());
    293289      } catch (Exception exception) {
    294         throw new Error (exception.toString());
     290      throw new Error (exception.toString());
    295291      }
    296292      defaultStyledDoc = new DefaultStyledDocument();
     
    299295      try { // get the document
    300296          String docContents = csModel.getNzdlService().getDocument(result.getCollectionName(),  result.getDocID());
    301            StringReader sr = new StringReader( docContents);
     297           StringReader sr = new StringReader(docContents);
    302298           if (NzdlPreferences.getInstance().getBoolean(Constants.RAW_TEXT)) { // display the document as raw text
    303299           documentPane.setEditorKit(styledEditorKit);
     
    310306           documentPane.setStyledDocument( htmlDoc );
    311307           }
    312            // htmlEditorKit.read( new StringReader(csModel.getNzdlService().getDocument(result.getCollectionName(),  result.getDocID())), htmlDoc, 0);
    313            }
     308      } // end try
    314309      catch(BadLocationException badLocException)
    315310      {
     
    321316      }
    322317
    323       //documentPane.setStyledDocument( htmlDoc );
    324       // should check for empty document here
    325       documentPane.setCaretPosition(1);
     318      if (documentPane.getLength > 0)
     319          documentPane.setCaretPosition(1);
    326320      // we might not be using htmlDoc at this point!!
    327321      htmlDoc.getImageData(nzdl, result.getCollectionName());
Note: See TracChangeset for help on using the changeset viewer.