Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 9705e1459621955023a7ccb807ca7d095e495ed8 (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
/*******************************************************************************
 * Copyright (c) 2000, 2013 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.breakpoints.provisional;

import java.util.HashMap;
import java.util.Map;

import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.PlatformObject;
import org.eclipse.debug.internal.ui.DebugPluginImages;
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.model.IWorkbenchAdapter;

/**
 * Category for breakpoints in "other" categories.   Clients which provide
 * custom content in the Breakpoints view may instantiate this object to
 * represent elements in a breakpoint organizer that do not fall into any known
 * category.
 *
 * @since 3.6
 *
 * @see IBreakpointContainer
 * @see org.eclipse.debug.ui.IBreakpointOrganizerDelegate
 */
public class OtherBreakpointCategory extends PlatformObject implements IWorkbenchAdapter {

	private static Map<IBreakpointOrganizer, IAdaptable[]> fOthers = new HashMap<>();
    private IBreakpointOrganizer fOrganizer;


    public static IAdaptable[] getCategories(IBreakpointOrganizer organizer) {
        IAdaptable[] others = fOthers.get(organizer);
        if (others == null) {
            others = new IAdaptable[]{new OtherBreakpointCategory(organizer)};
            fOthers.put(organizer, others);
        }
        return others;
    }

    /**
     * Constructs an 'other' category for the given organizer.
     *
     * @param organizer breakpoint organizer
     */
    private OtherBreakpointCategory(IBreakpointOrganizer organizer) {
        fOrganizer = organizer;
    }

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

    @Override
	public ImageDescriptor getImageDescriptor(Object object) {
        return DebugPluginImages.getImageDescriptor(IDebugUIConstants.IMG_VIEW_BREAKPOINTS);
    }

    @Override
	public String getLabel(Object o) {
        return fOrganizer.getOthersLabel();
    }

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

    @Override
	public boolean equals(Object obj) {
        if (obj instanceof OtherBreakpointCategory) {
            OtherBreakpointCategory category = (OtherBreakpointCategory) obj;
            return fOrganizer.equals(category.fOrganizer);
        }
        return false;
    }

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

Back to the top