<?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>Jayway Team Blog &#187; Rickard Nilsson</title>
	<atom:link href="http://blog.jayway.com/author/rickardnilsson/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.jayway.com</link>
	<description>Sharing Experience</description>
	<lastBuildDate>Sat, 11 Feb 2012 10:33:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Creating a TinyMce plugin for a Wicket application</title>
		<link>http://blog.jayway.com/2009/10/07/creating-a-tinymce-plugin-for-a-wicket-application/</link>
		<comments>http://blog.jayway.com/2009/10/07/creating-a-tinymce-plugin-for-a-wicket-application/#comments</comments>
		<pubDate>Wed, 07 Oct 2009 11:17:19 +0000</pubDate>
		<dc:creator>Rickard Nilsson</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[frameworks]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[tinymce]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[wicket]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=2009</guid>
		<description><![CDATA[I'm currently working on a web project based on Wicket. In this web project there was a request for a web based word processor. TinyMce fits the bill perfectly and as it happens is also integrated in Wicket. Lucky me! Another request required me to make my own plugin for TinyMce. Only, it turned out [...]]]></description>
			<content:encoded><![CDATA[<p>I'm currently working on a web project based on Wicket. In this web project there was a request for a web based word processor. TinyMce fits the bill perfectly and as it happens is also integrated in Wicket. Lucky me! </p>
<p>Another request required me to make my own plugin for TinyMce. Only, it turned out it's not the simplest thing to do, adding a plugin to TinyMce when it's integrated to Wicket. There is almost no help on how to do this so, after having fiddled with this for some time I thought I should help all other plugin creators out there.</p>
<p>Here we'll make a very redundant BoldMakerPlugin just because it's so easy to se it working. I'm assuming that you've got Wicket and also that you have managed to get TinyMce running, if you haven't it's just a matter of cut and paste from <a href="http://wicketstuff.org/confluence/display/STUFFWIKI/wicket-contrib-tinymce">WicketStuffs TinyMce page</a>. </p>
<p>To create a plugin you will need two files. Your plugin java file and an editor_plugin_src.js file. I placed my java file among the other wicket java files under src/main/java and named it BoldMakerPlugin.java. This is what it looks like.</p>
<p><code></p>
<pre class="java">&nbsp;
<span style="color: #a1a100;">import wicket.contrib.tinymce.settings.Plugin;</span>
<span style="color: #a1a100;">import wicket.contrib.tinymce.settings.PluginButton;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> BoldMakerPlugin <span style="color: #000000; font-weight: bold;">extends</span> Plugin<span style="color: #66cc66;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> PluginButton boldMakerButton;
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> BoldMakerPlugin<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">super</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;boldmaker&quot;</span><span style="color: #66cc66;">&#41;</span>;<span style="color: #808080; font-style: italic;">//decides which plugin folder to look in.</span>
		boldMakerButton = <span style="color: #000000; font-weight: bold;">new</span> PluginButton<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;boldmakerbutton&quot;</span>, <span style="color: #000000; font-weight: bold;">this</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> PluginButton getBoldMakerButton<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> boldMakerButton;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;</pre>
<p></code></p>
<p>Next I have to fool the TinyMce main script that my plugins JavaScript file is actually located in the same location as the other scripts. I do this by creating a package structure that is similar to what the TinyMce jar file uses. In this case I create a package called wicket.contrib.tinymce.tiny_mce.plugins.boldmaker and put it in src/main/resources. The last package should be similar to whatever you insert into your superclass from your java file.</p>
<p>In this location I put my editor_plugin_src.js file. Mine looks like this:</p>
<p><CODE></p>
<pre class="javascript">&nbsp;
<span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">var</span> DOM = tinymce.<span style="color: #006600;">DOM</span>;
&nbsp;
	tinymce.<span style="color: #006600;">create</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'tinymce.plugins.BoldMakerPlugin'</span>, <span style="color: #66cc66;">&#123;</span>
		init : <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>ed, url<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #003366; font-weight: bold;">var</span> t = <span style="color: #000066; font-weight: bold;">this</span>, s = <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">&#125;</span>;
&nbsp;
			t.<span style="color: #006600;">editor</span> = ed;
&nbsp;
			<span style="color: #009900; font-style: italic;">// Register commands</span>
			ed.<span style="color: #006600;">addCommand</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'mceBoldMaker'</span>, <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
				<span style="color: #003366; font-weight: bold;">var</span> win, de = DOM.<span style="color: #006600;">doc</span>.<span style="color: #006600;">documentElement</span>;
			<span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
			<span style="color: #009900; font-style: italic;">// Register buttons</span>
			ed.<span style="color: #006600;">addButton</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'boldmakerbutton'</span>, <span style="color: #66cc66;">&#123;</span>title : <span style="color: #3366CC;">'Test'</span>, cmd : <span style="color: #3366CC;">'mceBoldMaker'</span>, image : url + <span style="color: #3366CC;">'/../test/img/example.gif'</span>,
         	   onclick: <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
         	   		ed.<span style="color: #006600;">selection</span>.<span style="color: #006600;">setContent</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;&lt;b&gt;&quot;</span> + ed.<span style="color: #006600;">selection</span>.<span style="color: #006600;">getContent</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> + <span style="color: #3366CC;">&quot;&lt;/b&gt;&quot;</span><span style="color: #66cc66;">&#41;</span>;
            	<span style="color: #66cc66;">&#125;</span>
            <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
	<span style="color: #009900; font-style: italic;">// Register plugin</span>
	tinymce.<span style="color: #006600;">PluginManager</span>.<span style="color: #006600;">add</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'boldmaker'</span>, tinymce.<span style="color: #006600;">plugins</span>.<span style="color: #006600;">BoldMakerPlugin</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;</pre>
<p></CODE></p>
<p>Don't worry if you don't have a button image just yet, it'll be an invisible button with the plugin functionality.</p>
<p>After having done this you should compress it using some kind of JavaScript compressor. I used the one on <a href="http://javascriptcompressor.com/">http://javascriptcompressor.com/</a><br />
Create a new file, name it “editor_plugin.js” and paste your newly compressed JavaScript into it.</p>
<p>I'm adding my plugin in a InPlaceEditComponent instead of in a TextArea but the basics are the same. Add your plugin to the TinyMCESettings, add the settings to the component and then add your component to your page.</p>
<p><CODE></p>
<pre class="java">&nbsp;
InPlaceEditComponent component = <span style="color: #000000; font-weight: bold;">new</span> InPlaceEditComponent<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;editable&quot;</span>, <span style="color: #ff0000;">&quot;
&lt;h4 class='headline' style='color: black; font-weight: bold; font-family: sans-serif; font-size: 80%;'&gt;Insert headline here&lt;/h4&gt;
&nbsp;
&quot;</span> +
<span style="color: #ff0000;">&quot;&lt;span class='standardText' style='color: black; font-family: sans-serif; font-size: 80%;'&gt;Insert text here&lt;/span&gt;&quot;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
TinyMCESettings settings=component.<span style="color: #006600;">getSettings</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
BoldMakerPlugin boldMakerPlugin=<span style="color: #000000; font-weight: bold;">new</span> BoldMakerPlugin<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
settings.<span style="color: #006600;">add</span><span style="color: #66cc66;">&#40;</span>boldMakerPlugin.<span style="color: #006600;">getBoldMakerButton</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>, Toolbar.<span style="color: #006600;">first</span>, <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3APosition+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Position</span></a>.<span style="color: #006600;">before</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
component.<span style="color: #006600;">add</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> InPlaceEditBehavior<span style="color: #66cc66;">&#40;</span>settings, component<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
item.<span style="color: #006600;">add</span><span style="color: #66cc66;">&#40;</span>component<span style="color: #66cc66;">&#41;</span>;
&nbsp;</pre>
<p></CODE></p>
<p>If you've done everything correctly you should now be able to run your application and get your very first plugin working.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2009/10/07/creating-a-tinymce-plugin-for-a-wicket-application/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Setting up a local Subversion repository to use with your Eclipse</title>
		<link>http://blog.jayway.com/2009/04/03/setting-up-a-local-subversion-repository-to-use-with-your-eclipse/</link>
		<comments>http://blog.jayway.com/2009/04/03/setting-up-a-local-subversion-repository-to-use-with-your-eclipse/#comments</comments>
		<pubDate>Fri, 03 Apr 2009 08:33:48 +0000</pubDate>
		<dc:creator>Rickard Nilsson</dc:creator>
				<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[local]]></category>
		<category><![CDATA[repository]]></category>
		<category><![CDATA[subclipse]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=1498</guid>
		<description><![CDATA[I've been spending some time studying a tool for looking at the structure of code bases. After having tried out some of the more basic possibilities I wanted to go for the finer points and study changes between two versions of code to see what effect my changes made. This is where I realise that [...]]]></description>
			<content:encoded><![CDATA[<p>I've been spending some time studying a tool for looking at the structure of code bases. After having tried out some of the more basic possibilities I wanted to go for the finer points and study changes between two versions of code to see what effect my changes made. This is where I realise that I would like to have a local Subversion repository not only for this,  but also for how it would benefit some of my hobby projects. After some googling I found my way to <a href="http://subversion.tigris.org/project_packages.html">http://subversion.tigris.org/project_packages.html</a> where, since I'm on windows, I picked the windows path. I end up downloading the latest version of Subversion:  <a href="http://subversion.tigris.org/files/documents/15/45344/svn-win32-1.6.0.zip">http://subversion.tigris.org/files/documents/15/45344/svn-win32-1.6.0.zip</a></p>
<p>I unpack it in "C:\Program Files\Subversion". To get the commands to work you have to add the  bin to your path. In my case I add "C:\Program Files\Subversion\svn-win32-1.5.6\bin" to the path. After this I open up a  command window and do the following:</p>
<pre lang="text">
mkdir subversionRepository
cd subversionRepository
svnadmin create project1
</pre>
<p>Now, in order to make Subversion work in Eclipse I add http://subclipse.tigris.org/update_1.6.x  to my update sites. After downloading this I restart my Eclipse and go to Window -> Show View ->Other->SVN -> SVN Repositories.<br />
I right click in the opened view and create a new repository location. Instead of writing a http adress in the URL window I now type "file:///C:/subversionRepository/project1". Notice the three forward slashes after "file:".</p>
<p>I now have an empty repository that I want to put my project into so I right click on the repository and add a new remote folder that I call trunk. Right clicking on the trunk I can now import my project by importing the folder that contains the .project file. I hit F5 to refresh the view and can see that the trunk is now filled with my first version of my project.</p>
<p>But I also have to associate the repository version with Eclipse, so now I right click in the Package Explorer and choose Import -> SVN -> Checkout Projects from SVN. I pick my previously created repository, click next, mark the trunk and then click finish. I get a question if I want to overwrite my previously created project with the same name and say ok. I won't need that now that I got a versioning system! </p>
<p>I can now finally continue my studies of the tool I was looking into.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2009/04/03/setting-up-a-local-subversion-repository-to-use-with-your-eclipse/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
	</channel>
</rss>

