KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > views > breakpoints > OtherBreakpointCategory


1 /*******************************************************************************
2  * Copyright (c) 2000, 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 package org.eclipse.debug.internal.ui.views.breakpoints;
12
13 import java.util.HashMap JavaDoc;
14 import java.util.Map JavaDoc;
15
16 import org.eclipse.core.runtime.IAdaptable;
17 import org.eclipse.core.runtime.PlatformObject;
18 import org.eclipse.debug.internal.ui.DebugPluginImages;
19 import org.eclipse.debug.ui.IDebugUIConstants;
20 import org.eclipse.jface.resource.ImageDescriptor;
21 import org.eclipse.ui.model.IWorkbenchAdapter;
22
23 /**
24  * Category for breakpoints in "other" categories.
25  */

26 public class OtherBreakpointCategory extends PlatformObject implements IWorkbenchAdapter {
27     
28     private static Map JavaDoc fOthers = new HashMap JavaDoc();
29     private IBreakpointOrganizer fOrganizer;
30     
31     
32     public static IAdaptable[] getCategories(IBreakpointOrganizer organizer) {
33         IAdaptable[] others = (IAdaptable[]) fOthers.get(organizer);
34         if (others == null) {
35             others = new IAdaptable[]{new OtherBreakpointCategory(organizer)};
36             fOthers.put(organizer, others);
37         }
38         return others;
39     }
40     
41     /**
42      * Constructs an 'other' category for the given organizer.
43      *
44      * @param organizer breakpoint organizer
45      */

46     private OtherBreakpointCategory(IBreakpointOrganizer organizer) {
47         fOrganizer = organizer;
48     }
49
50     /* (non-Javadoc)
51      * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object)
52      */

53     public Object JavaDoc[] getChildren(Object JavaDoc o) {
54         return null;
55     }
56
57     /* (non-Javadoc)
58      * @see org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor(java.lang.Object)
59      */

60     public ImageDescriptor getImageDescriptor(Object JavaDoc object) {
61         return DebugPluginImages.getImageDescriptor(IDebugUIConstants.IMG_VIEW_BREAKPOINTS);
62     }
63
64     /* (non-Javadoc)
65      * @see org.eclipse.ui.model.IWorkbenchAdapter#getLabel(java.lang.Object)
66      */

67     public String JavaDoc getLabel(Object JavaDoc o) {
68         return fOrganizer.getOthersLabel();
69     }
70
71     /* (non-Javadoc)
72      * @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object)
73      */

74     public Object JavaDoc getParent(Object JavaDoc o) {
75         return null;
76     }
77     
78     /* (non-Javadoc)
79      * @see java.lang.Object#equals(java.lang.Object)
80      */

81     public boolean equals(Object JavaDoc obj) {
82         if (obj instanceof OtherBreakpointCategory) {
83             OtherBreakpointCategory category = (OtherBreakpointCategory) obj;
84             return fOrganizer.equals(category.fOrganizer);
85         }
86         return false;
87     }
88     
89     /* (non-Javadoc)
90      * @see java.lang.Object#hashCode()
91      */

92     public int hashCode() {
93         return fOrganizer.hashCode();
94     }
95 }
96
Popular Tags