Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 241804
Collapse All | Expand All

(-)src/org/eclipse/hyades/test/tools/ui/java/internal/junit/navigator/JUnitTestSuiteProxyFactory.java (-6 / +23 lines)
Lines 1-5 Link Here
1
/********************************************************************** 
1
/********************************************************************** 
2
 * Copyright (c) 2005 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-17 Link Here
12
package org.eclipse.hyades.test.tools.ui.java.internal.junit.navigator;
12
package org.eclipse.hyades.test.tools.ui.java.internal.junit.navigator;
13
13
14
import org.eclipse.hyades.models.common.testprofile.TPFTest;
14
import org.eclipse.hyades.models.common.testprofile.TPFTest;
15
import org.eclipse.hyades.models.common.testprofile.TPFTestCase;
15
import org.eclipse.hyades.models.common.testprofile.TPFTestSuite;
16
import org.eclipse.hyades.models.common.testprofile.TPFTestSuite;
16
import org.eclipse.hyades.test.ui.TestUIConstants;
17
import org.eclipse.hyades.test.ui.TestUIConstants;
17
import org.eclipse.hyades.test.ui.navigator.DefaultTypedElementProxyFactory;
18
import org.eclipse.hyades.test.ui.navigator.DefaultTypedElementProxyFactory;
Lines 19-29 Link Here
19
import org.eclipse.ui.IMemento;
20
import org.eclipse.ui.IMemento;
20
21
21
/**
22
/**
22
 * This factory is responsible to create special proxy node for JUnit test suite.
23
 * This factory is responsible to create special proxy nodes for JUnit test cases and suites.
24
 * <p/>
25
 * Those test cases should have the type org.eclipse.hyades.test.java.junit.testCase.
26
 * <p/>
23
 * Those test suites should have the type org.eclipse.hyades.test.java.junit.testSuite.
27
 * Those test suites should have the type org.eclipse.hyades.test.java.junit.testSuite.
28
 * <p/>
29
 *
24
 * 
30
 * 
25
 * @author jgout
31
 * @author  Jerome Gout
26
 * @since 4.0
32
 * @author  Paul E. Slauenwhite
33
 * @version July 23, 2008
34
 * @since   March 25, 2005
27
 */
35
 */
28
public class JUnitTestSuiteProxyFactory extends DefaultTypedElementProxyFactory {
36
public class JUnitTestSuiteProxyFactory extends DefaultTypedElementProxyFactory {
29
37
Lines 35-40 Link Here
35
            TPFTestSuite ts = (TPFTestSuite) test;
43
            TPFTestSuite ts = (TPFTestSuite) test;
36
            return new JUnitTestSuiteProxyNode(ts, parent);
44
            return new JUnitTestSuiteProxyNode(ts, parent);
37
        }
45
        }
46
        else if (test instanceof TPFTestCase) {
47
        	TPFTestCase tc = (TPFTestCase) test;
48
            return new JUnitTestCaseProxyNode(tc, parent);
49
        }
50
38
        return super.create(test, parent);
51
        return super.create(test, parent);
39
    }
52
    }
40
53
Lines 45-52 Link Here
45
        String nodeKind = memento.getString(TestUIConstants.TAG_NODE_KIND);
58
        String nodeKind = memento.getString(TestUIConstants.TAG_NODE_KIND);
46
        if(nodeKind.equals(TestUIConstants.TESTSUITE_NODE)) {
59
        if(nodeKind.equals(TestUIConstants.TESTSUITE_NODE)) {
47
            return new JUnitTestSuiteProxyNode(memento, parent);
60
            return new JUnitTestSuiteProxyNode(memento, parent);
48
        } else {
61
        } 
49
            //- since this is not a saved test suite, let's default factory handle this memento 
62
        else if(nodeKind.equals(TestUIConstants.TESTCASE_NODE)) {
63
            return (new JUnitTestCaseProxyNode(memento, parent));
64
        } 
65
        else {
66
            //- since this is not a saved test case or suite, let's default factory handle this memento 
50
            return super.recreate(memento, parent);
67
            return super.recreate(memento, parent);
51
        }
68
        }
52
    }
69
    }
(-)plugin.xml (-15 / +20 lines)
Lines 275-283 Link Here
275
      <typedElement
275
      <typedElement
276
            type="org.eclipse.hyades.test.java.junit.testSuite"
276
            type="org.eclipse.hyades.test.java.junit.testSuite"
277
            factoryID="org.eclipse.hyades.test.tools.ui.JUnitTestSuiteFactory"/>
277
            factoryID="org.eclipse.hyades.test.tools.ui.JUnitTestSuiteFactory"/>
278
      <typedElement
279
            type="org.eclipse.hyades.test.java.junit.testCase"
280
            factoryID="org.eclipse.hyades.test.tools.ui.JUnitTestSuiteFactory"/>
278
   </extension>
281
   </extension>
279
   <extension
282
   <extension
280
         point="org.eclipse.ui.popupMenus">
283
         point="org.eclipse.ui.popupMenus">
284
         
285
     <!-- Open JUnit test method from TPTP JUnit test case: -->
286
     <objectContribution
287
            adaptable="false"
288
            objectClass="org.eclipse.hyades.test.tools.ui.java.internal.junit.navigator.JUnitTestCaseProxyNode"
289
            id="org.eclipse.hyades.test.tools.ui.JUnitTestCaseContribution">
290
         <action
291
               enablesFor="1"
292
               label="%OPEN_JUNIT_TEST_SUITE_CODE"
293
               class="org.eclipse.hyades.test.tools.ui.java.internal.junit.actions.OpenJUnitTestCaseCodeAction"
294
               menubarPath="org.eclipse.ui.OpenWithSubMenu"
295
               id="org.eclipse.hyades.test.tools.ui.JUnitTestCaseOpenCode"/>
296
      </objectContribution>
297
298
     <!-- Open JUnit test class from TPTP JUnit test suite: -->
281
      <objectContribution
299
      <objectContribution
282
            adaptable="false"
300
            adaptable="false"
283
            objectClass="org.eclipse.hyades.test.tools.ui.java.internal.junit.navigator.JUnitTestSuiteProxyNode"
301
            objectClass="org.eclipse.hyades.test.tools.ui.java.internal.junit.navigator.JUnitTestSuiteProxyNode"
Lines 289-294 Link Here
289
               menubarPath="org.eclipse.ui.OpenWithSubMenu"
307
               menubarPath="org.eclipse.ui.OpenWithSubMenu"
290
               id="org.eclipse.hyades.test.tools.ui.JUnitTestSuiteOpenCode"/>
308
               id="org.eclipse.hyades.test.tools.ui.JUnitTestSuiteOpenCode"/>
291
      </objectContribution>
309
      </objectContribution>
310
311
     <!-- Import a JUnit test class to a TPTP JUnit test suite: -->
292
      <objectContribution
312
      <objectContribution
293
            adaptable="false"
313
            adaptable="false"
294
            id="org.eclipse.hyades.test.tools.ui.RegularJUnitTestSuiteContribution"
314
            id="org.eclipse.hyades.test.tools.ui.RegularJUnitTestSuiteContribution"
Lines 301-321 Link Here
301
               menubarPath="group.import"/>
321
               menubarPath="group.import"/>
302
      </objectContribution>
322
      </objectContribution>
303
   </extension>   
323
   </extension>   
304
   <extension
305
         point="org.eclipse.ui.popupMenus">
306
      <objectContribution
307
            adaptable="false"
308
            objectClass="org.eclipse.hyades.test.ui.internal.navigator.proxy.DefaultTestCaseProxyNode"
309
            id="org.eclipse.hyades.test.tools.ui.JUnitTestCaseContribution">
310
         <action
311
               enablesFor="1"
312
               label="%OPEN_JUNIT_TEST_SUITE_CODE"
313
               class="org.eclipse.hyades.test.tools.ui.java.internal.junit.actions.OpenJUnitTestSuiteCodeAction"
314
               menubarPath="org.eclipse.ui.OpenWithSubMenu"
315
               id="org.eclipse.hyades.test.tools.ui.JUnitTestCaseOpenCode"/>
316
      </objectContribution>
317
   </extension>   
318
   
319
   
324
   
320
   <extension
325
   <extension
321
         point="org.eclipse.hyades.ui.typeDescriptions">
326
         point="org.eclipse.hyades.ui.typeDescriptions">
(-)src/org/eclipse/hyades/test/tools/ui/java/internal/junit/actions/OpenJUnitTestSuiteCodeAction.java (-19 / +19 lines)
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
}
(-)src/org/eclipse/hyades/test/tools/ui/java/internal/junit/navigator/JUnitTestCaseProxyNode.java (+45 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2008 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
 * $Id$ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/ 
12
package org.eclipse.hyades.test.tools.ui.java.internal.junit.navigator;
13
14
import org.eclipse.hyades.models.common.testprofile.TPFTestCase;
15
import org.eclipse.hyades.test.ui.internal.navigator.proxy.DefaultTestCaseProxyNode;
16
import org.eclipse.hyades.test.ui.navigator.ITestCaseProxyNode;
17
import org.eclipse.ui.IMemento;
18
19
/**
20
 * JUnit test case proxy node to specialize the actions in the context menu 
21
 * of the Test Navigator.
22
 * <p/>
23
 * 
24
 * 
25
 * @author  Paul E. Slauenwhite
26
 * @version	July 23, 2008
27
 * @since 	July 23, 2008
28
 */
29
public class JUnitTestCaseProxyNode extends DefaultTestCaseProxyNode implements ITestCaseProxyNode {
30
31
    public JUnitTestCaseProxyNode(TPFTestCase ts, Object parent) {
32
        super(ts, parent);
33
    }
34
    
35
    public JUnitTestCaseProxyNode(IMemento memento, Object parent) {
36
        super(memento, parent);
37
    }
38
    
39
    /* (non-Javadoc)
40
     * @see org.eclipse.hyades.test.ui.internal.navigator.proxy.DefaultTestCaseProxyNode#getFactoryID()
41
     */
42
    public String getFactoryID() {
43
        return "org.eclipse.hyades.test.tools.ui.JUnitTestSuiteFactory"; //$NON-NLS-1$
44
    }
45
}
(-)src/org/eclipse/hyades/test/tools/ui/java/internal/junit/actions/OpenJUnitTestCaseCodeAction.java (+68 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2008 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
 * $Id$ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/ 
12
package org.eclipse.hyades.test.tools.ui.java.internal.junit.actions;
13
14
import org.eclipse.hyades.models.common.testprofile.TPFTestCase;
15
import org.eclipse.hyades.test.tools.ui.java.internal.junit.navigator.JUnitTestCaseProxyNode;
16
import org.eclipse.hyades.test.tools.ui.java.internal.junit.navigator.JUnitTestSuiteProxyNode;
17
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
18
import org.eclipse.jface.action.IAction;
19
import org.eclipse.jface.viewers.ISelection;
20
import org.eclipse.jface.viewers.IStructuredSelection;
21
import org.eclipse.jface.viewers.StructuredSelection;
22
import org.eclipse.ui.IActionDelegate;
23
24
/**
25
 * Action to open the source code of a JUnit test case.
26
 * </p>
27
 * 
28
 * 
29
 * @author  Paul E. Slauenwhite
30
 * @version July 23, 2008
31
 * @since   July 23, 2008
32
 */
33
public class OpenJUnitTestCaseCodeAction implements IActionDelegate {
34
35
    private IStructuredSelection selection = null;
36
37
    /* (non-Javadoc)
38
     * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
39
     */
40
    public void run(IAction action) {
41
    	
42
    	IProxyNode proxy = ((IProxyNode)(selection.getFirstElement()));
43
44
    	if (proxy instanceof JUnitTestCaseProxyNode) {
45
    	
46
    		JUnitTestCaseProxyNode tcpn = ((JUnitTestCaseProxyNode)(proxy));
47
    		
48
    		if (tcpn.getParent() instanceof JUnitTestSuiteProxyNode) {
49
    		
50
    			TPFTestCase tc = tcpn.getTestCase();
51
    			
52
    			OpenTestMethodAction tcAction = new OpenTestMethodAction(null);
53
    			tcAction.selectionChanged(new StructuredSelection(tc));
54
    			tcAction.run();
55
    		}
56
    	}
57
    }
58
59
    /* (non-Javadoc)
60
     * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
61
     */
62
    public void selectionChanged(IAction action, ISelection selection) {
63
        
64
    	if (selection instanceof IStructuredSelection) {
65
            this.selection = ((IStructuredSelection)(selection));
66
        }
67
    }
68
}

Return to bug 241804