Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: cde6b998e56eb1613fade53f350770b72dc643e6 (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
/*******************************************************************************
 * Copyright (c) 2012, 2014 Wind River Systems and others.
 * All rights reserved. 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/
 *
 * Contributors:
 *     Wind River Systems - initial API and implementation
 *******************************************************************************/
package org.eclipse.tcf.internal.cdt.ui.breakpoints;

import org.eclipse.cdt.debug.core.model.ICBreakpointType;
import org.eclipse.cdt.debug.ui.breakpoints.IFieldEditorFactory;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.preference.FieldEditor;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.tcf.services.IBreakpoints;
import org.osgi.framework.Bundle;
import org.osgi.framework.Version;


/**
 * CBreakpointTypeFieldEditorFactory - Create the field editor for hardware breakpoint support.
 */
public class CBreakpointTypeFieldEditorFactory implements IFieldEditorFactory {

    public final static String NAME_HARDWARE = "org.eclipse.tcf.cdt.Hardware";
    public final static String NAME_TEMPORARY = "org.eclipse.tcf.cdt.Temporary";

    public final static String LABEL_HARDWARE = "Hardware";
    public final static String LABEL_TEMPORARY = "Temporary";

    private final static boolean fgNeedContribution = needContribution();

    public FieldEditor createFieldEditor(String name, String labelText, Composite parent) {
        if (fgNeedContribution) {
            if (NAME_HARDWARE.equals(name)) {
                return new CBreakpointTypeFieldEditor (parent, LABEL_HARDWARE, ICBreakpointType.HARDWARE, IBreakpoints.CAPABILITY_BREAKPOINT_TYPE);
            } else if (NAME_TEMPORARY.equals(name)) {
                return new CBreakpointTypeFieldEditor (parent, LABEL_TEMPORARY, ICBreakpointType.TEMPORARY, IBreakpoints.CAPABILITY_TEMPORARY);
            }
        }
        return null;
    }

    private static boolean needContribution() {
        Bundle cdtDebugUi = Platform.getBundle("org.eclipse.cdt.debug.ui");
        if (cdtDebugUi != null) {
            int state = cdtDebugUi.getState();
            if (state == Bundle.ACTIVE || state == Bundle.RESOLVED || state == Bundle.STARTING) {
                Version version = cdtDebugUi.getVersion();
                // if cdt.debug.ui version is at least 7.4 (CDT 8.4) we don't need the contribution
                if (version.compareTo(Version.parseVersion("7.4")) >= 0)
                    return false;
            }
        }
        return true;
    }

}

Back to the top