KickJava   Java API By Example, From Geeks To Geeks.

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


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

18
19 package org.objectweb.jac.aspects.gui;
20
21 /**
22  * Useful methods that operate on views.
23  */

24 public class Views {
25
26     /**
27      * Finds a parent view with a given type
28      *
29      * @param start the view whose parents to search for
30      * @param parentClass the type of the requested parent class
31      * @return a parent view of start whose type is parentClass, or
32      * null if no such view can be found
33      */

34     public static View findParent(View start, Class JavaDoc parentClass) {
35         if (parentClass.isAssignableFrom(start.getClass()))
36             return start;
37         else if (start.getParentView()==null)
38             return null;
39         else
40             return findParent(start.getParentView(),parentClass);
41     }
42 }
43
Popular Tags