Esempio n. 1
0
 /** Called externally when the underlying corpus has changed. */
 private void dataChanged() {
   List<String> newDocs = new ArrayList<String>();
   if (corpus != null) {
     newDocs.addAll(corpus.getDocumentNames());
   }
   List<String> oldDocs = documentNames;
   documentNames = newDocs;
   oldDocs.clear();
 }
Esempio n. 2
0
 public void actionPerformed(ActionEvent e) {
   List<Resource> loadedDocuments;
   try {
     // get all the documents loaded in the system
     loadedDocuments = Gate.getCreoleRegister().getAllInstances("gate.Document");
   } catch (GateException ge) {
     // gate.Document is not registered in creole.xml....what is!?
     throw new GateRuntimeException(
         "gate.Document is not registered in the creole register!\n"
             + "Something must be terribly wrong...take a vacation!");
   }
   Vector<String> docNames = new Vector<String>();
   for (Resource loadedDocument : new ArrayList<Resource>(loadedDocuments)) {
     if (corpus.contains(loadedDocument)) {
       loadedDocuments.remove(loadedDocument);
     } else {
       docNames.add(loadedDocument.getName());
     }
   }
   JList docList = new JList(docNames);
   docList.getSelectionModel().setSelectionInterval(0, docNames.size() - 1);
   docList.setCellRenderer(renderer);
   final JOptionPane optionPane =
       new JOptionPane(
           new JScrollPane(docList), JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION);
   final JDialog dialog =
       optionPane.createDialog(CorpusEditor.this, "Add document(s) to this corpus");
   docList.addMouseListener(
       new MouseAdapter() {
         public void mouseClicked(MouseEvent e) {
           if (e.getClickCount() == 2) {
             optionPane.setValue(JOptionPane.OK_OPTION);
             dialog.dispose();
           }
         }
       });
   dialog.setVisible(true);
   if (optionPane.getValue().equals(JOptionPane.OK_OPTION)) {
     int[] selectedIndices = docList.getSelectedIndices();
     for (int selectedIndice : selectedIndices) {
       corpus.add((Document) loadedDocuments.get(selectedIndice));
     }
   }
   changeMessage();
 }
Esempio n. 3
0
 /**
  * Default constructor. Does nothing apart from calling the default constructor from the super
  * class. The actual object initialisation is done via the {@link #init} method.
  */
 public Transducer() {
   actionList = new ArrayList<Action>();
   actionList.add(null);
   actionList.add(new SerializeTransducerAction());
 }
Esempio n. 4
0
 /**
  * Gets the list of actions that can be performed on this resource.
  *
  * @return a List of Action objects (or null values)
  */
 @Override
 public List<Action> getActions() {
   List<Action> result = new ArrayList<Action>();
   result.addAll(actionList);
   return result;
 }