KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > packageview > PackageFragmentRootContainer


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 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 package org.eclipse.jdt.internal.ui.packageview;
12
13 import org.eclipse.core.runtime.Assert;
14 import org.eclipse.core.runtime.IAdaptable;
15
16 import org.eclipse.jface.resource.ImageDescriptor;
17
18 import org.eclipse.ui.model.IWorkbenchAdapter;
19
20 import org.eclipse.jdt.core.IJavaProject;
21 import org.eclipse.jdt.core.IPackageFragmentRoot;
22
23 public abstract class PackageFragmentRootContainer implements IAdaptable {
24     
25     private static WorkbenchAdapterImpl fgAdapterInstance= new WorkbenchAdapterImpl();
26     
27     private static class WorkbenchAdapterImpl implements IWorkbenchAdapter {
28
29         /* (non-Javadoc)
30          * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object)
31          */

32         public Object JavaDoc[] getChildren(Object JavaDoc o) {
33             if (o instanceof PackageFragmentRootContainer)
34                 return ((PackageFragmentRootContainer) o).getChildren();
35             return new Object JavaDoc[0];
36         }
37
38         /* (non-Javadoc)
39          * @see org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor(java.lang.Object)
40          */

41         public ImageDescriptor getImageDescriptor(Object JavaDoc o) {
42             if (o instanceof PackageFragmentRootContainer)
43                 return ((PackageFragmentRootContainer) o).getImageDescriptor();
44             return null;
45         }
46
47         /* (non-Javadoc)
48          * @see org.eclipse.ui.model.IWorkbenchAdapter#getLabel(java.lang.Object)
49          */

50         public String JavaDoc getLabel(Object JavaDoc o) {
51             if (o instanceof PackageFragmentRootContainer)
52                 return ((PackageFragmentRootContainer) o).getLabel();
53             return new String JavaDoc();
54         }
55
56         /* (non-Javadoc)
57          * @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object)
58          */

59         public Object JavaDoc getParent(Object JavaDoc o) {
60             if (o instanceof PackageFragmentRootContainer)
61                 return ((PackageFragmentRootContainer) o).getJavaProject();
62             return null;
63         }
64     }
65     
66     private IJavaProject fProject;
67
68     public PackageFragmentRootContainer(IJavaProject project) {
69         Assert.isNotNull(project);
70         fProject= project;
71     }
72
73     public Object JavaDoc getAdapter(Class JavaDoc adapter) {
74         if (adapter == IWorkbenchAdapter.class)
75             return fgAdapterInstance;
76         return null;
77     }
78
79     public abstract IAdaptable[] getChildren();
80     
81     public abstract IPackageFragmentRoot[] getPackageFragmentRoots();
82     
83     public abstract String JavaDoc getLabel();
84     
85     public abstract ImageDescriptor getImageDescriptor();
86     
87     public IJavaProject getJavaProject() {
88         return fProject;
89     }
90 }
91
Popular Tags