001: /*******************************************************************************
002: * Copyright (c) 2003, 2006 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.ui.internal.activities.ws;
011:
012: import java.util.Set;
013:
014: import org.eclipse.ui.activities.IActivity;
015: import org.eclipse.ui.activities.IActivityListener;
016: import org.eclipse.ui.activities.ICategory;
017: import org.eclipse.ui.activities.NotDefinedException;
018:
019: /**
020: * IActivity proxy that is used by the
021: * <code>IActivityCategoryContentProvider</code>. Each
022: * proxy keeps a pointer to the <code>ICategory</code> under which it is being
023: * provided.
024: *
025: * @since 3.0
026: */
027: public class CategorizedActivity implements IActivity {
028:
029: /**
030: * The real <code>IActivity</code>.
031: */
032: private IActivity activity;
033:
034: /**
035: * The <code>ICategory</code> under which this proxy will be rendered.
036: */
037: private ICategory category;
038:
039: /**
040: * Create a new instance.
041: *
042: * @param category the <code>ICategory</code> under which this proxy will be
043: * rendered.
044: * @param activity the real <code>IActivity</code>.
045: */
046: public CategorizedActivity(ICategory category, IActivity activity) {
047: this .activity = activity;
048: this .category = category;
049: }
050:
051: /* (non-Javadoc)
052: * @see org.eclipse.ui.activities.IActivity#addActivityListener(org.eclipse.ui.activities.IActivityListener)
053: */
054: public void addActivityListener(IActivityListener activityListener) {
055: activity.addActivityListener(activityListener);
056: }
057:
058: /* (non-Javadoc)
059: * @see java.lang.Comparable#compareTo(java.lang.Object)
060: */
061: public int compareTo(Object o) {
062: return activity.compareTo(o);
063: }
064:
065: /* (non-Javadoc)
066: * @see java.lang.Object#equals(java.lang.Object)
067: */
068: public boolean equals(Object o) {
069: if (o instanceof CategorizedActivity) {
070: if (((CategorizedActivity) o).getCategory().equals(
071: getCategory())) {
072: return ((CategorizedActivity) o).getActivity().equals(
073: getActivity());
074: }
075: }
076: return false;
077: }
078:
079: /**
080: * @return returns the <code>IActivity</code>.
081: */
082: public IActivity getActivity() {
083: return activity;
084: }
085:
086: /* (non-Javadoc)
087: * @see org.eclipse.ui.activities.IActivity#getActivityRequirementBindings()
088: */
089: public Set getActivityRequirementBindings() {
090: return activity.getActivityRequirementBindings();
091: }
092:
093: /* (non-Javadoc)
094: * @see org.eclipse.ui.activities.IActivity#getActivityPatternBindings()
095: */
096: public Set getActivityPatternBindings() {
097: return activity.getActivityPatternBindings();
098: }
099:
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 getId() {
111: return activity.getId();
112: }
113:
114: /* (non-Javadoc)
115: * @see org.eclipse.ui.activities.IActivity#getName()
116: */
117: public String 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(
146: IActivityListener activityListener) {
147: activity.removeActivityListener(activityListener);
148: }
149:
150: /* (non-Javadoc)
151: * @see java.lang.Object#toString()
152: */
153: public String toString() {
154: return category.getId() + " -> " + activity.getId(); //$NON-NLS-1$
155: }
156:
157: /* (non-Javadoc)
158: * @see org.eclipse.ui.activities.IActivity#getDescription()
159: */
160: public String getDescription() throws NotDefinedException {
161: return activity.getDescription();
162: }
163:
164: /* (non-Javadoc)
165: * @see org.eclipse.ui.activities.IActivity#isDefaultEnabled()
166: */
167: public boolean isDefaultEnabled() throws NotDefinedException {
168: return activity.isDefaultEnabled();
169: }
170: }
|