|
Lines 1-5
Link Here
|
| 1 |
/********************************************************************** |
1 |
/********************************************************************** |
| 2 |
* Copyright (c) 2005, 2006 IBM Corporation and others. |
2 |
* Copyright (c) 2005, 2008 IBM Corporation and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
|
Lines 12-71
Link Here
|
| 12 |
package org.eclipse.hyades.test.tools.ui.java.internal.junit.actions; |
12 |
package org.eclipse.hyades.test.tools.ui.java.internal.junit.actions; |
| 13 |
|
13 |
|
| 14 |
import org.eclipse.core.resources.IFile; |
14 |
import org.eclipse.core.resources.IFile; |
| 15 |
import org.eclipse.hyades.models.common.testprofile.TPFTestCase; |
|
|
| 16 |
import org.eclipse.hyades.models.common.testprofile.TPFTestSuite; |
15 |
import org.eclipse.hyades.models.common.testprofile.TPFTestSuite; |
| 17 |
import org.eclipse.hyades.test.tools.core.java.JUnitTestSuiteFacade; |
16 |
import org.eclipse.hyades.test.tools.core.java.JUnitTestSuiteFacade; |
| 18 |
import org.eclipse.hyades.test.tools.ui.java.internal.junit.navigator.JUnitTestSuiteProxyNode; |
17 |
import org.eclipse.hyades.test.tools.ui.java.internal.junit.navigator.JUnitTestSuiteProxyNode; |
| 19 |
import org.eclipse.hyades.test.ui.internal.navigator.proxy.DefaultTestCaseProxyNode; |
|
|
| 20 |
import org.eclipse.hyades.test.ui.navigator.IProxyNode; |
18 |
import org.eclipse.hyades.test.ui.navigator.IProxyNode; |
| 21 |
import org.eclipse.hyades.ui.internal.util.UIUtil; |
19 |
import org.eclipse.hyades.ui.internal.util.UIUtil; |
| 22 |
import org.eclipse.jface.action.IAction; |
20 |
import org.eclipse.jface.action.IAction; |
| 23 |
import org.eclipse.jface.viewers.ISelection; |
21 |
import org.eclipse.jface.viewers.ISelection; |
| 24 |
import org.eclipse.jface.viewers.IStructuredSelection; |
22 |
import org.eclipse.jface.viewers.IStructuredSelection; |
| 25 |
import org.eclipse.jface.viewers.StructuredSelection; |
|
|
| 26 |
import org.eclipse.ui.IActionDelegate; |
23 |
import org.eclipse.ui.IActionDelegate; |
| 27 |
|
24 |
|
| 28 |
/** |
25 |
/** |
| 29 |
* Action to open the source code of a JUnit test suite. |
26 |
* Action to open the source code of a JUnit test suite. |
| 30 |
* @author jgout, jcanches |
27 |
* </p> |
| 31 |
* @since 4.0 |
28 |
* |
|
|
29 |
* |
| 30 |
* @author Jerome Gout |
| 31 |
* @author Julien Canches |
| 32 |
* @author Paul E. Slauenwhite |
| 33 |
* @version July 23, 2008 |
| 34 |
* @since September 1, 2006 |
| 32 |
*/ |
35 |
*/ |
| 33 |
public class OpenJUnitTestSuiteCodeAction implements IActionDelegate { |
36 |
public class OpenJUnitTestSuiteCodeAction implements IActionDelegate { |
| 34 |
|
37 |
|
| 35 |
private IStructuredSelection selection; |
38 |
private IStructuredSelection selection = null; |
| 36 |
|
39 |
|
| 37 |
/* (non-Javadoc) |
40 |
/* (non-Javadoc) |
| 38 |
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) |
41 |
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) |
| 39 |
*/ |
42 |
*/ |
| 40 |
public void run(IAction action) { |
43 |
public void run(IAction action) { |
|
|
44 |
|
| 41 |
IProxyNode proxy = (IProxyNode) selection.getFirstElement(); |
45 |
IProxyNode proxy = (IProxyNode) selection.getFirstElement(); |
|
|
46 |
|
| 42 |
if (proxy instanceof JUnitTestSuiteProxyNode) { |
47 |
if (proxy instanceof JUnitTestSuiteProxyNode) { |
|
|
48 |
|
| 43 |
TPFTestSuite ts = ((JUnitTestSuiteProxyNode)proxy).getTestSuite(); |
49 |
TPFTestSuite ts = ((JUnitTestSuiteProxyNode)proxy).getTestSuite(); |
| 44 |
IFile javaFile = JUnitTestSuiteFacade.getJUnitSourceFile(ts); |
50 |
IFile javaFile = JUnitTestSuiteFacade.getJUnitSourceFile(ts); |
| 45 |
if(javaFile != null) { |
51 |
|
|
|
52 |
if(javaFile != null) { |
| 46 |
UIUtil.openEditor(javaFile, null, false); |
53 |
UIUtil.openEditor(javaFile, null, false); |
| 47 |
} |
54 |
} |
|
|
55 |
|
| 48 |
if(ts.eResource() != null) { |
56 |
if(ts.eResource() != null) { |
| 49 |
ts.eResource().unload(); |
57 |
ts.eResource().unload(); |
| 50 |
} |
58 |
} |
| 51 |
} else if (proxy instanceof DefaultTestCaseProxyNode) { |
59 |
} |
| 52 |
DefaultTestCaseProxyNode tcpn = (DefaultTestCaseProxyNode)proxy; |
|
|
| 53 |
if (tcpn.getParent() instanceof JUnitTestSuiteProxyNode) { |
| 54 |
TPFTestCase tc = tcpn.getTestCase(); |
| 55 |
OpenTestMethodAction tcAction = new OpenTestMethodAction(null); |
| 56 |
tcAction.selectionChanged(new StructuredSelection(tc)); |
| 57 |
tcAction.run(); |
| 58 |
} |
| 59 |
} |
| 60 |
} |
60 |
} |
| 61 |
|
61 |
|
| 62 |
/* (non-Javadoc) |
62 |
/* (non-Javadoc) |
| 63 |
* @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) |
63 |
* @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) |
| 64 |
*/ |
64 |
*/ |
| 65 |
public void selectionChanged(IAction action, ISelection selection) { |
65 |
public void selectionChanged(IAction action, ISelection selection) { |
| 66 |
if (selection instanceof IStructuredSelection) { |
66 |
|
|
|
67 |
if (selection instanceof IStructuredSelection) { |
| 67 |
this.selection = (IStructuredSelection) selection; |
68 |
this.selection = (IStructuredSelection) selection; |
| 68 |
} |
69 |
} |
| 69 |
} |
70 |
} |
| 70 |
|
|
|
| 71 |
} |
71 |
} |