Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 12ec02760499118508da95c32be14705fc0edc27 (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
/*******************************************************************************
 * Copyright (c) 2007 Wind River Systems, Inc. and others.
 * All rights reserved. This program and the accompanying materials 
 * are made available under the terms of the Eclipse Public License v1.0 
 * which accompanies this distribution, and is available at 
 * http://www.eclipse.org/legal/epl-v10.html 
 *  
 * Contributors:
 *     Wind River Systems - initial API and implementation
 *******************************************************************************/
package com.windriver.debug.tcf.ui.commands;

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

import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.ui.actions.IToggleBreakpointsTargetExtension;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IWorkbenchPart;

import com.windriver.debug.tcf.core.model.TCFBreakpoint;
import com.windriver.debug.tcf.ui.model.TCFNode;
import com.windriver.tcf.api.protocol.Protocol;
import com.windriver.tcf.api.services.IBreakpoints;

public class BreakpointCommand implements IToggleBreakpointsTargetExtension {
    
    public boolean canToggleBreakpoints(IWorkbenchPart part, ISelection selection) {
        Object obj = ((IStructuredSelection)selection).getFirstElement();
        if (obj instanceof TCFNode) {
            final TCFNode node = (TCFNode)obj;
            if (node == null) return false;
            final boolean[] res = new boolean[1];
            Protocol.invokeAndWait(new Runnable() {
                public void run() {
                    res[0] = node.getAddress() != null;
                }
            });
            return res[0];
        }
        else {
            return false;
        }
    }

    public void toggleBreakpoints(IWorkbenchPart part, ISelection selection) throws CoreException {
        Object obj = ((IStructuredSelection)selection).getFirstElement();
        if (obj instanceof TCFNode) {
            final TCFNode node = (TCFNode)obj;
            if (node == null) return;
            final CoreException[] res = new CoreException[1];
            Protocol.invokeAndWait(new Runnable() {
                public void run() {
                    try {
                        String addr = node.getAddress();
                        if (addr == null) return;
                        Map<String,Object> m = new HashMap<String,Object>();
                        m.put(IBreakpoints.PROP_ENABLED, Boolean.TRUE);
                        m.put(IBreakpoints.PROP_ADDRESS, addr);
                        new TCFBreakpoint(ResourcesPlugin.getWorkspace().getRoot(), m);
                    }
                    catch (CoreException x) {
                        res[0] = x;
                    }
                }
            });
            if (res[0] != null) throw res[0];
        }
    }

    public boolean canToggleLineBreakpoints(IWorkbenchPart part, ISelection selection) {
        // TODO Auto-generated method stub
        return false;
    }

    public void toggleLineBreakpoints(IWorkbenchPart part, ISelection selection) throws CoreException {
        // TODO Auto-generated method stub
        
    }

    public boolean canToggleMethodBreakpoints(IWorkbenchPart part, ISelection selection) {
        // TODO Auto-generated method stub
        return false;
    }

    public void toggleMethodBreakpoints(IWorkbenchPart part, ISelection selection) throws CoreException {
        // TODO Auto-generated method stub
        
    }

    public boolean canToggleWatchpoints(IWorkbenchPart part, ISelection selection) {
        // TODO Auto-generated method stub
        return false;
    }

    public void toggleWatchpoints(IWorkbenchPart part, ISelection selection) throws CoreException {
        // TODO Auto-generated method stub
        
    }
}

Back to the top