|
From: Christopher W. <caw...@us...> - 2005-03-28 23:23:34
|
Update of /cvsroot/rubyeclipse/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/launcher In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1489/src/org/rubypeople/rdt/testunit/launcher Modified Files: TestUnitLaunchShortcut.java TestUnitMainTab.java TestUnitRunnerConfiguration.java Log Message: apply david corbin's patches Index: TestUnitRunnerConfiguration.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/launcher/TestUnitRunnerConfiguration.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** TestUnitRunnerConfiguration.java 2 Mar 2005 00:54:40 -0000 1.9 --- TestUnitRunnerConfiguration.java 28 Mar 2005 23:23:23 -0000 1.10 *************** *** 59,62 **** --- 59,63 ---- String fileName = ""; String testClass = ""; + String testMethod = ""; // FIXME Remove keepAlive on this end and remove looking for it on // RemoteTestRunner.rb *************** *** 68,83 **** fileName = configuration.getAttribute(TestUnitLaunchConfigurationDelegate.LAUNCH_CONTAINER_ATTR, ""); testClass = configuration.getAttribute(TestUnitLaunchConfigurationDelegate.TESTTYPE_ATTR, ""); } catch (CoreException e) { TestunitPlugin.log(e); } ! return fileName + " " + port + " " + keepAlive + " " + testClass; } public String renderLoadPath() { String absoluteTestFilePath = RdtLaunchingPlugin.osDependentPath(this.getAbsoluteTestFileName()); ! if (absoluteTestFilePath.length() == 0) { ! return super.renderLoadPath(); ! } return super.renderLoadPath() + " -I " + absoluteTestFilePath; } --- 69,83 ---- fileName = configuration.getAttribute(TestUnitLaunchConfigurationDelegate.LAUNCH_CONTAINER_ATTR, ""); testClass = configuration.getAttribute(TestUnitLaunchConfigurationDelegate.TESTTYPE_ATTR, ""); + testMethod = configuration.getAttribute(TestUnitLaunchConfigurationDelegate.TESTNAME_ATTR, ""); } catch (CoreException e) { TestunitPlugin.log(e); } ! return fileName + " " + port + " " + keepAlive + " " + testClass + " " + testMethod; } public String renderLoadPath() { String absoluteTestFilePath = RdtLaunchingPlugin.osDependentPath(this.getAbsoluteTestFileName()); ! if (absoluteTestFilePath.length() == 0) { return super.renderLoadPath(); } return super.renderLoadPath() + " -I " + absoluteTestFilePath; } Index: TestUnitMainTab.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/launcher/TestUnitMainTab.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** TestUnitMainTab.java 2 Mar 2005 00:54:40 -0000 1.12 --- TestUnitMainTab.java 28 Mar 2005 23:23:23 -0000 1.13 *************** *** 36,43 **** --- 36,47 ---- import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; + import org.eclipse.swt.events.SelectionEvent; + import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; + import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; + import org.eclipse.swt.widgets.Text; import org.eclipse.ui.dialogs.ElementListSelectionDialog; import org.rubypeople.rdt.core.IRubyElement; *************** *** 53,57 **** /** * @author Chris ! * */ public class TestUnitMainTab extends AbstractLaunchConfigurationTab implements ILaunchConfigurationTab { --- 57,61 ---- /** * @author Chris ! * */ public class TestUnitMainTab extends AbstractLaunchConfigurationTab implements ILaunchConfigurationTab { *************** *** 64,67 **** --- 68,76 ---- protected String lastProject = ""; protected String lastFile = ""; + private Label classLabel; + private Button allClassesCheckBox; + private Button allMethodsCheckBox; + private Label testLabel; + private Text testMethodEditBox; public TestUnitMainTab() { *************** *** 110,114 **** }); ! new Label(composite, SWT.NONE).setText(TestUnitMessages.getString("LaunchConfigurationTab.RubyEntryPoint.classLabel")); classSelector = new RubyClassSelector(composite, fileSelector, projectSelector); classSelector.setBrowseDialogMessage(TestUnitMessages.getString("LaunchConfigurationTab.RubyEntryPoint.classSelectorMessage")); --- 119,137 ---- }); ! allClassesCheckBox = new Button(composite, SWT.CHECK); ! allClassesCheckBox.setText(TestUnitMessages.getString("LaunchConfigurationTab.RubyEntryPoint.allTestCases")); ! allClassesCheckBox.addSelectionListener(new SelectionListener() { ! ! public void widgetSelected(SelectionEvent e) { ! updateLaunchConfigurationDialog(); ! setControlState(); ! } ! ! public void widgetDefaultSelected(SelectionEvent e) {} ! }); ! ! classLabel = new Label(composite, SWT.NONE); ! classLabel.setText(TestUnitMessages.getString("LaunchConfigurationTab.RubyEntryPoint.classLabel")); ! classSelector = new RubyClassSelector(composite, fileSelector, projectSelector); classSelector.setBrowseDialogMessage(TestUnitMessages.getString("LaunchConfigurationTab.RubyEntryPoint.classSelectorMessage")); *************** *** 121,124 **** --- 144,184 ---- }); + allMethodsCheckBox = new Button(composite, SWT.CHECK); + allMethodsCheckBox.setText(TestUnitMessages.getString("LaunchConfigurationTab.RubyEntryPoint.allTestMethods")); + allMethodsCheckBox.addSelectionListener(new SelectionListener() { + + public void widgetSelected(SelectionEvent e) { + updateLaunchConfigurationDialog(); + setControlState(); + } + + public void widgetDefaultSelected(SelectionEvent e) {} + }); + + testLabel = new Label(composite, SWT.NONE); + testLabel.setText(TestUnitMessages.getString("LaunchConfigurationTab.RubyEntryPoint.methodLabel")); + + testMethodEditBox = new Text(composite, SWT.BORDER | SWT.BORDER); + testMethodEditBox.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + testMethodEditBox.addModifyListener(new ModifyListener() { + + public void modifyText(ModifyEvent e) { + updateLaunchConfigurationDialog(); + + } + }); + setControlState(); + + } + + private void setControlState() { + boolean allClassesChecked = allClassesCheckBox.getSelection(); + boolean allMethodsChecked = allMethodsCheckBox.getSelection(); + classLabel.setEnabled(!allClassesChecked); + classSelector.setEnabled(!allClassesChecked); + allMethodsCheckBox.setEnabled(!allClassesChecked); + testLabel.setEnabled(!(allClassesChecked || allMethodsChecked)); + testMethodEditBox.setEnabled(!(allClassesChecked || allMethodsChecked)); + } *************** *** 126,130 **** Composite composite = new Composite(parent, SWT.NONE); GridLayout compositeLayout = new GridLayout(); ! compositeLayout.marginWidth = 0; compositeLayout.numColumns = 1; composite.setLayout(compositeLayout); --- 186,190 ---- Composite composite = new Composite(parent, SWT.NONE); GridLayout compositeLayout = new GridLayout(); ! compositeLayout.marginWidth = 10; compositeLayout.numColumns = 1; composite.setLayout(compositeLayout); *************** *** 140,165 **** */ public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { ! IResource selectedResource = RubyPlugin.getDefault().getSelectedResource(); ! String projectName = ""; ! String fileName = ""; ! String type = ""; ! ! if (RubyPlugin.getDefault().isRubyFile(selectedResource)) { ! projectName = selectedResource.getProject().getName(); ! fileName = selectedResource.getProjectRelativePath().toString(); ! IRubyElement[] types = TestSearchEngine.findTests((IFile) selectedResource); ! if (types.length > 0) { ! type = types[0].getElementName(); ! } ! } ! configuration.setAttribute(RubyLaunchConfigurationAttribute.PROJECT_NAME, projectName); ! configuration.setAttribute(TestUnitLaunchConfigurationDelegate.LAUNCH_CONTAINER_ATTR, fileName); ! configuration.setAttribute(TestUnitLaunchConfigurationDelegate.TESTTYPE_ATTR, type); ! configuration.setAttribute(TestUnitLaunchConfigurationDelegate.TESTNAME_ATTR, ""); ! // set hidden attribute ! configuration.setAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, "org.rubypeople.rdt.debug.ui.rubySourceLocator"); ! } /* --- 200,225 ---- */ public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { ! IResource selectedResource = RubyPlugin.getDefault().getSelectedResource(); ! String projectName = ""; ! String fileName = ""; ! String type = ""; ! if (RubyPlugin.getDefault().isRubyFile(selectedResource)) { ! projectName = selectedResource.getProject().getName(); ! fileName = selectedResource.getProjectRelativePath().toString(); ! IRubyElement[] types = TestSearchEngine.findTests((IFile) selectedResource); ! if (types.length > 0) { ! type = types[0].getElementName(); ! } ! } ! configuration.setAttribute(RubyLaunchConfigurationAttribute.PROJECT_NAME, projectName); ! configuration.setAttribute(TestUnitLaunchConfigurationDelegate.LAUNCH_CONTAINER_ATTR, fileName); ! configuration.setAttribute(TestUnitLaunchConfigurationDelegate.TESTTYPE_ATTR, type); ! configuration.setAttribute(TestUnitLaunchConfigurationDelegate.TESTNAME_ATTR, ""); ! ! // set hidden attribute ! configuration.setAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, "org.rubypeople.rdt.debug.ui.rubySourceLocator"); ! } /* *************** *** 182,186 **** projectSelector.setSelectionText(projectName); fileSelector.setSelectionText(configuration.getAttribute(TestUnitLaunchConfigurationDelegate.LAUNCH_CONTAINER_ATTR, "")); ! classSelector.setSelectionText(configuration.getAttribute(TestUnitLaunchConfigurationDelegate.TESTTYPE_ATTR, "")); } catch (CoreException e) { TestunitPlugin.log(e); --- 242,256 ---- projectSelector.setSelectionText(projectName); fileSelector.setSelectionText(configuration.getAttribute(TestUnitLaunchConfigurationDelegate.LAUNCH_CONTAINER_ATTR, "")); ! ! String testClass = configuration.getAttribute(TestUnitLaunchConfigurationDelegate.TESTTYPE_ATTR, ""); ! classSelector.setSelectionText(testClass); ! if (testClass.length() == 0) { ! allClassesCheckBox.setSelection(true); ! } else { ! String testMethod = configuration.getAttribute(TestUnitLaunchConfigurationDelegate.TESTNAME_ATTR, ""); ! testMethodEditBox.setText(testMethod); ! if (testMethod.length() == 0) allMethodsCheckBox.setSelection(true); ! } ! setControlState(); } catch (CoreException e) { TestunitPlugin.log(e); *************** *** 194,198 **** */ public void performApply(ILaunchConfigurationWorkingCopy configuration) { ! configuration.setAttribute(TestUnitLaunchConfigurationDelegate.TESTTYPE_ATTR, classSelector.getValidatedSelectionText()); configuration.setAttribute(TestUnitLaunchConfigurationDelegate.LAUNCH_CONTAINER_ATTR, fileSelector.getValidatedSelectionText()); } --- 264,276 ---- */ public void performApply(ILaunchConfigurationWorkingCopy configuration) { ! String testMethod = testMethodEditBox.getText(); ! if (allMethodsCheckBox.getSelection()) testMethod = ""; ! String testCaseClass = classSelector.getValidatedSelectionText(); ! if (allClassesCheckBox.getSelection()) { ! testCaseClass = ""; ! testMethod = ""; ! } ! configuration.setAttribute(TestUnitLaunchConfigurationDelegate.TESTNAME_ATTR, testMethod); ! configuration.setAttribute(TestUnitLaunchConfigurationDelegate.TESTTYPE_ATTR, testCaseClass); configuration.setAttribute(TestUnitLaunchConfigurationDelegate.LAUNCH_CONTAINER_ATTR, fileSelector.getValidatedSelectionText()); } Index: TestUnitLaunchShortcut.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/launcher/TestUnitLaunchShortcut.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** TestUnitLaunchShortcut.java 2 Mar 2005 00:54:40 -0000 1.8 --- TestUnitLaunchShortcut.java 28 Mar 2005 23:23:23 -0000 1.9 *************** *** 20,24 **** import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.Status; ! import org.eclipse.debug.core.*; import org.eclipse.debug.ui.DebugUITools; import org.eclipse.debug.ui.IDebugModelPresentation; --- 20,28 ---- import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.Status; ! import org.eclipse.debug.core.DebugPlugin; ! import org.eclipse.debug.core.ILaunchConfiguration; ! import org.eclipse.debug.core.ILaunchConfigurationType; ! import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; ! import org.eclipse.debug.core.ILaunchManager; import org.eclipse.debug.ui.DebugUITools; import org.eclipse.debug.ui.IDebugModelPresentation; *************** *** 39,43 **** import org.rubypeople.rdt.testunit.TestunitPlugin; import org.rubypeople.rdt.testunit.views.TestUnitMessages; - import org.rubypeople.rdt.ui.RubyElementLabelProvider; public class TestUnitLaunchShortcut implements ILaunchShortcut { --- 43,46 ---- *************** *** 89,107 **** try { String container = getContainer(rubyElement); IRubyElement[] classes = TestSearchEngine.findTests((IFile) rubyElement.getUnderlyingResource()); - String testClass = null; - if (classes.length == 0) { - MessageDialog.openInformation(getShell(), TestUnitMessages.getString("LaunchTestAction.dialog.title"), TestUnitMessages.getString("LaunchTestAction.message.notests")); //$NON-NLS-1$ //$NON-NLS-2$ - } else if (classes.length > 1) { - testClass = chooseType(classes, mode); - } else { - testClass = classes[0].getElementName(); - } - if (testClass != null) { - ILaunchConfiguration config = findOrCreateLaunchConfiguration(rubyElement, mode, container, testClass, ""); - if (config != null) { - config.launch(mode, null); - } - } } catch (CoreException e) { log(e); --- 92,99 ---- try { String container = getContainer(rubyElement); + ILaunchConfiguration config = findOrCreateLaunchConfiguration(rubyElement, mode, container, "", ""); + if (config != null) + config.launch(mode, null); IRubyElement[] classes = TestSearchEngine.findTests((IFile) rubyElement.getUnderlyingResource()); } catch (CoreException e) { log(e); *************** *** 109,131 **** } - /** - * Prompts the user to select a type - * - * @return the selected type or <code>null</code> if none. - */ - protected String chooseType(IRubyElement[] types, String mode) { - ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), new RubyElementLabelProvider()); - dialog.setElements(types); - dialog.setTitle(TestUnitMessages.getString("LaunchTestAction.dialog.title2")); //$NON-NLS-1$ - if (mode.equals(ILaunchManager.DEBUG_MODE)) { - dialog.setMessage(TestUnitMessages.getString("LaunchTestAction.message.selectTestToRun")); //$NON-NLS-1$ - } else { - dialog.setMessage(TestUnitMessages.getString("LaunchTestAction.message.selectTestToDebug")); //$NON-NLS-1$ - } - dialog.setMultipleSelection(false); - if (dialog.open() == Window.OK) { return ((IRubyElement) dialog.getFirstResult()).getElementName(); } - return null; - } - protected ILaunchConfiguration findOrCreateLaunchConfiguration(IRubyElement rubyElement, String mode, String container, String testClass, String testName) throws CoreException { IFile rubyFile = (IFile) rubyElement.getUnderlyingResource(); --- 101,104 ---- *************** *** 137,141 **** for (int i = 0; i < configs.length; i++) { ILaunchConfiguration config = configs[i]; ! if ((config.getAttribute(TestUnitLaunchConfigurationDelegate.LAUNCH_CONTAINER_ATTR, "").equals(container)) && (config.getAttribute(TestUnitLaunchConfigurationDelegate.TESTTYPE_ATTR, "").equals(testClass)) && (config.getAttribute(TestUnitLaunchConfigurationDelegate.TESTNAME_ATTR, "").equals(testName)) && (config.getAttribute(RubyLaunchConfigurationAttribute.PROJECT_NAME, "").equals(rubyFile.getProject().getName()))) { candidateConfigs.add(config); } --- 110,117 ---- for (int i = 0; i < configs.length; i++) { ILaunchConfiguration config = configs[i]; ! if ((config.getAttribute(TestUnitLaunchConfigurationDelegate.LAUNCH_CONTAINER_ATTR, "").equals(container)) ! && (config.getAttribute(TestUnitLaunchConfigurationDelegate.TESTTYPE_ATTR, "").equals("")) ! && (config.getAttribute(TestUnitLaunchConfigurationDelegate.TESTNAME_ATTR, "").equals(testName)) ! && (config.getAttribute(RubyLaunchConfigurationAttribute.PROJECT_NAME, "").equals(rubyFile.getProject().getName()))) { candidateConfigs.add(config); } *************** *** 143,147 **** switch (candidateConfigs.size()) { case 0: ! return createConfiguration(rubyFile, container, testClass, testName); case 1: return (ILaunchConfiguration) candidateConfigs.get(0); --- 119,123 ---- switch (candidateConfigs.size()) { case 0: ! return createConfiguration(rubyFile, container, testName); case 1: return (ILaunchConfiguration) candidateConfigs.get(0); *************** *** 196,200 **** } ! protected ILaunchConfiguration createConfiguration(IFile rubyFile, String container, String testClass, String testName) { if (RubyRuntime.getDefault().getSelectedInterpreter() == null) { showNoInterpreterDialog(); --- 172,176 ---- } ! protected ILaunchConfiguration createConfiguration(IFile rubyFile, String container, String testName) { if (RubyRuntime.getDefault().getSelectedInterpreter() == null) { showNoInterpreterDialog(); *************** *** 219,223 **** wc.setAttribute(TestUnitLaunchConfigurationDelegate.LAUNCH_CONTAINER_ATTR, container); wc.setAttribute(TestUnitLaunchConfigurationDelegate.TESTNAME_ATTR, testName); ! wc.setAttribute(TestUnitLaunchConfigurationDelegate.TESTTYPE_ATTR, testClass); wc.setAttribute(TestUnitLaunchConfigurationDelegate.PORT_ATTR, port); wc.setAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, "org.rubypeople.rdt.debug.ui.rubySourceLocator"); --- 195,199 ---- wc.setAttribute(TestUnitLaunchConfigurationDelegate.LAUNCH_CONTAINER_ATTR, container); wc.setAttribute(TestUnitLaunchConfigurationDelegate.TESTNAME_ATTR, testName); ! wc.setAttribute(TestUnitLaunchConfigurationDelegate.TESTTYPE_ATTR, ""); wc.setAttribute(TestUnitLaunchConfigurationDelegate.PORT_ATTR, port); wc.setAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, "org.rubypeople.rdt.debug.ui.rubySourceLocator"); |