Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: bb5fb816350c75c5aba47bd6f1e02c715ec28440 (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
128
129
130
131
132
133
134
/*******************************************************************************
 * Copyright (c) 2014 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 org.eclipse.tcf.internal.debug.ui.launch;

import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.Launch;
import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.tcf.internal.debug.model.TCFLaunch;
import org.eclipse.tcf.internal.debug.ui.ImageCache;
import org.eclipse.tcf.internal.debug.ui.commands.MemoryMapWidget;
import org.eclipse.tcf.internal.debug.ui.model.TCFModelManager;
import org.eclipse.tcf.internal.debug.ui.model.TCFNode;

public class TCFMemoryMapTab extends AbstractLaunchConfigurationTab {

    private static final String TAB_ID = "org.eclipse.tcf.launch.memoryMapTab";

    private MemoryMapWidget widget;

    public void createControl(Composite parent) {
        TCFNode node = getSelectedNode();
        Composite composite = new Composite(parent, SWT.NONE);
        GridLayout layout = new GridLayout(1, false);
        composite.setFont(parent.getFont());
        composite.setLayout(layout);
        composite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true, 1, 1));
        widget = createWidget(composite, node);
        widget.addModifyListener(new ModifyListener() {
            public void modifyText(ModifyEvent evt) {
                updateLaunchConfigurationDialog();
            }
        });
        setControl(composite);
    }

    /**
     * Create the memory map widget.
     *
     * @param composite The parent composite.
     * @param node The TCF node.
     *
     * @return The memory map widget.
     */
    protected MemoryMapWidget createWidget(Composite composite, TCFNode node) {
        return new MemoryMapWidget(composite, node);
    }

    /**
     * Returns the memory map widget.
     *
     * @return The memory map widget.
     */
    protected final MemoryMapWidget getWidget() {
        return widget;
    }

    /**
     * Update the context for {@link MemoryMapWidget}.
     * @return <code>true</code> if the widgets context combo was updated.
     */
    public boolean updateContext() {
        if (widget != null) {
            TCFNode node = getSelectedNode();
            if (node != null) {
                return widget.setTCFNode(node);
            }
        }
        return false;
    }

    public void setDefaults(ILaunchConfigurationWorkingCopy cfg) {
    }

    public void initializeFrom(ILaunchConfiguration cfg) {
        setErrorMessage(null);
        setMessage(null);
        widget.loadData(cfg);
    }

    public void performApply(ILaunchConfigurationWorkingCopy cfg) {
        try {
            widget.saveData(cfg);
        }
        catch (Throwable x) {
            setErrorMessage("Cannot update memory map: " + x);
        }
    }

    @Override
    public void dispose() {
        if (widget != null) widget.dispose();
        super.dispose();
    }

    public String getName() {
        return "Symbol Files";
    }

    @Override
    public Image getImage() {
        return ImageCache.getImage(ImageCache.IMG_MEMORY_MAP);
    }

    @Override
    public String getId() {
        return TAB_ID;
    }

    private TCFNode getSelectedNode() {
        TCFNode node = null;
        IAdaptable adaptable = DebugUITools.getDebugContext();
        if (adaptable instanceof TCFLaunch) node = TCFModelManager.getRootNodeSync((Launch)adaptable);
        else if (adaptable != null) node = (TCFNode)adaptable.getAdapter(TCFNode.class);
        return node;
    }

}

Back to the top