<?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>Developer Papercuts &#187; Papercut</title>
	<atom:link href="http://www.vogella.de/blog/tag/papercut/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.vogella.de/blog</link>
	<description>Tips around Eclipse and Android programming</description>
	<lastBuildDate>Wed, 08 Feb 2012 17:31:00 +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>Eclipse Papercut #7 &#8211; Adding the PDE Plugin creation wizard to the Eclipse toolbar</title>
		<link>http://www.vogella.de/blog/2011/01/13/eclipse-papercut-7-adding-the-pde-plugin-creation-wizard-to-the-eclipse-toolbar/</link>
		<comments>http://www.vogella.de/blog/2011/01/13/eclipse-papercut-7-adding-the-pde-plugin-creation-wizard-to-the-eclipse-toolbar/#comments</comments>
		<pubDate>Thu, 13 Jan 2011 05:39:56 +0000</pubDate>
		<dc:creator>Lars Vogel</dc:creator>
				<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Papercut]]></category>
		<category><![CDATA[PDE]]></category>
		<category><![CDATA[Plug-in]]></category>
		<category><![CDATA[Plugin]]></category>

		<guid isPermaLink="false">http://www.vogella.de/blog/?p=3732</guid>
		<description><![CDATA[Its been a while since I wrote my last Eclipse papercut blog entry.

Today I demonstrate how to add the PDE wizard for creating new plugins to the Eclipse toolbar. I personally create plugin projects on a regular basis therefore it is annoying to select the wizard via File-&#62; New -&#62; blablabla.

I know that I ...]]></description>
			<content:encoded><![CDATA[<p>Its been a while since I wrote my last <a href="http://www.vogella.de/blog/category/papercut/">Eclipse papercut</a> blog entry.</p>
<p>Today I demonstrate how to add the PDE wizard for creating new <a href="http://www.vogella.de/articles/EclipsePlugIn/article.html">plugins</a> to the Eclipse toolbar. I personally create plugin projects on a regular basis therefore it is annoying to select the wizard via File-&gt; New -&gt; blablabla.</p>
<p>I know that I can use Ctrl+3 to select the wizard but I want to be able to select this wizard from the main toolbar. </p>
<p>This is really easily. First find the related Wizard via the <a href="http://www.vogella.de/articles/EclipseCodeAccess/article.html#pluginspy_ui">Plugin Spy</a>. We see that the wizard is called NewPluginProjectWizard.</p>
<p>Then create a <a href="http://www.vogella.de/articles/EclipseCommands/article.html">command</a> with the following default handler.</p>
<pre class="brush: plain; title: ; notranslate">

package de.vogella.plugin.pdewizard.handlers;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.pde.internal.ui.wizards.plugin.NewPluginProjectWizard;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.handlers.HandlerUtil;

public class SampleHandler extends AbstractHandler {
	public Object execute(ExecutionEvent event) throws ExecutionException {
		Shell shell = HandlerUtil.getActiveShell(event);
		WizardDialog wizard = new WizardDialog(shell,
				new NewPluginProjectWizard());
		wizard.open();
		return null;
	}
}
</pre>
<p>Via the <a href="http://www.vogella.de/articles/EclipseCodeAccess/article.html#pluginspy_menu">plugin menu spy</a> you also find quickly a nice place to put your new toolitem to <a href="http://www.vogella.de/articles/EclipseCommands/article.html#toolbar">the main toobar</a> </p>
<pre class="brush: plain; title: ; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;?eclipse version=&quot;3.4&quot;?&gt;
&lt;plugin&gt;
   &lt;extension
         point=&quot;org.eclipse.ui.commands&quot;&gt;
      &lt;command
            defaultHandler=&quot;de.vogella.plugin.pdewizard.handlers.NewPluginWizardHandler&quot;
            id=&quot;de.vogella.plugin.pdewizard.commands.pluginwizard&quot;
            name=&quot;New Plugin Wizard&quot;&gt;
      &lt;/command&gt;
   &lt;/extension&gt;
   &lt;extension
         id=&quot;toolbar:org.eclipse.ui.workbench.file?after=newWizardDropDown&quot;
         point=&quot;org.eclipse.ui.menus&quot;&gt;
      &lt;menuContribution
            locationURI=&quot;toolbar:org.eclipse.ui.workbench.file&quot;&gt;
            &lt;command
                  commandId=&quot;de.vogella.plugin.pdewizard.commands.pluginwizard&quot;
                  icon=&quot;icons/sample.gif&quot;
                  tooltip=&quot;Create new plugin&quot;&gt;
            &lt;/command&gt;
      &lt;/menuContribution&gt;
   &lt;/extension&gt;

&lt;/plugin&gt;
</pre>
<p>If you also add the dependencies to org.eclipse.ui, org.eclipse.pde.ui, org.eclipse.pde.ui.templates and org.eclipse.core.runtime then you should be able to create a new plugin project via your new button in the main toolbar. </p>
<p>I hope this help. You can <a href="http://www.twitter.com/vogella">follow me on Twitter</a>. </p>
<p>EDIT: A simpler solution was proposed by <a href="http://blog.hantsuki.org/">Remy Suen</a>: Since the new/import/export wizards are parameterized commands, the same effect can actually be achieved with pure XML.</p>
<pre class="brush: plain; title: ; notranslate">
&lt;extension
id=&quot;toolbar:org.eclipse.ui.workbench.file?after=newWizardDropDown&quot;
point=&quot;org.eclipse.ui.menus&quot;&gt;
&lt;menuContribution
locationURI=&quot;toolbar:org.eclipse.ui.workbench.file&quot;&gt;
&lt;command
commandId=&quot;org.eclipse.ui.newWizard&quot;&gt;
&lt;parameter
name=&quot;newWizardId&quot;
value=&quot;org.eclipse.pde.ui.NewProjectWizard&quot;&gt;
&lt;/parameter&gt;
&lt;/command&gt;
&lt;/menuContribution&gt;
&lt;/extension&gt;
</pre>
<p class="wp-flattr-button"></p> <p><a href="http://www.vogella.de/blog/?flattrss_redirect&amp;id=3732&amp;md5=085102e12f6265877e50ecfe82220a1b" title="Flattr" target="_blank"><img src="http://www.vogella.de/blog/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.vogella.de/blog/2011/01/13/eclipse-papercut-7-adding-the-pde-plugin-creation-wizard-to-the-eclipse-toolbar/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Eclipse Papercut #6 &#8211; Modifying Mylyn Context</title>
		<link>http://www.vogella.de/blog/2009/10/05/modifying-mylyn-context/</link>
		<comments>http://www.vogella.de/blog/2009/10/05/modifying-mylyn-context/#comments</comments>
		<pubDate>Mon, 05 Oct 2009 06:06:55 +0000</pubDate>
		<dc:creator>Lars Vogel</dc:creator>
				<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Papercut]]></category>
		<category><![CDATA[Commands]]></category>
		<category><![CDATA[JDT]]></category>
		<category><![CDATA[Mylyn]]></category>
		<category><![CDATA[Plugin]]></category>

		<guid isPermaLink="false">http://www.vogella.de/blog/?p=1183</guid>
		<description><![CDATA[Change the Mylyn context in a task]]></description>
			<content:encoded><![CDATA[<p>In this episode of <a href="http://www.vogella.de/blog/2009/06/29/paper-cuts/">Eclipse Papercuts </a> I will demonstrate how to modify the <a href="www.eclipse.org/mylyn/?phpMyAdmin=pGYgzr5q5pQd6aMfv3bd9m1zbi3">Mylyn</a> tasks context. Many thanks to <a href="http://greensopinion.blogspot.com/">David Green </a> for providing sample code to access the Mylyn context.</p>
<p><a href="http://www.vogella.de/articles/Mylyn/article.html">Mylyn</a> makes certain assumptions how the developer works. If you start a new task the Mylyn context is empty and fills up based on the selected files. </p>
<p>Which is not always the way I work. Frequently I know that for my task a whole package (or project) is relevant. I would like to include all classes in this package / project in my Mylyn task.</p>
<p>Ok, lets see how we can solve this papercut. I describe how to add Java classes from a package to an active task.</p>
<p>Create an command which extends the package explorer with a new popup commands as described here <a href="http://www.vogella.de/articles/EclipsePlugIn/article.html#packageexplorer">Extend the package explorer</a>.</p>
<p>Create the command handler with the following coding:</p>
<pre class="brush: java; title: ; notranslate">

package de.vogella.mylyn.tasksmodify.handlers;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.mylyn.context.core.ContextCore;
import org.eclipse.mylyn.context.core.IInteractionContext;
import org.eclipse.mylyn.internal.context.core.ContextCorePlugin;
import org.eclipse.mylyn.monitor.core.InteractionEvent;
import org.eclipse.mylyn.monitor.core.InteractionEvent.Kind;
import org.eclipse.ui.handlers.HandlerUtil;

public class SampleHandler extends AbstractHandler {
	public Object execute(ExecutionEvent event) throws ExecutionException {

		IStructuredSelection selection = (IStructuredSelection) HandlerUtil
				.getActiveMenuSelection(event);
		if (selection ==null){
			return null;
		}

		Object firstElement = selection.getFirstElement();

		if (firstElement instanceof IPackageFragment) {
			IPackageFragment mypackage = (IPackageFragment) firstElement;
			try {
				if (mypackage.getKind() == IPackageFragmentRoot.K_SOURCE){
					 ICompilationUnit[] compilationUnits = mypackage.getCompilationUnits();
					 for (ICompilationUnit iCompilationUnit : compilationUnits) {
						 IInteractionContext activeContext = ContextCore.getContextManager()
							.getActiveContext();
						 ContextCorePlugin.getContextManager().processInteractionEvent(iCompilationUnit,
									Kind.PROPAGATION, InteractionEvent.ID_UNKNOWN, activeContext);
					}
				}
			} catch (JavaModelException e) {
				e.printStackTrace();
			}
		}

		return null;
	}
}
</pre>
<p>Launch your plugin. Create a Mylyn task and select a package in the package explorer. Select your commands and all files of this package will be added to the task.</p>
<p>Further reading: If you want to access other Java Elements, e.g. Project and add them to the Mylyn task this tutorial might help you: <a href="http://www.vogella.de/articles/EclipseJDT/article.html">Eclipse JDT</a>.</p>
<p>Please note that ContextCorePlugin is supposed to be internal API but I did not find another way of accessing the Mylyn tasks. </p>
<p class="wp-flattr-button"></p>]]></content:encoded>
			<wfw:commentRss>http://www.vogella.de/blog/2009/10/05/modifying-mylyn-context/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Eclipse Papercut #5 &#8211; Getting external libraries as bundles</title>
		<link>http://www.vogella.de/blog/2009/09/21/eclipse-plugin-libraries/</link>
		<comments>http://www.vogella.de/blog/2009/09/21/eclipse-plugin-libraries/#comments</comments>
		<pubDate>Mon, 21 Sep 2009 05:45:11 +0000</pubDate>
		<dc:creator>Lars Vogel</dc:creator>
				<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Papercut]]></category>
		<category><![CDATA[bundle]]></category>
		<category><![CDATA[OSGi]]></category>
		<category><![CDATA[Plugin]]></category>

		<guid isPermaLink="false">http://www.vogella.de/blog/?p=548</guid>
		<description><![CDATA[Explains why Eclipse Plugins are improving the definition of the external API and how to get prepared Eclipse plugins via the Springsource bundle repository. ]]></description>
			<content:encoded><![CDATA[<p>In this episode of <a href="http://www.vogella.de/blog/?p=385">Eclipse Papercuts</a> I explain how you get bundles for popolar Java libraries for your  <a href="http://www.vogella.de/articles/EclipsePlugIn/article.html">Eclipse plugin</a> development. </p>
<p>I believe it has advantages to work with plugin projects instead of pure Java projects even if the plan is not to create <a href="http://www.vogella.de/articles/EclipsePlugIn/article.html">Eclipse plugins</a> / <a href="http://www.vogella.de/articles/RichClientPlatform/article.html">RCP applications</a>.  </p>
<p>The core strength of OSGi for this scenario is in my opinion the encapsalation and protection of your inner classes. With <a href="http://www.vogella.de/articles/OSGi/article.html">OSGi bundles </a>  you decide which packages of your project are exported and therefore visible to other projects (via the tab Runtime in the editor for the file plugin.xml).</p>
<p>This leaves only one problem: If you are using externally libraries you <a href="http://www.vogella.de/articles/EclipseJarToPlugin/article.html">have to convert them into bundles / plugins</a>.</p>
<p>I would be nicer to consume pre-packages bundles. As I created a bug <a href="http://sourceforge.net/tracker/?func=detail&amp;aid=2860779&amp;group_id=15255&amp;atid=365255">iText should be OSGi</a> and <a href="http://twitter.com/vogella">tweeted </a>about it <a href="http://aniszczyk.org/">Chris Aniszczyk</a> pointed me to <a href="http://www.eclipse.org/orbit/">Eclipse Orbit</a>.</p>
<p>Eclipse Orbit provides lots of standard libraries already pre-packaged as bundles / plugins. </p>
<p>Lets see how you could get the iText version from Orbit. Check the <a href="http://wiki.eclipse.org/index.php/Orbit_Faq">Orbit FAQ </a>to find out more.</p>
<p>You need to <a href="http://www.vogella.de/articles/EclipseCodeAccess/article.html#versioncontrol_cvs">connect via cvs </a> to the Eclipse cvs repository. CVS URL is :pserver:anonymous@dev.eclipse.org/cvsroot/tools</p>
<p>Navigate to &#8220;org.eclipse.orbit&#8221;. Select &#8220;com.lowagie.text&#8221; and check it out.</p>
<p><a href="http://www.vogella.de/blog/wp-content/uploads/2009/09/orbit10.gif"><img src="http://www.vogella.de/blog/wp-content/uploads/2009/09/orbit10.gif" alt="orbit10" width="388" height="138" class="aligncenter size-full wp-image-1125" /></a></p>
<p>Orbit keeps the different version of the library as cvs branches. Select your project and select Replace With -&gt; Another Branch or Version&#8230;<br />
<a href="http://www.vogella.de/blog/wp-content/uploads/2009/09/orbit20.gif"><img src="http://www.vogella.de/blog/wp-content/uploads/2009/09/orbit20.gif" alt="orbit20" width="586" height="560" class="aligncenter size-full wp-image-1126" /></a></p>
<p><a href="http://www.vogella.de/blog/wp-content/uploads/2009/09/orbit30.gif"><img src="http://www.vogella.de/blog/wp-content/uploads/2009/09/orbit30.gif" alt="orbit30" width="447" height="321" class="aligncenter size-full wp-image-1142" /></a></p>
<p>After selecting the branch and pressing ok the system will download the library and you can start using the library.</p>
<p>In addition to Orbit you can also use the <a href="http://www.springsource.com/repository/app/">Springsource bundle repository</a>. On this website you can search for bundles and download then directly. You can then import them as plugin projects into your workspace. </p>
<p class="wp-flattr-button"></p>]]></content:encoded>
			<wfw:commentRss>http://www.vogella.de/blog/2009/09/21/eclipse-plugin-libraries/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Eclipse Papercut #4 &#8211; Modifying Eclipse PDE default launch configuration</title>
		<link>http://www.vogella.de/blog/2009/07/27/modify-eclipse-pde-code/</link>
		<comments>http://www.vogella.de/blog/2009/07/27/modify-eclipse-pde-code/#comments</comments>
		<pubDate>Mon, 27 Jul 2009 09:29:27 +0000</pubDate>
		<dc:creator>Lars Vogel</dc:creator>
				<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Papercut]]></category>
		<category><![CDATA[PDE]]></category>
		<category><![CDATA[Planet]]></category>

		<guid isPermaLink="false">http://www.vogella.de/blog/?p=603</guid>
		<description><![CDATA[Explains how to change the default PDE launch configuration. Demonstrates how to get and modify Eclipse PDE code.]]></description>
			<content:encoded><![CDATA[<p>In this episode of the <a href="http://www.vogella.de/blog/category/papercut/"> Eclipse Papercut series </a> I will change the default PDE launch configuration. During this process I show how to get and modify Eclipse PDE code.</p>
<p>Lets define the papercut: </p>
<p>One thing I always have to do during <a href="http://www.vogella.de/articles/EclipsePlugIn/article.html">plugin </a>and <a href="http://www.vogella.de/articles/RichClientPlatform/article.html">Eclipse RCP</a> development is to make the following settings in the launch configuration:</p>
<ol>
<li><a href="http://www.vogella.de/articles/RichClientPlatform/article.html#runconfiguration_parameters">add -consoleLog in the arguments tab </a></li>
<li><a href="http://www.vogella.de/articles/RichClientPlatform/article.html#runconfiguration_check">Select the flag &#8220;Validate plug-in automatically prio to launching&#8221; on the plug-ins tab</a></li>
</ol>
<p>This papercut has two dimensions. </p>
<p>The first one is that for everybody who knows about these settings it is not a problem to set them up. It is just time-consuming and error prone. Sometimes I&#8217;m searching why something does not work and then I&#8217;m banging my head because I forgot to set -consoleLog.</p>
<p>The second dimension is that this default launch configuration makes it harder for new plugin and Eclipse RCP developers to get started. I frequently see questions in the Eclipse newsgroup and other places which can be answered by: &#8220;please set -consoleLog&#8221; or &#8220;press the Validate button&#8221;.</p>
<p>So I seek to change the current behavior.</p>
<p>Adding &#8220;-consoleLog&#8221; is easy. Go to preference, select the target platform, select &#8220;Edit&#8221; and add -consoleLog as a argument. </p>
<p><a href="http://www.vogella.de/blog/wp-content/uploads/2009/07/target10.gif"><img src="http://www.vogella.de/blog/wp-content/uploads/2009/07/target10.gif" alt="target10" width="655" height="421" class="alignnone size-full wp-image-647" /></a></p>
<p><a href="http://www.vogella.de/blog/wp-content/uploads/2009/07/target20.gif"><img src="http://www.vogella.de/blog/wp-content/uploads/2009/07/target20.gif" alt="target20" width="664" height="294" class="alignnone size-full wp-image-648" /></a></p>
<p>Of course this does not help the new developers but I come back to this later in this post.</p>
<p>To set the &#8220;Validate plug-in automatically prio to launching&#8221; flag we have to look into Eclipse PDE code. </p>
<p>A launch configuration is contributed by the extension point &#8220;org.eclipse.debug.core.launchConfigurationTypes&#8221;. To search through your existing plugins <a href="http://www.vogella.de/articles/EclipseCodeAccess/article.html#importplugins">import your plugins into a new workspace</a>. A <a href="http://www.vogella.de/articles/EclipseCodeAccess/article.html#search_plugin">plugin search</a> reveals that &#8220;org.eclipse.pde.ui&#8221; contributes such an extension.</p>
<p>Eclipse PDE can be found in the <a href="http://wiki.eclipse.org/index.php/CVS_Howto">Eclipse cvs</a> via the repository path &#8220;/cvsroot/eclipse&#8221;. Search here for the folder &#8220;pde&#8221; which contains the pde plugins. Checkout the plugin &#8220;org.eclipse.pde.ui&#8221;. </p>
<p>Here we find quickly the right extension point.</p>
<p><a href="http://www.vogella.de/blog/wp-content/uploads/2009/07/pde10.gif"><img src="http://www.vogella.de/blog/wp-content/uploads/2009/07/pde10-300x133.gif" alt="pde10" width="300" height="133" class="alignnone size-medium wp-image-656" /></a></p>
<p>After some pocking around the code and some <a href="http://www.vogella.de/articles/EclipseDebugging/article.html">debugging </a> I found the class &#8220;AbstractPluginBlock&#8221; and the method &#8220;setDefaults&#8221;. The change is trivial:</p>
<pre class="brush: java; title: ; notranslate">
public void setDefaults(ILaunchConfigurationWorkingCopy config) {
	config.setAttribute(IPDELauncherConstants.INCLUDE_OPTIONAL, true);
	config.setAttribute(IPDELauncherConstants.AUTOMATIC_ADD, true);
	config.setAttribute(IPDELauncherConstants.AUTOMATIC_VALIDATE, true); // This has changed from false to true
	config.setAttribute(IPDELauncherConstants.SHOW_SELECTED_ONLY, false);
}
</pre>
<p>If you now run Eclipse with this adjusted plugin the flag &#8220;Validate&#8230;&#8221; will be flagged for a new runtime configuration. </p>
<p>Now lets return to the addtion of &#8220;-consoleLog&#8221; to the target platform. I argued earlier that the absence of &#8220;-consoleLog&#8221; makes it harder for beginner to get started with plugin and RCP development. Changing the target platform is not trivial for starters, so the better solution was if was part of the standard code. </p>
<p>We find the relevant code easily with a text seach for an existing launch parameter, e.g. &#8220;-arch&#8221;. The responsible class is &#8220;LaunchArgumentsHelper&#8221; and the method getInitialProgramArguments(). We add &#8220;-consoleLog&#8221; to the following line:</p>
<pre class="brush: java; title: ; notranslate">

StringBuffer buffer = new StringBuffer(&quot;-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog&quot;); //$NON-NLS-1$
</pre>
<p>Thats it. By <a href="http://www.vogella.de/articles/EclipsePlugIn/article.html#deployplugin">deploying the plugin </a>into our Eclipse IDE we have the changed behavior.</p>
<p>I have submitted bugs and attached the patches. <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=272076">Bug Report for &#8220;Validate plug-in automatically prio to launching&#8221;</a> and <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=284704"> Bug Report for -consoleLog</a>.</p>
<p>I hope that these patches will get accepted. If they would be accepted I believe it would be a little easier for new developers to get started.</p>
<p>If someone finds a reason why these settings should not always be the default I would suggest a new PDE <a href="http://www.vogella.de/articles/EclipsePreferences/article.html"> preference page</a> which contains the settings for these launch parameters. </p>
<p class="wp-flattr-button"></p>]]></content:encoded>
			<wfw:commentRss>http://www.vogella.de/blog/2009/07/27/modify-eclipse-pde-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Eclipse Papercut #2 – Changing Eclipse subversive default behavior</title>
		<link>http://www.vogella.de/blog/2009/07/08/modify-eclipse-code/</link>
		<comments>http://www.vogella.de/blog/2009/07/08/modify-eclipse-code/#comments</comments>
		<pubDate>Wed, 08 Jul 2009 21:53:09 +0000</pubDate>
		<dc:creator>Lars Vogel</dc:creator>
				<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Papercut]]></category>
		<category><![CDATA[Plugin]]></category>
		<category><![CDATA[Subversive]]></category>
		<category><![CDATA[svn]]></category>

		<guid isPermaLink="false">http://www.vogella.de/blog/?p=443</guid>
		<description><![CDATA[How to modify the Eclipse source code]]></description>
			<content:encoded><![CDATA[<p><strong>Update: Igor Burilo (Eclipse Subversive developer) was kind enough to accept a modified version of patch developed in this episode. While I&#8217;m very happy about this, this unfortunately renders this example irrelevant . You still might want to read this to see how to checkout code from the Eclipse version control system</strong>.</p>
<p>In this second part of my <a href="http://www.vogella.de/blog/?p=385">7 Paper Cuts in Eclipse</a> I want to change some standard Eclipse code.</p>
<p>This second papercut is a bit more complex as the <a href="http://www.vogella.de/blog/?p=421"> first papercut</a>; I&#8217;m planning to return to simpler examples in the next papercut.</p>
<p>So lets define the papercut:</p>
<p>I frequently create example projects which I share in a svn repository. For related projects I use the mulitproject layout. The standard in subversion is &#8220;Simple Mode &#8211; One project for one repository&#8221;. Therefore everytime I share a project I have to switch in the subversion dialog from &#8220;Simple Mode&#8221; to &#8220;Advanced Mode&#8221;.</p>
<p><a href="http://www.vogella.de/blog/wp-content/uploads/2009/07/papercut1_101.gif"><img src="http://www.vogella.de/blog/wp-content/uploads/2009/07/papercut1_101.gif" alt="papercut1_10" width="572" height="596" class="alignnone size-full wp-image-444" /></a></p>
<p>Nothing big? I agree, hence the perfect example for a papercut. </p>
<p>To change the coding of this dialog we need to find the class which is responsible to display this page. <a href="http://www.vogella.de/articles/EclipseCodeAccess/article.html#pluginspy">Plug-in Spy<a href="http://www.vogella.de/articles/EclipseCodeAccess/article.html#pluginspy"> </a> make this easy via Alt + Shift + F1.</p>
<p><a href="http://www.vogella.de/blog/wp-content/uploads/2009/07/papercut1_201.gif"><img src="http://www.vogella.de/blog/wp-content/uploads/2009/07/papercut1_201.gif" alt="papercut1_20" width="576" height="598" class="alignnone size-full wp-image-445" /></a></p>
<p>Now you need to download the source code of the plug-in &#8221;<br />
org.eclipse.team.svn.ui&#8221;. This plug-in is stored in svn and can get access via subversion itself. The URL for the subversion repository view is: &#8220;http://dev.eclipse.org/svnroot/technology/org.eclipse.subversive&#8221;. See <a href="http://www.vogella.de/articles/EclipseCodeAccess/article.html#versioncontrol"> here </a> to learn how to use svn and cvs to access the Eclipse code</p>
<p>Add this repository in the &#8220;SVN Repository&#8221; view and check-out (download) the plug-ins &#8221;<br />
org.eclipse.team.svn.ui&#8221; and &#8220;org.eclipse.team.svn.core&#8221;. You find them in &#8220;trunk&#8221;.</p>
<p><a href="http://www.vogella.de/blog/wp-content/uploads/2009/07/papercut1_301.gif"><img src="http://www.vogella.de/blog/wp-content/uploads/2009/07/papercut1_301.gif" alt="papercut1_30" width="407" height="482" class="alignnone size-full wp-image-453" /></a></p>
<p>Looking at the coding of SelectProjectNamePage.java changing the selection only requires a few lines to be changed.</p>
<p>I use <a href="http://www.vogella.de/articles/EclipsePreferences/article.html">Eclipse Preferences </a> to remember the last user selection.</p>
<pre class="brush: java; title: ; notranslate">
protected SelectProjectNamePageSimpleModeComposite simpleModeComposite;
	protected ShareProjectNameAdvancedModeComposite advancedModeComposite;
	private static String SELECTION_MODE = &quot;isSimpleMode&quot;;

	public SelectProjectNamePage() {
		super(
			SelectProjectNamePage.class.getName(),
			&quot;&quot;,  //$NON-NLS-1$
			SVNTeamUIPlugin.instance().getImageDescriptor(&quot;icons/wizards/newconnect.gif&quot;)); //$NON-NLS-1$
		Preferences preferences = new ConfigurationScope()
		.getNode(&quot;org.eclipse.team.svn.ui.wizard.shareproject&quot;);
		Preferences preference = preferences.node(&quot;note1&quot;);
		this.isSimpleMode = preference.getBoolean(SELECTION_MODE, true);;
	}
</pre>
<p>and I have to change a few more lines to use isSimpleMode everywhere:</p>
<pre class="brush: java; title: ; notranslate">
this.simpleModeRadionButton.setSelection(this.isSimpleMode);
....
this.advancedModeRadionButton.setSelection(!this.isSimpleMode); // Either or
this.advancedModeRadionButton.addSelectionListener(modeListener);
</pre>
<p>And I have to set the preference in the ModeListener</p>
<pre class="brush: java; title: ; notranslate">

	protected class ModeListener extends SelectionAdapter {
		public void widgetSelected(SelectionEvent e) {
			//change controls area mode
			Button modeButton = (Button) e.widget;
			if (SelectProjectNamePage.this.simpleModeRadionButton == modeButton &amp;&amp; SelectProjectNamePage.this.isSimpleMode == false) {
				SelectProjectNamePage.this.isSimpleMode = true;
				preference.putBoolean(SELECTION_MODE, true);
				enableControlsArea();
			} else if (SelectProjectNamePage.this.advancedModeRadionButton == modeButton &amp;&amp; SelectProjectNamePage.this.isSimpleMode == true) {
				SelectProjectNamePage.this.isSimpleMode = false;
				preference.putBoolean(SELECTION_MODE, false);
				enableControlsArea();
			}
		}
	}
</pre>
<p>The full source code is attached.</p>
<p><a href='http://www.vogella.de/blog/wp-content/uploads/2009/07/SelectProjectNamePage1.zip'>SelectProjectNamePage</a></p>
<p>If you now export these two plug-ins into your runnig Eclipse, this dialog will remember the last selection (Simple vrs. Advanced).</p>
<p>As I hope this behavior is useful to others I created a bug report (with a patch). See <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=282583"> Bug </a>. I hope the subversion programmers will consider this patch (or an improved version of it).</p>
<p>Remember sharing is good. Open Source does not only allow you to solve your issues but it makes it easy to contribute back.</p>
<p>See <a href="http://www.vogella.de/blog/?cat=10"> Eclipse Papercuts</a> to get all posts in this series.</p>
<p class="wp-flattr-button"></p>]]></content:encoded>
			<wfw:commentRss>http://www.vogella.de/blog/2009/07/08/modify-eclipse-code/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

