View | Details | Raw Unified | Return to bug 199288
Collapse All | Expand All

(-)ui/org/eclipse/debug/internal/ui/views/expression/ExpressionView.java (-3 / +107 lines)
Lines 11-19 Link Here
11
 *******************************************************************************/
11
 *******************************************************************************/
12
package org.eclipse.debug.internal.ui.views.expression;
12
package org.eclipse.debug.internal.ui.views.expression;
13
13
14
 
14
import org.eclipse.core.runtime.IAdaptable;
15
import org.eclipse.debug.core.DebugPlugin;
15
import org.eclipse.debug.core.DebugPlugin;
16
import org.eclipse.debug.core.IExpressionManager;
17
import org.eclipse.debug.core.ILaunch;
18
import org.eclipse.debug.core.model.IDebugElement;
19
import org.eclipse.debug.core.model.IWatchExpression;
16
import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
20
import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
21
import org.eclipse.debug.internal.ui.actions.expressions.PasteWatchExpressionsAction;
17
import org.eclipse.debug.internal.ui.preferences.IDebugPreferenceConstants;
22
import org.eclipse.debug.internal.ui.preferences.IDebugPreferenceConstants;
18
import org.eclipse.debug.internal.ui.viewers.model.provisional.TreeModelViewer;
23
import org.eclipse.debug.internal.ui.viewers.model.provisional.TreeModelViewer;
19
import org.eclipse.debug.internal.ui.views.variables.AvailableLogicalStructuresAction;
24
import org.eclipse.debug.internal.ui.views.variables.AvailableLogicalStructuresAction;
Lines 21-26 Link Here
21
import org.eclipse.debug.internal.ui.views.variables.VariablesView;
26
import org.eclipse.debug.internal.ui.views.variables.VariablesView;
22
import org.eclipse.debug.internal.ui.views.variables.VariablesViewMessages;
27
import org.eclipse.debug.internal.ui.views.variables.VariablesViewMessages;
23
import org.eclipse.debug.internal.ui.views.variables.details.AvailableDetailPanesAction;
28
import org.eclipse.debug.internal.ui.views.variables.details.AvailableDetailPanesAction;
29
import org.eclipse.debug.ui.DebugUITools;
24
import org.eclipse.debug.ui.IDebugUIConstants;
30
import org.eclipse.debug.ui.IDebugUIConstants;
25
import org.eclipse.jface.action.IAction;
31
import org.eclipse.jface.action.IAction;
26
import org.eclipse.jface.action.IMenuManager;
32
import org.eclipse.jface.action.IMenuManager;
Lines 29-39 Link Here
29
import org.eclipse.jface.util.LocalSelectionTransfer;
35
import org.eclipse.jface.util.LocalSelectionTransfer;
30
import org.eclipse.jface.viewers.ISelection;
36
import org.eclipse.jface.viewers.ISelection;
31
import org.eclipse.swt.SWT;
37
import org.eclipse.swt.SWT;
38
import org.eclipse.swt.dnd.Clipboard;
32
import org.eclipse.swt.dnd.DND;
39
import org.eclipse.swt.dnd.DND;
33
import org.eclipse.swt.dnd.TextTransfer;
40
import org.eclipse.swt.dnd.TextTransfer;
34
import org.eclipse.swt.dnd.Transfer;
41
import org.eclipse.swt.dnd.Transfer;
42
import org.eclipse.swt.widgets.Display;
43
import org.eclipse.ui.ISharedImages;
35
import org.eclipse.ui.IWorkbenchActionConstants;
44
import org.eclipse.ui.IWorkbenchActionConstants;
36
 
45
import org.eclipse.ui.PlatformUI;
46
import org.eclipse.ui.texteditor.IWorkbenchActionDefinitionIds;
47
37
/**
48
/**
38
 * Displays expressions and their values with a detail
49
 * Displays expressions and their values with a detail
39
 * pane.
50
 * pane.
Lines 127-131 Link Here
127
        viewer.addDragSupport(DND.DROP_MOVE, new Transfer[] {LocalSelectionTransfer.getTransfer()}, new SelectionDragAdapter(viewer));
138
        viewer.addDragSupport(DND.DROP_MOVE, new Transfer[] {LocalSelectionTransfer.getTransfer()}, new SelectionDragAdapter(viewer));
128
        viewer.addDropSupport(DND.DROP_MOVE|DND.DROP_COPY, new Transfer[] {LocalSelectionTransfer.getTransfer(), TextTransfer.getInstance()}, new ExpressionDropAdapter(viewer));
139
        viewer.addDropSupport(DND.DROP_MOVE|DND.DROP_COPY, new Transfer[] {LocalSelectionTransfer.getTransfer(), TextTransfer.getInstance()}, new ExpressionDropAdapter(viewer));
129
    }    	
140
    }    	
130
    
141
142
	/*
143
	 * (non-Javadoc)
144
	 * 
145
	 * @see org.eclipse.debug.internal.ui.views.variables.VariablesView#createActions()
146
	 */
147
	protected void createActions() {
148
		super.createActions();
149
150
		PasteWatchExpressionsAction paste = new PasteWatchExpressionsAction(this);
151
		configure(paste, IWorkbenchActionDefinitionIds.PASTE,
152
				PASTE_ACTION, ISharedImages.IMG_TOOL_PASTE);
153
	}
154
155
	/**
156
	 * Configures the action to override the global action, and registers the
157
	 * action with this view.
158
	 * 
159
	 * @param action
160
	 * 		action
161
	 * @param defId
162
	 * 		action definition id
163
	 * @param globalId
164
	 * 		global action id
165
	 * @param imgId
166
	 * 		image identifier
167
	 */
168
	private void configure(IAction action, String defId, String globalId,
169
			String imgId) {
170
		setAction(defId, action);
171
		action.setActionDefinitionId(defId);
172
		getViewSite().getActionBars().setGlobalActionHandler(globalId, action);
173
		action.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages()
174
				.getImageDescriptor(imgId));
175
	}
176
177
	/**
178
	 * Returns whether the given selection can be pasted into the expressions
179
	 * view.
180
	 * 
181
	 * @param selection
182
	 * 		the selection to paste
183
	 * @return whether the given selection can be pasted into the given target
184
	 */
185
	public boolean canPaste() {
186
		String clipboardText = getClipboardText();
187
		if (clipboardText != null && clipboardText.length() > 0) {
188
			return true;
189
		}
190
		return false;
191
	}
192
193
	/**
194
	 * Pastes the selection into the given target
195
	 * 
196
	 * @param selection
197
	 * 		breakpoints
198
	 * @return whether successful
199
	 */
200
	public boolean performPaste() {
201
		String clipboardText = getClipboardText();
202
		if (clipboardText != null && clipboardText.length() > 0) {
203
			IExpressionManager expressionManager = DebugPlugin.getDefault()
204
					.getExpressionManager();
205
			IWatchExpression watchExpression = expressionManager
206
					.newWatchExpression(clipboardText);
207
			expressionManager.addExpression(watchExpression);
208
			watchExpression.setExpressionContext(getContext());
209
			return true;
210
		}
211
		return false;
212
	}
213
214
	// TODO: duplicate code from WatchExpressionAction
215
	protected IDebugElement getContext() {
216
        IAdaptable object = DebugUITools.getDebugContext();
217
        IDebugElement context = null;
218
        if (object instanceof IDebugElement) {
219
            context = (IDebugElement) object;
220
        } else if (object instanceof ILaunch) {
221
            context = ((ILaunch) object).getDebugTarget();
222
        }
223
        return context;
224
	}
225
226
	protected String getClipboardText() {
227
		Clipboard clipboard = new Clipboard(Display.getDefault());
228
		try {
229
			TextTransfer textTransfer = TextTransfer.getInstance();
230
			return (String) clipboard.getContents(textTransfer);
231
		} finally {
232
			clipboard.dispose();
233
		}
234
	}
131
}
235
}
(-)ui/org/eclipse/debug/internal/ui/actions/ActionMessages.properties (+1 lines)
Lines 182-187 Link Here
182
ConfigureColumnsAction_0=Select &Columns...
182
ConfigureColumnsAction_0=Select &Columns...
183
ConfigureColumnsAction_1=Select the &columns to display:
183
ConfigureColumnsAction_1=Select the &columns to display:
184
ConfigureColumnsAction_2=Select Columns
184
ConfigureColumnsAction_2=Select Columns
185
PasteWatchExpressionsAction_0=&Paste
185
ProfileLastAction_0=Profi&le Last Launched
186
ProfileLastAction_0=Profi&le Last Launched
186
ProfileLastAction_1=Profi&le
187
ProfileLastAction_1=Profi&le
187
ProfileLastAction_2=Profile the selected resource or active editor
188
ProfileLastAction_2=Profile the selected resource or active editor
(-)ui/org/eclipse/debug/internal/ui/actions/ActionMessages.java (+2 lines)
Lines 76-81 Link Here
76
76
77
	public static String OpenLaunchDialogAction_1;
77
	public static String OpenLaunchDialogAction_1;
78
78
79
	public static String PasteWatchExpressionsAction_0;
80
79
	public static String ProfileLastAction_0;
81
	public static String ProfileLastAction_0;
80
82
81
	public static String ProfileLastAction_1;
83
	public static String ProfileLastAction_1;
(-)ui/org/eclipse/debug/ui/IDebugView.java (-4 / +4 lines)
Lines 49-55 Link Here
49
	 * Action id for a view's cut action. Any view
49
	 * Action id for a view's cut action. Any view
50
	 * with a cut action that should be invoked when
50
	 * with a cut action that should be invoked when
51
	 * CTRL+X is pressed should store their
51
	 * CTRL+X is pressed should store their
52
	 * copy action with this key.
52
	 * cut action with this key.
53
	 * 
53
	 * 
54
	 * @see #setAction(String, IAction)
54
	 * @see #setAction(String, IAction)
55
	 */
55
	 */
Lines 59-65 Link Here
59
	 * Action id for a view's double-click action. Any view
59
	 * Action id for a view's double-click action. Any view
60
	 * with an action that should be invoked when
60
	 * with an action that should be invoked when
61
	 * the mouse is double-clicked should store their
61
	 * the mouse is double-clicked should store their
62
	 * action with this key.
62
	 * double-click action with this key.
63
	 * 
63
	 * 
64
	 * @see #setAction(String, IAction)
64
	 * @see #setAction(String, IAction)
65
	 */
65
	 */
Lines 69-75 Link Here
69
	 * Action id for a view's find action. Any view
69
	 * Action id for a view's find action. Any view
70
	 * with a find action that should be invoked when
70
	 * with a find action that should be invoked when
71
	 * CTRL+F is pressed should store their
71
	 * CTRL+F is pressed should store their
72
	 * copy action with this key.
72
	 * find action with this key.
73
	 * 
73
	 * 
74
	 * @see #setAction(String, IAction)
74
	 * @see #setAction(String, IAction)
75
	 */
75
	 */
Lines 79-85 Link Here
79
	 * Action id for a view's paste action. Any view
79
	 * Action id for a view's paste action. Any view
80
	 * with a paste action that should be invoked when
80
	 * with a paste action that should be invoked when
81
	 * CTRL+V is pressed should store their
81
	 * CTRL+V is pressed should store their
82
	 * copy action with this key.
82
	 * paste action with this key.
83
	 * 
83
	 * 
84
	 * @see #setAction(String, IAction)
84
	 * @see #setAction(String, IAction)
85
	 */
85
	 */
(-)ui/org/eclipse/debug/internal/ui/actions/expressions/PasteWatchExpressionsAction.java (+47 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 Adobe Systems, Inc. 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
 *     Adobe Systems, Inc. - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.debug.internal.ui.actions.expressions;
12
13
import org.eclipse.debug.internal.ui.actions.ActionMessages;
14
import org.eclipse.debug.internal.ui.views.expression.ExpressionView;
15
import org.eclipse.ui.actions.SelectionListenerAction;
16
17
/**
18
 * Paste a watch expression into the expressions view.
19
 */
20
public class PasteWatchExpressionsAction extends SelectionListenerAction {
21
22
	private final ExpressionView fExpressionView;
23
24
	public PasteWatchExpressionsAction(ExpressionView expressionView) {
25
		super(ActionMessages.PasteWatchExpressionsAction_0);
26
		fExpressionView = expressionView;
27
//        setToolTipText(BreakpointGroupMessages.PasteWatchExpressionsAction_1);
28
//        PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IDebugHelpContextIds.PASTE_WATCH_EXPRESSIONS_ACTION);
29
	}
30
31
	/* (non-Javadoc)
32
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
33
	 */
34
	public void run() {
35
		if (fExpressionView.canPaste()) {
36
			fExpressionView.performPaste();
37
		}
38
	}
39
40
	/* (non-Javadoc)
41
	 * @see org.eclipse.jface.action.Action#isEnabled()
42
	 */
43
	public boolean isEnabled() {
44
		return fExpressionView.canPaste();
45
	}
46
47
}

Return to bug 199288