Permalink
Browse files

[BUG #6819] Moved the run/stop button implementation to its own class

  • Loading branch information...
1 parent bca2f03 commit 97fb1a5d4394c89b1dd6069b292bdd09874b2437 @danielwagner danielwagner committed Sep 18, 2012
@@ -76,9 +76,10 @@ qx.Class.define("testrunner.view.Mobile", {
{
this.__testRows = {};
var mainPage = this.__mainPage = new qx.ui.mobile.page.NavigationPage();
- mainPage.setTitle("qooxdoo Test Runner");
+ mainPage.setTitle("qx Test Runner");
- var runButton = this.__runButton = this._getRunButton();
+ var runButton = this.__runButton = new testrunner.view.MainButton();
+ runButton.addListener("tap", this._onRunButtonTap, this);
mainPage.getRightContainer().add(runButton);
mainPage.addListener("initialize", function()
@@ -173,19 +174,6 @@ qx.Class.define("testrunner.view.Mobile", {
},
/**
- * Returns the Run/Stop button
- *
- * @return {qx.ui.mobile.form.Group} Group widget
- */
- _getRunButton : function()
- {
- var runButton = new qx.ui.mobile.form.Button();
- qx.bom.element.Class.replace(runButton.getContentElement(), "button", "navigationbar-backbutton");
- runButton.addListener("tap", this._onRunButtonTap, this);
- return runButton;
- },
-
- /**
* Returns the status bar widget
*
* @return {qx.ui.mobile.form.Group} Group widget
@@ -267,36 +255,30 @@ qx.Class.define("testrunner.view.Mobile", {
break;
case "loading" :
this.setStatus("Loading tests...");
- this.__runButton.setEnabled(false);
break;
case "ready" :
this.setStatus(this.getSelectedTests().length + " tests ready to run.");
- this.__runButton.setEnabled(true);
- this.__runButton.setValue("Run");
break;
case "error" :
this.setStatus("Couldn't load test suite!");
- this.__runButton.setEnabled(false);
break;
case "running" :
this.setStatus("Running tests...");
- this.__runButton.setValue("Stop");
break;
case "finished" :
this.__suiteResults.finishedAt = new Date().getTime();
this.setStatus("Test suite finished. " + this._getSummary());
//re-apply selection so the same suite can be executed again
this.setSelectedTests(new qx.data.Array());
this.setSelectedTests(this.__testList);
- this.__runButton.setValue("Run");
break;
case "aborted" :
this.setSelectedTests(new qx.data.Array());
this.setSelectedTests(this.__testList);
- this.__runButton.setValue("Run");
this.setStatus("Test run aborted");
break;
}
+ this.__runButton.setState(value);
},
/**
@@ -0,0 +1,54 @@
+qx.Class.define("testrunner.view.mobile.MainButton", {
+
+ extend : qx.ui.mobile.form.Button,
+
+ construct : function(label, icon)
+ {
+ this.base(arguments, label, icon);
+ qx.bom.element.Class.replace(this.getContentElement(), "button", "navigationbar-backbutton");
+ },
+
+ properties :
+ {
+ state :
+ {
+ apply : "_applyState"
+ }
+ },
+
+ members :
+ {
+ _applyState : function(value)
+ {
+ var el = this.getContentElement();
+ var cls = qx.bom.element.Class;
+ cls.removeClasses(el, ["runbutton", "stopbutton"]);
+ switch(value) {
+ case "init":
+ break;
+ case "loading":
+ this.setEnabled(false);
+ break;
+ case "ready":
+ this.setEnabled(true);
+ this.setValue("Run");
+ cls.add(el, "runbutton");
+ break;
+ case "error":
+ this.setEnabled(false);
+ break;
+ case "running":
+ this.setValue("Stop");
+ cls.add(el, "stopbutton");
+ break;
+ case "finished":
+ this.setValue("Run");
+ cls.add(el, "runbutton");
+ break;
+ case "aborted":
+ this.setValue("Run");
+ cls.add(el, "runbutton");
+ }
+ }
+ }
+});
Oops, something went wrong.

0 comments on commit 97fb1a5

Please sign in to comment.