1   package com.ontotext.gate.vr.dialog;
2   /*CloseOKListener*/
3   import java.awt.event.*;
4   import javax.swing.*;
5   import java.util.*;
6   
7   
8   import com.ontotext.gate.vr.dialog.*;
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 CloseOKListener implements ActionListener {
15    MultipleSelectionDialog dialog;
16  
17    /**@param the dialog that this listener has been/shall be
18     * associated with*/
19    public CloseOKListener(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      try {
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.closeOntologies(selection);
35          dialog.dispose();
36        } // if ok
37      } catch (gate.creole.ResourceInstantiationException x) {
38        x.printStackTrace(gate.util.Err.getPrintWriter());
39      }
40  
41    } // actionPerformed
42  }// class CloseOKListener
43