<?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>Silveira Neto &#187; development</title>
	<atom:link href="http://silveiraneto.net/tag/development/feed/" rel="self" type="application/rss+xml" />
	<link>http://silveiraneto.net</link>
	<description></description>
	<lastBuildDate>Fri, 09 Mar 2012 04:13:27 +0000</lastBuildDate>
	<language>pt-br</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Capturas de Tela no Android</title>
		<link>http://silveiraneto.net/2010/03/04/capturas-de-tela-no-android/</link>
		<comments>http://silveiraneto.net/2010/03/04/capturas-de-tela-no-android/#comments</comments>
		<pubDate>Thu, 04 Mar 2010 14:36:28 +0000</pubDate>
		<dc:creator>Silveira</dc:creator>
				<category><![CDATA[english]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[Dalvik]]></category>
		<category><![CDATA[Dalvik Debug Monitor Server]]></category>
		<category><![CDATA[ddms]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[mobile]]></category>

		<guid isPermaLink="false">http://silveiraneto.net/?p=3215</guid>
		<description><![CDATA[<a href="http://silveiraneto.net/2010/03/04/capturas-de-tela-no-android/" title="Capturas de Tela no Android"></a>Quando desenvolvendo aplicações móveis para o Android as vezes precisamos obter imagens do dispositivo para comparar com um alguma referencia no computador. Como tirar screenshots no Android? Usar uma aplicação para isso e então passar as imagens para o computador? &#8230;<p class="read-more"><a href="http://silveiraneto.net/2010/03/04/capturas-de-tela-no-android/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://silveiraneto.net/2010/03/04/capturas-de-tela-no-android/" title="Capturas de Tela no Android"></a><p>Quando desenvolvendo aplicações móveis para o Android as vezes precisamos obter imagens do dispositivo para comparar com um alguma referencia no computador. Como tirar screenshots no Android? Usar uma aplicação para isso e então passar as imagens para o computador? Não, há um jeito mais fácil.</p>
<p>Juntamente com o <a title="Android SDK" href="http://developer.android.com/sdk/index.html">Android SDK</a> há uma ferramenta na pasta tools chamada <strong>ddms </strong> (Dalvik Debug Monitor Server). O ddms ainda está pouco integrado com o plugin ADT do Eclipse e também pouco documentado, mas é extremamente útil para várias tarefas como monitoras o heap de memória, threads, processos e, é claro, tirar screenshots.</p>
<p>Para utiliza-lo com todas suas funcionalidades lembre-se de desligar primeiro o Eclipse (porque no momento só pode ter um aplicativo conectado ao ADB), porém que para fins de captura de tela isso não é necessário. Selecione um dispositivo, vá no menu Devices → Screen Capture (Control-S). Pronto, você tem no computador uma captura da tela do dispositivo.</p>
<p style="text-align: center;"><img class="size-full wp-image-3216 aligncenter" title="device" src="http://silveiraneto.net/wp-content/uploads/2010/03/device.png" alt="" width="240" height="320" /></p>
]]></content:encoded>
			<wfw:commentRss>http://silveiraneto.net/2010/03/04/capturas-de-tela-no-android/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Beware the locale</title>
		<link>http://silveiraneto.net/2010/02/22/beware-the-locale/</link>
		<comments>http://silveiraneto.net/2010/02/22/beware-the-locale/#comments</comments>
		<pubDate>Mon, 22 Feb 2010 20:16:12 +0000</pubDate>
		<dc:creator>Silveira</dc:creator>
				<category><![CDATA[english]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[i18n]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JUnit]]></category>
		<category><![CDATA[locale]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[String]]></category>
		<category><![CDATA[teste unitário]]></category>
		<category><![CDATA[toString]]></category>
		<category><![CDATA[unit testing]]></category>

		<guid isPermaLink="false">http://silveiraneto.net/?p=3189</guid>
		<description><![CDATA[<a href="http://silveiraneto.net/2010/02/22/beware-the-locale/" title="Beware the locale"></a>Today I was programming a toString method for a class widely used in a application, using the very useful String.format that provides a C&#8217;s like printf formatter. @Override public String toString&#40;&#41; &#123; return String.format&#40;&#34;VO[a: %.1f, b: %.1f, c: %.1f]&#34;, a, &#8230;<p class="read-more"><a href="http://silveiraneto.net/2010/02/22/beware-the-locale/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://silveiraneto.net/2010/02/22/beware-the-locale/" title="Beware the locale"></a><p style="text-align: center;"><a href="http://www.flickr.com/photos/seeminglee/4139558009/"><img class="aligncenter" src="http://farm3.static.flickr.com/2699/4139558009_4a8c9bea31.jpg" alt="See-ming Lee 李思明 SML Photo" width="500" height="333" /></a></p>
<p>Today I was programming a toString method for a class widely used in a application, using the very useful String.format that provides a C&#8217;s like printf formatter.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@Override
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> toString<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #003399;">String</span>.<span style="color: #006633;">format</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;VO[a: %.1f, b: %.1f, c: %.1f]&quot;</span>, a, b, a<span style="color: #339933;">+</span>b<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>%.1f means a float with one digit precision after the dot separator. The code produces something like:</p>
<pre><strong>VO[a: 1.0, b: 2.0, c: 3.0]</strong></pre>
<p>The problem arises when running a JUnit test on this method wrote using a regular expression to extract the values from the String to test it correctness. We cannot assume that the dot will be always the separator for displaying a float value, in my locale pt_BR would be a comma. So the output would be:</p>
<pre><strong>VO[a: 1,0, b: 2,0, c: 3,0]</strong></pre>
<p>For a predictable output we can set a <a title="Java Locale API" href="http://java.sun.com/j2se/1.4.2/docs/api/java/util/Locale.html">Locale</a> for String.format:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #003399;">Locale</span> en <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Locale</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;en&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #003399;">String</span>.<span style="color: #006633;">format</span><span style="color: #009900;">&#40;</span>en, <span style="color: #0000ff;">&quot;VO[a: %.1f, b: %.1f, c: %.1f]&quot;</span>, a, b, a<span style="color: #339933;">+</span>b<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>So it will always use the dot as common separator. Of course you should follow and respect the localization and internationalization efforts in others moments but in this toString case we are using it internally for debug and unitary testing so we can set a English default locale for safety reasons.</p>
]]></content:encoded>
			<wfw:commentRss>http://silveiraneto.net/2010/02/22/beware-the-locale/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Compiling Inkscape</title>
		<link>http://silveiraneto.net/2008/08/04/compiling-inkscape/</link>
		<comments>http://silveiraneto.net/2008/08/04/compiling-inkscape/#comments</comments>
		<pubDate>Mon, 04 Aug 2008 17:12:34 +0000</pubDate>
		<dc:creator>Silveira</dc:creator>
				<category><![CDATA[english]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[Inkscape]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://silveiraneto.net/?p=1046</guid>
		<description><![CDATA[<a href="http://silveiraneto.net/2008/08/04/compiling-inkscape/" title="Compiling Inkscape"></a>Inkscape is a Open Source vector graphics editor that works with SVG (Scalable Vector Graphics) format, Inkscape works with transparency, gradients, node editing, pattern fills, PNG export, and more. It also runs on Linux, Windows and OSX, those three are &#8230;<p class="read-more"><a href="http://silveiraneto.net/2008/08/04/compiling-inkscape/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://silveiraneto.net/2008/08/04/compiling-inkscape/" title="Compiling Inkscape"></a><p style="text-align: center;"><img class="size-full wp-image-1048 aligncenter" title="inkscape screenshot" src="http://silveiraneto.net/wp-content/uploads/2008/08/inkscape_screenshot.jpg" alt="Inkscape running" width="400" height="320" /></p>
<p><a title="Inkscape.org" href="http://inkscape.org">Inkscape</a> is a Open Source vector graphics editor that works with SVG (Scalable Vector Graphics) format, Inkscape works with transparency, gradients, node editing, pattern fills, PNG export, and more. It also runs on Linux, Windows and OSX, those three are officially supported, but also runs in a broad list of Operational Systems. Is a software that I work daily and frequently is featured <a href="http://silveiraneto.net/tag/svg">here in my blog</a>.</p>
<p>You can download <a title="Inkscape Download" href="http://inkscape.org/download/?lang=en">Inkscape</a> or directly install it via some package system like Apt:</p>
<blockquote><p>sudo apt-get install inskcape</p></blockquote>
<p>But sometimes we need some special feature that is not available yet in the repositories or we want gain speed by having special binaries for our platforms or we want to help developing a new feature. In those cases we need to compile the software by ourself.</p>
<p>Those tips are valid for Ubuntu 8.04 but some part of them can be applied in others distributions. The Inkscape compiled here is the version 0.46+devel so newest versions can have compiling procedures slightly different.</p>
<p><strong>Getting sources via APT.</strong>The easiest way to compile Inkscape on Ubuntu is</p>
<blockquote><p>sudo su<br />
apt-get build-dep inkscape<br />
apt-get source inkscape<br />
cd inkscape<br />
./autogen.sh<br />
./configure<br />
make<br />
make install</p></blockquote>
<p>This will get a version of inkscape, compile it and install. If the first step doesn&#8217;t work well, you can try install all necessary packages by yourself using:</p>
<blockquote><p>sudo apt-get install autotools-dev fakeroot dh-make build-essential autoconf automake intltool libglib2.0-dev libpng12-dev libgc-dev libfreetype6-dev liblcms1-dev libgtkmm-2.4-dev libxslt1-dev libboost-dev libpopt-dev libgsl0ldbl libgsl0-dev libgsl0-dbg libgnome-vfsmm-2.6-dev libssl-dev libmagick++9-dev libwpg-dev</p></blockquote>
<p><strong>Getting sources via SVN.</strong> The recipe I showed above will compile a stable version of Inkscape but not the last version of Inkscape. For that we need to grab the source directly from the Subversion repositories and so compile it.</p>
<p>At your home folder:</p>
<blockquote><p>sudo apt-get install subversion<br />
svn checkout https://inkscape.svn.sourceforge.net/svnroot/inkscape/inkscape/trunk inkscape</p></blockquote>
<p>A alternative way to subversion is getting sources from <a href="http://inkscape.modevia.com/svn-snap/?M=D">here</a>. Those are tarballs built every hour after someone change something in the development repositories. Download a tarball, and decompress it on your home folder.</p>
<p>Install all tools we need to compile Inkscape, this should fits:</p>
<blockquote><p>sudo apt-get install autotools-dev fakeroot dh-make build-essential autoconf automake intltool libglib2.0-dev libpng12-dev libgc-dev libfreetype6-dev liblcms1-dev libgtkmm-2.4-dev libxslt1-dev libboost-dev libpopt-dev libgsl0ldbl libgsl0-dev libgsl0-dbg libgnome-vfsmm-2.6-dev libssl-dev libmagick++9-dev libwpg-dev</p></blockquote>
<p>Enter in the directory with the Inkscape source and do:</p>
<blockquote><p>./autogen.sh<br />
mkdir build<br />
cd build<br />
../configure<br />
make<br />
sudo make install</p></blockquote>
<p>In both cases, grabbing sources via svn or via apt, or can set the place where the software will be installed so it not cause conflicts with you already installed version of Inkscape. You can do that replacing the <em>./configure</em> step with something like:</p>
<blockquote><p>./configure &#8211;prefix=/home/yourname/inkscape</p></blockquote>
<p>If you had some trouble in one of those steps, consider reading some of those other tutorials:</p>
<ul>
<li><a href="http://www.inkscape.org/wiki/index.php/CompilingInkscape">http://www.inkscape.org/wiki/index.php/CompilingInkscape</a></li>
<li><a href="http://www.inkscape.org/wiki/index.php/CompilingUbuntu">http://www.inkscape.org/wiki/index.php/CompilingUbuntu</a></li>
<li><a href="https://help.ubuntu.com/community/CompilingEasyHowTo">https://help.ubuntu.com/community/CompilingEasyHowTo</a></li>
</ul>
<p><small><strong>ps:</strong> thanks guys from the inkscape-devel@lists.sourceforge.net specially heathenx.</small></p>
]]></content:encoded>
			<wfw:commentRss>http://silveiraneto.net/2008/08/04/compiling-inkscape/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Netbeans: your first plugin</title>
		<link>http://silveiraneto.net/2008/02/24/netbeans-your-first-plugin/</link>
		<comments>http://silveiraneto.net/2008/02/24/netbeans-your-first-plugin/#comments</comments>
		<pubDate>Sun, 24 Feb 2008 17:19:17 +0000</pubDate>
		<dc:creator>Silveira</dc:creator>
				<category><![CDATA[english]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[dialogs API]]></category>
		<category><![CDATA[en]]></category>
		<category><![CDATA[helloyou]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[module]]></category>
		<category><![CDATA[netbeans]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://silveiraneto.net/2008/02/24/netbeans-your-first-plugin/</guid>
		<description><![CDATA[<a href="http://silveiraneto.net/2008/02/24/netbeans-your-first-plugin/" title="Netbeans: your first plugin"></a>Netbeans have a modular architecture that permits plug and unplug functionalities easily using the Plugin Manager. It&#8217;s also easy create new plugins using Netbeans itself.http://silveiraneto.net/wp-admin/media-upload.php?post_id=705&#038;TB_iframe=true 1º Step: A new module. Create a New Project clicking in File → New Project. &#8230;<p class="read-more"><a href="http://silveiraneto.net/2008/02/24/netbeans-your-first-plugin/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://silveiraneto.net/2008/02/24/netbeans-your-first-plugin/" title="Netbeans: your first plugin"></a><p>Netbeans have a <a href="http://www.netbeans.org/features/platform/index.html">modular architecture</a> that permits plug and unplug functionalities easily using the <em>Plugin Manager</em>.</p>
<p>It&#8217;s also easy create new plugins using Netbeans itself.http://silveiraneto.net/wp-admin/media-upload.php?post_id=705&#038;TB_iframe=true</p>
<p><span id="more-705"></span></p>
<p><strong>1º Step: A new module.</strong></p>
<p>Create a New Project clicking in <em>File → New Project</em>.</p>
<p style="text-align: center"><img src="http://silveiraneto.net/wp-content/uploads/2008/02/filenewproject.png" alt="Netbeans: File → New Project" /><br />
<small>Figure 1. Creating a new project</small></p>
<p>In <em>Categories</em> select <em>Netbeans Module</em> and in <em>Projects</em> select <em>Module</em>.</p>
<p style="text-align: center"><img src="http://silveiraneto.net/wp-content/uploads/2008/02/newmodule.png" alt="Netbeans New Module" /><br />
<small>Figure 2. Creating a new module.</small></p>
<p>Click in <em>Next</em>.</p>
<p>In the next screen you can choose your module name, like HelloYou. Leave the rest with the default values.</p>
<p style="text-align: center"><img src="http://silveiraneto.net/wp-content/uploads/2008/02/nameandlocation.png" alt="Netbeans Module Name and Location" /><br />
<small>Figure 3. Naming the module.</small></p>
<p>Now you have to set up the package base name, something like <em>org.yourorg.helloyou</em>.</p>
<p style="text-align: center"><img src="http://silveiraneto.net/wp-content/uploads/2008/02/basicmoduleconfiguration.png" alt="Basic Module Configuration" /><br />
<small>Figure 4. Package name.</small></p>
<p>Now you have an empty module, but we need some action.</p>
<p><strong>2º Step: Some action.</strong></p>
<p>Right click in your source package and click in <strong>New → Action</strong>.</p>
<p style="text-align: center"><img src="http://silveiraneto.net/wp-content/uploads/2008/02/newaction.png" alt="Netbeans Add Action" /><br />
<small>Figure 5. Adding some action.</small></p>
<p>Now we&#8217;ll fill another wizard. The first screen is about <em>Action Type</em>. Leave all with the default values (the <em>Always Enabled</em> option) and click <em>Next</em>.</p>
<p style="text-align: center"><img src="http://silveiraneto.net/wp-content/uploads/2008/02/actiontype.png" alt="Action Type" /><br />
<small>Figure 6. Filling the Action Type.</small></p>
<p>In the <em>GUI Registration</em> screen we can set where we want our action appears as an menu item. We chose Menu file and select <em>Global Toolbar Button</em>. In <em>Toolbar</em> select <em>Build</em> and in <em>Position</em> select <em>Profile Main Project&#8230;- HERE</em>. Click <em>Next</em>.</p>
<p style="text-align: center"><img src="http://silveiraneto.net/wp-content/uploads/2008/02/guiregistration.png" alt="Gui Registration" /><br />
<small>Figure 7. GUI Registration.</small></p>
<p>Now we will set up the screen <em>Name, Icon and Location</em>. In <em>Class Name</em> we choose HelloAction. Display Name is how the class will appear in the menu, so we can spaces. You should select an icon in dimensions of 16&#215;16. In the same directory you can put to an icon in 24&#215;24. If your 16&#215;16 icon is named ball.png your 24&#215;24 icon should be ball24.png. Doesn&#8217;t matter where is this icon, it&#8217;ll be automatically copied to the module directory.  Now click <strong>Finish</strong>.</p>
<p style="text-align: center"><img src="http://silveiraneto.net/wp-content/uploads/2008/02/nameiconlocation.png" alt="Netbeans Name Icon and Location." /><br />
<small>Figure 8. Name, Icon and Location.<br />
</small></p>
<p>I used an smile icon from the <a href="http://www.pidgin.im/">Pidgin Project</a>.</p>
<p><img src="http://silveiraneto.net/wp-content/uploads/2008/02/wink.png" alt="Wink" /><img src="http://silveiraneto.net/wp-content/uploads/2008/02/wink24.png" alt="Wink24" /></p>
<p>After clicked in <strong>Finish</strong> your project will look like that:</p>
<p style="text-align: center"><img src="http://silveiraneto.net/wp-content/uploads/2008/02/likethatcode.png" alt="Look like that" /><br />
<small>Figure 9. Empty action.<br />
</small></p>
<p>At this point we can already test our module! For doing that right click in <img src="http://silveiraneto.net/wp-content/uploads/2008/02/puzzle1.png" alt="Puzzle" /><em>HelloYou</em> (puzzle icon) and select <em>Install/Reload in Target Platform</em>. This will open a new instance of Netbeans with your module installed!</p>
<p style="text-align: center"><img src="http://silveiraneto.net/wp-content/uploads/2008/02/firstinstallreloadintargetplatform.png" alt="Install or reload in target platform" /><br />
<small>Figure 10. Install/Reload in target platform.</small></p>
<p>If everything goes alright you will see your icon in the toolbar.</p>
<p style="text-align: center"><img src="http://silveiraneto.net/wp-content/uploads/2008/02/noticethesmile.png" alt="Notice the smile" /><br />
<small>Figure 11. Look! We got an plugin!<br />
</small></p>
<p>But if you click in the smile nothing happens. We have defined no action at all.</p>
<p><strong>3º Step: Creating dependencies.</strong></p>
<p>A module can have dependencies from others modules. When you try to install it, Netbeans will ask about install their modules dependencies. Is much like an Linux package system.</p>
<p>We can see and set up the dependencies in our module properties screen. You can right click <img src="http://silveiraneto.net/wp-content/uploads/2008/02/puzzle1.png" alt="Puzzle" /><em>HelloYou</em> and go in <em>Properties</em>. Another way to do the same is going in <em>File → &#8220;HelloYou&#8221; Properties</em>.</p>
<p style="text-align: center"><img src="http://silveiraneto.net/wp-content/uploads/2008/02/menuhelloyouproperties.png" alt="Helloyou properties" /><br />
<small>Figure 12. File → &#8220;HelloYou&#8221; Properties.<br />
</small></p>
<p>In the <em>Project Properties</em> screen select <em>Libraries</em> in the left side, <em>Categories</em>. There are listed the Java, Netbeans and all <em>Module Dependencies</em> of your module. By default you&#8217;ll see <em>Utilities API</em> module dependence.</p>
<p style="text-align: center"><img src="http://silveiraneto.net/wp-content/uploads/2008/02/projectproperties.png" alt="Netbeans Project Properties" /><br />
<small>Figure 13. Module Dependences.</small></p>
<p>Click in the button <em>Add </em>(that one near the module dependencies). You&#8217;ll see the <em>Add Module Dependency</em> screen where are listed all Netbeans modules.</p>
<p style="text-align: center"><img src="http://silveiraneto.net/wp-content/uploads/2008/02/addmodulesdependencies.png" alt="Netbeans add modules dependency" /><br />
<small>Figure 14. Add Modules Dependency</small></p>
<p>We want add an dependency for the <em>Dialogs API</em>. Type &#8220;dialogs&#8221; in the filter text field.</p>
<p style="text-align: center"><img src="http://silveiraneto.net/wp-content/uploads/2008/02/dialogsapi.png" alt="Netbeans Dialogs API" /><br />
<small>Figure 15. Dialogs API.</small></p>
<p>Select the module <em>Dialogs API</em> and click <em>OK</em>. Now our module have two dependencies: <em>Utilities API</em> and <em>Dialogs API</em>.</p>
<p style="text-align: center"><img src="http://silveiraneto.net/wp-content/uploads/2008/02/moremodulesdependecies.png" alt="More module dependencies" /><br />
<small>Figure 16. Dialogs API and Utilities API. </small></p>
<p>Now for the first time, let&#8217;s right some code.</p>
<p>In HelloAction.java file there&#8217;s a class <em>HelloAction</em> that extends <a href="http://bits.netbeans.org/dev/javadoc/org-openide-util/org/openide/util/actions/CallableSystemAction.html" title="Netbeans API"><em>CallableSystemAction</em></a> (an abstract class). In the method <em>performAction</em>() there&#8217;s nothing but:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//TODO implement action body</span></pre></div></div>

<p>We will rewrite the <em>performAction</em> method:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> performAction<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #003399;">String</span> msg <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Hello Netbeans World!&quot;</span><span style="color: #339933;">;</span>
   <span style="color: #000066; font-weight: bold;">int</span> msgType <span style="color: #339933;">=</span> NotifyDescriptor.<span style="color: #006633;">INFORMATION_MESSAGE</span><span style="color: #339933;">;</span>
   NotifyDescriptor d <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> NotifyDescriptor.<span style="color: #006633;">Message</span><span style="color: #009900;">&#40;</span>msg, msgType<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   DialogDisplayer.<span style="color: #006633;">getDefault</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">notify</span><span style="color: #009900;">&#40;</span>d<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>You will see some warnings (cannot find symbol). Just fix the imports (Ctrl+Shift+I). To test your module, do it again: <img src="http://silveiraneto.net/wp-content/uploads/2008/02/puzzle1.png" alt="Puzzle" /><em>HelloYou</em> → <em>Install/Reload in Target Platform</em>. A new instance of Netbeans will open and you&#8217;ll see our smile face button again. When you click it, Netbeans will show an dialog.</p>
<p style="text-align: center"><img src="http://silveiraneto.net/wp-content/uploads/2008/02/netbeanshelloworld.png" alt="Netbeans Hello World" /><br />
<small>Figure 17. Hello Netbeans World.</small></p>
<p>Let&#8217;s do more. Let&#8217;s talk with the user using <em><a href="http://bits.netbeans.org/dev/javadoc/org-openide-dialogs/org/openide/NotifyDescriptor.InputLine.html">NotifyDescriptor.InputLine</a></em>. Will create an input line dialog, get the user name (if he clicks in Ok) and display a message to him.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> performAction<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    NotifyDescriptor.<span style="color: #006633;">InputLine</span> question<span style="color: #339933;">;</span>
    question <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> NotifyDescriptor.<span style="color: #006633;">InputLine</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Name:&quot;</span>,
        <span style="color: #0000ff;">&quot;What's your name?&quot;</span>,
        NotifyDescriptor.<span style="color: #006633;">OK_CANCEL_OPTION</span>,
        NotifyDescriptor.<span style="color: #006633;">QUESTION_MESSAGE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>DialogDisplayer.<span style="color: #006633;">getDefault</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">notify</span><span style="color: #009900;">&#40;</span>question<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> NotifyDescriptor.<span style="color: #006633;">OK_OPTION</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
         <span style="color: #003399;">String</span> msg <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Hello &quot;</span><span style="color: #339933;">+</span>question.<span style="color: #006633;">getInputText</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;!&quot;</span><span style="color: #339933;">;</span>
         <span style="color: #000066; font-weight: bold;">int</span> msgType <span style="color: #339933;">=</span> NotifyDescriptor.<span style="color: #006633;">INFORMATION_MESSAGE</span><span style="color: #339933;">;</span>
         NotifyDescriptor d <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> NotifyDescriptor.<span style="color: #006633;">Message</span><span style="color: #009900;">&#40;</span>msg, msgType<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
         DialogDisplayer.<span style="color: #006633;">getDefault</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">notify</span><span style="color: #009900;">&#40;</span>d<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Again, <img src="http://silveiraneto.net/wp-content/uploads/2008/02/puzzle1.png" alt="Puzzle" /><em>HelloYou</em> → <em>Install/Reload in Target Platform</em>.</p>
<p>After the new Netbeans instance opens, click in our smile face.</p>
<p style="text-align: center"><img src="http://silveiraneto.net/wp-content/uploads/2008/02/typeyourname.png" alt="Type your name" /></p>
<p style="text-align: center"><img src="http://silveiraneto.net/wp-content/uploads/2008/02/hellosilveira.png" alt="Hello Silveira" /></p>
<p>That&#8217;s it. You made your Netbeans plugin!</p>
<p><strong>Learn more about Netbeans Module Development:</strong></p>
<ul>
<li><strong><a href="http://platform.netbeans.org/tutorials/quickstart-nbm.html">Introduction to NetBeans Module Development Tutorial</a></strong> &#8211; A tutorial I based to make this one.</li>
<li><strong><a href="http://www.netbeans.org/kb/trails/platform.html">NetBeans Modules and Rich-Client Applications Learning Trail</a></strong> &#8211; All resources you need to learn more about Netbeans Platform. Lot&#8217;s of tutorials.</li>
<li><strong><a href="http://plugins.netbeans.org/PluginPortal/">Netbeans Plugin Portal</a></strong> &#8211; You can download and also make a <a href="http://autoupdate.netbeans.org/nbm/nbm_package.html">NBM file</a> to share your plugins with the community.</li>
<li><strong><a href="http://www.amazon.com/Rich-Client-Programming-Plugging-NetBeans/dp/0132354802">Rich Client Programming: Plugging into the NetBeans Platform</a></strong> &#8211;  <a href="http://weblogs.java.net/blog/timboudreau/">Tim Boudreau</a>,  <a href="http://www.ohloh.net/accounts/8184">Jaroslav Tulach</a> and <a href="http://blogs.sun.com/geertjan/">Geertjan Wielenga</a> wrote the best book about Netbeans platform. I&#8217;m reading it.</li>
<li><strong><a href="http://wiki.netbeans.org/NetBeansDeveloperFAQ">Netbeans Developer FAQ</a></strong> &#8211; An big FAQ for person writing NetBeans extension modules (plug-ins), or applications based on the NetBeans platform.</li>
</ul>
<p><strong>added in 02.</strong><strong>27</strong><strong>.08:</strong> now this tutorial is also available in the <a href="http://wiki.netbeans.org/YourFirstNetbeansModule" title="Wiki">Netbeans Wiki</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://silveiraneto.net/2008/02/24/netbeans-your-first-plugin/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
	</channel>
</rss>

