Skip to main content
summaryrefslogtreecommitdiffstats
blob: 8764cf3bc27369b4b062e4f72de1092ab308bf75 (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) 2005, 2007 IBM Corporation 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:
 *     IBM Corporation - initial API and implementation
 *     Bjorn Freeman-Benson - initial API and implementation
 *******************************************************************************/
package org.eclipse.debug.examples.ui.pda.views;

import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.examples.core.pda.model.PDADebugTarget;
import org.eclipse.debug.examples.ui.pda.DebugUIPlugin;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.jface.window.Window;


/**
 * Pushes a value onto the data stack.
 */
public class PushAction extends Action {
    
    private PDADebugTarget fTarget;
    private DataStackView fView;

    /**
     * Constructs an action to pop values off the stack 
     */
    protected PushAction(DataStackView view) {
        super("Push");
        ImageRegistry imageRegistry = DebugUIPlugin.getDefault().getImageRegistry();
        setImageDescriptor(imageRegistry.getDescriptor(DebugUIPlugin.IMG_ELCL_PUSH));
        setDisabledImageDescriptor(imageRegistry.getDescriptor(DebugUIPlugin.IMG_DLCL_PUSH));
        setToolTipText("Push");
        setEnabled(false);     
        fView = view;
    }
    
    public void run() {
        InputDialog dialog = new InputDialog(fView.getSite().getShell(), "Specify Value", "Enter value to push", null, null);
        if (dialog.open() == Window.OK) {
            try {
                fTarget.push(dialog.getValue());
            } catch (DebugException e) {
            }
        }
        fView.getViewer().refresh();
    }

    protected void setDebugTarget(PDADebugTarget target) {
        fTarget = target;
        setEnabled(fTarget != null && fTarget.canPush());
    }
    
    
}

Back to the top