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 205093 | Differences between
and this patch

Collapse All | Expand All

(-)src-ui/org/eclipse/tptp/test/tools/api/internal/ui/test/generation/TPTPJUnitTestSuiteGenerationPane.java (-24 / +31 lines)
Lines 46-51 Link Here
46
	private Text testSuiteLocationText = null;
46
	private Text testSuiteLocationText = null;
47
	private Combo testSuiteGeneratorCombo = null;
47
	private Combo testSuiteGeneratorCombo = null;
48
	private Button testSuiteLocationButton = null;
48
	private Button testSuiteLocationButton = null;
49
	
49
50
50
	public TPTPJUnitTestSuiteGenerationPane(Composite parent){		
51
	public TPTPJUnitTestSuiteGenerationPane(Composite parent){		
51
		this(parent, SWT.SHADOW_NONE);		
52
		this(parent, SWT.SHADOW_NONE);		
Lines 61-82 Link Here
61
	public Combo getTestSuiteGeneratorCombo() {
62
	public Combo getTestSuiteGeneratorCombo() {
62
		return testSuiteGeneratorCombo;
63
		return testSuiteGeneratorCombo;
63
	}
64
	}
65
	
64
66
65
	public Text getTestSuiteLocationText() {
67
	public Text getTestSuiteLocationText() {
66
		return testSuiteLocationText;
68
		return testSuiteLocationText;
67
	}
69
	}
68
70
	
71
	
69
	public void init(){
72
	public void init(){
70
 
73
 
71
	    testSuiteGeneratorCombo.select(0);
74
		testSuiteGeneratorCombo.select(0);
72
		
75
		
73
		testSuiteLocationText.setEnabled(false);
76
		testSuiteLocationText.setEnabled(true);
74
		testSuiteLocationText.setText("");
77
		testSuiteLocationText.setText("");
75
78
76
		//Work-around: Set the text field's background color to gray since disabled/enabled un-editable text fields have a gray background, by default.
79
		//Work-around: Set the text field's background color to white since disabled/enabled un-editable text fields have a gray background, by default.
77
	    testSuiteLocationText.setBackground(((Color)(testSuiteGeneratorCombo.getData("Background"))));	    			
80
		testSuiteLocationText.setBackground(testSuiteGeneratorCombo.getBackground());
78
81
79
		testSuiteLocationButton.setEnabled(false);		
82
		testSuiteLocationButton.setEnabled(true);		
80
	}
83
	}
81
84
82
	private void buildPane(){
85
	private void buildPane(){
Lines 99-125 Link Here
99
	    
102
	    
100
	    testSuiteGeneratorCombo = new Combo(testGroup, SWT.READ_ONLY);
103
	    testSuiteGeneratorCombo = new Combo(testGroup, SWT.READ_ONLY);
101
	    testSuiteGeneratorCombo.setLayoutData(GridDataFactory.fillDefaults().span(2, 1).grab(true, false).create());
104
	    testSuiteGeneratorCombo.setLayoutData(GridDataFactory.fillDefaults().span(2, 1).grab(true, false).create());
102
	    testSuiteGeneratorCombo.add("Do not generate test suite");
103
	    testSuiteGeneratorCombo.add("TPTP JUnit Test Suite Generator");
105
	    testSuiteGeneratorCombo.add("TPTP JUnit Test Suite Generator");
104
	    testSuiteGeneratorCombo.addSelectionListener(new SelectionAdapter() {
106
107
	    
108
//	    testSuiteGeneratorCombo.addSelectionListener(new SelectionAdapter() {
105
			
109
			
106
	    	public void widgetSelected(SelectionEvent e) {	    		
110
//	    	 public void widgetSelected(SelectionEvent e) {	    		
107
	    		
108
	    		if(testSuiteGeneratorCombo.getSelectionIndex() != 0){
109
		    	
110
	    			testSuiteLocationButton.setEnabled(true);
111
		    		
111
		    		
112
	    			testSuiteLocationText.setEnabled(true);
112
//		    	if(testSuiteGeneratorCombo.getSelectionIndex() != 0){
113
	    			
113
			    	
114
	    			//Work-around: Set the text field's background color to white since disabled/enabled un-editable text fields have a gray background, by default.
114
//		    		testSuiteLocationButton.setEnabled(true);
115
	    		    testSuiteLocationText.setBackground(testSuiteGeneratorCombo.getBackground());	    			
115
			    		
116
	    		}	    		
116
//		    		testSuiteLocationText.setEnabled(true);
117
	    		else{
117
		    			
118
	    			init();
118
		    		//Work-around: Set the text field's background color to white since disabled/enabled un-editable text fields have a gray background, by default.
119
	    		}
119
//		    		testSuiteLocationText.setBackground(testSuiteGeneratorCombo.getBackground());    			
120
			}		
120
//		    	}	    		
121
		});
121
//		    	else{
122
122
//		    		init();
123
//		    	}
124
//			}	
125
//		});
126
	    
127
	    
128
	    
123
	    //TODO: Create extension point for user-defined test suite generators:
129
	    //TODO: Create extension point for user-defined test suite generators:
124
//	    IConfigurationElement[] elements = 
130
//	    IConfigurationElement[] elements = 
125
//	    	Platform.getExtensionRegistry().getConfigurationElementsFor("org.eclipse.hyades.test.core.TestGenerator");
131
//	    	Platform.getExtensionRegistry().getConfigurationElementsFor("org.eclipse.hyades.test.core.TestGenerator");
Lines 185-187 Link Here
185
	    layout(false,true);
191
	    layout(false,true);
186
	}	
192
	}	
187
}
193
}
194
(-)src-ui/org/eclipse/tptp/test/tools/api/internal/ui/recording/APIRecordingLaunchConfigurationPage.java (-3 / +4 lines)
Lines 22-28 Link Here
22
import org.eclipse.swt.widgets.Listener;
22
import org.eclipse.swt.widgets.Listener;
23
import org.eclipse.swt.widgets.Text;
23
import org.eclipse.swt.widgets.Text;
24
import org.eclipse.tptp.test.tools.api.internal.resources.Messages;
24
import org.eclipse.tptp.test.tools.api.internal.resources.Messages;
25
import org.eclipse.tptp.test.tools.api.internal.ui.test.generation.TPTPJUnitTestSuiteGenerationPane;
25
import org.eclipse.tptp.test.tools.api.internal.ui.test.generation.TPTPJUnitTestSuiteGenerationPaneAPI;
26
import org.eclipse.tptp.test.tools.api.internal.ui.util.APIRecordingConstants;
26
import org.eclipse.tptp.test.tools.api.internal.ui.util.APIRecordingConstants;
27
import org.eclipse.tptp.trace.ui.provisional.launcher.IConfigurationPage;
27
import org.eclipse.tptp.trace.ui.provisional.launcher.IConfigurationPage;
28
import org.eclipse.tptp.trace.ui.provisional.launcher.IStatusListener;
28
import org.eclipse.tptp.trace.ui.provisional.launcher.IStatusListener;
Lines 40-51 Link Here
40
public class APIRecordingLaunchConfigurationPage implements IConfigurationPage {
40
public class APIRecordingLaunchConfigurationPage implements IConfigurationPage {
41
41
42
	private IStatusListener statusListener = null;
42
	private IStatusListener statusListener = null;
43
	private TPTPJUnitTestSuiteGenerationPane testGenerationPane = null;
43
	private TPTPJUnitTestSuiteGenerationPaneAPI testGenerationPane = null;
44
	private ILaunchConfiguration launchConfiguration = null;
44
	private ILaunchConfiguration launchConfiguration = null;
45
	
45
	
46
	public void createControl(Composite parent) {
46
	public void createControl(Composite parent) {
47
		
47
		
48
		testGenerationPane  = new TPTPJUnitTestSuiteGenerationPane(parent);
48
		testGenerationPane  = new TPTPJUnitTestSuiteGenerationPaneAPI(parent);
49
		
49
		
50
		Listener listener = new Listener(){
50
		Listener listener = new Listener(){
51
    		
51
    		
Lines 83-88 Link Here
83
		Combo testSuiteGeneratorCombo = testGenerationPane.getTestSuiteGeneratorCombo();
83
		Combo testSuiteGeneratorCombo = testGenerationPane.getTestSuiteGeneratorCombo();
84
		testSuiteGeneratorCombo.addListener(SWT.Selection, listener);
84
		testSuiteGeneratorCombo.addListener(SWT.Selection, listener);
85
		
85
		
86
		
86
		try {
87
		try {
87
			
88
			
88
			testSuiteLocationText.setText(launchConfiguration.getAttribute(APIRecordingConstants.LAUNCH_CONFIGURATION_ATTRIBUTE_KEY_TEST_SUITE_LOCATION, ""));
89
			testSuiteLocationText.setText(launchConfiguration.getAttribute(APIRecordingConstants.LAUNCH_CONFIGURATION_ATTRIBUTE_KEY_TEST_SUITE_LOCATION, ""));
(-)src-ui/org/eclipse/tptp/test/tools/api/internal/ui/test/generation/wizards/GenerateTPTPJUnitTestSuiteWizardPageOne.java (+3 lines)
Lines 91-96 Link Here
91
		Combo testSuiteGeneratorCombo = testGenerationPane.getTestSuiteGeneratorCombo();
91
		Combo testSuiteGeneratorCombo = testGenerationPane.getTestSuiteGeneratorCombo();
92
		testSuiteGeneratorCombo.addListener(SWT.Selection, listener);
92
		testSuiteGeneratorCombo.addListener(SWT.Selection, listener);
93
		
93
		
94
		//Fire the selection event to set the messages in the wizard/dialog:
95
		listener.handleEvent(null);
96
		
94
		setControl(testGenerationPane);
97
		setControl(testGenerationPane);
95
	}
98
	}
96
	
99
	
(-)src-ui/org/eclipse/tptp/test/tools/api/internal/ui/test/generation/TPTPJUnitTestSuiteGenerationPaneAPI.java (+187 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2006, 2007 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: TPTPJUnitTestSuiteGenerationPane.java,v 1.5 2007/04/19 18:43:36 paules Exp $
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
package org.eclipse.tptp.test.tools.api.internal.ui.test.generation;
13
14
import java.util.Collections;
15
16
import org.eclipse.core.resources.IFile;
17
import org.eclipse.core.runtime.IPath;
18
import org.eclipse.core.runtime.Path;
19
import org.eclipse.emf.common.ui.dialogs.WorkspaceResourceDialog;
20
import org.eclipse.jface.layout.GridDataFactory;
21
import org.eclipse.swt.SWT;
22
import org.eclipse.swt.events.SelectionAdapter;
23
import org.eclipse.swt.events.SelectionEvent;
24
import org.eclipse.swt.graphics.Color;
25
import org.eclipse.swt.layout.GridData;
26
import org.eclipse.swt.layout.GridLayout;
27
import org.eclipse.swt.widgets.Button;
28
import org.eclipse.swt.widgets.Combo;
29
import org.eclipse.swt.widgets.Composite;
30
import org.eclipse.swt.widgets.Group;
31
import org.eclipse.swt.widgets.Label;
32
import org.eclipse.swt.widgets.Text;
33
34
/**
35
 * TPTP JUnit test suite generation pane.
36
 * <p>
37
 * 
38
 * 
39
 * @author  Paul E. Slauenwhite
40
 * @version November 15, 2006
41
 * @since   September 7, 2006
42
 * @provisional
43
 */
44
public class TPTPJUnitTestSuiteGenerationPaneAPI extends Composite {
45
	
46
	private Text testSuiteLocationText = null;
47
	private Combo testSuiteGeneratorCombo = null;
48
	private Button testSuiteLocationButton = null;
49
50
	public TPTPJUnitTestSuiteGenerationPaneAPI(Composite parent){		
51
		this(parent, SWT.SHADOW_NONE);		
52
	}
53
	
54
	public TPTPJUnitTestSuiteGenerationPaneAPI(Composite parent, int style){
55
56
		super(parent, style);
57
				
58
		buildPane();
59
	}
60
61
	public Combo getTestSuiteGeneratorCombo() {
62
		return testSuiteGeneratorCombo;
63
	}
64
65
	public Text getTestSuiteLocationText() {
66
		return testSuiteLocationText;
67
	}
68
69
	public void init(){
70
 
71
	    testSuiteGeneratorCombo.select(0);
72
		
73
		testSuiteLocationText.setEnabled(false);
74
		testSuiteLocationText.setText("");
75
76
		//Work-around: Set the text field's background color to gray since disabled/enabled un-editable text fields have a gray background, by default.
77
	    testSuiteLocationText.setBackground(((Color)(testSuiteGeneratorCombo.getData("Background"))));	    			
78
79
		testSuiteLocationButton.setEnabled(false);		
80
	}
81
82
	private void buildPane(){
83
		
84
		setLayout(new GridLayout());
85
		setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
86
			
87
		GridLayout layout = new GridLayout();
88
		layout.numColumns = 3;
89
		layout.horizontalSpacing = 5;
90
		layout.verticalSpacing = 10;
91
		
92
		Group testGroup = new Group(this, SWT.SHADOW_ETCHED_IN);
93
		testGroup.setLayout(layout);
94
		testGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
95
		testGroup.setText("Test suite generator and location");
96
						    
97
	    Label testSuiteGeneratorLabel = new Label(testGroup, SWT.NONE);
98
	    testSuiteGeneratorLabel.setText("Generator: ");
99
	    
100
	    testSuiteGeneratorCombo = new Combo(testGroup, SWT.READ_ONLY);
101
	    testSuiteGeneratorCombo.setLayoutData(GridDataFactory.fillDefaults().span(2, 1).grab(true, false).create());
102
	    testSuiteGeneratorCombo.add("Do not generate test suite");
103
	    testSuiteGeneratorCombo.add("TPTP JUnit Test Suite Generator");
104
	    testSuiteGeneratorCombo.addSelectionListener(new SelectionAdapter() {
105
			
106
	    	public void widgetSelected(SelectionEvent e) {	    		
107
	    		
108
	    		if(testSuiteGeneratorCombo.getSelectionIndex() != 0){
109
		    	
110
	    			testSuiteLocationButton.setEnabled(true);
111
		    		
112
	    			testSuiteLocationText.setEnabled(true);
113
	    			
114
	    			//Work-around: Set the text field's background color to white since disabled/enabled un-editable text fields have a gray background, by default.
115
	    		    testSuiteLocationText.setBackground(testSuiteGeneratorCombo.getBackground());	    			
116
	    		}	    		
117
	    		else{
118
	    			init();
119
	    		}
120
			}		
121
		});
122
123
	    //TODO: Create extension point for user-defined test suite generators:
124
//	    IConfigurationElement[] elements = 
125
//	    	Platform.getExtensionRegistry().getConfigurationElementsFor("org.eclipse.hyades.test.core.TestGenerator");
126
//	    for(int i = 0; i < elements.length; i++) {
127
//	    	String name = elements[i].getAttribute("name");
128
//	    	testSuiteGeneratorCombo.add(name);
129
//	    }	    
130
	    
131
	    Label testSuiteLocationLabel = new Label(testGroup, SWT.NONE);
132
	    testSuiteLocationLabel.setText("Location: ");
133
	    
134
	    testSuiteLocationText = new Text(testGroup, SWT.SINGLE | SWT.BORDER);
135
	    testSuiteLocationText.setEditable(false);
136
	    testSuiteLocationText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.CENTER).create());
137
	    
138
	    //Work-around: Persist the text field's background original color since disabled/enabled un-editable text fields have a gray background, by default.
139
	    testSuiteLocationText.setData("Background",testSuiteLocationText.getBackground());
140
141
	    testSuiteLocationButton = new Button(testGroup, SWT.PUSH);
142
	    testSuiteLocationButton.setText("Browse...");
143
	    
144
	    testSuiteLocationButton.addSelectionListener(new SelectionAdapter() {
145
			
146
	    	public void widgetSelected(SelectionEvent e) {
147
				
148
	    		//TODO: Use standard Eclipse/TPTP dialog:
149
	    		//TODO: Only select Java and Pluign projects.
150
		    	//TODO: Use UIUtil.validateJavaFileName and UIUtil.validateOSFileName:
151
		    	//TODO: Check for existing file and do not allow user to overwrite:
152
		    	//TODO: Create new directory?:
153
	    		IPath path = null;
154
	    		String testSuiteLocationPath = testSuiteLocationText.getText().trim();
155
	    		
156
	    		if((testSuiteLocationPath.length() > 0) && (Path.EMPTY.isValidPath(testSuiteLocationPath))){
157
	    			path = new Path(testSuiteLocationPath);
158
	    		}
159
	    		
160
	    		//TODO: If project does not exist, only set file name:	    		
161
	    		//TODO: Set text field to "" if file is null and cancel is selected:
162
	    		IFile testSuiteLocationFile = WorkspaceResourceDialog.openNewFile(
163
	    				testSuiteLocationButton.getParent().getShell(), 
164
						"Test Suite", 
165
						"Select a test suite location under a Java project:", 
166
						path, 
167
						Collections.EMPTY_LIST);
168
	    		
169
	    		if(testSuiteLocationFile != null){
170
	    			
171
	    			testSuiteLocationPath = testSuiteLocationFile.getFullPath().toString();
172
	    			
173
	    			if(!testSuiteLocationPath.endsWith(".testsuite")){	    				
174
		    			testSuiteLocationText.setText(testSuiteLocationPath.concat(".testsuite"));
175
	    			}
176
	    			else{
177
	    				testSuiteLocationText.setText(testSuiteLocationPath);
178
	    			}
179
	    		}
180
			}
181
		});
182
	    
183
	    init();
184
	    
185
	    layout(false,true);
186
	}	
187
}

Return to bug 205093