KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jac > aspects > gui > ClassChooser


1 /*
2   Copyright (C) 2001-2003 Renaud Pawlak <renaud@aopsys.com>,
3                           Laurent Martelli <laurent@aopsys.com>
4   
5   This program is free software; you can redistribute it and/or modify
6   it under the terms of the GNU Lesser General Public License as
7   published by the Free Software Foundation; either version 2 of the
8   License, or (at your option) any later version.
9
10   This program is distributed in the hope that it will be useful,
11   but WITHOUT ANY WARRANTY; without even the implied warranty of
12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13   GNU Lesser General Public License for more details.
14
15   You should have received a copy of the GNU Lesser General Public License
16   along with this program; if not, write to the Free Software
17   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */

18
19 package org.objectweb.jac.aspects.gui;
20
21 import org.objectweb.jac.core.rtti.ClassItem;
22 import java.util.Iterator JavaDoc;
23 import java.util.Vector JavaDoc;
24
25
26
27 /**
28  * Used to choose a class to instantiate
29  */

30 public class ClassChooser {
31    public ClassChooser(ClassItem root) {
32       this.root = root;
33    }
34    ClassItem root;
35    public ClassItem getRoot() {
36       return root;
37    }
38    ClassItem choice;
39    public void setChoice(ClassItem cl) {
40       this.choice = cl;
41    }
42    public ClassItem getChoice() {
43       return choice;
44    }
45
46    public Vector JavaDoc getChoices() {
47       Vector JavaDoc result = new Vector JavaDoc();
48       if (!root.isAbstract())
49          result.add(root);
50       Iterator JavaDoc it = root.getChildren().iterator();
51       while (it.hasNext()) {
52          ClassItem cl = (ClassItem)it.next();
53          if (!cl.isAbstract())
54             result.add(cl);
55       }
56       return result;
57    }
58 }
59
Popular Tags