TermListModel.java

00001 /* 
00002 ** Author(s): Miguel Calejo
00003 ** Contact:   interprolog@declarativa.com, http://www.declarativa.com
00004 ** Copyright (C) Declarativa, Portugal, 2000-2002
00005 ** Use and distribution, without any warranties, under the terms of the 
00006 ** GNU Library General Public License, readable in http://www.fsf.org/copyleft/lgpl.html
00007 */
00008 package com.declarativa.interprolog.gui;
00009 import com.declarativa.interprolog.*;
00010 import javax.swing.*;
00011 import javax.swing.event.*;
00012 import java.io.Serializable;
00013 
00014 
00017 public class TermListModel implements Serializable,ListModel{
00018         TermModel[] terms;
00019         
00020         public static ObjectExamplePair example(){
00021                 TermModel[] Atuples = new TermModel[1];
00022                 Atuples[0]=new TermModel("c");
00023                 return new ObjectExamplePair("TermListModel",
00024                         new TermListModel(Atuples),
00025                         new TermListModel(new TermModel[0])
00026                         );
00027         }
00028         
00029         public void addListDataListener(ListDataListener l) {
00030                 //System.out.println("Should add a ListDataListener...");
00031         }
00032         public void removeListDataListener(ListDataListener l) {
00033                 //System.out.println("Should remove a ListDataListener...");
00034         }
00035         public Object getElementAt(int index) {
00036                 return terms[index];
00037         }
00038         public int getSize() {
00039                 return terms.length;
00040         }
00041         public TermListModel(TermModel[] terms){
00042                 if (terms == null) 
00043                         throw new RuntimeException("The TermListModel constructor needs a non-null argument");
00044                 for (int t=0; t<terms.length; t++) {
00045                         if (terms[t]==null)
00046                                 throw new RuntimeException("Null term in TermListModel term "+t);
00047                 }
00048                 this.terms=terms;
00049         }
00050 }

Generated on Wed Jul 26 13:30:44 2006 for XSB by  doxygen 1.4.5