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

(-)a/org.eclipse.jdt.junit/META-INF/MANIFEST.MF (-1 / +2 lines)
Lines 7-13 Bundle-Activator: org.eclipse.jdt.internal.junit.ui.JUnitPlugin Link Here
7
Bundle-ActivationPolicy: lazy
7
Bundle-ActivationPolicy: lazy
8
Bundle-Vendor: %providerName
8
Bundle-Vendor: %providerName
9
Bundle-Localization: plugin
9
Bundle-Localization: plugin
10
Export-Package: org.eclipse.jdt.internal.junit.buildpath;x-internal:=true,
10
Export-Package: org.eclipse.jdt.internal.junit;x-internal:=true,
11
 org.eclipse.jdt.internal.junit.buildpath;x-internal:=true,
11
 org.eclipse.jdt.internal.junit.launcher;x-internal:=true,
12
 org.eclipse.jdt.internal.junit.launcher;x-internal:=true,
12
 org.eclipse.jdt.internal.junit.refactoring;x-internal:=true,
13
 org.eclipse.jdt.internal.junit.refactoring;x-internal:=true,
13
 org.eclipse.jdt.internal.junit.ui;x-internal:=true,
14
 org.eclipse.jdt.internal.junit.ui;x-internal:=true,
(-)a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/JUnitCopyQualifiedNameAction.java (+85 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2014 IBM Corporation 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
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.jdt.internal.junit.ui;
12
13
import org.eclipse.swt.SWTError;
14
import org.eclipse.swt.dnd.Clipboard;
15
import org.eclipse.swt.dnd.DND;
16
import org.eclipse.swt.dnd.TextTransfer;
17
import org.eclipse.swt.dnd.Transfer;
18
19
import org.eclipse.jface.dialogs.MessageDialog;
20
21
import org.eclipse.ui.IWorkbenchPartSite;
22
import org.eclipse.ui.actions.SelectionListenerAction;
23
24
import org.eclipse.jdt.internal.junit.model.TestCaseElement;
25
import org.eclipse.jdt.internal.junit.model.TestElement;
26
import org.eclipse.jdt.internal.junit.model.TestSuiteElement;
27
28
import org.eclipse.jdt.internal.ui.actions.ActionMessages;
29
import org.eclipse.jdt.internal.ui.actions.CopyQualifiedNameAction;
30
31
public class JUnitCopyQualifiedNameAction extends SelectionListenerAction {
32
	
33
	private IWorkbenchPartSite fSite;
34
	private Clipboard fClipboard;
35
	private TestElement fTestElement;
36
	
37
	
38
	public JUnitCopyQualifiedNameAction(IWorkbenchPartSite site, Clipboard clipboard) {
39
		super(ActionMessages.CopyQualifiedNameAction_ActionName);
40
		setActionDefinitionId(CopyQualifiedNameAction.ACTION_DEFINITION_ID);
41
		setToolTipText(ActionMessages.CopyQualifiedNameAction_ToolTipText);
42
		fSite= site;
43
		fClipboard= clipboard;
44
	}
45
46
	public void handleTestSelected(TestElement test) {
47
		fTestElement= test;
48
		setEnabled(fTestElement != null);
49
	}
50
	
51
	/*
52
	 * SelectionListener
53
	 */
54
	
55
	@Override
56
	public void run() {
57
58
		String qualifiedName;
59
		if (fTestElement instanceof TestSuiteElement) {
60
			qualifiedName= ((TestSuiteElement)fTestElement).getClassName();
61
		} else if (fTestElement instanceof TestCaseElement) {
62
			qualifiedName= ((TestCaseElement)fTestElement).getClassName()
63
					+ "." //$NON-NLS-1$
64
					+ ((TestCaseElement)fTestElement).getTestMethodName()
65
					+"()"; //$NON-NLS-1$
66
		} else {
67
			qualifiedName= null;
68
		}
69
		
70
		if (qualifiedName != null) {
71
			TextTransfer plainTextTransfer= TextTransfer.getInstance();
72
			try{
73
				fClipboard.setContents(
74
					new String[]{ qualifiedName },
75
					new Transfer[]{ plainTextTransfer });
76
			}  catch (SWTError e){
77
				if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD)
78
					throw e;
79
				if (MessageDialog.openQuestion(fSite.getShell(), JUnitMessages.CopyTraceAction_problem, JUnitMessages.CopyTraceAction_clipboard_busy))
80
					run();
81
			}
82
		}
83
	}
84
85
}
(-)a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/TestRunnerViewPart.java (+7 lines)
Lines 149-154 import org.eclipse.jdt.internal.junit.model.TestRunSession; Link Here
149
149
150
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
150
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
151
151
152
import org.eclipse.jdt.internal.ui.actions.CopyQualifiedNameAction;
152
import org.eclipse.jdt.internal.ui.viewsupport.ViewHistory;
153
import org.eclipse.jdt.internal.ui.viewsupport.ViewHistory;
153
154
154
/**
155
/**
Lines 211-216 public class TestRunnerViewPart extends ViewPart { Link Here
211
212
212
	private StopAction fStopAction;
213
	private StopAction fStopAction;
213
	private JUnitCopyAction fCopyAction;
214
	private JUnitCopyAction fCopyAction;
215
	private JUnitCopyQualifiedNameAction fCopyQualifiedNameAction;
214
	private Action fPasteAction;
216
	private Action fPasteAction;
215
217
216
	private Action fRerunLastTestAction;
218
	private Action fRerunLastTestAction;
Lines 1755-1760 action enablement Link Here
1755
		fCopyAction.setActionDefinitionId(ActionFactory.COPY.getCommandId());
1757
		fCopyAction.setActionDefinitionId(ActionFactory.COPY.getCommandId());
1756
		actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), fCopyAction);
1758
		actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), fCopyAction);
1757
		
1759
		
1760
		fCopyQualifiedNameAction= new JUnitCopyQualifiedNameAction(getSite(), fClipboard);
1761
		fCopyQualifiedNameAction.setActionDefinitionId(CopyQualifiedNameAction.ACTION_HANDLER_ID);
1762
		actionBars.setGlobalActionHandler(CopyQualifiedNameAction.ACTION_HANDLER_ID, fCopyQualifiedNameAction);
1763
		
1758
		fPasteAction= new JUnitPasteAction(parent.getShell(), fClipboard);
1764
		fPasteAction= new JUnitPasteAction(parent.getShell(), fClipboard);
1759
		fPasteAction.setActionDefinitionId(ActionFactory.PASTE.getCommandId());
1765
		fPasteAction.setActionDefinitionId(ActionFactory.PASTE.getCommandId());
1760
		actionBars.setGlobalActionHandler(ActionFactory.PASTE.getId(), fPasteAction);
1766
		actionBars.setGlobalActionHandler(ActionFactory.PASTE.getId(), fPasteAction);
Lines 2007-2012 action enablement Link Here
2007
	public void handleTestSelected(TestElement test) {
2013
	public void handleTestSelected(TestElement test) {
2008
		showFailure(test);
2014
		showFailure(test);
2009
		fCopyAction.handleTestSelected(test);
2015
		fCopyAction.handleTestSelected(test);
2016
		fCopyQualifiedNameAction.handleTestSelected(test);
2010
	}
2017
	}
2011
2018
2012
	private void showFailure(final TestElement test) {
2019
	private void showFailure(final TestElement test) {
(-)a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/TestViewer.java (-2 / +4 lines)
Lines 241-252 public class TestViewer { Link Here
241
			if (fLayoutMode == TestRunnerViewPart.LAYOUT_HIERARCHICAL) {
241
			if (fLayoutMode == TestRunnerViewPart.LAYOUT_HIERARCHICAL) {
242
				manager.add(new Separator());
242
				manager.add(new Separator());
243
				manager.add(new ExpandAllAction());
243
				manager.add(new ExpandAllAction());
244
				manager.add(new Separator());
244
			}
245
			}
245
246
247
			JUnitCopyQualifiedNameAction copyQualifiedAction= new JUnitCopyQualifiedNameAction(fTestRunnerPart.getSite(), fClipboard);
248
			copyQualifiedAction.handleTestSelected(testElement);
249
			manager.add(copyQualifiedAction);
246
		}
250
		}
247
		if (fTestRunSession != null && fTestRunSession.getFailureCount() + fTestRunSession.getErrorCount() > 0) {
251
		if (fTestRunSession != null && fTestRunSession.getFailureCount() + fTestRunSession.getErrorCount() > 0) {
248
			if (fLayoutMode != TestRunnerViewPart.LAYOUT_HIERARCHICAL)
249
				manager.add(new Separator());
250
			manager.add(new CopyFailureListAction(fTestRunnerPart, fClipboard));
252
			manager.add(new CopyFailureListAction(fTestRunnerPart, fClipboard));
251
		}
253
		}
252
		manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
254
		manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));

Return to bug 362072