1   package com.ontotext.gate.vr.dialog;
2   
3   import java.awt.event.*;
4   import javax.swing.*;
5   import java.util.*;
6   
7   
8   
9   /** Listeners like this one are used to be set to the
10   *  OK button of the MultipleSelectionDialog. Thus,
11   *  different actions could be performed on OK while the
12   *  MultipleSelectionDialog stays flexible
13   *  note: could be moved to MultipleSelectionDialog */
14  public class SaveOKListener implements ActionListener {
15    MultipleSelectionDialog dialog;
16  
17    /**@param the dialog that this listener has been/shall be
18     * associated with*/
19    public SaveOKListener(MultipleSelectionDialog dialog) {
20      if ( null == dialog )
21        throw new gate.util.GateRuntimeException("dialog not set (is null)");
22      this.dialog = dialog;
23    }// constructor
24  
25    public void actionPerformed(ActionEvent e) {
26  
27      if ( dialog.okBtn == e.getSource()) {
28        Object[] oarr = dialog.guiList.getSelectedValues();
29  
30        Vector selection = new Vector(oarr.length);
31        for ( int i = 0 ; i < oarr.length ; i++ ) {
32           selection.add(oarr[i]);
33        }
34        dialog.editor.saveOntologies(selection);
35        dialog.dispose();
36      } // if ok
37  
38    } // actionPerformed
39  }// class SaveOKListener
40