KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > intro > impl > model > viewer > IntroModelContentProvider


1 /*******************************************************************************
2  * Copyright (c) 2004, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.ui.internal.intro.impl.model.viewer;
13
14 import org.eclipse.jface.viewers.ITreeContentProvider;
15 import org.eclipse.jface.viewers.Viewer;
16 import org.eclipse.ui.internal.intro.impl.model.AbstractIntroContainer;
17 import org.eclipse.ui.internal.intro.impl.model.AbstractIntroElement;
18
19 public class IntroModelContentProvider implements ITreeContentProvider {
20
21     public Object JavaDoc[] getChildren(Object JavaDoc element) {
22
23         AbstractIntroElement introElement = null;
24         if (element instanceof AbstractIntroElement)
25             // synch the resource first.
26
introElement = (AbstractIntroElement) element;
27
28         if (introElement != null
29                 && introElement
30                     .isOfType(AbstractIntroElement.ABSTRACT_CONTAINER))
31             return ((AbstractIntroContainer) introElement).getChildren();
32
33         return new Object JavaDoc[0];
34     }
35
36     public Object JavaDoc getParent(Object JavaDoc element) {
37         AbstractIntroElement introElement = null;
38         if (element instanceof AbstractIntroElement) {
39             // synch the resource first.
40
introElement = (AbstractIntroElement) element;
41             return introElement.getParent();
42         }
43         return null;
44     }
45
46
47     public boolean hasChildren(Object JavaDoc element) {
48         AbstractIntroElement introElement = null;
49         if (element instanceof AbstractIntroElement)
50             // synch the resource first.
51
introElement = (AbstractIntroElement) element;
52         if (introElement != null
53                 && introElement
54                     .isOfType(AbstractIntroElement.ABSTRACT_CONTAINER))
55             return true;
56         return false;
57     }
58
59
60     public Object JavaDoc[] getElements(Object JavaDoc element) {
61         return getChildren(element);
62     }
63
64
65     public void dispose() {
66         // nothing to dispose
67
}
68
69     /*
70      * (non-Javadoc)
71      *
72      * @see org.eclipse.jface.viewers.IIntroContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer,
73      * java.lang.Object, java.lang.Object)
74      */

75     public void inputChanged(Viewer viewer, Object JavaDoc oldInput, Object JavaDoc newInput) {
76         // do nothing
77

78     }
79
80 }
81
Popular Tags