<commit_before><?xml version="1.0" encoding="utf-8"?>
<!--
  //////////////////////////////////////////////////////////////////
  // Copyright (c) 2008-2013 Esri. All Rights Reserved.
  //
  // Licensed 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.
  ////////////////////////////////////////////////////////////////
-->
<s:SkinnableContainer xmlns:fx="http://ns.adobe.com/mxml/2009"
                      xmlns:s="library://ns.adobe.com/flex/spark"
                      creationComplete="this_creationCompleteHandler(event)"
                      minHeight="150"
                      minWidth="450">
    <fx:Script>
        <![CDATA[
            import com.esri.builder.eventbus.AppEvent;
            import com.esri.builder.model.Model;

            import mx.events.CloseEvent;
            import mx.events.FlexEvent;
            import mx.utils.StringUtil;

            private var originalAppName:String;
            [Bindable]
            private var newApplicationName:String;
            [Bindable]
            private var hasValidApplicationName:Boolean;

            public function set applicationName(value:String):void
            {
                newApplicationName = value;
                originalAppName = value;
            }

            private function this_creationCompleteHandler(event:FlexEvent):void
            {
                applicationNameTextInput.text = originalAppName;
                applicationNameTextInput.setFocus()
                applicationNameTextInput.selectAll();
            }

            private function validateApplicationNames():void
            {
                newApplicationName = StringUtil.trim(applicationNameTextInput.text);
                hasValidApplicationName = newApplicationName.length && (newApplicationName != originalAppName);
            }

            private function applicationNameTextInput_enterHandler(event:FlexEvent):void
            {
                if (hasValidApplicationName)
                {
                    dispatchCloseAndRenameExecute();
                }
            }

            private function cancelButton_clickHandler(event:MouseEvent):void
            {
                dispatchEvent(new CloseEvent(CloseEvent.CLOSE));
            }

            private function okButton_clickHandler(event:MouseEvent):void
            {
                dispatchCloseAndRenameExecute();
            }

            private function dispatchCloseAndRenameExecute():void
            {
                dispatchRenameExecute();
                dispatchEvent(new CloseEvent(CloseEvent.CLOSE));
            }

            private function dispatchRenameExecute():void
            {
                if (hasValidApplicationName)
                {
                    Model.instance.status = '';
                    AppEvent.dispatch(AppEvent.RENAME_EXECUTE, newApplicationName);
                }
                else
                {
                    Model.instance.status = resourceManager.getString('BuilderStrings', 'renameApplicationPopUp.noApplicationName');
                }
            }
        ]]>
    </fx:Script>

    <!--background-->
    <s:Rect left="0" right="0" top="0" bottom="0">
        <s:fill>
            <s:SolidColor color="#FFFFFF"/>
        </s:fill>

        <s:stroke>
            <s:SolidColorStroke caps="none"
                                color="#000000"
                                joints="miter"
                                miterLimit="4"
                                weight="2"/>
        </s:stroke>
    </s:Rect>

    <s:Rect height="25"
            left="2" right="2" top="2">
        <s:fill>
            <s:LinearGradient rotation="90">
                <s:GradientEntry alpha="1"
                                 color="#FFFFFF"
                                 ratio="0"/>
                <s:GradientEntry alpha="1.0"
                                 color="#CCCCCC"
                                 ratio="1"/>
            </s:LinearGradient>
        </s:fill>
    </s:Rect>

    <s:Line left="0" right="0" top="26">
        <s:stroke>
            <s:SolidColorStroke caps="none"
                                color="#000000"
                                joints="miter"
                                miterLimit="4"
                                weight="2"/>
        </s:stroke>
    </s:Line>

    <!--content-->
    <s:Label left="10" top="9"
             color="#000000"
             fontSize="14"
             styleName="boldText"
             text="{resourceManager.getString('BuilderStrings', 'renameApplicationPopUp.title')}"
             textAlign="center"
             verticalAlign="middle"/>

    <s:Form horizontalCenter="0" verticalCenter="0">
        <s:FormItem label="{resourceManager.getString('BuilderStrings', 'renameApplicationPopUp.projectName')}">
            <s:TextInput id="applicationNameTextInput"
                         width="200"
                         change="validateApplicationNames()"
                         enter="applicationNameTextInput_enterHandler(event)"
                         maxChars="100"
                         restrict='\u0020-\u007E^/?\\&gt;&lt;:*|"”\^.#&apos;%;@=+'/>
        </s:FormItem>
    </s:Form>

    <s:HGroup bottom="5"
              horizontalAlign="center"
              horizontalCenter="0"
              verticalAlign="middle">
        <s:Button id="okButton"
                  click="okButton_clickHandler(event)"
                  enabled="{hasValidApplicationName}"<commit_msg>Issue #116: Allow period as part of the application name when renaming an app.<commit_after><?xml version="1.0" encoding="utf-8"?>
<!--
  //////////////////////////////////////////////////////////////////
  // Copyright (c) 2008-2013 Esri. All Rights Reserved.
  //
  // Licensed 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.
  ////////////////////////////////////////////////////////////////
-->
<s:SkinnableContainer xmlns:fx="http://ns.adobe.com/mxml/2009"
                      xmlns:s="library://ns.adobe.com/flex/spark"
                      creationComplete="this_creationCompleteHandler(event)"
                      minHeight="150"
                      minWidth="450">
    <fx:Script>
        <![CDATA[
            import com.esri.builder.eventbus.AppEvent;
            import com.esri.builder.model.Model;

            import flashx.textLayout.operations.FlowTextOperation;

            import mx.events.CloseEvent;
            import mx.events.FlexEvent;
            import mx.utils.StringUtil;

            import spark.events.TextOperationEvent;

            private var originalAppName:String;
            [Bindable]
            private var newApplicationName:String;
            [Bindable]
            private var hasValidApplicationName:Boolean;

            public function set applicationName(value:String):void
            {
                newApplicationName = value;
                originalAppName = value;
            }

            private function this_creationCompleteHandler(event:FlexEvent):void
            {
                applicationNameTextInput.text = originalAppName;
                applicationNameTextInput.setFocus()
                applicationNameTextInput.selectAll();
            }

            private function validateApplicationNames():void
            {
                newApplicationName = StringUtil.trim(applicationNameTextInput.text);
                hasValidApplicationName = newApplicationName.length && (newApplicationName != originalAppName);
            }

            private function applicationNameTextInput_enterHandler(event:FlexEvent):void
            {
                if (hasValidApplicationName)
                {
                    dispatchCloseAndRenameExecute();
                }
            }

            private function cancelButton_clickHandler(event:MouseEvent):void
            {
                dispatchEvent(new CloseEvent(CloseEvent.CLOSE));
            }

            private function okButton_clickHandler(event:MouseEvent):void
            {
                dispatchCloseAndRenameExecute();
            }

            private function dispatchCloseAndRenameExecute():void
            {
                dispatchRenameExecute();
                dispatchEvent(new CloseEvent(CloseEvent.CLOSE));
            }

            private function dispatchRenameExecute():void
            {
                if (hasValidApplicationName)
                {
                    Model.instance.status = '';
                    AppEvent.dispatch(AppEvent.RENAME_EXECUTE, newApplicationName);
                }
                else
                {
                    Model.instance.status = resourceManager.getString('BuilderStrings', 'renameApplicationPopUp.noApplicationName');
                }
            }

            private function applicationNameTextInput_changingHandler(event:TextOperationEvent):void
            {
                var operation:FlowTextOperation = event.operation as FlowTextOperation;
                if (operation && operation.hasOwnProperty("text"))
                {
                    var currentText:String = applicationNameTextInput.text;
                    var leading:String = currentText.slice(0, operation.absoluteStart);
                    var trailing:String = currentText.slice(operation.absoluteEnd);
                    var textPreview:String = leading + operation["text"] + trailing;

                    //periods at the start/end, consecutive
                    //illegal filename characters
                    //non-basic Latin Unicode character range
                    var illegalEntries:RegExp = /(?: ^\. | \.$ | \.{2} | [<>:"\/\\|?*#%;@=+] | [^\u0020-\u007F] )/ix;
                    if (illegalEntries.test(textPreview))
                    {
                        event.stopImmediatePropagation();
                        event.preventDefault();
                    }
                }
            }
        ]]>
    </fx:Script>

    <!--background-->
    <s:Rect left="0" right="0" top="0" bottom="0">
        <s:fill>
            <s:SolidColor color="#FFFFFF"/>
        </s:fill>

        <s:stroke>
            <s:SolidColorStroke caps="none"
                                color="#000000"
                                joints="miter"
                                miterLimit="4"
                                weight="2"/>
        </s:stroke>
    </s:Rect>

    <s:Rect height="25"
            left="2" right="2" top="2">
        <s:fill>
            <s:LinearGradient rotation="90">
                <s:GradientEntry alpha="1"
                                 color="#FFFFFF"
                                 ratio="0"/>
                <s:GradientEntry alpha="1.0"
                                 color="#CCCCCC"
                                 ratio="1"/>
            </s:LinearGradient>
        </s:fill>
    </s:Rect>

    <s:Line left="0" right="0" top="26">
        <s:stroke>
            <s:SolidColorStroke caps="none"
                                color="#000000"
                                joints="miter"
                                miterLimit="4"
                                weight="2"/>
        </s:stroke>
    </s:Line>

    <!--content-->
    <s:Label left="10" top="9"
             color="#000000"
             fontSize="14"
             styleName="boldText"
             text="{resourceManager.getString('BuilderStrings', 'renameApplicationPopUp.title')}"
             textAlign="center"
             verticalAlign="middle"/>

    <s:Form horizontalCenter="0" verticalCenter="0">
        <s:FormItem label="{resourceManager.getString('BuilderStrings', 'renameApplicationPopUp.projectName')}">
            <s:TextInput id="applicationNameTextInput"
                         width="200"
                         change="validateApplicationNames()"
                         changing="applicationNameTextInput_changingHandler(event)"
                         enter="applicationNameTextInput_enterHandler(event)"
                         maxChars="100"
                         restrict='\u0020-\u007E^/?\\&gt;&lt;:*|"”\^.#&apos;%;@=+'/>
        </s:FormItem>
    </s:Form>

    <s:HGroup bottom="5"
              horizontalAlign="center"
              horizontalCenter="0"
              verticalAlign="middle">
        <s:Button id="okButton"
                  click="okButton_clickHandler(event)"
                  enabled="{hasValidApplicationName}"
{'fraction_non_alphanumeric': 0.12266745966842614, 'fraction_numerical': 0.014125343840606647, 'mean_word_length': 1.4601316752011704, 'pattern_counts': {'":': 0, '<': 78, '<?xml version=': 2, '>': 76, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 8}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6613153', 'n_tokens_mistral': 3373, 'n_tokens_neox': 3099, 'n_words': 587}