KickJava   Java API By Example, From Geeks To Geeks.

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


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.debug.internal.ui.views.breakpoints;
12
13 import org.eclipse.core.runtime.PlatformObject;
14 import org.eclipse.debug.internal.ui.views.DebugUIViewsMessages;
15 import org.eclipse.jface.resource.ImageDescriptor;
16 import org.eclipse.jface.resource.JFaceResources;
17 import org.eclipse.swt.SWT;
18 import org.eclipse.swt.graphics.FontData;
19 import org.eclipse.swt.graphics.RGB;
20 import org.eclipse.ui.IWorkingSet;
21 import org.eclipse.ui.model.IWorkbenchAdapter;
22 import org.eclipse.ui.model.IWorkbenchAdapter2;
23
24 /**
25  * Represents a breakpoint category for a specific working set.
26  */

27 public class WorkingSetCategory extends PlatformObject implements IWorkbenchAdapter, IWorkbenchAdapter2 {
28     
29     private IWorkingSet fWorkingSet;
30
31     /**
32      * Constructs a new workings set category for the given working set.
33      *
34      * @param workingSet
35      */

36     public WorkingSetCategory(IWorkingSet workingSet) {
37         fWorkingSet = workingSet;
38     }
39     
40     /* (non-Javadoc)
41      * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object)
42      */

43     public Object JavaDoc[] getChildren(Object JavaDoc o) {
44         return null;
45     }
46
47     /* (non-Javadoc)
48      * @see org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor(java.lang.Object)
49      */

50     public ImageDescriptor getImageDescriptor(Object JavaDoc object) {
51         return fWorkingSet.getImageDescriptor();
52     }
53
54     /* (non-Javadoc)
55      * @see org.eclipse.ui.model.IWorkbenchAdapter#getLabel(java.lang.Object)
56      */

57     public String JavaDoc getLabel(Object JavaDoc o) {
58         StringBuffer JavaDoc name = new StringBuffer JavaDoc(fWorkingSet.getName());
59         if (isDefault()) {
60             name.append(DebugUIViewsMessages.WorkingSetCategory_0);
61         }
62         return name.toString();
63     }
64
65     /* (non-Javadoc)
66      * @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object)
67      */

68     public Object JavaDoc getParent(Object JavaDoc o) {
69         return null;
70     }
71     
72     /**
73      * Returns the working set for this category.
74      *
75      * @return
76      */

77     public IWorkingSet getWorkingSet() {
78         return fWorkingSet;
79     }
80
81     /* (non-Javadoc)
82      * @see java.lang.Object#equals(java.lang.Object)
83      */

84     public boolean equals(Object JavaDoc obj) {
85         if (obj instanceof WorkingSetCategory) {
86             WorkingSetCategory category = (WorkingSetCategory) obj;
87             return category.getWorkingSet().equals(fWorkingSet);
88         }
89         return false;
90     }
91     
92     /* (non-Javadoc)
93      * @see java.lang.Object#hashCode()
94      */

95     public int hashCode() {
96         return fWorkingSet.hashCode();
97     }
98
99     /* (non-Javadoc)
100      * @see org.eclipse.ui.model.IWorkbenchAdapter2#getForeground(java.lang.Object)
101      */

102     public RGB getForeground(Object JavaDoc element) {
103         return null;
104     }
105
106     /* (non-Javadoc)
107      * @see org.eclipse.ui.model.IWorkbenchAdapter2#getBackground(java.lang.Object)
108      */

109     public RGB getBackground(Object JavaDoc element) {
110         return null;
111     }
112
113     /* (non-Javadoc)
114      * @see org.eclipse.ui.model.IWorkbenchAdapter2#getFont(java.lang.Object)
115      */

116     public FontData getFont(Object JavaDoc element) {
117         if (isDefault()) {
118             FontData[] fontData = JFaceResources.getDefaultFont().getFontData();
119             if (fontData != null && fontData.length > 0) {
120                 FontData data = fontData[0];
121                 data.setStyle(SWT.BOLD);
122                 return data;
123             }
124         }
125         return null;
126     }
127     
128     /**
129      * Whether this is the default breakpoint working set.
130      *
131      * @return whether this is the default breakpoint working set
132      */

133     private boolean isDefault() {
134         return fWorkingSet.equals(BreakpointSetOrganizer.getDefaultWorkingSet());
135     }
136 }
137
138
Popular Tags