KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > activities > ws > CategorizedActivity


1 /*******************************************************************************
2  * Copyright (c) 2003, 2006 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.ui.internal.activities.ws;
12
13 import java.util.Set JavaDoc;
14
15 import org.eclipse.ui.activities.IActivity;
16 import org.eclipse.ui.activities.IActivityListener;
17 import org.eclipse.ui.activities.ICategory;
18 import org.eclipse.ui.activities.NotDefinedException;
19
20 /**
21  * IActivity proxy that is used by the
22  * <code>IActivityCategoryContentProvider</code>. Each
23  * proxy keeps a pointer to the <code>ICategory</code> under which it is being
24  * provided.
25  *
26  * @since 3.0
27  */

28 public class CategorizedActivity implements IActivity {
29
30     /**
31      * The real <code>IActivity</code>.
32      */

33     private IActivity activity;
34
35     /**
36      * The <code>ICategory</code> under which this proxy will be rendered.
37      */

38     private ICategory category;
39
40     /**
41      * Create a new instance.
42      *
43      * @param category the <code>ICategory</code> under which this proxy will be
44      * rendered.
45      * @param activity the real <code>IActivity</code>.
46      */

47     public CategorizedActivity(ICategory category, IActivity activity) {
48         this.activity = activity;
49         this.category = category;
50     }
51
52     /* (non-Javadoc)
53      * @see org.eclipse.ui.activities.IActivity#addActivityListener(org.eclipse.ui.activities.IActivityListener)
54      */

55     public void addActivityListener(IActivityListener activityListener) {
56         activity.addActivityListener(activityListener);
57     }
58
59     /* (non-Javadoc)
60      * @see java.lang.Comparable#compareTo(java.lang.Object)
61      */

62     public int compareTo(Object JavaDoc o) {
63         return activity.compareTo(o);
64     }
65
66     /* (non-Javadoc)
67      * @see java.lang.Object#equals(java.lang.Object)
68      */

69     public boolean equals(Object JavaDoc o) {
70         if (o instanceof CategorizedActivity) {
71             if (((CategorizedActivity) o).getCategory().equals(getCategory())) {
72                 return ((CategorizedActivity) o).getActivity().equals(
73                         getActivity());
74             }
75         }
76         return false;
77     }
78
79     /**
80      * @return returns the <code>IActivity</code>.
81      */

82     public IActivity getActivity() {
83         return activity;
84     }
85
86     /* (non-Javadoc)
87      * @see org.eclipse.ui.activities.IActivity#getActivityRequirementBindings()
88      */

89     public Set JavaDoc getActivityRequirementBindings() {
90         return activity.getActivityRequirementBindings();
91     }
92
93     /* (non-Javadoc)
94      * @see org.eclipse.ui.activities.IActivity#getActivityPatternBindings()
95      */

96     public Set JavaDoc getActivityPatternBindings() {
97         return activity.getActivityPatternBindings();
98     }
99
100     /**
101      * @return returns the <code>ICategory</code>.
102      */

103     public ICategory getCategory() {
104         return category;
105     }
106
107     /* (non-Javadoc)
108      * @see org.eclipse.ui.activities.IActivity#getId()
109      */

110     public String JavaDoc getId() {
111         return activity.getId();
112     }
113
114     /* (non-Javadoc)
115      * @see org.eclipse.ui.activities.IActivity#getName()
116      */

117     public String JavaDoc getName() throws NotDefinedException {
118         return activity.getName();
119     }
120
121     /* (non-Javadoc)
122      * @see java.lang.Object#hashCode()
123      */

124     public int hashCode() {
125         return activity.hashCode();
126     }
127
128     /* (non-Javadoc)
129      * @see org.eclipse.ui.activities.IActivity#isDefined()
130      */

131     public boolean isDefined() {
132         return activity.isDefined();
133     }
134
135     /* (non-Javadoc)
136      * @see org.eclipse.ui.activities.IActivity#isEnabled()
137      */

138     public boolean isEnabled() {
139         return activity.isEnabled();
140     }
141
142     /* (non-Javadoc)
143      * @see org.eclipse.ui.activities.IActivity#removeActivityListener(org.eclipse.ui.activities.IActivityListener)
144      */

145     public void removeActivityListener(IActivityListener activityListener) {
146         activity.removeActivityListener(activityListener);
147     }
148
149     /* (non-Javadoc)
150      * @see java.lang.Object#toString()
151      */

152     public String JavaDoc toString() {
153         return category.getId() + " -> " + activity.getId(); //$NON-NLS-1$
154
}
155
156     /* (non-Javadoc)
157      * @see org.eclipse.ui.activities.IActivity#getDescription()
158      */

159     public String JavaDoc getDescription() throws NotDefinedException {
160         return activity.getDescription();
161     }
162     
163     /* (non-Javadoc)
164      * @see org.eclipse.ui.activities.IActivity#isDefaultEnabled()
165      */

166     public boolean isDefaultEnabled() throws NotDefinedException {
167         return activity.isDefaultEnabled();
168     }
169 }
170
Popular Tags