From: shleh <shleh> Date: Sun, 19 Sep 2004 01:07:54 +0000 (+0000) Subject: getting the path to phpunit from a preference page. added icons to progressComposite X-Git-Url: http://secure.phpeclipse.com getting the path to phpunit from a preference page. added icons to progressComposite --- diff --git a/net.sourceforge.phpeclipse.phpunit/icons/error.gif b/net.sourceforge.phpeclipse.phpunit/icons/error.gif new file mode 100644 index 0000000..8612eaf Binary files /dev/null and b/net.sourceforge.phpeclipse.phpunit/icons/error.gif differ diff --git a/net.sourceforge.phpeclipse.phpunit/icons/failure.gif b/net.sourceforge.phpeclipse.phpunit/icons/failure.gif new file mode 100644 index 0000000..d45b970 Binary files /dev/null and b/net.sourceforge.phpeclipse.phpunit/icons/failure.gif differ diff --git a/net.sourceforge.phpeclipse.phpunit/plugin.xml b/net.sourceforge.phpeclipse.phpunit/plugin.xml index a86b87c..efe47a2 100644 --- a/net.sourceforge.phpeclipse.phpunit/plugin.xml +++ b/net.sourceforge.phpeclipse.phpunit/plugin.xml @@ -43,5 +43,14 @@ </action> </objectContribution> </extension> + <extension + point="org.eclipse.ui.preferencePages"> + <page + name="PHPUnit Preference" + category="PHPUnit" + class="net.sourceforge.phpeclipse.phpunit.preferences.PHPUnitPreferencePage" + id="net.sourceforge.phpeclipse.phpunit.preferences.PHPUnitPreferencePage"> + </page> + </extension> </plugin> diff --git a/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/PHPUnitImages.java b/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/PHPUnitImages.java index 006336a..69e9756 100644 --- a/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/PHPUnitImages.java +++ b/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/PHPUnitImages.java @@ -34,8 +34,7 @@ public class PHPUnitImages { * Available cached Images in the Java plugin image registry. */ - public static final String IMG_SELECT_TEST_SUITE = - NAME_PREFIX + "tsuite.gif"; + public static final String IMG_SELECT_TEST_SUITE = NAME_PREFIX + "tsuite.gif"; public static final String IMG_RUN_TEST_SUITE = NAME_PREFIX + "start.gif"; public static final String IMG_TEST_ERROR = NAME_PREFIX + "testerr.gif"; public static final String IMG_TEST_FAILURE = NAME_PREFIX + "testfail.gif"; @@ -44,6 +43,8 @@ public class PHPUnitImages { public static final String IMG_TEST_SUITE_PASS = NAME_PREFIX + "tsuiteok.gif"; public static final String IMG_TEST_SUITE_FAILURE = NAME_PREFIX + "tsuitefail.gif"; + public static final String IMG_ERROR = NAME_PREFIX + "error.gif"; + public static final String IMG_FAILURE = NAME_PREFIX + "failure.gif"; @@ -56,6 +57,8 @@ public class PHPUnitImages { public static final ImageDescriptor DESC_TEST_SUITE_PASS = createManaged(IMG_TEST_SUITE_PASS); public static final ImageDescriptor DESC_TEST_SUITE_FAILURE = createManaged(IMG_TEST_SUITE_FAILURE); + public static final ImageDescriptor DESC_ERROR = createManaged(IMG_ERROR); + public static final ImageDescriptor DESC_FAILURE = createManaged(IMG_FAILURE); /** * Returns the image managed under the given key in this registry. * diff --git a/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/PHPUnitView.java b/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/PHPUnitView.java index e304352..765b4a9 100644 --- a/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/PHPUnitView.java +++ b/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/PHPUnitView.java @@ -7,6 +7,7 @@ import java.io.File; import java.io.FileWriter; import java.io.IOException; +import net.sourceforge.phpeclipse.phpunit.preferences.PHPUnitPreferencePage; import net.sourceforge.phpeclipse.phpunit.testpool.TestCase; import net.sourceforge.phpeclipse.phpunit.testpool.TestPool; import net.sourceforge.phpeclipse.phpunit.testpool.TestSuite; @@ -278,9 +279,11 @@ public class PHPUnitView extends ViewPart { out.write("<?php" + "\n"); out.write("ob_start();" + "\n"); + + String path = PHPUnitPlugin.getDefault().getPreferenceStore().getString(PHPUnitPreferencePage.PHPUNIT_PATH); + - //TODO: use install dir for path to phpunit. include it with plugin. - out.write("$path = \"C:/Documents and Settings/Ali Echihabi/My Documents/workspace.eclipse2.1/PHPUnit/phpunit\";" + "\n"); + out.write("$path = \"" + path + "\";" + "\n"); out.write("include_once($path . \"/phpunit_test.php\");" + "\n"); out.write("include_once $path . \"/socketTestResult.php\";" + "\n"); diff --git a/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/ProgressInfoComposite.java b/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/ProgressInfoComposite.java index 488bd01..2541c87 100644 --- a/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/ProgressInfoComposite.java +++ b/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/ProgressInfoComposite.java @@ -9,6 +9,7 @@ package net.sourceforge.phpeclipse.phpunit; import net.sourceforge.phpeclipse.phpunit.testpool.TestPool; import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Image; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; @@ -26,9 +27,10 @@ public class ProgressInfoComposite extends Composite { private Label labelRuns, labelRunsVal; // Runs: 12 - private Label labelErrors, labelErrorsVal; - private Label labelFailures, labelFailuresVal; + private Label labelErrors, labelErrorsImage, labelErrorsVal; + private Label labelFailures, labelFailuresImage, labelFailuresVal; + private ProgressBar progressBar; /** @@ -55,6 +57,7 @@ public class ProgressInfoComposite extends Composite { Composite labelsComposite = new Composite(this, SWT.NONE); + labelsComposite.setLayoutData( new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL)); @@ -65,11 +68,16 @@ public class ProgressInfoComposite extends Composite { labelRunsVal = new Label(labelsComposite, SWT.NONE); labelRunsVal.setText("0 / 0"); + labelFailuresImage = new Label(labelsComposite, SWT.NONE); + labelFailuresImage.setImage(PHPUnitImages.DESC_FAILURE.createImage()); labelFailures = new Label(labelsComposite, SWT.NONE); labelFailures.setText("Failures: "); labelFailuresVal = new Label(labelsComposite, SWT.NONE); labelFailuresVal.setText("0"); + + labelErrorsImage = new Label(labelsComposite, SWT.NONE); + labelErrorsImage.setImage(PHPUnitImages.DESC_ERROR.createImage()); labelErrors = new Label(labelsComposite, SWT.NONE); labelErrors.setText("Errors: "); labelErrorsVal = new Label(labelsComposite, SWT.NONE); diff --git a/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/actions/RunTestsAction.java b/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/actions/RunTestsAction.java index 2e1c39c..2e0a6eb 100644 --- a/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/actions/RunTestsAction.java +++ b/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/actions/RunTestsAction.java @@ -74,7 +74,7 @@ public class RunTestsAction implements IObjectActionDelegate { public void run(IAction action) { try { - PHPUnitView.getDefault().startTests(); + PHPUnitView.getDefault().startTests(""); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); diff --git a/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/preferences/PHPUnitPreferencePage.java b/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/preferences/PHPUnitPreferencePage.java new file mode 100644 index 0000000..f2d2a1d --- /dev/null +++ b/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/preferences/PHPUnitPreferencePage.java @@ -0,0 +1,64 @@ +package net.sourceforge.phpeclipse.phpunit.preferences; + +import org.eclipse.jface.preference.*; +import org.eclipse.ui.IWorkbenchPreferencePage; +import org.eclipse.ui.IWorkbench; +import net.sourceforge.phpeclipse.phpunit.PHPUnitPlugin; +import org.eclipse.jface.preference.IPreferenceStore; + +/** + * This class represents a preference page that + * is contributed to the Preferences dialog. By + * subclassing <samp>FieldEditorPreferencePage</samp>, we + * can use the field support built into JFace that allows + * us to create a page that is small and knows how to + * save, restore and apply itself. + * <p> + * This page is used to modify preferences only. They + * are stored in the preference store that belongs to + * the main plug-in class. That way, preferences can + * be accessed directly via the preference store. + */ + +public class PHPUnitPreferencePage + extends FieldEditorPreferencePage + implements IWorkbenchPreferencePage { + + + public static final String PHPUNIT_PATH = "PHPUnitPathPreference"; + + + public PHPUnitPreferencePage() { + super(GRID); + setPreferenceStore(PHPUnitPlugin.getDefault().getPreferenceStore()); + setDescription("Please browse for the folder containing the PHPUnit files (among them: \"phpunit.php\" and \"socketTestResult.php\"). If you don't have it, please download the latest version from http://sourceforge.net/projects/phpunit/ first. "); + initializeDefaults(); + } +/** + * Sets the default values of the preferences. + */ + private void initializeDefaults() { + IPreferenceStore store = getPreferenceStore(); + + } + +/** + * Creates the field editors. Field editors are abstractions of + * the common GUI blocks needed to manipulate various types + * of preferences. Each field editor knows how to save and + * restore itself. + */ + + public void createFieldEditors() { + + addField(new DirectoryFieldEditor(PHPUNIT_PATH, + "&PHPUnit Path:", getFieldEditorParent())); + + + + } + + public void init(IWorkbench workbench) { + + } +} \ No newline at end of file