flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p...@apache.org
Subject svn commit: r1451713 - in /flex/asjs/branches/develop/frameworks/as/src/org/apache/flex: core/ html/staticControls/ html/staticControls/beads/models/
Date Fri, 01 Mar 2013 20:49:58 GMT
Author: pent
Date: Fri Mar  1 20:49:58 2013
New Revision: 1451713

URL: http://svn.apache.org/r1451713
Log:
Moved button group management to the RadioButton. Map to IButtonGroup is done through ValuesManager

Added:
    flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/core/IButtonGroup.as   (with
props)
Modified:
    flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/core/ButtonGroup.as
    flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/core/IRadioButtonBead.as
    flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/core/IValueToggleButtonModel.as
    flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/html/staticControls/RadioButton.as
    flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/html/staticControls/beads/models/ValueToggleButtonModel.as

Modified: flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/core/ButtonGroup.as
URL: http://svn.apache.org/viewvc/flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/core/ButtonGroup.as?rev=1451713&r1=1451712&r2=1451713&view=diff
==============================================================================
--- flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/core/ButtonGroup.as (original)
+++ flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/core/ButtonGroup.as Fri Mar
 1 20:49:58 2013
@@ -21,27 +21,8 @@ package org.apache.flex.core
 	import flash.events.Event;
 	import flash.events.EventDispatcher;
 
-	public class ButtonGroup extends EventDispatcher
+	public class ButtonGroup extends EventDispatcher implements IButtonGroup
 	{
-		private static var groups:Object;
-		
-		public static function getGroup( name:String ) : ButtonGroup
-		{
-			if( groups == null ) {
-				groups = new Object();
-			}
-			
-			var result:ButtonGroup;
-			if( groups.hasOwnProperty(name) ) result = groups[name];
-			else {
-				result = new ButtonGroup();
-				result.name = name;
-				groups[name] = result;
-			}
-			return result;
-		}
-		
-		
 		public function ButtonGroup()
 		{
 		}

Added: flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/core/IButtonGroup.as
URL: http://svn.apache.org/viewvc/flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/core/IButtonGroup.as?rev=1451713&view=auto
==============================================================================
--- flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/core/IButtonGroup.as (added)
+++ flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/core/IButtonGroup.as Fri
Mar  1 20:49:58 2013
@@ -0,0 +1,31 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.core
+{
+	import flash.events.IEventDispatcher;
+
+	public interface IButtonGroup extends IEventDispatcher
+	{	
+		function get name() : String;
+		function set name(value:String):void;
+		
+		function get value() : Object;
+		function set value(newValue:Object):void;
+	}
+}
\ No newline at end of file

Propchange: flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/core/IButtonGroup.as
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/core/IRadioButtonBead.as
URL: http://svn.apache.org/viewvc/flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/core/IRadioButtonBead.as?rev=1451713&r1=1451712&r2=1451713&view=diff
==============================================================================
--- flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/core/IRadioButtonBead.as
(original)
+++ flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/core/IRadioButtonBead.as
Fri Mar  1 20:49:58 2013
@@ -25,5 +25,8 @@ package org.apache.flex.core
 		
 		function get html():String;
 		function set html(value:String):void;
+		
+		function get selected():Boolean;
+		function set selected(value:Boolean):void;
 	}
 }
\ No newline at end of file

Modified: flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/core/IValueToggleButtonModel.as
URL: http://svn.apache.org/viewvc/flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/core/IValueToggleButtonModel.as?rev=1451713&r1=1451712&r2=1451713&view=diff
==============================================================================
--- flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/core/IValueToggleButtonModel.as
(original)
+++ flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/core/IValueToggleButtonModel.as
Fri Mar  1 20:49:58 2013
@@ -25,7 +25,5 @@ package org.apache.flex.core
 		
 		function get groupName():String;
 		function set groupName(value:String):void;
-		
-		function get buttonGroup():ButtonGroup;
 	}
 }
\ No newline at end of file

Modified: flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/html/staticControls/RadioButton.as
URL: http://svn.apache.org/viewvc/flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/html/staticControls/RadioButton.as?rev=1451713&r1=1451712&r2=1451713&view=diff
==============================================================================
--- flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/html/staticControls/RadioButton.as
(original)
+++ flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/html/staticControls/RadioButton.as
Fri Mar  1 20:49:58 2013
@@ -23,9 +23,9 @@ package org.apache.flex.html.staticContr
 	import flash.events.Event;
 	import flash.events.MouseEvent;
 	
-	import org.apache.flex.core.ButtonGroup;
 	import org.apache.flex.core.IBead;
 	import org.apache.flex.core.IBeadModel;
+	import org.apache.flex.core.IButtonGroup;
 	import org.apache.flex.core.IInitModel;
 	import org.apache.flex.core.IInitSkin;
 	import org.apache.flex.core.IRadioButtonBead;
@@ -42,10 +42,9 @@ package org.apache.flex.html.staticContr
 			addEventListener(MouseEvent.CLICK, internalMouseHandler);
 		}
 		
-		private function handleValueChange(event:Event):void
-		{
-			selected = IValueToggleButtonModel(model).buttonGroup.value == value;
-		}
+		protected static var groups:Array = new Array();
+		
+		private var _buttonGroup:IButtonGroup;
 		
 		private var _groupName:String;
 		
@@ -56,8 +55,22 @@ package org.apache.flex.html.staticContr
 		
 		public function set groupName(value:String) : void
 		{
-			IValueToggleButtonModel(model).groupName = value;
-			IValueToggleButtonModel(model).buttonGroup.addEventListener("valueChange", handleValueChange);
+			for(var i:int=0; i < groups.length; i++)
+			{
+				var bg:IButtonGroup = groups[i] as IButtonGroup;
+				if( bg.name == value ) {
+					_buttonGroup = bg;
+					break;
+				}
+			}
+			
+			if( _buttonGroup == null )  {
+				_buttonGroup = new (ValuesManager.valuesImpl.getValue("IButtonGroup")) as IButtonGroup;
+				_buttonGroup.name = value;
+				groups.push(_buttonGroup);
+			}
+			
+			_buttonGroup.addEventListener("valueChange", handleButtonGroupValueChange);
 		}
 		
 		public function get text():String
@@ -77,6 +90,10 @@ package org.apache.flex.html.staticContr
 		public function set selected(selValue:Boolean):void
 		{
 			IValueToggleButtonModel(model).selected = selValue;
+			
+			if( selValue ) {
+				_buttonGroup.value = value;
+			}
 		}
 		
 		public function get value():Object
@@ -196,6 +213,11 @@ package org.apache.flex.html.staticContr
 			return null;
 		}
 		
+		private function handleButtonGroupValueChange(event:Event):void
+		{
+			selected = _buttonGroup.value == value;
+		}
+		
 		private function internalMouseHandler(event:MouseEvent) : void
 		{
 			// prevent radiobutton from being turned off by a click

Modified: flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/html/staticControls/beads/models/ValueToggleButtonModel.as
URL: http://svn.apache.org/viewvc/flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/html/staticControls/beads/models/ValueToggleButtonModel.as?rev=1451713&r1=1451712&r2=1451713&view=diff
==============================================================================
--- flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/html/staticControls/beads/models/ValueToggleButtonModel.as
(original)
+++ flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/html/staticControls/beads/models/ValueToggleButtonModel.as
Fri Mar  1 20:49:58 2013
@@ -20,7 +20,6 @@ package org.apache.flex.html.staticContr
 {
 	import flash.events.Event;
 	
-	import org.apache.flex.core.ButtonGroup;
 	import org.apache.flex.core.IValueToggleButtonModel;
 
 	public class ValueToggleButtonModel extends ToggleButtonModel implements IValueToggleButtonModel
@@ -30,18 +29,6 @@ package org.apache.flex.html.staticContr
 			super();
 		}
 		
-		override public function set selected(selValue:Boolean):void
-		{
-			if( selValue != super.selected )
-			{
-				super.selected = selValue;
-				
-				if( selValue ) {
-					_buttonGroup.value = this.value;
-				}
-			}
-		}
-		
 		private var _value:Object;
 		
 		public function get value():Object
@@ -71,16 +58,7 @@ package org.apache.flex.html.staticContr
 			{
 				_groupName = value;
 				dispatchEvent(new Event("groupNameChange"));
-				
-				_buttonGroup = ButtonGroup.getGroup(groupName);
 			}
 		}
-		
-		private var _buttonGroup:ButtonGroup;
-		
-		public function get buttonGroup() : ButtonGroup
-		{
-			return _buttonGroup;
-		}
 	}
 }
\ No newline at end of file



Mime
View raw message