~ubuntu-branches/debian/sid/eclipse-cdt/sid

« back to all changes in this revision

Viewing changes to dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/breakpoints/BreakpointVMModelProxyStrategy.java

  • Committer: Package Import Robot
  • Author(s): Jakub Adam
  • Date: 2011-10-06 21:15:04 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20111006211504-8dutmljjih0zikfv
Tags: 8.0.1-1
* New upstream release.
* Split the JNI packages into a separate architecture dependent
  package and made eclipse-cdt architecture independent.
* Install JNI libraries into multiarch aware location
* Bumped Standards-Version to 3.9.2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*******************************************************************************
 
2
 * Copyright (c) 2008, 2010 Wind River Systems 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
 *     Wind River Systems - initial API and implementation
 
10
 *******************************************************************************/
 
11
package org.eclipse.cdt.dsf.debug.ui.viewmodel.breakpoints;
 
12
 
 
13
import org.eclipse.cdt.dsf.ui.viewmodel.AbstractVMProvider;
 
14
import org.eclipse.cdt.dsf.ui.viewmodel.DefaultVMModelProxyStrategy;
 
15
import org.eclipse.core.runtime.CoreException;
 
16
import org.eclipse.debug.core.DebugPlugin;
 
17
import org.eclipse.debug.core.model.IBreakpoint;
 
18
import org.eclipse.debug.internal.ui.breakpoints.provisional.IBreakpointContainer;
 
19
import org.eclipse.debug.internal.ui.viewers.model.provisional.ICheckboxModelProxy;
 
20
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
 
21
import org.eclipse.jface.viewers.TreePath;
 
22
 
 
23
/**
 
24
 * Breakpoints VM model proxy that includes an ICheckboxModelProxy implementation.
 
25
 * 
 
26
 * @since 2.1
 
27
 */
 
28
public class BreakpointVMModelProxyStrategy extends DefaultVMModelProxyStrategy implements ICheckboxModelProxy {
 
29
    
 
30
    public BreakpointVMModelProxyStrategy(AbstractVMProvider provider, Object rootElement) {
 
31
        super(provider, rootElement);
 
32
    }
 
33
    
 
34
    public boolean setChecked(IPresentationContext context, Object viewerInput, TreePath path, boolean checked) {
 
35
        Object lastSegment = path.getLastSegment();
 
36
        if (lastSegment instanceof IBreakpointContainer) {
 
37
            IBreakpoint[] breakpoints = ((IBreakpointContainer) lastSegment).getBreakpoints();
 
38
            for (int i = 0; i < breakpoints.length; ++i) {
 
39
                try {
 
40
                    breakpoints[i].setEnabled(checked);
 
41
                } catch (CoreException e) {
 
42
                    return false;
 
43
                }
 
44
            }
 
45
            return true;
 
46
        }
 
47
        else {
 
48
            IBreakpoint breakpoint = (IBreakpoint)DebugPlugin.getAdapter(lastSegment, IBreakpoint.class);
 
49
            if (breakpoint != null) {
 
50
                try {
 
51
                    breakpoint.setEnabled(checked);
 
52
                } catch (CoreException e) {
 
53
                    return false;
 
54
                }
 
55
                return true;
 
56
            }
 
57
        } 
 
58
        return false;
 
59
    }
 
60
}