<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>borisSCHEIMAN // &#187; Flex</title>
	<atom:link href="http://www.bscheiman.org/category/programming/flex/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bscheiman.org</link>
	<description>Lifestyle, hobbies, work, rage...</description>
	<lastBuildDate>Wed, 08 Dec 2010 20:20:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Flex Builder 3: Autogenerating setter/getter</title>
		<link>http://www.bscheiman.org/2009/05/26/flex-builder-3-autogenerating-settergetter/</link>
		<comments>http://www.bscheiman.org/2009/05/26/flex-builder-3-autogenerating-settergetter/#comments</comments>
		<pubDate>Tue, 26 May 2009 17:06:13 +0000</pubDate>
		<dc:creator>Boris</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Personal]]></category>

		<guid isPermaLink="false">http://www.bscheiman.org/?p=109</guid>
		<description><![CDATA[Use the following script with Eclipse Monkey; activate with ALT+9 after selecting variables:

]]></description>
			<content:encoded><![CDATA[<p>Use the following script with <a title="Eclipse Monkey" href="http://www.eclipse.org/proposals/dash/html/maintopic.html">Eclipse Monkey</a>; activate with ALT+9 after selecting variables:</p>
<p><span id="more-109"></span></p>
<pre class="brush: jscript; title: ; notranslate">
/*
 * Menu: Actionscript &gt; Generate Properties
 * Key: M3+9
 * DOM: http://download.eclipse.org/technology/dash/update/org.eclipse.eclipsemonkey.lang.javascript
 */

function main() {
    var editor = editors.activeEditor
    var source = editor.source

    if (editor.selectionRange) {
        var range = editor.selectionRange
        var offset = range.startingOffset

        var text = source.substring(offset, range.endingOffset)
        var result = text.match(/([\w_]+\s*:\s*[\w_]+)/g);

        o = &quot;&quot;

        for (var i = 0, n = result.length; i &lt; n; ++i)
        o += getvar(result[i])

        o += &quot;\n&quot;;

        for (var i = 0, n = result.length; i &lt; n; ++i)
        o += props(result[i])

        o += &quot;\n&quot;

        //  debug(o)
        editor.applyEdit(offset, range.endingOffset - offset, o)
    }
}

String.prototype.trim = function() {
    return this.replace(/^\s+|\s+$/, '');
};

function props(v) {
    var parts = v.split(&quot;:&quot;);

    if (2 != parts.length) return &quot;&quot;;

    parts[0] = parts[0].trim();
    parts[1] = parts[1].trim();

    var s = &quot;\n\t\tpublic function get &quot; + parts[0].replace(&quot;_&quot;, &quot;&quot;) + &quot;() : &quot; + parts[1] + &quot; {&quot;;
    if (parts[0].indexOf(&quot;_&quot;) &lt; 0) s += &quot;\n\t\t\treturn _&quot; + parts[0] + &quot;;&quot;;
    else s += &quot;\n\t\t\treturn &quot; + parts[0] + &quot;;&quot;;
    s += &quot;\n\t\t}\n\n&quot;;

    s += &quot;\t\t[Bindable]\n&quot;;
    s += &quot;\t\tpublic function set &quot; + parts[0].replace(&quot;_&quot;, &quot;&quot;) + &quot;(value : &quot; + parts[1] + &quot;) : void {&quot;;

    if (parts[0].indexOf(&quot;_&quot;) &lt; 0) s += &quot;\n\t\t\t_&quot; + parts[0] + &quot; = value;&quot;;
    else s += &quot;\n\t\t\t&quot; + parts[0] + &quot; = value;&quot;;

    s += &quot;\n\t\t}\n&quot;;

    return s;
}

function getvar(s) {
    if (1 &gt; s.length) return &quot;&quot;;

    if (s.indexOf(&quot;_&quot;) &lt; 0) return &quot;\n\t\tprotected var _&quot; + s + &quot;;&quot;;

    return &quot;\n\t\tprotected var &quot; + s + &quot;;&quot;;
}

function debug(s) {
    Packages.org.eclipse.jface.dialogs.MessageDialog.openInformation(window.getShell(), &quot;Monkey Debugging&quot;, s);
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.bscheiman.org/2009/05/26/flex-builder-3-autogenerating-settergetter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

