You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ah...@apache.org on 2014/04/25 08:18:17 UTC
[18/46] FlexPMD Donation from Adobe Systems Inc
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/assets/cancelledIcon.png
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/assets/cancelledIcon.png b/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/assets/cancelledIcon.png
new file mode 100644
index 0000000..9bca099
Binary files /dev/null and b/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/assets/cancelledIcon.png differ
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/assets/down.png
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/assets/down.png b/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/assets/down.png
new file mode 100644
index 0000000..3b15bee
Binary files /dev/null and b/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/assets/down.png differ
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/assets/icon_tool_trash.png
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/assets/icon_tool_trash.png b/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/assets/icon_tool_trash.png
new file mode 100644
index 0000000..b4b470d
Binary files /dev/null and b/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/assets/icon_tool_trash.png differ
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/assets/icon_tool_trash2.png
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/assets/icon_tool_trash2.png b/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/assets/icon_tool_trash2.png
new file mode 100644
index 0000000..282a037
Binary files /dev/null and b/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/assets/icon_tool_trash2.png differ
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/assets/todoLogo.png
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/assets/todoLogo.png b/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/assets/todoLogo.png
new file mode 100644
index 0000000..a314b8d
Binary files /dev/null and b/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/assets/todoLogo.png differ
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/assets/todoLogo_big.png
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/assets/todoLogo_big.png b/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/assets/todoLogo_big.png
new file mode 100644
index 0000000..bb89f68
Binary files /dev/null and b/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/assets/todoLogo_big.png differ
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/assets/up.png
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/assets/up.png b/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/assets/up.png
new file mode 100644
index 0000000..5dc169c
Binary files /dev/null and b/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/assets/up.png differ
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/api/IGetCustomRuleset.as
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/api/IGetCustomRuleset.as b/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/api/IGetCustomRuleset.as
new file mode 100644
index 0000000..3f92817
--- /dev/null
+++ b/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/api/IGetCustomRuleset.as
@@ -0,0 +1,28 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 com.adobe.ac.pmd.api
+{
+ import com.adobe.ac.pmd.model.RootRuleset;
+
+ public interface IGetCustomRuleset
+ {
+ function getCustomRuleset() : void;
+ function onReceiveCustomRuleset( ruleset : RootRuleset ) : void;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/api/IGetRootRuleset.as
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/api/IGetRootRuleset.as b/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/api/IGetRootRuleset.as
new file mode 100644
index 0000000..54ea211
--- /dev/null
+++ b/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/api/IGetRootRuleset.as
@@ -0,0 +1,28 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 com.adobe.ac.pmd.api
+{
+ import com.adobe.ac.pmd.model.RootRuleset;
+
+ public interface IGetRootRuleset
+ {
+ function getRootRuleset() : void;
+ function onReceiveRootRuleset( ruleset : RootRuleset ) : void;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/control/Controller.as
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/control/Controller.as b/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/control/Controller.as
new file mode 100644
index 0000000..3aaa1b9
--- /dev/null
+++ b/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/control/Controller.as
@@ -0,0 +1,40 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 com.adobe.ac.pmd.control
+{
+ import com.adobe.ac.pmd.control.commands.GetCustomRulesetCommand;
+ import com.adobe.ac.pmd.control.commands.GetRootRulesetCommand;
+ import com.adobe.ac.pmd.control.commands.GetRulesetContentCommand;
+ import com.adobe.ac.pmd.control.events.GetCustomRulesetEvent;
+ import com.adobe.ac.pmd.control.events.GetRootRulesetEvent;
+ import com.adobe.ac.pmd.control.events.GetRulesetContentEvent;
+ import com.adobe.cairngorm.control.FrontController;
+
+ public class Controller extends FrontController
+ {
+ public function Controller()
+ {
+ super();
+
+ addCommand( GetRootRulesetEvent.EVENT_NAME, GetRootRulesetCommand );
+ addCommand( GetRulesetContentEvent.EVENT_NAME, GetRulesetContentCommand );
+ addCommand( GetCustomRulesetEvent.EVENT_NAME, GetCustomRulesetCommand );
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/control/commands/GetCustomRulesetCommand.as
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/control/commands/GetCustomRulesetCommand.as b/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/control/commands/GetCustomRulesetCommand.as
new file mode 100644
index 0000000..937a7df
--- /dev/null
+++ b/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/control/commands/GetCustomRulesetCommand.as
@@ -0,0 +1,63 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 com.adobe.ac.pmd.control.commands
+{
+ import com.adobe.ac.pmd.api.IGetCustomRuleset;
+ import com.adobe.ac.pmd.control.events.GetCustomRulesetEvent;
+ import com.adobe.ac.pmd.services.rulesets.RulesetDelegate;
+ import com.adobe.ac.pmd.services.translators.RootRulesetTranslator;
+ import com.adobe.cairngorm.commands.ICommand;
+ import com.adobe.cairngorm.control.CairngormEvent;
+
+ import mx.controls.Alert;
+ import mx.logging.ILogger;
+ import mx.logging.Log;
+ import mx.rpc.IResponder;
+ import mx.rpc.events.ResultEvent;
+
+ public class GetCustomRulesetCommand implements ICommand, IResponder
+ {
+ private static const LOG : ILogger = Log.getLogger( "com.adobe.ac.pmd.control.commands.GetCustomRulesetCommand" );
+
+ private var invoker : IGetCustomRuleset;
+
+ public function GetCustomRulesetCommand()
+ {
+ }
+
+ public function execute( event : CairngormEvent ) : void
+ {
+ invoker = GetCustomRulesetEvent( event ).invoker;
+ new RulesetDelegate().getCustomRuleset( this );
+ }
+
+ public function result( data : Object ) : void // NO PMD
+ {
+ var xml : XML = XML( ResultEvent( data ).result );
+
+ invoker.onReceiveCustomRuleset( RootRulesetTranslator.deserialize( xml ) );
+ }
+
+ public function fault( info : Object ) : void // NO PMD
+ {
+ Alert.show( info.toString() ); // NO PMD
+ LOG.error( info.toString() );
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/control/commands/GetRootRulesetCommand.as
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/control/commands/GetRootRulesetCommand.as b/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/control/commands/GetRootRulesetCommand.as
new file mode 100644
index 0000000..11def22
--- /dev/null
+++ b/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/control/commands/GetRootRulesetCommand.as
@@ -0,0 +1,63 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 com.adobe.ac.pmd.control.commands
+{
+ import com.adobe.ac.pmd.api.IGetRootRuleset;
+ import com.adobe.ac.pmd.control.events.GetRootRulesetEvent;
+ import com.adobe.ac.pmd.services.rulesets.RulesetDelegate;
+ import com.adobe.ac.pmd.services.translators.RootRulesetTranslator;
+ import com.adobe.cairngorm.commands.ICommand;
+ import com.adobe.cairngorm.control.CairngormEvent;
+
+ import mx.controls.Alert;
+ import mx.logging.ILogger;
+ import mx.logging.Log;
+ import mx.rpc.IResponder;
+ import mx.rpc.events.ResultEvent;
+
+ public class GetRootRulesetCommand implements ICommand, IResponder
+ {
+ private static const LOG : ILogger = Log.getLogger( "com.adobe.ac.pmd.control.commands.GetRootRulesetCommand" );
+
+ private var invoker : IGetRootRuleset;
+
+ public function GetRootRulesetCommand()
+ {
+ }
+
+ public function execute( event : CairngormEvent ) : void
+ {
+ invoker = GetRootRulesetEvent( event ).invoker;
+ new RulesetDelegate().getRootRuleset( this );
+ }
+
+ public function result( data : Object ) : void // NO PMD
+ {
+ var xml : XML = XML( ResultEvent( data ).result );
+
+ invoker.onReceiveRootRuleset( RootRulesetTranslator.deserialize( xml ) );
+ }
+
+ public function fault( info : Object ) : void // NO PMD
+ {
+ Alert.show( info.toString() ); // NO PMD
+ LOG.error( info.toString() );
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/control/commands/GetRulesetContentCommand.as
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/control/commands/GetRulesetContentCommand.as b/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/control/commands/GetRulesetContentCommand.as
new file mode 100644
index 0000000..73bf956
--- /dev/null
+++ b/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/control/commands/GetRulesetContentCommand.as
@@ -0,0 +1,65 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 com.adobe.ac.pmd.control.commands
+{
+ import com.adobe.ac.pmd.api.IGetRulesetContent;
+ import com.adobe.ac.pmd.control.events.GetRulesetContentEvent;
+ import com.adobe.ac.pmd.model.Ruleset;
+ import com.adobe.ac.pmd.services.rulesets.RulesetDelegate;
+ import com.adobe.ac.pmd.services.translators.RulesetTranslator;
+ import com.adobe.cairngorm.commands.ICommand;
+ import com.adobe.cairngorm.control.CairngormEvent;
+
+ import mx.logging.ILogger;
+ import mx.logging.Log;
+ import mx.rpc.IResponder;
+ import mx.rpc.events.ResultEvent;
+
+ public class GetRulesetContentCommand implements ICommand, IResponder
+ {
+ private static const LOG : ILogger =
+ Log.getLogger( "com.adobe.ac.pmd.control.commands.GetRulesetContentCommand" );
+
+ private var invoker : IGetRulesetContent;
+
+ public function GetRulesetContentCommand()
+ {
+ }
+
+ public function execute( event : CairngormEvent ) : void
+ {
+ invoker = GetRulesetContentEvent( event ).invoker;
+ new RulesetDelegate().getRuleset( this, GetRulesetContentEvent( event ).ref );
+ }
+
+ public function result( data : Object ) : void // NO PMD
+ {
+ var xml : XML = ResultEvent( data ).result as XML;
+ var ruleset : Ruleset = RulesetTranslator.deserialize( xml );
+
+ trace( "received " + ruleset.name + " length " + ruleset.rules.length );
+ invoker.onReceiveRulesetContent( ruleset );
+ }
+
+ public function fault( info : Object ) : void // NO PMD
+ {
+ LOG.error( info.toString() );
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/control/events/GetCustomRulesetEvent.as
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/control/events/GetCustomRulesetEvent.as b/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/control/events/GetCustomRulesetEvent.as
new file mode 100644
index 0000000..1b505a8
--- /dev/null
+++ b/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/control/events/GetCustomRulesetEvent.as
@@ -0,0 +1,48 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 com.adobe.ac.pmd.control.events
+{
+ import com.adobe.ac.pmd.api.IGetCustomRuleset;
+ import com.adobe.cairngorm.control.CairngormEvent;
+
+ import flash.events.Event;
+
+ public class GetCustomRulesetEvent extends CairngormEvent
+ {
+ public static const EVENT_NAME : String = "ruleset.getRoot";
+
+ private var _invoker : IGetCustomRuleset;
+
+ public function GetCustomRulesetEvent( invoker : IGetCustomRuleset )
+ {
+ super( EVENT_NAME );
+ _invoker = invoker;
+ }
+
+ public function get invoker() : IGetCustomRuleset
+ {
+ return _invoker;
+ }
+
+ override public function clone() : Event
+ {
+ return new GetCustomRulesetEvent( _invoker );
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/control/events/GetRootRulesetEvent.as
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/control/events/GetRootRulesetEvent.as b/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/control/events/GetRootRulesetEvent.as
new file mode 100644
index 0000000..e1077d7
--- /dev/null
+++ b/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/control/events/GetRootRulesetEvent.as
@@ -0,0 +1,48 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 com.adobe.ac.pmd.control.events
+{
+ import com.adobe.ac.pmd.api.IGetRootRuleset;
+ import com.adobe.cairngorm.control.CairngormEvent;
+
+ import flash.events.Event;
+
+ public class GetRootRulesetEvent extends CairngormEvent
+ {
+ public static const EVENT_NAME : String = "ruleset.getCustom";
+
+ private var _invoker : IGetRootRuleset;
+
+ public function GetRootRulesetEvent( invoker : IGetRootRuleset )
+ {
+ super( EVENT_NAME );
+ _invoker = invoker;
+ }
+
+ public function get invoker() : IGetRootRuleset
+ {
+ return _invoker;
+ }
+
+ override public function clone() : Event
+ {
+ return new GetRootRulesetEvent( _invoker );
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/services/MyServiceLocator.mxml
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/services/MyServiceLocator.mxml b/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/services/MyServiceLocator.mxml
new file mode 100644
index 0000000..1cb3af4
--- /dev/null
+++ b/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/services/MyServiceLocator.mxml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+
+ 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.
+
+-->
+<cairngorm:ServiceLocator xmlns:cairngorm="com.adobe.cairngorm.business.*"
+ xmlns:mx="http://www.adobe.com/2006/mxml"
+ >
+
+ <mx:Script>
+ <![CDATA[
+ public static const RULESETS_PREFIX : String = "rulesets/";
+ ]]>
+ </mx:Script>
+
+ <mx:HTTPService id="rootRulesetService"
+ resultFormat="e4x"
+ url="{ RULESETS_PREFIX }com/adobe/ac/pmd/all_flex.xml"
+ />
+
+ <mx:HTTPService id="rulesetService"
+ resultFormat="e4x"
+ />
+
+</cairngorm:ServiceLocator>
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/services/rulesets/RulesetDelegate.as
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/services/rulesets/RulesetDelegate.as b/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/services/rulesets/RulesetDelegate.as
new file mode 100644
index 0000000..ecddba0
--- /dev/null
+++ b/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/services/rulesets/RulesetDelegate.as
@@ -0,0 +1,96 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 com.adobe.ac.pmd.services.rulesets
+{
+ import com.adobe.ac.pmd.services.MyServiceLocator;
+ import com.adobe.cairngorm.business.ServiceLocator;
+
+ import flash.events.Event;
+ import flash.events.IOErrorEvent;
+ import flash.events.SecurityErrorEvent;
+ import flash.net.FileReference;
+
+ import mx.rpc.Fault;
+ import mx.rpc.IResponder;
+ import mx.rpc.events.FaultEvent;
+ import mx.rpc.events.ResultEvent;
+ import mx.rpc.http.HTTPService;
+
+ public class RulesetDelegate
+ {
+ private var _responder : IResponder;
+ private var _fileReference : FileReference;
+
+ public function RulesetDelegate()
+ {
+ }
+
+ public function getRuleset( responder : IResponder, ref : String ) : void
+ {
+ rulesetService.url = MyServiceLocator.RULESETS_PREFIX + ref;
+ rulesetService.send().addResponder( responder );
+ }
+
+ public function getRootRuleset( responder : IResponder ) : void
+ {
+ rootRulesetService.send().addResponder( responder );
+ }
+
+ public function getCustomRuleset( responder : IResponder ) : void
+ {
+ _responder = responder;
+ _fileReference = new FileReference();
+ _fileReference.addEventListener( Event.SELECT, onRulesetSelected );
+ _fileReference.addEventListener( Event.COMPLETE, onRulesetLoaded );
+ _fileReference.addEventListener( IOErrorEvent.IO_ERROR, onIoError );
+ _fileReference.addEventListener( SecurityErrorEvent.SECURITY_ERROR, onSecurityError );
+ _fileReference.browse();
+ }
+
+ private function onIoError( event : IOErrorEvent ) : void
+ {
+ _responder.fault( new FaultEvent( FaultEvent.FAULT, false, false, new Fault( "", event.text ) ) );
+ }
+
+ private function onSecurityError( event : SecurityError ) : void
+ {
+ _responder.fault( new FaultEvent( FaultEvent.FAULT, false, false, new Fault( event.errorID.toString(), event.message ) ) );
+ }
+
+ private function onRulesetSelected( event : Event ) : void
+ {
+ _fileReference.load();
+ }
+
+ private function onRulesetLoaded( event : Event ) : void
+ {
+ _responder.result( new ResultEvent( ResultEvent.RESULT, false, false, new XML( FileReference( event.target ).data.toString() ) ) );
+ }
+
+ private function get rootRulesetService() : HTTPService
+ {
+ return MyServiceLocator( ServiceLocator.getInstance() ).rootRulesetService;
+ }
+
+ private function get rulesetService() : HTTPService
+ {
+ return MyServiceLocator( ServiceLocator.getInstance() ).rulesetService;
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/services/translators/PropertyTranslator.as
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/services/translators/PropertyTranslator.as b/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/services/translators/PropertyTranslator.as
new file mode 100644
index 0000000..245cfb4
--- /dev/null
+++ b/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/services/translators/PropertyTranslator.as
@@ -0,0 +1,44 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 com.adobe.ac.pmd.services.translators
+{
+ import com.adobe.ac.pmd.model.Property;
+
+ import mx.collections.ArrayCollection;
+ import mx.collections.ListCollectionView;
+
+ public class PropertyTranslator
+ {
+ public static function deserializeProperties( xmlList : XMLList ) : ListCollectionView
+ {
+ var properties : ListCollectionView = new ArrayCollection();
+
+ for( var childIndex : int = 0; childIndex < xmlList.length(); childIndex++ )
+ {
+ var propertyXml : XML = xmlList[ childIndex ];
+ var property : Property = new Property(); // NO PMD AvoidInstanciationInLoop
+
+ property.name = propertyXml.@name;
+ property.value = propertyXml.children()[ 0 ].toString();
+ properties.addItem( property );
+ }
+ return properties;
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/services/translators/RootRulesetTranslator.as
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/services/translators/RootRulesetTranslator.as b/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/services/translators/RootRulesetTranslator.as
new file mode 100644
index 0000000..ebe5686
--- /dev/null
+++ b/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/services/translators/RootRulesetTranslator.as
@@ -0,0 +1,107 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 com.adobe.ac.pmd.services.translators
+{
+ import com.adobe.ac.pmd.model.RootRuleset;
+ import com.adobe.ac.pmd.model.Rule;
+ import com.adobe.ac.pmd.model.Ruleset;
+
+ import mx.collections.ArrayCollection;
+
+ public class RootRulesetTranslator
+ {
+ public static function deserialize( xml : XML ) : RootRuleset
+ {
+ var ruleset : RootRuleset = new RootRuleset();
+ var children : XMLList = xml.children();
+
+ ruleset.name = xml.@name;
+
+ for( var i : int = 1; i < children.length(); i++ )
+ {
+ var ruleXml : XML = children[ i ];
+
+ if( ruleXml.@ref != undefined )
+ {
+ var childRuleset : Ruleset = new Ruleset(); // NO PMD AvoidInstanciationInLoop
+
+ childRuleset.isRef = true;
+ childRuleset.getRulesetContent( ruleXml.@ref );
+ ruleset.rulesets.addItem( childRuleset );
+ }
+ else
+ {
+ if ( ! ruleset.rulesets )
+ {
+ ruleset.rulesets = new ArrayCollection();
+ }
+ var nestingRuleset : Ruleset;
+ if ( ruleset.rulesets.length == 0 )
+ {
+ nestingRuleset = new Ruleset(); // NO PMD AvoidInstanciationInLoop
+
+ nestingRuleset.name = "Custom ruleset";
+ ruleset.rulesets.addItem( nestingRuleset );
+ }
+ else
+ {
+ nestingRuleset = Ruleset( ruleset.rulesets.getItemAt( 0 ) );
+ }
+ var newRule : Rule = RuleTranslator.deserialize( ruleXml );
+
+ newRule.ruleset = nestingRuleset;
+ nestingRuleset.rules.addItem( newRule );
+ }
+ }
+
+ return ruleset;
+ }
+
+ public static function serializeRootRuleset( ruleset : RootRuleset ) : XML
+ {
+ var xmlString : String = "<ruleset name=\"" + ruleset.name + "\"" +
+ "xmlns=\"http://pmd.sf.net/ruleset/1.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
+ "xsi:schemaLocation=\"http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd\"" +
+ "xsi:noNamespaceSchemaLocation=\"http://pmd.sf.net/ruleset_xml_schema.xsd\">" +
+ "<description>" + ( ruleset.description ? ruleset.description : "" ) + "</description>";
+
+ for each( var childRuleset : Ruleset in ruleset.rulesets )
+ {
+ xmlString += serializeRuleset( childRuleset ).toXMLString();
+ }
+ xmlString += "</ruleset>";
+
+ return XML( xmlString );
+ }
+
+ private static function serializeRuleset( ruleset : Ruleset ) : XMLList
+ {
+ var xmlString : String = "";
+
+ for each( var rule : Rule in ruleset.rules )
+ {
+ if ( !rule.deleted )
+ {
+ xmlString += RuleTranslator.serialize( rule ).toXMLString();
+ }
+ }
+
+ return new XMLList( xmlString );
+ }}
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/services/translators/RuleTranslator.as
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/services/translators/RuleTranslator.as b/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/services/translators/RuleTranslator.as
new file mode 100644
index 0000000..4b2ef82
--- /dev/null
+++ b/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/services/translators/RuleTranslator.as
@@ -0,0 +1,98 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 com.adobe.ac.pmd.services.translators
+{
+ import com.adobe.ac.pmd.model.Property;
+ import com.adobe.ac.pmd.model.Rule;
+ import com.adobe.ac.pmd.model.ViolationPriority;
+
+ public class RuleTranslator
+ {
+ private static const INDENT : String = " ";
+
+ public static function deserialize( ruleXml : XML ) : Rule
+ {
+ var rule : Rule = new Rule();
+
+ rule.since = ruleXml.@since;
+ rule.name = ruleXml.attribute( "class" );
+ rule.message = ruleXml.@message;
+
+ for ( var childIndex : int = 0; childIndex < ruleXml.children().length(); childIndex++ )
+ {
+ var child : XML = ruleXml.children()[ childIndex ];
+ var name : String = child.name().toString().replace( child.namespace() + "::", "" );
+
+ deserializeChildren( rule, name, child.children() );
+ }
+
+ return rule;
+ }
+
+ public static function serialize( rule : Rule ) : XML
+ {
+ var xmlString : String = "<rule since=\"" + rule.since + "\" class=\"" + rule.name + "\" message=\"" + rule.message +
+ "\">";
+
+ xmlString += "<description>" + ( rule.description ? rule.description : "" ) + "</description>";
+ xmlString += "<priority>" + ( rule.priority ? rule.priority.level : ViolationPriority.WARNING.level ) + "</priority>";
+
+ if ( rule.properties.length > 0 )
+ {
+ xmlString += "<properties>";
+
+ for each ( var property : Property in rule.properties )
+ {
+ xmlString += "<property name=\"" + property.name + "\">";
+ xmlString += "<value>" + property.value + "</value>";
+ xmlString += "</property>";
+ }
+ xmlString += "</properties>";
+ }
+
+ if ( rule.examples )
+ {
+ xmlString += "<example><![CDATA[" + rule.examples + "]]></example>";
+ }
+ xmlString += "</rule>";
+ return XML( xmlString );
+ }
+
+ private static function deserializeChildren( rule : Rule, propertyName : String, value : XMLList ) : void
+ {
+ switch ( propertyName )
+ {
+ case "priority":
+ rule.priority = ViolationPriority.create( Number( value.toString() ) );
+ break;
+ case "description":
+ rule.description = value.toString();
+ break;
+ case "properties":
+ rule.properties = PropertyTranslator.deserializeProperties( value );
+ break;
+ case "example":
+ rule.examples = value.toString();
+ break;
+ default:
+ break;
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/services/translators/RulesetTranslator.as
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/services/translators/RulesetTranslator.as b/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/services/translators/RulesetTranslator.as
new file mode 100644
index 0000000..f0f3525
--- /dev/null
+++ b/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/services/translators/RulesetTranslator.as
@@ -0,0 +1,63 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 com.adobe.ac.pmd.services.translators
+{
+ import com.adobe.ac.pmd.model.Rule;
+ import com.adobe.ac.pmd.model.Ruleset;
+ import com.adobe.ac.pmd.model.RootRuleset;
+
+ public class RulesetTranslator
+ {
+ public static function deserialize( xml : XML ) : Ruleset
+ {
+ var ruleset : Ruleset = new Ruleset();
+ var children : XMLList = xml.children();
+
+ ruleset.name = xml.@name;
+
+ for ( var i : int = 1; i < children.length(); i++ )
+ {
+ var ruleXml : XML = children[ i ];
+
+ var rule : Rule = RuleTranslator.deserialize( ruleXml );
+
+ rule.ruleset = ruleset;
+ ruleset.rules.addItem( rule );
+ ruleset.isRef = false;
+ }
+
+ return ruleset;
+ }
+
+ public static function serializeRootRuleset( ruleset : Ruleset ) : XML
+ {
+ var xmlString : String = "<ruleset name=\"" + ruleset.name + "\"" + "xmlns=\"http://pmd.sf.net/ruleset/1.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
+ "xsi:schemaLocation=\"http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd\"" + "xsi:noNamespaceSchemaLocation=\"http://pmd.sf.net/ruleset_xml_schema.xsd\">" +
+ "<description>" + ( ruleset.description ? ruleset.description : "" ) + "</description>";
+
+ for each ( var rule : Rule in ruleset.rules )
+ {
+ xmlString += RuleTranslator.serialize( rule ).toXMLString();
+ }
+ xmlString += "</ruleset>";
+
+ return XML( xmlString );
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/view/RuleEditor.mxml
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/view/RuleEditor.mxml b/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/view/RuleEditor.mxml
new file mode 100644
index 0000000..1afc08e
--- /dev/null
+++ b/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/view/RuleEditor.mxml
@@ -0,0 +1,140 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+
+ 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.
+
+-->
+<mx:Form xmlns:mx="http://www.adobe.com/2006/mxml"
+ xmlns:view="com.adobe.ac.pmd.view.*"
+ width="450"
+ height="100%"
+ paddingBottom="0"
+ paddingLeft="0"
+ paddingRight="0"
+ paddingTop="5"
+ visible="{ model.selectedRule != null }"
+ >
+
+ <mx:Script>
+ <![CDATA[
+ import com.adobe.ac.pmd.model.ViolationPriority;
+
+ private static const FORM_LABELS_WIDTH : int = 90;
+
+ private function onPrioritiesValueCommit() : void
+ {
+ if ( model.selectedRule )
+ {
+ model.selectedRule.priority = ViolationPriority( priorities.selectedItem );
+ }
+ }
+ ]]>
+ </mx:Script>
+
+ <view:RuleEditorPM id="model"
+ />
+
+ <mx:Label width="{ width }"
+ text="{ model.selectedRule.shortName }"
+ truncateToFit="true"
+ fontWeight="bold"
+ />
+
+ <mx:HRule width="{ width }"
+ styleName="flexUnitHRule"
+ />
+
+ <mx:FormItem label="Message"
+ >
+
+ <mx:TextInput id="message"
+ width="{ width - FORM_LABELS_WIDTH }"
+ text="{ model.selectedRule.message }"
+ toolTip="{ model.selectedRule.message }"
+ enabled="{ model.selectedRule != null }"
+ change="model.selectedRule.message = message.text"
+ />
+
+ </mx:FormItem>
+
+ <mx:FormItem label="Description"
+ >
+
+ <mx:TextArea id="description"
+ width="{ width - FORM_LABELS_WIDTH }"
+ height="150"
+ text="{ model.selectedRule.description }"
+ enabled="{ model.selectedRule != null }"
+ change="model.selectedRule.description = description.text"
+ />
+
+ </mx:FormItem>
+
+ <mx:FormItem label="Priority"
+ >
+
+ <mx:ComboBox id="priorities"
+ dataProvider="{ ViolationPriority.values }"
+ enabled="{ model.selectedRule != null }"
+ selectedIndex="{ model.selectedRule.priority.level == 1 ? 0 : model.selectedRule.priority.level == 3 ? 1 : 2 }"
+ change="onPrioritiesValueCommit()"
+ />
+
+ </mx:FormItem>
+
+ <mx:FormItem label="Examples"
+ >
+
+ <mx:TextArea id="examples"
+ width="{ width - FORM_LABELS_WIDTH }"
+ height="150"
+ text="{ model.selectedRule.examples }"
+ enabled="{ model.selectedRule != null }"
+ change="model.selectedRule.examples = examples.text"
+ wordWrap="false"
+ />
+
+ </mx:FormItem>
+
+ <mx:FormItem label="Properties"
+ visible="{ model.selectedRule.properties.length > 0 }"
+ >
+
+ <mx:DataGrid width="{ width - FORM_LABELS_WIDTH }"
+ dataProvider="{ model.selectedRule.properties }"
+ editable="true"
+ rowCount="3"
+ >
+
+ <mx:columns>
+
+ <mx:DataGridColumn dataField="name"
+ editable="false"
+ headerText="Name"
+ />
+
+ <mx:DataGridColumn dataField="value"
+ editable="true"
+ headerText="Value"
+ />
+
+ </mx:columns>
+
+ </mx:DataGrid>
+
+ </mx:FormItem>
+
+</mx:Form>
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/view/RuleEditorPM.as
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/view/RuleEditorPM.as b/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/view/RuleEditorPM.as
new file mode 100644
index 0000000..9f2ddbd
--- /dev/null
+++ b/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/view/RuleEditorPM.as
@@ -0,0 +1,33 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 com.adobe.ac.pmd.view
+{
+ import com.adobe.ac.model.IPresentationModel;
+ import com.adobe.ac.pmd.model.Rule;
+
+ public class RuleEditorPM implements IPresentationModel
+ {
+ public function RuleEditorPM()
+ {
+ }
+
+ [Bindable]
+ public var selectedRule : Rule;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/view/RuleSetNavigator.mxml
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/view/RuleSetNavigator.mxml b/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/view/RuleSetNavigator.mxml
new file mode 100644
index 0000000..aa1f05a
--- /dev/null
+++ b/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/view/RuleSetNavigator.mxml
@@ -0,0 +1,160 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+
+ 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.
+
+-->
+<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"
+ xmlns:renderers="com.adobe.ac.pmd.view.renderers.*"
+ xmlns:view="com.adobe.ac.pmd.view.*"
+ paddingTop="5"
+ creationComplete="model.getRootRuleset()"
+ >
+ <mx:Metadata>
+ [Event(name="selectedRuleChange", type="com.adobe.ac.pmd.view.events.SelectedRuleChangeEvent")]
+ </mx:Metadata>
+
+ <mx:Script>
+ <![CDATA[
+ import com.adobe.ac.pmd.model.Rule;
+ import com.adobe.ac.pmd.model.Ruleset;
+ import com.adobe.ac.pmd.model.events.RulesetReceivedEvent;
+ import com.adobe.ac.pmd.view.events.SelectedRuleChangeEvent;
+
+ import mx.collections.IHierarchicalCollectionViewCursor;
+ import mx.core.Application;
+ import mx.events.CollectionEvent;
+ import mx.events.CollectionEventKind;
+
+ public function onRuleRemoved() : void
+ {
+ model.rootRuleset.rulesChanged();
+ onChange();
+ }
+
+ private function onChange() : void
+ {
+ dispatchEvent( new SelectedRuleChangeEvent( dg.selectedItem as Rule ) );
+ }
+
+ private function onRulesetReceived( event : RulesetReceivedEvent ) : void
+ {
+ openRuleset( event.ruleset )
+ }
+
+ public function openRuleset( ruleset : Ruleset ) : void
+ {
+ dg.dataProvider.openNode( ruleset );
+ ruleset.rules.addEventListener( CollectionEvent.COLLECTION_CHANGE, onRulesChange );
+ selectDefaultRule();
+ }
+
+ private function onRulesChange( event : CollectionEvent ) : void
+ {
+ if ( event.kind == CollectionEventKind.REMOVE )
+ {
+ selectFirstRule();
+ }
+ }
+
+ private function selectDefaultRule() : void
+ {
+ var ruleNameToLoad : String = Application.application.parameters[ "rule" ];
+ var index : int = -1;
+
+ if ( ruleNameToLoad )
+ {
+ for each ( var ruleset : Ruleset in model.rootRuleset.rulesets )
+ {
+ index++;
+ for each ( var rule : Rule in ruleset.rules )
+ {
+ index++;
+ if ( rule.name.indexOf( ruleNameToLoad ) != -1 )
+ {
+ dg.selectedIndex = index;
+ onChange();
+ return;
+ }
+ }
+ }
+ }
+ else
+ {
+ selectFirstRule();
+ }
+ }
+
+ private function selectFirstRule() : void
+ {
+ dg.selectedIndex = 1;
+ onChange();
+ }
+ ]]>
+ </mx:Script>
+
+ <view:RuleSetNavigatorPM id="model"
+ rulesetReceived="onRulesetReceived( event )"
+ />
+
+ <mx:AdvancedDataGrid id="dg"
+ width="100%"
+ height="100%"
+ change="onChange()"
+ >
+
+ <mx:dataProvider>
+
+ <mx:HierarchicalData source="{ model.rootRuleset.rulesets }"
+ childrenField="rules"
+ />
+
+ </mx:dataProvider>
+
+ <mx:columns>
+
+ <mx:AdvancedDataGridColumn dataField="name"
+ headerText="Name"
+ />
+
+ <mx:AdvancedDataGridColumn width="100"
+ dataField="priority"
+ headerText="Priority"
+ />
+
+ <mx:AdvancedDataGridColumn width="50"
+ headerText=""
+ sortable="false"
+ >
+
+ <mx:itemRenderer>
+
+ <mx:Component>
+
+ <renderers:DeleteButtonRenderer ruleRemoved="outerDocument.onRuleRemoved()"
+ />
+
+ </mx:Component>
+
+ </mx:itemRenderer>
+
+ </mx:AdvancedDataGridColumn>
+
+ </mx:columns>
+
+ </mx:AdvancedDataGrid>
+
+</mx:VBox>
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/view/RuleSetNavigatorPM.as
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/view/RuleSetNavigatorPM.as b/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/view/RuleSetNavigatorPM.as
new file mode 100644
index 0000000..f1a5ab0
--- /dev/null
+++ b/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/view/RuleSetNavigatorPM.as
@@ -0,0 +1,162 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 com.adobe.ac.pmd.view
+{
+ import com.adobe.ac.model.IPresentationModel;
+ import com.adobe.ac.pmd.api.IGetCustomRuleset;
+ import com.adobe.ac.pmd.api.IGetRootRuleset;
+ import com.adobe.ac.pmd.control.events.GetCustomRulesetEvent;
+ import com.adobe.ac.pmd.control.events.GetRootRulesetEvent;
+ import com.adobe.ac.pmd.model.Property;
+ import com.adobe.ac.pmd.model.RootRuleset;
+ import com.adobe.ac.pmd.model.Rule;
+ import com.adobe.ac.pmd.model.Ruleset;
+ import com.adobe.ac.pmd.model.ViolationPriority;
+ import com.adobe.ac.pmd.model.events.RulesetReceivedEvent;
+ import com.adobe.ac.pmd.services.translators.RootRulesetTranslator;
+
+ import flash.events.Event;
+ import flash.events.EventDispatcher;
+ import flash.net.FileReference;
+
+ [Event( name="rootRulesetReceived", type = "flash.events.Event" )]
+ [Event( name="rulesetReceived", type = "com.adobe.ac.pmd.model.events.RulesetReceivedEvent" )] // NO PMD UnboundTypeInMetadata
+ public class RuleSetNavigatorPM extends EventDispatcher implements IPresentationModel, IGetRootRuleset, IGetCustomRuleset
+ {
+ public static const ROOT_RULESET_RECEIVED : String = "rootRulesetReceived";
+ public static const PARAMETERIZED_RULE_NAME : String = "com.adobe.ac.pmd.rules.parameterized.ParameterizedRegExpBasedRule";
+
+ [Bindable]
+ public var rootRuleset : RootRuleset;
+
+ private var rulesetReceived : int;
+
+ public function RuleSetNavigatorPM()
+ {
+ }
+
+ public function addNewRegExpBasedRule() : Ruleset
+ {
+ var property : Property = new Property();
+
+ property.name = "expression";
+
+ var rule : Rule = new Rule();
+
+ rule.name = PARAMETERIZED_RULE_NAME;
+ rule.properties.addItem( property );
+ rule.priority = ViolationPriority.INFO;
+ rootRuleset.addRegExpBasedRule( rule );
+
+ return rootRuleset.customRuleset;
+ }
+
+ public function getRootRuleset() : void
+ {
+ new GetRootRulesetEvent( this ).dispatch();
+ }
+
+ public function getCustomRuleset() : void
+ {
+ new GetCustomRulesetEvent( this ).dispatch();
+ }
+
+ public function onReceiveCustomRuleset( ruleset : RootRuleset ) : void
+ {
+ markRulesetAsEntirelyDeleted();
+
+ for each ( var rule : Rule in Ruleset( ruleset.rulesets.getItemAt( 0 ) ).rules )
+ {
+ if ( rule.name != PARAMETERIZED_RULE_NAME )
+ {
+ markRuleAsUsed( rule );
+ }
+ }
+ addCustomRuleset( ruleset );
+ rootRuleset.rulesChanged();
+ dispatchEvent( new Event( ROOT_RULESET_RECEIVED ) );
+ dispatchEvent( new RulesetReceivedEvent( ruleset.rulesets.getItemAt( 0 ) as Ruleset ) );
+ }
+
+ private function addCustomRuleset( ruleset : RootRuleset ) : void
+ {
+ for each ( var rule : Rule in Ruleset( ruleset.rulesets.getItemAt( 0 ) ).rules )
+ {
+ if ( rule.name == PARAMETERIZED_RULE_NAME )
+ {
+ rootRuleset.addRegExpBasedRule( rule );
+ }
+ }
+ }
+
+ private function markRuleAsUsed( ruleToFind : Rule ) : void
+ {
+ for each ( var childRuleset : Ruleset in rootRuleset.rulesets )
+ {
+ for each ( var rule : Rule in childRuleset.rules )
+ {
+ if ( rule.name == ruleToFind.name )
+ {
+ rule.unDelete();
+ return;
+ }
+ }
+ }
+
+ }
+
+ private function markRulesetAsEntirelyDeleted() : void
+ {
+ for each ( var childRuleset : Ruleset in rootRuleset.rulesets )
+ {
+ for each ( var rule : Rule in childRuleset.rules )
+ {
+ rule.remove();
+ }
+ }
+ }
+
+ public function onReceiveRootRuleset( ruleset : RootRuleset ) : void
+ {
+ rulesetReceived = 0;
+ rootRuleset = ruleset;
+
+ for each ( var childRuleset : Ruleset in ruleset.rulesets )
+ {
+ childRuleset.addEventListener( RulesetReceivedEvent.EVENT_NAME, onRulesetReceived );
+ }
+
+ dispatchEvent( new Event( ROOT_RULESET_RECEIVED ) );
+ }
+
+ public function exportRootRuleset() : void
+ {
+ var xml : XML = RootRulesetTranslator.serializeRootRuleset( rootRuleset );
+ var fileReference : FileReference = new FileReference();
+
+ fileReference.save( xml, "pmd.xml" );
+ }
+
+ private function onRulesetReceived( event : RulesetReceivedEvent ) : void
+ {
+ rulesetReceived++;
+ dispatchEvent( event );
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/view/events/SelectedRuleChangeEvent.as
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/view/events/SelectedRuleChangeEvent.as b/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/view/events/SelectedRuleChangeEvent.as
new file mode 100644
index 0000000..6659466
--- /dev/null
+++ b/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/view/events/SelectedRuleChangeEvent.as
@@ -0,0 +1,48 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 com.adobe.ac.pmd.view.events
+{
+ import com.adobe.ac.pmd.model.Rule;
+
+ import flash.events.Event;
+
+ public class SelectedRuleChangeEvent extends Event
+ {
+ public static const EVENT_NAME : String = "selectedRuleChange";
+
+ private var _rule : Rule;
+
+ public function SelectedRuleChangeEvent( rule : Rule )
+ {
+ super( EVENT_NAME );
+
+ _rule = rule;
+ }
+
+ public function get selectedRule() : Rule
+ {
+ return _rule;
+ }
+
+ override public function clone() : Event
+ {
+ return new SelectedRuleChangeEvent( selectedRule );
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/view/renderers/DeleteButtonRenderer.mxml
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/view/renderers/DeleteButtonRenderer.mxml b/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/view/renderers/DeleteButtonRenderer.mxml
new file mode 100644
index 0000000..3b30044
--- /dev/null
+++ b/FlexPMD/flex-pmd-ruleset-creator/src/main/flex/com/adobe/ac/pmd/view/renderers/DeleteButtonRenderer.mxml
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+
+ 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.
+
+-->
+<mx:Button xmlns:mx="http://www.adobe.com/2006/mxml"
+ icon="{ rule.deleted ? UNDELETE_SKIN : DELETE_SKIN }"
+ toolTip="{ rule.deleted ? 'Add this rule (' + rule.shortName + ') to your ruleset' : 'Remove this rule (' + rule.shortName + ') from your ruleset' }"
+ skin="mx.skins.ProgrammaticSkin"
+ buttonMode="true"
+ click="onClick()"
+ mouseChildren="false"
+ useHandCursor="true"
+ >
+
+ <mx:Metadata>
+ [Event(name="ruleRemoved", type="flash.events.Event")]
+ </mx:Metadata>
+
+ <mx:Script>
+ <![CDATA[
+ import com.adobe.ac.pmd.model.Rule;
+
+ import mx.events.ListEvent;
+
+ public static const RULE_REMOVED : String = "ruleRemoved";
+
+ [Bindable]
+ private var rule : Rule;
+
+ [Embed(source='/assets/icon_tool_trash2.png')]
+ private static const DELETE_SKIN : Class;
+
+ [Embed(source='/assets/add-10.png')]
+ private static const UNDELETE_SKIN : Class;
+
+ override public function set data( value : Object ) : void // NO PMD
+ {
+ super.data = value;
+
+ rule = value as Rule;
+ }
+
+ private function onClick() : void
+ {
+ if ( rule )
+ {
+ if ( rule.deleted )
+ {
+ rule.unDelete();
+ }
+ else
+ {
+ rule.remove();
+ }
+
+ dispatchEvent( new Event( RULE_REMOVED, true ) );
+ }
+ }
+ ]]>
+ </mx:Script>
+
+</mx:Button>
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-ruleset-creator/src/main/locales/en_US/Main.properties
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset-creator/src/main/locales/en_US/Main.properties b/FlexPMD/flex-pmd-ruleset-creator/src/main/locales/en_US/Main.properties
new file mode 100644
index 0000000..09697dc
--- /dev/null
+++ b/FlexPMD/flex-pmd-ruleset-creator/src/main/locales/en_US/Main.properties
@@ -0,0 +1,15 @@
+# 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.
+
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-ruleset-creator/src/main/resources/placeholder.txt
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset-creator/src/main/resources/placeholder.txt b/FlexPMD/flex-pmd-ruleset-creator/src/main/resources/placeholder.txt
new file mode 100644
index 0000000..aa36679
--- /dev/null
+++ b/FlexPMD/flex-pmd-ruleset-creator/src/main/resources/placeholder.txt
@@ -0,0 +1,16 @@
+====
+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.
+====
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-ruleset-creator/src/test/flex/AllTests.as
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset-creator/src/test/flex/AllTests.as b/FlexPMD/flex-pmd-ruleset-creator/src/test/flex/AllTests.as
new file mode 100644
index 0000000..3c57f93
--- /dev/null
+++ b/FlexPMD/flex-pmd-ruleset-creator/src/test/flex/AllTests.as
@@ -0,0 +1,42 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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
+{
+ import com.adobe.ac.pmd.model.RuleTest;
+ import com.adobe.ac.pmd.model.RulesetTest;
+ import com.adobe.ac.pmd.services.translators.RuleTranslatorTest;
+ import com.adobe.ac.pmd.services.translators.RulesetTranslatorTest;
+ import com.adobe.ac.pmd.view.RuleSetNavigatorPMTest;
+
+ import flexunit.framework.TestSuite;
+
+ public class AllTests extends TestSuite
+ {
+ public function AllTests()
+ {
+ super();
+
+ addTestSuite( RuleSetNavigatorPMTest );
+ addTestSuite( RulesetTest );
+ addTestSuite( RuleTest );
+ addTestSuite( RuleTranslatorTest );
+ addTestSuite( RulesetTranslatorTest );
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-ruleset-creator/src/test/flex/com/adobe/ac/pmd/model/RulesetTest.as
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset-creator/src/test/flex/com/adobe/ac/pmd/model/RulesetTest.as b/FlexPMD/flex-pmd-ruleset-creator/src/test/flex/com/adobe/ac/pmd/model/RulesetTest.as
new file mode 100644
index 0000000..f70d229
--- /dev/null
+++ b/FlexPMD/flex-pmd-ruleset-creator/src/test/flex/com/adobe/ac/pmd/model/RulesetTest.as
@@ -0,0 +1,72 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 com.adobe.ac.pmd.model
+{
+ import com.adobe.ac.pmd.control.events.GetRulesetContentEvent;
+ import com.adobe.ac.pmd.model.events.RulesetReceivedEvent;
+
+ import flexunit.framework.CairngormEventSource;
+ import flexunit.framework.EventfulTestCase;
+
+ import mx.collections.ArrayCollection;
+
+ public class RulesetTest extends EventfulTestCase
+ {
+ private var model : Ruleset;
+
+ public function RulesetTest()
+ {
+ }
+
+ override public function setUp():void
+ {
+ model = new Ruleset();
+ }
+
+ public function testGetRulesetContent() : void
+ {
+ listenForEvent( CairngormEventSource.instance, GetRulesetContentEvent.EVENT_NAME );
+
+ model.getRulesetContent( "ref" );
+
+ assertEvents();
+ assertEquals( model, GetRulesetContentEvent( lastDispatchedExpectedEvent ).invoker );
+ assertEquals( "ref", GetRulesetContentEvent( lastDispatchedExpectedEvent ).ref );
+ }
+
+ public function testOnReceiveRulesetContent() : void
+ {
+ var receivedRuleset : Ruleset = new Ruleset();
+
+ listenForEvent( model, RulesetReceivedEvent.EVENT_NAME );
+
+ receivedRuleset.name = "name";
+ receivedRuleset.description = "description";
+ receivedRuleset.rules = new ArrayCollection();
+
+ model.onReceiveRulesetContent( receivedRuleset );
+
+ assertEvents();
+ assertEquals( model, RulesetReceivedEvent( lastDispatchedExpectedEvent ).ruleset );
+ assertEquals( receivedRuleset.name, model.name );
+ assertEquals( receivedRuleset.description, model.description );
+ assertEquals( receivedRuleset.rules, model.rules );
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-ruleset-creator/src/test/flex/com/adobe/ac/pmd/services/translators/RuleTranslatorTest.as
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset-creator/src/test/flex/com/adobe/ac/pmd/services/translators/RuleTranslatorTest.as b/FlexPMD/flex-pmd-ruleset-creator/src/test/flex/com/adobe/ac/pmd/services/translators/RuleTranslatorTest.as
new file mode 100644
index 0000000..9e78169
--- /dev/null
+++ b/FlexPMD/flex-pmd-ruleset-creator/src/test/flex/com/adobe/ac/pmd/services/translators/RuleTranslatorTest.as
@@ -0,0 +1,59 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 com.adobe.ac.pmd.services.translators
+{
+ import com.adobe.ac.pmd.model.Rule;
+
+ import flexunit.framework.EventfulTestCase;
+
+ public class RuleTranslatorTest extends EventfulTestCase
+ {
+ public function testSerialize() : void
+ {
+ var rule : Rule = new Rule();
+
+ rule.name = "ruleName";
+
+ var xml : XML = RuleTranslator.serialize( rule );
+
+ assertEquals( <rule since="null" class="ruleName" message="null"><description/><priority>3</priority></rule>, xml );
+
+ rule.since = "0.9";
+ rule.message = "";
+ xml = RuleTranslator.serialize( rule );
+
+ assertEquals( <rule since="0.9" class="ruleName" message=""><description/><priority>3</priority></rule>, xml );
+ }
+
+ public function testDeserialize() : void
+ {
+ var xml : XML = <rule since="0.9" class="ruleName" message=""><description/><priority>3</priority></rule>;
+ var rule : Rule = RuleTranslator.deserialize( xml );
+ var expectedRule : Rule = new Rule();
+
+ expectedRule.name = "ruleName";
+ expectedRule.since = "0.9";
+ expectedRule.message = "";
+
+ assertEquals( expectedRule.name, rule.name );
+ assertEquals( expectedRule.since, rule.since );
+ assertEquals( expectedRule.message, rule.message );
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-ruleset-creator/src/test/flex/com/adobe/ac/pmd/services/translators/RulesetTranslatorTest.as
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset-creator/src/test/flex/com/adobe/ac/pmd/services/translators/RulesetTranslatorTest.as b/FlexPMD/flex-pmd-ruleset-creator/src/test/flex/com/adobe/ac/pmd/services/translators/RulesetTranslatorTest.as
new file mode 100644
index 0000000..e076f8e
--- /dev/null
+++ b/FlexPMD/flex-pmd-ruleset-creator/src/test/flex/com/adobe/ac/pmd/services/translators/RulesetTranslatorTest.as
@@ -0,0 +1,45 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 com.adobe.ac.pmd.services.translators
+{
+ import com.adobe.ac.pmd.model.Rule;
+ import com.adobe.ac.pmd.model.Ruleset;
+
+ import flexunit.framework.EventfulTestCase;
+
+ public class RulesetTranslatorTest extends EventfulTestCase
+ {
+ public function testSerialize() : void
+ {
+ var ruleset : Ruleset = new Ruleset();
+
+ ruleset.name = "ruleName";
+
+ var xml : XML = RulesetTranslator.serializeRootRuleset( ruleset );
+
+ assertEquals( <ruleset name="ruleName" xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd" xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd" xmlns="http://pmd.sf.net/ruleset/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><description/></ruleset>, xml );
+
+ ruleset.rules.addItem( new Rule() );
+
+ xml = RulesetTranslator.serializeRootRuleset( ruleset );
+
+ assertEquals( <ruleset name="ruleName" xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd" xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd" xmlns="http://pmd.sf.net/ruleset/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><description/><rule since="null" class="null" message="null"><description/><priority>3</priority></rule></ruleset>, xml );
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-ruleset-creator/src/test/flex/com/adobe/ac/pmd/view/RuleSetNavigatorPMTest.as
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset-creator/src/test/flex/com/adobe/ac/pmd/view/RuleSetNavigatorPMTest.as b/FlexPMD/flex-pmd-ruleset-creator/src/test/flex/com/adobe/ac/pmd/view/RuleSetNavigatorPMTest.as
new file mode 100644
index 0000000..f41c0c7
--- /dev/null
+++ b/FlexPMD/flex-pmd-ruleset-creator/src/test/flex/com/adobe/ac/pmd/view/RuleSetNavigatorPMTest.as
@@ -0,0 +1,80 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 com.adobe.ac.pmd.view
+{
+ import com.adobe.ac.pmd.control.events.GetRootRulesetEvent;
+ import com.adobe.ac.pmd.model.RootRuleset;
+ import com.adobe.ac.pmd.model.Ruleset;
+ import com.adobe.ac.pmd.model.events.RulesetReceivedEvent;
+
+ import flexunit.framework.CairngormEventSource;
+ import flexunit.framework.EventfulTestCase;
+
+ import mx.collections.ArrayCollection;
+
+ public class RuleSetNavigatorPMTest extends EventfulTestCase
+ {
+ private var model : RuleSetNavigatorPM;
+
+ public function RuleSetNavigatorPMTest()
+ {
+ }
+
+ override public function setUp() : void
+ {
+ model = new RuleSetNavigatorPM();
+ }
+
+ public function testGetRootRuleset() : void
+ {
+ listenForEvent( CairngormEventSource.instance, GetRootRulesetEvent.EVENT_NAME );
+
+ model.getRootRuleset();
+
+ assertEvents();
+ }
+
+ public function testOnReceiveRootRuleset() : void
+ {
+ var emptyRootRuleset : RootRuleset = new RootRuleset();
+
+ listenForEvent( model, RuleSetNavigatorPM.ROOT_RULESET_RECEIVED );
+
+ model.onReceiveRootRuleset( emptyRootRuleset );
+
+ assertEvents();
+ assertEquals( emptyRootRuleset, model.rootRuleset );
+
+ var rootRuleset : RootRuleset = new RootRuleset();
+
+ rootRuleset.rulesets = new ArrayCollection();
+ rootRuleset.rulesets.addItem( new Ruleset() );
+ rootRuleset.rulesets.addItem( new Ruleset() );
+
+ model.onReceiveRootRuleset( rootRuleset );
+
+ assertEquals( rootRuleset, model.rootRuleset );
+
+ for each( var childRuleset : Ruleset in rootRuleset.rulesets )
+ {
+ assertTrue( childRuleset.hasEventListener( RulesetReceivedEvent.EVENT_NAME ) );
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-ruleset/.externalToolBuilders/net.sourceforge.pmd.eclipse.plugin.pmdBuilder.launch
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset/.externalToolBuilders/net.sourceforge.pmd.eclipse.plugin.pmdBuilder.launch b/FlexPMD/flex-pmd-ruleset/.externalToolBuilders/net.sourceforge.pmd.eclipse.plugin.pmdBuilder.launch
new file mode 100644
index 0000000..725ec3c
--- /dev/null
+++ b/FlexPMD/flex-pmd-ruleset/.externalToolBuilders/net.sourceforge.pmd.eclipse.plugin.pmdBuilder.launch
@@ -0,0 +1,25 @@
+<!--
+
+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.
+
+-->
+<?xml version="1.0" encoding="UTF-8"?>
+<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
+<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_BUILDER_ENABLED" value="false"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_DISABLED_BUILDER" value="net.sourceforge.pmd.eclipse.plugin.pmdBuilder"/>
+<mapAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS"/>
+<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
+</launchConfiguration>