Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 0b1d871cef5290009ab591a57a39c4c256f051dd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*******************************************************************************
 * Copyright (c) 2000, 2009 IBM Corporation and others.
 *
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.debug.internal.ui.views.breakpoints;

import org.eclipse.core.runtime.PlatformObject;
import org.eclipse.debug.internal.ui.views.DebugUIViewsMessages;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.ui.IWorkingSet;
import org.eclipse.ui.model.IWorkbenchAdapter;
import org.eclipse.ui.model.IWorkbenchAdapter2;

/**
 * Represents a breakpoint category for a specific working set.
 */
public class WorkingSetCategory extends PlatformObject implements IWorkbenchAdapter, IWorkbenchAdapter2 {

    private IWorkingSet fWorkingSet;

    /**
     * Constructs a new workings set category for the given working set.
     *
     * @param workingSet
     */
    public WorkingSetCategory(IWorkingSet workingSet) {
        fWorkingSet = workingSet;
    }

    @Override
	public Object[] getChildren(Object o) {
        return null;
    }

    @Override
	public ImageDescriptor getImageDescriptor(Object object) {
        return fWorkingSet.getImageDescriptor();
    }

    @Override
	public String getLabel(Object o) {
        StringBuffer name = new StringBuffer(fWorkingSet.getName());
        if (isDefault()) {
            name.append(DebugUIViewsMessages.WorkingSetCategory_0);
        }
        return name.toString();
    }

    @Override
	public Object getParent(Object o) {
        return null;
    }

    /**
     * Returns the working set for this category.
     *
     * @return
     */
    public IWorkingSet getWorkingSet() {
        return fWorkingSet;
    }

    @Override
	public boolean equals(Object obj) {
        if (obj instanceof WorkingSetCategory) {
            WorkingSetCategory category = (WorkingSetCategory) obj;
            return category.getWorkingSet().equals(fWorkingSet);
        }
        return false;
    }

    @Override
	public int hashCode() {
        return fWorkingSet.hashCode();
    }

    @Override
	public RGB getForeground(Object element) {
        return null;
    }

    @Override
	public RGB getBackground(Object element) {
        return null;
    }

    @Override
	public FontData getFont(Object element) {
        if (isDefault()) {
            FontData[] fontData = JFaceResources.getDefaultFont().getFontData();
            if (fontData != null && fontData.length > 0) {
                FontData data = fontData[0];
                data.setStyle(SWT.BOLD);
                return data;
            }
        }
        return null;
    }

    /**
     * Whether this is the default breakpoint working set.
     *
     * @return whether this is the default breakpoint working set
     */
    private boolean isDefault() {
        return fWorkingSet.equals(BreakpointSetOrganizer.getDefaultWorkingSet());
    }

    @Override
	public String toString() {
        return fWorkingSet.getName();
    }
}

Back to the top