<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Eclipse on E</title>
	<atom:link href="http://eclipseone.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://eclipseone.wordpress.com</link>
	<description>For a simpler and faster Eclipse</description>
	<lastBuildDate>Tue, 29 Nov 2011 20:28:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='eclipseone.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Eclipse on E</title>
		<link>http://eclipseone.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://eclipseone.wordpress.com/osd.xml" title="Eclipse on E" />
	<atom:link rel='hub' href='http://eclipseone.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Skip over certain classes when using Step Into in Eclipse&#8217;s debugger</title>
		<link>http://eclipseone.wordpress.com/2011/06/29/skip-over-certain-classes-when-using-step-into-in-eclipses-debugger/</link>
		<comments>http://eclipseone.wordpress.com/2011/06/29/skip-over-certain-classes-when-using-step-into-in-eclipses-debugger/#comments</comments>
		<pubDate>Wed, 29 Jun 2011 07:29:19 +0000</pubDate>
		<dc:creator>Byron</dc:creator>
				<category><![CDATA[Debugging & Launching]]></category>
		<category><![CDATA[Preferences]]></category>

		<guid isPermaLink="false">http://eclipseone.wordpress.com/?p=1573</guid>
		<description><![CDATA[Whenever I use the Step Into feature (F5) in Eclipse&#8217;s debugger, I&#8217;m mainly interested in stepping through code in my own classes, not the ones from external libraries or even Java classes. For example, there&#8217;s almost no reason to ever want to step into Spring&#8217;s code or proxy classes (other than to learn more about [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eclipseone.wordpress.com&amp;blog=10678932&amp;post=1573&amp;subd=eclipseone&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Whenever I use the Step Into feature (F5) in Eclipse&#8217;s debugger, I&#8217;m mainly interested in stepping through code in my  own classes, not the ones from external libraries or even Java classes.</p>
<p>For example, there&#8217;s almost no reason to ever want to step into Spring&#8217;s code or proxy classes (other than to learn more about them or maybe debug a potential bug in Spring). And normally I&#8217;m not interested in Java util classes (eg. ArrayList). This also goes for Hibernate, Apache Commons, Google and many other external libraries.</p>
<p>Fortunately, Eclipse makes it easy to specify which classes to skip by allowing step filters. This makes it easier to focus on your own code and also keeps your editor area clean since Eclipse won&#8217;t be opening classes in separate editors all the time.</p>
<p><span id="more-1573"></span></p>
<h3>Enable Step Filters</h3>
<p>To use step filters, the first step is to enable it. Eclipse comes with some default filters so let&#8217;s start by enabling them all. This will filter all Java classes (ie.<em> java.*</em>) and all Sun classes (ie. <em>sun.*</em>).</p>
<ol>
<li>Go to <strong>Window &gt; Preferences &gt; Java &gt; Debug &gt; Step Filtering</strong>.</li>
<li>Select the option <em>Use Step Filters</em>.</li>
<li>Click <strong>Select All</strong> to enable all the filters.<em></em></li>
<li>Leave the other options below the filter list as-is.</li>
</ol>
<p>Here&#8217;s an example of what it should look like:</p>
<p><a href="http://eclipseone.files.wordpress.com/2011/06/enabling-step-filters2.jpg"><img class="aligncenter size-full wp-image-1581" title="Enabling step filters" src="http://eclipseone.files.wordpress.com/2011/06/enabling-step-filters2.jpg?w=468&#038;h=464" alt="" width="468" height="464" /></a></p>
<p><strong>NB: </strong>Even with step filters enabled, you can still set breakpoints within any of these classes (if you have the source) and Eclipse will still stop at the breakpoint. Step filtering only affects the way that Step Into works.</p>
<p>Also note that Eclipse will still step into your classes if they&#8217;re called from the ignored classes. For example, when you call <em>Collections.sort(List, Comparator)</em> and pass your own <em>Comparator</em> implementation, Eclipse will not step into the sort code, but it will step into your Comparator when it&#8217;s called by the sort code.</p>
<p>If you want to change this behaviour (ie. prevent Eclipse from stopping in your method), then deselect <em>Step through filters.</em> However, I&#8217;d recommend only doing this if you&#8217;ve tried out the default, because most times you&#8217;ll probably want to step through your own code.</p>
<p>The next step is to create some step filters of your own.</p>
<h3>Creating your own step filters</h3>
<p>Once you&#8217;ve enabled step filters, all you have to do is add the classes you want to filter. Let&#8217;s assume that we want to ignore all classes from Spring, especially proxy classes.</p>
<ol>
<li>If you&#8217;re not there already, go to <strong>Window &gt; Preferences &gt; Java &gt; Debug &gt; Step Filtering</strong>.</li>
<li>Click <strong>Add Filter&#8230;</strong> A dialog should appear prompting you to enter a pattern.<strong><br />
</strong></li>
<li>Enter a regular expression for the classes you want to filter in the <em>Pattern to filter</em> field then click <strong>Ok</strong>. In our example, enter <em>org.springframework.* </em>(see image below). It&#8217;s easier to specify the top level package name with an asterix at the end.</li>
<li>Add another filter with the pattern <em>$Proxy*</em> to skip over Spring proxy classes (eg. when using Spring Transactions).</li>
<li>Click <strong>Ok</strong> on the Preferences dialog when you&#8217;re done.</li>
</ol>
<p>Here&#8217;s what the step filter pattern dialog should look like:</p>
<p><a href="http://eclipseone.files.wordpress.com/2011/06/pattern-for-step-filter.jpg"><img class="aligncenter size-full wp-image-1579" title="Pattern for step filter" src="http://eclipseone.files.wordpress.com/2011/06/pattern-for-step-filter.jpg?w=468" alt=""   /></a></p>
<p>Now when you use the debugger, you won&#8217;t be taken into Spring classes when you use Step Into (F5).</p>
<h3>Some ideas for custom filters</h3>
<p>In addition to the Spring classes, you might also want to consider adding the following common libraries to your step filters to make debugging easier:</p>
<ul>
<li>org.apache.*</li>
<li>org.hibernate.*</li>
<li>com.google.*</li>
<li>org.eclipse.*</li>
<li>org.osgi.*</li>
</ul>
<p>The last two are especially useful if you&#8217;re doing Eclipse RCP and/or OSGi development.</p>
<h3>Related Tips</h3>
<ul>
<li><a href="http://eclipseone.wordpress.com/2009/12/28/setup-eclipse-breakpoints-to-stop-only-under-certain-conditions/">Setup Eclipse breakpoints to stop only under certain conditions</a></li>
<li><a href="http://eclipseone.wordpress.com/2010/01/14/rundebug-a-class-in-eclipse-as-a-junit-test-or-java-app-with-a-single-keystroke/">Run/debug a class in Eclipse as a JUnit test or Java app with a single keystroke</a></li>
<li><a href="http://eclipseone.wordpress.com/2010/02/01/generate-static-imports-in-eclipse-on-autocomplete/">Generate static imports in Eclipse on autocomplete for JUnit Assert, StringUtils and others</a></li>
<li><a href="http://eclipseone.wordpress.com/2010/01/15/always-rundebug-the-last-launched-class-instead-of-the-selected-one-in-eclipse/">Always run/debug the last launched class instead of the selected one in Eclipse</a></li>
</ul>
<h3>Share This Tip</h3>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/eclipseone.wordpress.com/1573/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/eclipseone.wordpress.com/1573/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/eclipseone.wordpress.com/1573/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/eclipseone.wordpress.com/1573/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/eclipseone.wordpress.com/1573/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/eclipseone.wordpress.com/1573/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/eclipseone.wordpress.com/1573/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/eclipseone.wordpress.com/1573/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/eclipseone.wordpress.com/1573/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/eclipseone.wordpress.com/1573/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/eclipseone.wordpress.com/1573/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/eclipseone.wordpress.com/1573/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/eclipseone.wordpress.com/1573/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/eclipseone.wordpress.com/1573/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eclipseone.wordpress.com&amp;blog=10678932&amp;post=1573&amp;subd=eclipseone&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://eclipseone.wordpress.com/2011/06/29/skip-over-certain-classes-when-using-step-into-in-eclipses-debugger/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9af99e9ee23204988228aaf14316cbd1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Byron</media:title>
		</media:content>

		<media:content url="http://eclipseone.files.wordpress.com/2011/06/enabling-step-filters2.jpg" medium="image">
			<media:title type="html">Enabling step filters</media:title>
		</media:content>

		<media:content url="http://eclipseone.files.wordpress.com/2011/06/pattern-for-step-filter.jpg" medium="image">
			<media:title type="html">Pattern for step filter</media:title>
		</media:content>
	</item>
		<item>
		<title>The easiest ways to navigate methods in a class using Eclipse keyboard shortcuts</title>
		<link>http://eclipseone.wordpress.com/2011/02/21/the-easiest-ways-to-navigate-methods-in-a-class-using-eclipse-keyboard-shortcuts/</link>
		<comments>http://eclipseone.wordpress.com/2011/02/21/the-easiest-ways-to-navigate-methods-in-a-class-using-eclipse-keyboard-shortcuts/#comments</comments>
		<pubDate>Mon, 21 Feb 2011 08:48:32 +0000</pubDate>
		<dc:creator>Byron</dc:creator>
				<category><![CDATA[Keyboard Shortcuts]]></category>
		<category><![CDATA[Navigation & Browsing]]></category>

		<guid isPermaLink="false">http://eclipseone.wordpress.com/?p=333</guid>
		<description><![CDATA[Java classes can get big and hairy, making it difficult to find the method you&#8217;re looking for when browsing or editing a class. There is no specific order to where methods can be in a class and different developers have different preferences about where to put them. You could use the mouse wheel and scroll [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eclipseone.wordpress.com&amp;blog=10678932&amp;post=333&amp;subd=eclipseone&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Java classes can get big and hairy, making it difficult to find the method you&#8217;re looking for when browsing or editing a class. There is no specific order to where methods can be in a class and different developers have different preferences about where to put them.</p>
<p>You could use the mouse wheel and scroll ferociously until you eventually find the method or you could even use Page Down/Page Up on your keyboard. But these methods can be time-consuming and haphazard, especially when the class has lots of methods or they&#8217;re scattered in an arbitrary order.</p>
<p>Luckily, Eclipse has a number of fast and easy ways to help you navigate methods in a class, especially using the keyboard. I&#8217;ll discuss some of those keyboard shortcuts and also which ones to use when.</p>
<p><span id="more-333"></span></p>
<h3>Quick Outline</h3>
<p>The Quick Outline is basically a scaled-down popup version of the Outline View. The main advantage over the Outline View is that it has a search box that allows you to search for a method.</p>
<p>Here&#8217;s how to use the Quick Outline:</p>
<ul>
<li>Press <strong>Ctrl+O</strong> from anywhere within the class.</li>
<li>Type a search term in the search box and Eclipse will just show all methods that match the search term. By default Eclipse does an exact match search, but you can use wildcards.</li>
<li>Once you see the method you&#8217;re interested in, press <strong>Down</strong> to select the method (if it&#8217;s not selected already).</li>
<li>Press <strong>Enter</strong> once the method is selected. Eclipse will take you directly to the method&#8217;s declaration.</li>
</ul>
<p>This is an example of the popup for Java&#8217;s <em>ArrayList</em>.</p>
<p><a href="http://eclipseone.files.wordpress.com/2011/02/quick-outline-for-arraylist.jpg"><img class="aligncenter size-full wp-image-1521" title="Quick Outline for ArrayList" src="http://eclipseone.files.wordpress.com/2011/02/quick-outline-for-arraylist.jpg?w=468" alt=""   /></a>Searching for <em>*rem</em> will search for all method names that contain the word <em>rem</em>. Here&#8217;s an example:</p>
<p><a href="http://eclipseone.files.wordpress.com/2011/02/quick-outline-with-wildcard-search.jpg"><img class="aligncenter size-full wp-image-1522" title="Quick Outline with Wildcard Search" src="http://eclipseone.files.wordpress.com/2011/02/quick-outline-with-wildcard-search.jpg?w=468" alt=""   /></a></p>
<p><strong>Notes:</strong></p>
<ul>
<li>Sort the view using the the down arrow menu in the top right corner. It makes it easier to find methods by scanning.</li>
<li>Resize the Quick Outline popup to see more methods. Eclipse remembers the size of the popup for the next time you open it.</li>
</ul>
<h3>Next Member &amp; Previous Member</h3>
<p>Another way to move between methods is to use two features called Go To Next Member and Go To Previous Member.</p>
<p>When you press <strong>Ctrl+Shift+Down</strong>, Eclipse moves the cursor to the next method in the class. Pressing <strong>Ctrl+Shift+Up</strong> moves to the previous method.</p>
<p>Here&#8217;s a video to give you a quick example of how these shortcuts work:</p>
<span style="text-align:center; display: block;"><a href="http://eclipseone.wordpress.com/2011/02/21/the-easiest-ways-to-navigate-methods-in-a-class-using-eclipse-keyboard-shortcuts/"><img src="http://img.youtube.com/vi/g9EzbZZvp1U/2.jpg" alt="" /></a></span>
<p>This shortcut works best if you&#8217;re already positioned in a method or if the class has few fields. That&#8217;s because to Eclipse a member can either be a method <em>or</em> a field. If you&#8217;re at the top of the class, you have to move through all the fields before you actually start moving through the methods themselves, a time-consuming process especially for bigger classes with lots of fields.</p>
<p style="text-align:left;">It helps to <a href="http://eclipseone.wordpress.com/2010/10/26/generate-rename-and-delete-getterssetters-in-eclipse/">generate getters and setters at the bottom of the class</a> because you don&#8217;t have to navigate through them to get to the useful methods.</p>
<h3>Open Declaration</h3>
<p>If you&#8217;ve got lots of private methods in your class then Open Declaration might be the best way to navigate between them.</p>
<p>When you&#8217;re positioned on a method call and press <strong>F3</strong>, Eclipse takes you directly to the definition of that method. For example, if you&#8217;re busy in the method <em>process()</em> and your cursor&#8217;s positioned on <em>initProcessing()</em>, pressing <strong>F3</strong> will take you directly to the declaration for that method further down the class.</p>
<p><pre class="brush: java;">
public void process() {
    //Do things...
    initProcessing();
    //...
}
...
private void initProcessing() {
    //Init something...
}
</pre></p>
<p>This feature works very well with <strong>Alt+Left</strong> (Backward History). See the section below for more details about the Backward History.</p>
<h3>Navigating Back to a Previously Viewed Method</h3>
<p>While browsing code, you&#8217;ll often want to return to the previous method you were viewing once you&#8217;re done viewing the method it calls.</p>
<p>To do this, use <strong>Alt+Left</strong> (Backward History) to move back to the last navigation point. This feature isn&#8217;t specific to just methods, but also works for navigating between previously visited editors. But it works great if you&#8217;ve just been browsing methods within a class.</p>
<h3>Quick Mentions</h3>
<ul>
<li>Eclipse&#8217;s <strong>Outline View</strong> also allows easy navigation but mostly with the mouse. You could <a href="http://eclipseone.wordpress.com/2010/02/15/the-fastest-ways-to-navigate-views-in-eclipse-using-the-keyboard/">navigate to the view</a> using <strong>Alt+Shift+Q, O</strong>, and you can move to methods by typing their first letter, but I&#8217;ve found the Quick Outline to be more keyboard friendly. Also, the Outline View doesn&#8217;t support wildcard searches.</li>
<li>You can also use Eclipse&#8217;s <strong>Call Hierarchy</strong> (<strong>Ctrl+Alt+H</strong>) especially if you&#8217;re trying to understand the flow of methods in a class and move between them easily. Knowing how to <a href="http://eclipseone.wordpress.com/2010/02/15/the-fastest-ways-to-navigate-views-in-eclipse-using-the-keyboard/">navigate between views and editors with the keyboard</a> helps a lot since you&#8217;ll be moving between the Call Hierarchy view and editors a lot.</li>
</ul>
<h3>What Should I Use When?</h3>
<ul>
<li>Use Next/Previous Member shortcut if the class is small or you have a good idea of where other methods are in relation to the current method (eg. are they above/below the current method).</li>
<li>Use the Quick Outline if you don&#8217;t know the class too well or there are lots of methods in the class.</li>
<li>Use Open Declaration if you&#8217;re moving between many private methods of the class. It&#8217;s normally the fastest way to move to another private method in the class, but only if you&#8217;re already positioned in a method that calls it.</li>
</ul>
<h3>Related Tips</h3>
<ul>
<li><a href="http://eclipseone.wordpress.com/2009/12/03/find-all-classes-that-overridereimplement-a-method/">Find all classes that override/reimplement a method</a></li>
<li><a href="http://eclipseone.wordpress.com/2009/12/09/jump-to-the-start-and-end-of-methods-loops-blocks-and-xml-tags/">Jump to the start and end of methods, loops, blocks and XML tags</a></li>
<li><a href="http://eclipseone.wordpress.com/2009/12/20/select-entire-strings-and-methods-in-eclipse-with-a-single-keystroke/">Select entire strings and methods in Eclipse with a single keystroke</a></li>
<li><a href="http://eclipseone.wordpress.com/2010/02/10/change-a-methods-arguments-across-multiple-classes-in-eclipse/">Add, remove and reorder a method’s arguments instantly across multiple classes in Eclipse</a></li>
<li><a href="http://eclipseone.wordpress.com/2010/05/25/quick-ways-to-navigate-eclipse-editors-using-the-keyboard/">Quick ways to navigate Eclipse editors using the keyboard</a></li>
<li><a href="http://eclipseone.wordpress.com/2010/02/03/how-to-manage-keyboard-shortcuts-in-eclipse/">How to manage keyboard shortcuts in Eclipse and why you should</a></li>
</ul>
<h3>Share This Tip</h3>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/eclipseone.wordpress.com/333/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/eclipseone.wordpress.com/333/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/eclipseone.wordpress.com/333/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/eclipseone.wordpress.com/333/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/eclipseone.wordpress.com/333/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/eclipseone.wordpress.com/333/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/eclipseone.wordpress.com/333/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/eclipseone.wordpress.com/333/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/eclipseone.wordpress.com/333/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/eclipseone.wordpress.com/333/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/eclipseone.wordpress.com/333/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/eclipseone.wordpress.com/333/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/eclipseone.wordpress.com/333/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/eclipseone.wordpress.com/333/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eclipseone.wordpress.com&amp;blog=10678932&amp;post=333&amp;subd=eclipseone&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://eclipseone.wordpress.com/2011/02/21/the-easiest-ways-to-navigate-methods-in-a-class-using-eclipse-keyboard-shortcuts/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9af99e9ee23204988228aaf14316cbd1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Byron</media:title>
		</media:content>

		<media:content url="http://eclipseone.files.wordpress.com/2011/02/quick-outline-for-arraylist.jpg" medium="image">
			<media:title type="html">Quick Outline for ArrayList</media:title>
		</media:content>

		<media:content url="http://eclipseone.files.wordpress.com/2011/02/quick-outline-with-wildcard-search.jpg" medium="image">
			<media:title type="html">Quick Outline with Wildcard Search</media:title>
		</media:content>
	</item>
		<item>
		<title>Generate, rename and delete getters/setters instantly in Eclipse</title>
		<link>http://eclipseone.wordpress.com/2010/10/26/generate-rename-and-delete-getterssetters-in-eclipse/</link>
		<comments>http://eclipseone.wordpress.com/2010/10/26/generate-rename-and-delete-getterssetters-in-eclipse/#comments</comments>
		<pubDate>Tue, 26 Oct 2010 07:53:12 +0000</pubDate>
		<dc:creator>Byron</dc:creator>
				<category><![CDATA[Editing]]></category>
		<category><![CDATA[Refactoring]]></category>

		<guid isPermaLink="false">http://eclipseone.wordpress.com/?p=1440</guid>
		<description><![CDATA[Despite the arguments and debates about getters and setters in Java, the fact is that they&#8217;re a reality and you have to work with them. But managing getters and setters is a time-consuming effort. Creating a getter/setter for 5 fields in a class can take minutes, renaming one is error-prone and deleting one is just [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eclipseone.wordpress.com&amp;blog=10678932&amp;post=1440&amp;subd=eclipseone&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Despite the arguments and debates about getters and setters in Java, the fact is that they&#8217;re a reality and you have to work with them.</p>
<p>But managing getters and setters is a time-consuming effort. Creating a getter/setter for 5 fields in a class can take minutes, renaming one is error-prone and deleting one is just plain inconvenient.</p>
<p>There are options like <a href="http://projectlombok.org/">Project Lombok</a> (that implicitly creates getters/setters without the need to code them) and you could avoid getters/setters altogether by redesigning your classes.</p>
<p>But these options aren&#8217;t always available, so it&#8217;s a good thing Eclipse has some handy features for managing getters and setters. Combined with the <a href="http://eclipseone.wordpress.com/2010/03/08/generate-class-constructors-in-eclipse-based-on-fields-or-superclass-constructors/">ability to generate constructors based on fields</a>, you can get the boilerplate code out of the way in seconds and get on with the real coding.</p>
<p><span id="more-1440"></span></p>
<h3>Generate getters and setters</h3>
<p>To generate getters and setters, do the following:</p>
<ol>
<li>Create the fields you want in the class then press <strong>Alt+Shift+S, R</strong>. A dialog will pop up allowing you to choose the fields you want to generate getters and setters for.</li>
<li>Click <strong>Select All</strong> to create getters/setters for all fields. Of course you can choose individual fields as required.</li>
<li>Change <strong>Insertion point</strong> to <em>Last Member</em>. This tells Eclipse that you want to put the methods at the bottom of the class. This is normally the best option for me as I want them out of the way.</li>
<li>Click <strong>Ok</strong>. Eclipse will create the getters and setters for you.</li>
</ol>
<p style="text-align:left;">Here&#8217;s an example of what the dialog should look like.</p>
<p style="text-align:left;"><a href="http://eclipseone.files.wordpress.com/2010/10/generate-getters-and-setters-dialog1.jpg"><img class="aligncenter size-full wp-image-1454" title="Generate Getters and Setters Dialog" src="http://eclipseone.files.wordpress.com/2010/10/generate-getters-and-setters-dialog1.jpg?w=468&#038;h=503" alt="" width="468" height="503" /></a></p>
<p><strong>Note:</strong> By default, Eclipse doesn&#8217;t allow you to create a setter for a <em>final</em> field &#8211; the setter just doesn&#8217;t appear in the dialog. This can be a nuisance, especially if you&#8217;ve enabled autoformatting to make fields <em>final</em> where possible. To bypass this restriction, enable the checkbox <strong>Allow setters for final fields</strong> on the dialog. The setter for the field will now appear in the dialog. Once you click Ok, Eclipse will remove the <em>final</em> keyword from the field and generate the setter. Eclipse also remembers this setting.</p>
<p><strong></strong>Another way to add just a single getter/setter is to position your cursor anywhere in the class (outside any method), start typing either &#8220;get&#8221; or &#8220;set&#8221; and press <strong>Ctrl+Space</strong>. The options on the autocomplete menu will include any getters/setters of fields that don&#8217;t have any defined yet. This is a quick way to create a single getter/setter but isn&#8217;t geared for bulk creation.</p>
<p>Here&#8217;s an example of how the autocomplete looks:</p>
<p><a href="http://eclipseone.files.wordpress.com/2010/10/generate-getter-using-autocomplete.jpg"><img class="aligncenter size-full wp-image-1455" title="Generate Getter using Autocomplete" src="http://eclipseone.files.wordpress.com/2010/10/generate-getter-using-autocomplete.jpg?w=468" alt=""   /></a></p>
<h3>Rename getters and setters</h3>
<p>The easiest way to rename getters/setters is to use the Rename refactoring.</p>
<p>Place your cursor on the field name (anywhere in the class, not just the declaration) and press <strong>Alt+Shift+R</strong>. If you&#8217;re using in-place rename (the default), then just rename the field, press Enter and Eclipse will rename the corresponding getters and setters as well.</p>
<p>If you&#8217;ve chosen to use the classic Refactor dialog (see note below) then make sure you enable <em>Rename getter</em> and <em>Rename setter</em> on the Rename dialog.</p>
<p><a href="http://eclipseone.files.wordpress.com/2010/10/rename-field-and-getters-and-settersdialog.jpg"><img class="aligncenter size-full wp-image-1456" title="Rename Field and Getters and SettersDialog" src="http://eclipseone.files.wordpress.com/2010/10/rename-field-and-getters-and-settersdialog.jpg?w=468" alt=""   /></a><strong>Note: </strong>You can choose to do renaming using the traditional Rename dialog by going to <strong>Window &gt; Preferences &gt; Java </strong>and unchecking <strong>Rename in editor without  dialog</strong>. I prefer using the Rename dialog as it highlights the whole name by default making it easier to overwrite and I have the option of not renaming the getters and setters if I don&#8217;t want to. The Eclipse default these days is to use the new in-place renaming.<strong></strong></p>
<p>Although Eclipse will rename the getter/setter, it won&#8217;t rename the  argument passed to the setter method. If you want consistency, you can navigate to that method (eg. using <strong>Ctrl+O</strong>) and rename the argument yourself.</p>
<h3>Delete getters and setters</h3>
<p>Deleting getters and setters isn&#8217;t as straightforward as just deleting the field in the editor. However, you can delete a field and its getters/setters from the Outline view.</p>
<p><a href="http://eclipseone.wordpress.com/2010/02/15/the-fastest-ways-to-navigate-views-in-eclipse-using-the-keyboard/">Open the Outline view</a> (<strong>Alt+Shift+Q, O</strong>), select the field you want to delete and press <strong>Delete</strong> (or right-click, Delete). Eclipse will ask you whether you want to delete the getters/setters as well. Just choose <em>Yes To All</em> and they will be removed.</p>
<p>You need to have fields visible in the Outline view to use this feature (ie. untoggle the Hide Fields button <a href="http://eclipseone.files.wordpress.com/2010/10/hide-fields-toggle.jpg"><img class="alignnone size-full wp-image-1462" title="Hide Fields Toggle" src="http://eclipseone.files.wordpress.com/2010/10/hide-fields-toggle.jpg?w=468" alt=""   /></a>).</p>
<p><a href="http://eclipseone.files.wordpress.com/2010/10/delete-getters-and-setters-from-outline-view.jpg"><img class="aligncenter size-full wp-image-1460" title="Delete Getters and Setters from Outline View" src="http://eclipseone.files.wordpress.com/2010/10/delete-getters-and-setters-from-outline-view.jpg?w=468&#038;h=295" alt="" width="468" height="295" /></a></p>
<p>You can select multiple fields simultaneously. And you can delete individual getters/setters (excluding the field) by just selecting the getter/setter and pressing <strong>Delete</strong>.</p>
<h3>Related Tips</h3>
<ul>
<li><a href="http://eclipseone.wordpress.com/2010/03/08/generate-class-constructors-in-eclipse-based-on-fields-or-superclass-constructors/">Generate class constructors in Eclipse based on fields or superclass constructors</a></li>
<li><a href="http://eclipseone.wordpress.com/2010/02/10/change-a-methods-arguments-across-multiple-classes-in-eclipse/">Add, remove and reorder a method’s arguments instantly across multiple classes in Eclipse</a></li>
<li><a href="http://eclipseone.wordpress.com/2009/12/09/jump-to-the-start-and-end-of-methods-loops-blocks-and-xml-tags/">Jump to the start and end of methods, loops, blocks and XML tags</a></li>
<li><a href="http://eclipseone.wordpress.com/2010/02/15/the-fastest-ways-to-navigate-views-in-eclipse-using-the-keyboard/">The fastest ways to navigate views in Eclipse using the keyboard</a></li>
<li><a href="http://eclipseone.wordpress.com/2010/07/21/convert-nestedanonymous-classes-into-top-level-classes-using-eclipse-refactoring/">Convert nested/anonymous classes into top level classes using Eclipse refactoring</a></li>
</ul>
<h3>Share This Tip</h3>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/eclipseone.wordpress.com/1440/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/eclipseone.wordpress.com/1440/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/eclipseone.wordpress.com/1440/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/eclipseone.wordpress.com/1440/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/eclipseone.wordpress.com/1440/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/eclipseone.wordpress.com/1440/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/eclipseone.wordpress.com/1440/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/eclipseone.wordpress.com/1440/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/eclipseone.wordpress.com/1440/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/eclipseone.wordpress.com/1440/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/eclipseone.wordpress.com/1440/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/eclipseone.wordpress.com/1440/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/eclipseone.wordpress.com/1440/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/eclipseone.wordpress.com/1440/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eclipseone.wordpress.com&amp;blog=10678932&amp;post=1440&amp;subd=eclipseone&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://eclipseone.wordpress.com/2010/10/26/generate-rename-and-delete-getterssetters-in-eclipse/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9af99e9ee23204988228aaf14316cbd1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Byron</media:title>
		</media:content>

		<media:content url="http://eclipseone.files.wordpress.com/2010/10/generate-getters-and-setters-dialog1.jpg" medium="image">
			<media:title type="html">Generate Getters and Setters Dialog</media:title>
		</media:content>

		<media:content url="http://eclipseone.files.wordpress.com/2010/10/generate-getter-using-autocomplete.jpg" medium="image">
			<media:title type="html">Generate Getter using Autocomplete</media:title>
		</media:content>

		<media:content url="http://eclipseone.files.wordpress.com/2010/10/rename-field-and-getters-and-settersdialog.jpg" medium="image">
			<media:title type="html">Rename Field and Getters and SettersDialog</media:title>
		</media:content>

		<media:content url="http://eclipseone.files.wordpress.com/2010/10/hide-fields-toggle.jpg" medium="image">
			<media:title type="html">Hide Fields Toggle</media:title>
		</media:content>

		<media:content url="http://eclipseone.files.wordpress.com/2010/10/delete-getters-and-setters-from-outline-view.jpg" medium="image">
			<media:title type="html">Delete Getters and Setters from Outline View</media:title>
		</media:content>
	</item>
		<item>
		<title>The fastest ways to open editors in Eclipse using the keyboard</title>
		<link>http://eclipseone.wordpress.com/2010/09/20/the-fastest-ways-to-open-editors-in-eclipse-using-the-keyboard/</link>
		<comments>http://eclipseone.wordpress.com/2010/09/20/the-fastest-ways-to-open-editors-in-eclipse-using-the-keyboard/#comments</comments>
		<pubDate>Mon, 20 Sep 2010 07:26:59 +0000</pubDate>
		<dc:creator>Byron</dc:creator>
				<category><![CDATA[Editors]]></category>
		<category><![CDATA[Keyboard Shortcuts]]></category>
		<category><![CDATA[Navigation & Browsing]]></category>

		<guid isPermaLink="false">http://eclipseone.wordpress.com/?p=1273</guid>
		<description><![CDATA[Something you do a lot in Eclipse is open files such as classes, XML files and property files in editors. But using the mouse to hunt through the Package Explorer folder hierarchy takes a long time, especially if you forgot where the files are located. The problem gets worse the more projects and files you [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eclipseone.wordpress.com&amp;blog=10678932&amp;post=1273&amp;subd=eclipseone&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Something you do a lot in Eclipse is open files such as classes, XML files and property files in editors. But using the mouse to hunt through the Package Explorer folder hierarchy takes a long time, especially if you forgot where the files are located. The problem gets worse the more projects and files you have in your workspace, so there must be a better way of opening editors.</p>
<p>Luckily, Eclipse has a number of ways to open editors easily using the keyboard. Couple these with <a href="http://eclipseone.wordpress.com/2010/05/25/quick-ways-to-navigate-eclipse-editors-using-the-keyboard/">oodles of keyboard shortcuts to navigate between editors</a> once you&#8217;ve opened them, and you&#8217;ve got enough tools to stay away from the mouse and make coding go a lot faster. I&#8217;ll discuss some of the more efficient options and then give a summary of when to use which method.</p>
<p><span id="more-1273"></span></p>
<h3>Open Resources</h3>
<p>Probably the most effective way to open a file in an editor is by using the Open Resource functionality. If there&#8217;s one feature you want to use every day, it&#8217;s this one.</p>
<p>When you press <strong>Ctrl+Shift+R</strong>, you get a dialog that allows you to search all the files currently in your workspace. You can find <em>any </em>files such as classes, XML, property, HTML and other files. Here&#8217;s an example:</p>
<p><a href="http://eclipseone.files.wordpress.com/2010/09/open-resource-dialog.jpg"><img class="aligncenter size-full wp-image-1388" title="Open Resource Dialog" src="http://eclipseone.files.wordpress.com/2010/09/open-resource-dialog.jpg?w=468" alt=""   /></a></p>
<p>To find a file, start typing its name and once it&#8217;s selected, just press <strong>Enter</strong>. Eclipse filters the files as you type, so you can immediately see  when your file appears in the list.  You can also move through the list by pressing the <strong>Up</strong> and <strong>Down</strong> arrows, even if the search box has the focus (ie. you don&#8217;t have to use Tab to move to the list).</p>
<p>The search box supports wildcards, so you could type <em>*Dao</em> to search for all files that contain the word <em>Dao</em>. If you don&#8217;t include wildcard characters (* and ?) then Eclipse will do a direct match of the string you enter to the files in your workspace. The search isn&#8217;t case-sensitive, though, so you don&#8217;t have to worry about camel case.</p>
<h3>Open Types</h3>
<p>When you press <strong>Ctrl+Shift+T</strong>, you get a dialog similar to the Open Resources dialog called the Open Types dialog. Here&#8217;s an example:</p>
<p style="text-align:center;"><a href="http://eclipseone.files.wordpress.com/2010/09/open-type-dialog.jpg"><img class="aligncenter size-full wp-image-1389" title="Open Type Dialog" src="http://eclipseone.files.wordpress.com/2010/09/open-type-dialog.jpg?w=468" alt=""   /></a></p>
<p>Like the Open Resource dialog it shows a list of resources that match your search text. However, it <em>only</em> shows Java types (eg. classes, enums, interfaces, etc). It doesn&#8217;t show any other files in the workspace such as HTML or XML files. The other difference is that it shows Java types both from your workspace <em>and</em> referenced libraries, including 3rd party and Java library classes.</p>
<p>Similar to the Open Resources dialog, this dialog also supports wildcard characters but goes one step further by supporting camel case searches. For example, if you want to search for <em>NullPointerException</em>, you can type <em>NPE</em> and Eclipse will filter the types based on their case-sensitive camel case names. Note that typing <em>Npe</em> will not return the same results, as the camel cases are different.</p>
<p>The Open Types dialog is ideal for quickly opening 3rd party classes or built-in Java classes such as <em>ArrayList</em> or <em>String</em>.</p>
<h3>Open Declaration &amp; Implementation (Quick Type Hierarchy)</h3>
<p>If you press <strong>F3</strong> (Open Declaration) while your cursor is on a Java type such as a class, method or field, Eclipse will open the type&#8217;s declaration (if it&#8217;s not opened yet) and navigate you to the definition. In the example below, pressing F3 on the method <em>length()</em> will open <em>String.class</em> and take you to the implementation of <em>String.length()</em>.</p>
<p><pre class="brush: java; gutter: false;">
String name = &quot;&quot;;
if (name.length() &gt; 0) {...}
</pre></p>
<p>But Open Declaration isn&#8217;t always enough. For example, if you call the method on an interface, eg. the <em>add() </em>method of <em>List</em>, F3 will take you to the interface <em>List </em>and position you on the <em>add() </em>method. But often you actually want to go to one of the implementations of <em>add()</em>, eg. <em>ArrayList.add()</em>.</p>
<p>In that case you can view the Quick Type Hierarchy (<strong>Ctrl+T</strong>) on the method and choosing the specific implementation you want. I discuss Quick Type Hierarchy in more detail in <a href="http://eclipseone.wordpress.com/2009/12/03/find-all-classes-that-overridereimplement-a-method/">how to find all methods that override a certain method of a class</a>, but here&#8217;s a quick example of what you&#8217;ll see:</p>
<p><a href="http://eclipseone.files.wordpress.com/2009/12/quick-type-hierarchy.jpg"><img class="aligncenter size-full wp-image-253" title="Quick Type Hierarchy Example" src="http://eclipseone.files.wordpress.com/2009/12/quick-type-hierarchy.jpg?w=468" alt="Quick Type Hierarchy Example"   /></a></p>
<p><strong>Bonus Tip:</strong> To access the mouse equivalent of these 2 features, hold down <strong>Ctrl </strong>and hover over the element you want. Eclipse will underline it, allowing you to click on the element. If the element doesn&#8217;t have additional implementations, Eclipse will take you automatically to its sole declaration. If there are one or more implementations, you&#8217;ll get a popup menu offering you the option of opening either the declaration or implementation, eg:</p>
<p><a href="http://eclipseone.files.wordpress.com/2010/09/open-declaration-or-implementation-hover-popup.jpg"><img class="aligncenter size-full wp-image-1394" title="Open Declaration or Implementation Hover Popup" src="http://eclipseone.files.wordpress.com/2010/09/open-declaration-or-implementation-hover-popup.jpg?w=468" alt=""   /></a></p>
<h3>Quick mentions</h3>
<p>Here are some more features that you may find useful from time to time.</p>
<ul>
<li><em>Open Super Implementation</em>: When you&#8217;re positioned in a subclass that overrides a superclass method, you can choose <strong>Navigate &gt; Open Super Implementation</strong> from the application menu to go to the super&#8217;s method. You can <a href="http://eclipseone.wordpress.com/2010/02/03/how-to-manage-keyboard-shortcuts-in-eclipse/">configure a shortcut</a> for this by looking for the command <em>Open Super Implementation</em> in the Keys preference dialog. Alternatively, press <strong>Alt-N, S</strong> to invoke it via menu mnemonics (although this is not as reliable as configuring a shortcut).</li>
<li><em>Open Type Hierarchy</em>: The Type Hierarchy shows you a tree  representing a class&#8217;s hierarchy (ie. superclasses and subclasses). Just  press <strong>F4</strong> while positioned on a class name and the Type Hierarchy  view will open. From there you can move directly to certain classes and  methods in the type hierarchy.</li>
<li><em>Recent Files</em>: If you&#8217;ve accidentally closed a file you still need, just press <strong>Alt+F</strong> and then the number of the file as indicated on the File menu. Eg. Alt+F, 1 will take you to the most recently opened file.</li>
<li><em>Show In</em>: By using shortcuts to open editors, you don&#8217;t need to rely on the Package Explorer that much anymore, so it&#8217;s a good candidate for <a href="http://eclipseone.wordpress.com/2009/12/10/use-fast-views-to-maximise-screen-space/">becoming a fast view, which could save you lots of screen space</a>. But if you want to open the current editor in the Package Explorer, just press <strong>Alt+Shift+W, P</strong>, and Eclipse will <a href="http://eclipseone.wordpress.com/2010/01/06/instantly-show-a-classfile-in-the-packageproject-explorer-in-eclipse/">instantly navigate to the file in the Package Explorer</a>.</li>
</ul>
<h3>Which one should I use when?</h3>
<p>If you don&#8217;t have enough time to learn all of these, here&#8217;s a quick guide on where to start and when to use them.</p>
<ul>
<li>For fast, everyday, general usage, use Open Resource. I use it to open all resources, even Java types because the list only shows classes in my workspace which makes the search go faster. Definitely worthwile to learn.</li>
<li>If you&#8217;re browsing code (eg. during a code review or to debug it) then Open Declaration and Quick Type Hierarchy are very useful especially when combined with Open Resource.</li>
<li>If you want to view class hierarchies (eg. subclasses or superclasses), use Open Type Hierarchy,  Open Super Implementation or Open Quick Hierarchy. They&#8217;re not only a  good way of opening resources but also of getting an idea of your class  hierarchy and hence your design.</li>
<li>If you&#8217;re trying to open 3rd party classes or Java built-in classes, first try using Open Declaration (F3), because the chances are you&#8217;ll probably be in the part of the code that uses these classes. However, if you&#8217;re not anywhere near the code, use Open Type.</li>
</ul>
<p>Also keep in mind that you can change the keyboard shortcut on any of the features above by checking out <a href="http://eclipseone.wordpress.com/2010/02/03/how-to-manage-keyboard-shortcuts-in-eclipse/">how to manage keyboard shortcuts</a> and using the appropriate command names to search for and modify the key<em></em>.</p>
<h3>Related Tips</h3>
<ul>
<li><a href="http://eclipseone.wordpress.com/2010/05/25/quick-ways-to-navigate-eclipse-editors-using-the-keyboard/">Quick ways to navigate Eclipse editors using the keyboard</a></li>
<li><a href="http://eclipseone.wordpress.com/2010/02/15/the-fastest-ways-to-navigate-views-in-eclipse-using-the-keyboard/">The fastest ways to navigate views in Eclipse using the keyboard</a></li>
<li><a href="http://eclipseone.wordpress.com/2010/01/08/switch-and-close-editors-faster-with-the-keyboard-using-eclipses-quick-switch-editor/">Switch and close editors faster with the keyboard using Eclipse’s Quick Switch Editor</a></li>
<li><a href="http://eclipseone.wordpress.com/2009/12/03/find-all-classes-that-overridereimplement-a-method/">Find all classes that override/reimplement a method</a></li>
<li><a href="http://eclipseone.wordpress.com/2010/01/06/instantly-show-a-classfile-in-the-packageproject-explorer-in-eclipse/">Instantly show a class/file in the Package/Project Explorer in Eclipse</a></li>
<li><a href="http://eclipseone.wordpress.com/2010/02/03/how-to-manage-keyboard-shortcuts-in-eclipse/">How to manage keyboard shortcuts in Eclipse and why you should</a></li>
</ul>
<h3>Share This Tip</h3>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:570px;width:1px;height:1px;overflow:hidden;">http://eclipseone.wordpress.com/2009/12/03/find-all-classes-that-overridereimplement-a-method/</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/eclipseone.wordpress.com/1273/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/eclipseone.wordpress.com/1273/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/eclipseone.wordpress.com/1273/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/eclipseone.wordpress.com/1273/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/eclipseone.wordpress.com/1273/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/eclipseone.wordpress.com/1273/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/eclipseone.wordpress.com/1273/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/eclipseone.wordpress.com/1273/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/eclipseone.wordpress.com/1273/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/eclipseone.wordpress.com/1273/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/eclipseone.wordpress.com/1273/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/eclipseone.wordpress.com/1273/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/eclipseone.wordpress.com/1273/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/eclipseone.wordpress.com/1273/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eclipseone.wordpress.com&amp;blog=10678932&amp;post=1273&amp;subd=eclipseone&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://eclipseone.wordpress.com/2010/09/20/the-fastest-ways-to-open-editors-in-eclipse-using-the-keyboard/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9af99e9ee23204988228aaf14316cbd1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Byron</media:title>
		</media:content>

		<media:content url="http://eclipseone.files.wordpress.com/2010/09/open-resource-dialog.jpg" medium="image">
			<media:title type="html">Open Resource Dialog</media:title>
		</media:content>

		<media:content url="http://eclipseone.files.wordpress.com/2010/09/open-type-dialog.jpg" medium="image">
			<media:title type="html">Open Type Dialog</media:title>
		</media:content>

		<media:content url="http://eclipseone.files.wordpress.com/2009/12/quick-type-hierarchy.jpg" medium="image">
			<media:title type="html">Quick Type Hierarchy Example</media:title>
		</media:content>

		<media:content url="http://eclipseone.files.wordpress.com/2010/09/open-declaration-or-implementation-hover-popup.jpg" medium="image">
			<media:title type="html">Open Declaration or Implementation Hover Popup</media:title>
		</media:content>
	</item>
		<item>
		<title>Configure those annoying tooltips in Eclipse to only popup on request</title>
		<link>http://eclipseone.wordpress.com/2010/08/24/configure-tooltips-in-eclipse-to-only-popup-on-request/</link>
		<comments>http://eclipseone.wordpress.com/2010/08/24/configure-tooltips-in-eclipse-to-only-popup-on-request/#comments</comments>
		<pubDate>Tue, 24 Aug 2010 07:30:29 +0000</pubDate>
		<dc:creator>Byron</dc:creator>
				<category><![CDATA[Annoyances]]></category>
		<category><![CDATA[Maximise Screen Space]]></category>
		<category><![CDATA[Navigation & Browsing]]></category>
		<category><![CDATA[Preferences]]></category>

		<guid isPermaLink="false">http://eclipseone.wordpress.com/?p=1340</guid>
		<description><![CDATA[Whenever you hover over any piece of code in Eclipse, it pops up a tooltip that displays more information about the item, such as its declaration, variable values or Javadoc information, as in the example below. Although useful at times, this becomes extremely annoying after a while, especially when you&#8217;re using your mouse to browse [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eclipseone.wordpress.com&amp;blog=10678932&amp;post=1340&amp;subd=eclipseone&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Whenever you hover over any piece of code in Eclipse, it pops up a tooltip that displays more information about the item, such as its declaration, variable values or  Javadoc information, as in the example below.</p>
<p><a href="http://eclipseone.files.wordpress.com/2010/08/unwanted-hover-tooltip-in-eclipse.jpg"><img class="aligncenter size-full wp-image-1349" title="Unwanted Hover Tooltip in Eclipse" src="http://eclipseone.files.wordpress.com/2010/08/unwanted-hover-tooltip-in-eclipse.jpg?w=468&#038;h=185" alt="" width="468" height="185" /></a></p>
<p>Although useful <em>at times</em>, this becomes extremely annoying after a while, especially when you&#8217;re using your mouse to browse some code. Popup after popup of unwanted information keeps obscuring your view of the code, leading to some lengthy expletives and big productivity loss. It&#8217;s useful information, but not every time<em> all the time</em>, almost like your car&#8217;s GPS giving you directions to 10 different places at once while you&#8217;re still parked in the driveway.</p>
<p>Luckily there is a way to alleviate the problem and all it takes is changing some preferences in Eclipse. We don&#8217;t want to completely disable tooltips (they can be useful), so I&#8217;ll show you how to tell Eclipse to bring up the tooltips only when you request them.</p>
<p><span id="more-1340"></span></p>
<h3>Show tooltips only on request</h3>
<p>To tell Eclipse to only show tooltips on request, do the following:</p>
<ol>
<li>Go to <strong>Window &gt; Preferences &gt; Java &gt; Editor &gt; Hovers</strong>.</li>
<li>Select the <em>Source</em> item in the list. Make sure the entire row is highlighted and that the checkbox is  selected.</li>
<li>Move focus to the <em>Pressed key modifier while hovering</em> field, positioning the cursor at the end of the default value <em>Shift</em>.  Press and release <strong>Ctrl</strong>. The value should now  read <em>Shift+Ctrl</em>. If you made a mistake, just clear the field by pressing <strong>Backspace</strong> or <strong>Delete</strong> and try again.</li>
<li>Select the <em>Combined Hover</em> item in the list.</li>
<li>Move focus to the <em>Pressed key modifier while hovering</em> field and press <strong>Shift</strong>. The value should now read <em>Shift</em>.</li>
<li>Click Ok to accept the changes.</li>
</ol>
<p>The preferences should look something like this:</p>
<p><a href="http://eclipseone.files.wordpress.com/2010/08/hovers-preferences.jpg"></a><a href="http://eclipseone.files.wordpress.com/2010/08/hovers-preferences1.jpg"><img class="aligncenter size-full wp-image-1357" title="Hovers Preferences" src="http://eclipseone.files.wordpress.com/2010/08/hovers-preferences1.jpg?w=468&#038;h=290" alt="" width="468" height="290" /></a></p>
<p>You should now notice the following:</p>
<ul>
<li>If you want to show the Javadoc or the declaration of some element hold down <strong>Shift</strong> while hovering over the element.</li>
<li>Variable values won&#8217;t popup automatically anymore. To show a variable&#8217;s value in debug mode, press <strong>Shift</strong> and hover over the variable. This is probably the only time when it&#8217;s a bit of a hassle to press Shift, but the pros totally outweigh the cons here as I view variable values a lot less than the number of times annoying tooltips appear.</li>
<li>If you want to show a quick preview of a method&#8217;s code, press <strong>Ctrl+Shift</strong> and hover over the method. This is a nice feature combined with the tooltip enrichment Eclipse provides, so you can view a method&#8217;s code in a scrollable tooltip without having to navigate to the method and back again.</li>
</ul>
<h3>Other options &#8211; configure, disable or use the keyboard</h3>
<p>You can, of course, choose your own modifier keys in Preferences, but these are the ones I found that work the best, especially given that <strong>Ctrl</strong> and a click is a way to go to an element&#8217;s declaration or implementation in Eclipse. I&#8217;ve found <strong>Shift</strong> to conflict the least with existing features and easy enough to use on a frequent basis. Keep in mind that 2 hovers can&#8217;t share the same modifier key (which is why we reassigned the Source hover to use <strong>Shift+Ctrl</strong>).</p>
<p>You can also disable tooltips completely by deselecting the <em>Combined Hover</em> checkbox in the preference above, but I&#8217;ve found the Shift key to be a nice middle ground so keep it enabled.</p>
<p>To get similar information using the keyboard, press <strong>F2</strong> while the cursor&#8217;s positioned on the code. To show variable values in debug mode, press <strong>Ctrl+Shift+D</strong>. A nice tip if you&#8217;ve disabled tooltips completely.</p>
<h3>Related tips</h3>
<ul>
<li><a href="http://eclipseone.wordpress.com/2010/05/05/add-comments-and-javadocs-in-eclipse-with-a-single-keystroke/">Add comments and Javadocs in Eclipse with a single keystroke</a></li>
<li><a href="http://eclipseone.wordpress.com/2010/01/15/always-rundebug-the-last-launched-class-instead-of-the-selected-one-in-eclipse/">Always  run/debug the last launched class instead of the selected one in  Eclipse</a></li>
<li><a href="http://eclipseone.wordpress.com/2009/12/10/use-fast-views-to-maximise-screen-space/">Use Fast Views to maximise screen space</a></li>
<li>Also check out <a href="http://eclipseone.wordpress.com/category/preferences/">many other preferences</a> you can configure and <a href="http://eclipseone.wordpress.com/category/annoyances/">annoyances you can remove</a> to make Eclipse easier to use.</li>
</ul>
<h3>Share this tip</h3>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/eclipseone.wordpress.com/1340/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/eclipseone.wordpress.com/1340/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/eclipseone.wordpress.com/1340/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/eclipseone.wordpress.com/1340/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/eclipseone.wordpress.com/1340/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/eclipseone.wordpress.com/1340/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/eclipseone.wordpress.com/1340/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/eclipseone.wordpress.com/1340/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/eclipseone.wordpress.com/1340/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/eclipseone.wordpress.com/1340/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/eclipseone.wordpress.com/1340/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/eclipseone.wordpress.com/1340/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/eclipseone.wordpress.com/1340/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/eclipseone.wordpress.com/1340/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eclipseone.wordpress.com&amp;blog=10678932&amp;post=1340&amp;subd=eclipseone&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://eclipseone.wordpress.com/2010/08/24/configure-tooltips-in-eclipse-to-only-popup-on-request/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9af99e9ee23204988228aaf14316cbd1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Byron</media:title>
		</media:content>

		<media:content url="http://eclipseone.files.wordpress.com/2010/08/unwanted-hover-tooltip-in-eclipse.jpg" medium="image">
			<media:title type="html">Unwanted Hover Tooltip in Eclipse</media:title>
		</media:content>

		<media:content url="http://eclipseone.files.wordpress.com/2010/08/hovers-preferences1.jpg" medium="image">
			<media:title type="html">Hovers Preferences</media:title>
		</media:content>
	</item>
		<item>
		<title>Convert nested/anonymous classes into top level classes using Eclipse refactoring</title>
		<link>http://eclipseone.wordpress.com/2010/07/21/convert-nestedanonymous-classes-into-top-level-classes-using-eclipse-refactoring/</link>
		<comments>http://eclipseone.wordpress.com/2010/07/21/convert-nestedanonymous-classes-into-top-level-classes-using-eclipse-refactoring/#comments</comments>
		<pubDate>Wed, 21 Jul 2010 07:34:08 +0000</pubDate>
		<dc:creator>Byron</dc:creator>
				<category><![CDATA[Editing]]></category>
		<category><![CDATA[Refactoring]]></category>

		<guid isPermaLink="false">http://eclipseone.wordpress.com/?p=1300</guid>
		<description><![CDATA[Nested classes, eg. anonymous classes, are often more convenient than creating separate classes, especially when working with something like the Command pattern or event listeners. For example: But there comes a point when the nested class becomes so bulky that code becomes unreadable. And sometimes you want to reuse the same class in another place [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eclipseone.wordpress.com&amp;blog=10678932&amp;post=1300&amp;subd=eclipseone&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://en.wikipedia.org/wiki/Nested_class">Nested classes</a>, eg. anonymous classes, are often more convenient than creating separate classes, especially when working with something like the Command pattern or event listeners. For example:</p>
<p><pre class="brush: java; gutter: false;">
JButton button = new JButton();
button.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
        // ... Do something useful
    }
});
</pre></p>
<p>But there comes a point when the nested class becomes so bulky that code becomes unreadable. And sometimes you want to reuse the same class in another place &#8211; something that&#8217;s difficult with anonymous inner classes.</p>
<p>The answer would be to change the nested class into a top level public class (or a first-class citizen, if you like) that exists in its own file (eg. <em>SomethingUsefulActionListener.java</em>). But doing this manually can take a lot of time and is error-prone.</p>
<p>Eclipse has a couple of refactorings and quick fixes that help to make the job a lot easier. Converting an anonymous inner class to a top level class requires two refactorings only and will take you a couple of seconds instead of minutes. A (named) inner class takes only one refactoring. And passing arguments to the new class is also easy if you use some of Eclipse&#8217;s Quick Fixes.</p>
<p><span id="more-1300"></span></p>
<h3>Convert the anonymous inner class into a top level</h3>
<p>Converting an anonymous inner class into a top level class takes 2 main refactorings: Convert it to a nested class and then convert the nested class to a top level class. If you have a nested class (ie. a named inner class), then just start at step 4.</p>
<p>Here are the instructions, but there&#8217;s also a video below with a quick example.</p>
<p>1. Convert the anonymous inner class to a nested class by standing on the anonymous class&#8217; constructor and choosing <strong>Refactor &gt; Convert Anonymous Class to Nested&#8230;</strong> (or <strong>Alt-T, O</strong>). A dialog prompting for the nested class details will appear.</p>
<p><a href="http://eclipseone.files.wordpress.com/2010/07/convert-anonymous-class-to-nested1.jpg"><img class="aligncenter size-full wp-image-1316" title="Convert Anonymous Class to Nested" src="http://eclipseone.files.wordpress.com/2010/07/convert-anonymous-class-to-nested1.jpg?w=468" alt=""   /></a></p>
<p>2. Enter a name for the new nested class, select <em>public</em> as the visibility and deselect <em>Declare the nested type as final</em>.</p>
<p><a href="http://eclipseone.files.wordpress.com/2010/07/enter-name-for-nested-class.jpg"><img class="aligncenter size-full wp-image-1311" title="Enter Name for Nested Class" src="http://eclipseone.files.wordpress.com/2010/07/enter-name-for-nested-class.jpg?w=468" alt=""   /></a></p>
<p>3. Click Ok. Eclipse will create a new nested class inside the enclosing class and leave the constructor call where the anonymous class used to be declared.</p>
<p>4. Now convert the nested class into a top level class by standing on the class name and choosing <strong>Refactor &gt; Convert Member Type to Top Level&#8230; </strong>(or <strong>Alt-T, V</strong>). A dialog prompting for the enclosing instance name will appear.</p>
<p><a href="http://eclipseone.files.wordpress.com/2010/07/convert-member-type-to-top-level2.jpg"><img class="aligncenter size-full wp-image-1317" title="Convert Member Type to Top Level" src="http://eclipseone.files.wordpress.com/2010/07/convert-member-type-to-top-level2.jpg?w=468" alt=""   /></a></p>
<p>5. (Optional) If you want to access the enclosing class within your new class, then enter a name for the field that will be assigned to the class. I normally leave this blank.</p>
<p>6. Click Ok. Eclipse will create the new class (<em>UsefulAction.java</em>) and move it to a new file in the same package.</p>
<p>Here&#8217;s a quick video to show you how easy this is. In the example, we&#8217;ll convert an anonymous inner <em>ActionListener</em> class to a class called <em>UsefulAction.java</em>.</p>
<span style="text-align:center; display: block;"><a href="http://eclipseone.wordpress.com/2010/07/21/convert-nestedanonymous-classes-into-top-level-classes-using-eclipse-refactoring/"><img src="http://img.youtube.com/vi/mi7AbuUYJ6g/2.jpg" alt="" /></a></span>
<h3>Passing arguments from the enclosing class into the new class</h3>
<p>What about when the nested class accesses fields in the enclosing class? How do you easily get private fields from the enclosing class into the new top level class?</p>
<p>There isn&#8217;t a one-shot way to do this, but there are techniques to make it go a bit faster. One trick is via the following steps:</p>
<ol>
<li>First make sure you&#8217;ve created a named nested class (steps 1-3).</li>
<li>Copy and paste the relevant private fields of the enclosing class into the nested class.</li>
<li><a href="http://eclipseone.wordpress.com/2010/03/08/generate-class-constructors-in-eclipse-based-on-fields-or-superclass-constructors/">Automatically generate a constructor for the nested class</a> based on the fields you just copied (<strong>Alt+Shift+S, O</strong>).</li>
<li><a href="http://eclipseone.wordpress.com/2010/03/10/navigate-and-fix-errors-amp-warnings-in-a-class-with-eclipse-keyboard-shortcuts/">Navigate to the constructor error</a> (<strong>Ctrl+.</strong>) where the nested class is instantiated and add the fields to the constructor.</li>
</ol>
<p>The easiest way to see how this works is to watch the following video. In the example, I&#8217;ll pass the fields <em>name</em> and <em>address</em> to the new class<strong></strong>.</p>
<span style="text-align:center; display: block;"><a href="http://eclipseone.wordpress.com/2010/07/21/convert-nestedanonymous-classes-into-top-level-classes-using-eclipse-refactoring/"><img src="http://img.youtube.com/vi/KqdhqhsBIMk/2.jpg" alt="" /></a></span>
<p>Related Tips</p>
<ul>
<li><a href="http://eclipseone.wordpress.com/2010/01/06/instantly-show-a-classfile-in-the-packageproject-explorer-in-eclipse/">Instantly show a class/file in the Package/Project Explorer in Eclipse</a></li>
<li><a href="http://eclipseone.wordpress.com/2010/03/08/generate-class-constructors-in-eclipse-based-on-fields-or-superclass-constructors/">Generate class constructors in Eclipse based on fields or superclass constructors</a></li>
<li><a href="http://eclipseone.wordpress.com/2010/03/10/navigate-and-fix-errors-amp-warnings-in-a-class-with-eclipse-keyboard-shortcuts/">Navigate and fix errors and warnings in a class with Eclipse keyboard shortcuts</a></li>
<li><a href="http://eclipseone.wordpress.com/2010/04/19/extract-constants-from-strings-and-numbers-with-eclipse-refactorings/">Extract constants from strings and numbers with Eclipse refactorings</a></li>
<li><a href="http://eclipseone.wordpress.com/2010/02/10/change-a-methods-arguments-across-multiple-classes-in-eclipse/">Add, remove and reorder a method’s arguments instantly across multiple classes in Eclipse</a></li>
<li>Some more tips on <a href="http://eclipseone.wordpress.com/category/refactoring/">refactoring faster</a> and <a href="http://eclipseone.wordpress.com/category/quick-fixes/">using quick fixes more effectively</a>.</li>
</ul>
<h3>Share This Tip</h3>
<p class="getsocial" style="text-align:left;"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1001.png?w=468" alt="" /><a title="Add to Facebook" rel="nofollow" href="http://www.facebook.com/sharer.php?u=http://eclipseone.wordpress.com/2010/07/21/convert-nestedanonymous-classes-into-top-level-classes-using-eclipse-refactoring" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1011.png?w=468" alt="Add to Facebook" /></a><a title="Add to Digg" rel="nofollow" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F07%2F21%2Fconvert-nestedanonymous-classes-into-top-level-classes-using-eclipse-refactoring&amp;title=Convert%20nested%2Fanonymous%20classes%20into%20top%20level%20classes%20u..." target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1021.png?w=468" alt="Add to Digg" /></a><a title="Add to Del.icio.us" rel="nofollow" href="http://del.icio.us/post?url=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F07%2F21%2Fconvert-nestedanonymous-classes-into-top-level-classes-using-eclipse-refactoring&amp;title=Convert%20nested%2Fanonymous%20classes%20into%20top%20level%20classes%20using%20Eclipse%20refactoring" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1031.png?w=468" alt="Add to Del.icio.us" /></a><a title="Add to Stumbleupon" rel="nofollow" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F07%2F21%2Fconvert-nestedanonymous-classes-into-top-level-classes-using-eclipse-refactoring&amp;title=Convert%20nested%2Fanonymous%20classes%20into%20top%20level%20classes%20using%20Eclipse%20refactoring" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1041.png?w=468" alt="Add to Stumbleupon" /></a><a title="Add to Reddit" rel="nofollow" href="http://reddit.com/submit?url=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F07%2F21%2Fconvert-nestedanonymous-classes-into-top-level-classes-using-eclipse-refactoring&amp;title=Convert%20nested%2Fanonymous%20classes%20into%20top%20level%20classes%20using%20Eclipse%20refactoring" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1051.png?w=468" alt="Add to Reddit" /></a><a title="Add to Blinklist" rel="nofollow" href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Description=&amp;Url=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F07%2F21%2Fconvert-nestedanonymous-classes-into-top-level-classes-using-eclipse-refactoring&amp;Title=Convert%20nested%2Fanonymous%20classes%20into%20top%20level%20classes%20using%20Eclipse%20refactoring" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1061.png?w=468" alt="Add to Blinklist" /></a><a title="Add to Twitter" rel="nofollow" href="http://twitter.com/home/?status=Convert%20nested%2Fanonymous%20classes%20into%20top%20level%20classes%20using%20Eclipse%20refactoring+%40+http%3A%2F%2Fbit.ly%2Famr0sS" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1071.png?w=468" alt="Add to Twitter" /></a><a title="Add to Technorati" rel="nofollow" href="http://www.technorati.com/faves?add=http://eclipseone.wordpress.com/2010/07/21/convert-nestedanonymous-classes-into-top-level-classes-using-eclipse-refactoring" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1081.png?w=468" alt="Add to Technorati" /></a><a title="Add to Yahoo Buzz" rel="nofollow" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F07%2F21%2Fconvert-nestedanonymous-classes-into-top-level-classes-using-eclipse-refactoring&amp;headline=Convert%20nested%2Fanonymous%20classes%20into%20top%20level%20classes%20using%20Eclipse%20refactoring" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1091.png?w=468" alt="Add to Yahoo Buzz" /></a><a title="Add to Newsvine" rel="nofollow" href="http://www.newsvine.com/_wine/save?u=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F07%2F21%2Fconvert-nestedanonymous-classes-into-top-level-classes-using-eclipse-refactoring&amp;h=Convert%20nested%2Fanonymous%20classes%20into%20top%20level%20classes%20using%20Eclipse%20refactoring" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1101.png?w=468" alt="Add to Newsvine" /></a><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1111.png?w=468" alt="" /></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/eclipseone.wordpress.com/1300/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/eclipseone.wordpress.com/1300/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/eclipseone.wordpress.com/1300/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/eclipseone.wordpress.com/1300/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/eclipseone.wordpress.com/1300/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/eclipseone.wordpress.com/1300/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/eclipseone.wordpress.com/1300/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/eclipseone.wordpress.com/1300/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/eclipseone.wordpress.com/1300/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/eclipseone.wordpress.com/1300/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/eclipseone.wordpress.com/1300/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/eclipseone.wordpress.com/1300/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/eclipseone.wordpress.com/1300/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/eclipseone.wordpress.com/1300/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eclipseone.wordpress.com&amp;blog=10678932&amp;post=1300&amp;subd=eclipseone&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://eclipseone.wordpress.com/2010/07/21/convert-nestedanonymous-classes-into-top-level-classes-using-eclipse-refactoring/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9af99e9ee23204988228aaf14316cbd1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Byron</media:title>
		</media:content>

		<media:content url="http://eclipseone.files.wordpress.com/2010/07/convert-anonymous-class-to-nested1.jpg" medium="image">
			<media:title type="html">Convert Anonymous Class to Nested</media:title>
		</media:content>

		<media:content url="http://eclipseone.files.wordpress.com/2010/07/enter-name-for-nested-class.jpg" medium="image">
			<media:title type="html">Enter Name for Nested Class</media:title>
		</media:content>

		<media:content url="http://eclipseone.files.wordpress.com/2010/07/convert-member-type-to-top-level2.jpg" medium="image">
			<media:title type="html">Convert Member Type to Top Level</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1001.png" medium="image" />

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1011.png" medium="image">
			<media:title type="html">Add to Facebook</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1021.png" medium="image">
			<media:title type="html">Add to Digg</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1031.png" medium="image">
			<media:title type="html">Add to Del.icio.us</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1041.png" medium="image">
			<media:title type="html">Add to Stumbleupon</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1051.png" medium="image">
			<media:title type="html">Add to Reddit</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1061.png" medium="image">
			<media:title type="html">Add to Blinklist</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1071.png" medium="image">
			<media:title type="html">Add to Twitter</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1081.png" medium="image">
			<media:title type="html">Add to Technorati</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1091.png" medium="image">
			<media:title type="html">Add to Yahoo Buzz</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1101.png" medium="image">
			<media:title type="html">Add to Newsvine</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1111.png" medium="image" />
	</item>
		<item>
		<title>Quick ways to navigate Eclipse editors using the keyboard</title>
		<link>http://eclipseone.wordpress.com/2010/05/25/quick-ways-to-navigate-eclipse-editors-using-the-keyboard/</link>
		<comments>http://eclipseone.wordpress.com/2010/05/25/quick-ways-to-navigate-eclipse-editors-using-the-keyboard/#comments</comments>
		<pubDate>Tue, 25 May 2010 07:23:52 +0000</pubDate>
		<dc:creator>Byron</dc:creator>
				<category><![CDATA[Editors]]></category>
		<category><![CDATA[Navigation & Browsing]]></category>

		<guid isPermaLink="false">http://eclipseone.wordpress.com/?p=1275</guid>
		<description><![CDATA[You&#8217;ll often end up with a lot of open editors in Eclipse and consequently needing to navigate between them. You can use the mouse for this, but that often disturbs your flow when your typing, slowing you down. That&#8217;s why there are a number of ways to navigate between editors in Eclipse using only the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eclipseone.wordpress.com&amp;blog=10678932&amp;post=1275&amp;subd=eclipseone&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>You&#8217;ll often end up with a lot of open editors in Eclipse and consequently needing to navigate between them. You can use the mouse for this, but that often disturbs your flow when your typing, slowing you down.</p>
<p>That&#8217;s why there are a number of ways to navigate between editors in Eclipse using only the keyboard. Combined with the ability to <a href="http://eclipseone.wordpress.com/2010/02/15/the-fastest-ways-to-navigate-views-in-eclipse-using-the-keyboard/">quickly navigate views using the keyboard</a>, it&#8217;s an easy way to work faster and almost get rid of the mouse (reducing company spending&#8230; well, slightly).</p>
<p><span id="more-1275"></span></p>
<h3>Cycle through open editors</h3>
<p>This is probably the fastest way to navigate between editors in most cases. When you press <strong>Ctrl+F6</strong> (Next Editor), a popup appears with a list of  all open editors. The list is sorted in order of most recently used, so if you press Ctrl+F6 and release it immediately, Eclipse will take you to the last active editor. Press <strong>Ctrl+Shift+F6</strong> to reverse the direction.</p>
<p>This is a great way of jumping between 2 editors, eg. to read something in the one while typing in the other. Here&#8217;s an example showing what happens when you press Ctrl+F6 while on <em>Template.java</em>.</p>
<p><a href="http://eclipseone.files.wordpress.com/2010/05/next-editor-example.jpg"><img class="aligncenter size-full wp-image-1276" title="Next Editor Example" src="http://eclipseone.files.wordpress.com/2010/05/next-editor-example.jpg?w=468" alt=""   /></a></p>
<p>I <em>strongly recommend </em>mapping the Next Editor command to <strong>Ctrl+Tab</strong> in addition to (or instead of) Ctrl+F6. Just make a binding for the command Next Editor under <strong>Window &gt; Preferences &gt; General &gt; Keys</strong> &#8211; see <a href="../2010/02/03/how-to-manage-keyboard-shortcuts-in-eclipse/">how  to manage your keyboard shortcuts</a> for details on how to do this. But why remap the key? Well, not only is it a lot easier and faster to press (you can use one hand to do this), it&#8217;s also standard for most Windows applications so you may already be familiar with it. It makes switching editors 5 times faster (yes, statistically proven).</p>
<p>Another way of using cycling is to press <strong>Ctrl+F6</strong> and then  press <strong>F6 </strong>repeatedly while holding down <strong>Ctrl</strong>. Eclipse will  highlight the next editor in the list until you release Ctrl, after  which it will activate the highlighted editor. This is a good way to  navigate a short list of editors (eg. 5-10 open editors) but can get a bit  cumbersome when there are more editors.</p>
<h3>Quick Switch Editor</h3>
<p>Another fast way of navigating editors is via  the Quick Switch Editor functionality. I&#8217;ve posted <a href="http://eclipseone.wordpress.com/2010/01/08/switch-and-close-editors-faster-with-the-keyboard-using-eclipses-quick-switch-editor/">another tip  dedicated entirely to this feature</a>, so won&#8217;t discuss it in detail here  but just give a brief rundown of how it works. Basically, it&#8217;s great when you have a large number of editors open.</p>
<p>By pressing <strong>Ctrl+E</strong>,  you can get a list of all open editors. This list is searchable  and  even supports wildcards, which is why it&#8217;s great for cases where you have a  large number of editors open. The Quick Switch Editor is also flexible  in that it supports closing editors directly without activating them.  Here&#8217;s an example of what you&#8217;ll see:</p>
<p style="text-align:center;"><a href="http://eclipseone.files.wordpress.com/2010/01/quick-switch-editor-example1.jpg"><img class="aligncenter" title="Quick Switch Editor  Example" src="http://eclipseone.files.wordpress.com/2010/01/quick-switch-editor-example1.jpg?w=468&#038;h=127" alt="" width="468" height="127" /></a></p>
<h3>Move sequentially from one editor to the next</h3>
<p>You can also move between editors in the order of their tabs in the editor area. To move to the next editor just press <strong>Ctrl+Page Down</strong>, while <strong>Ctrl+Page Up</strong> takes you to the previous editor.</p>
<p>In the example below, when you press Ctrl+Page Down, Eclipse will activate the editor <em>Engine.java</em>, assuming that we&#8217;re currently positioned on <em>TestSomeUtils.java</em>. Repeating this will take you to <em>ClientDataSource.java</em>.</p>
<p><a href="http://eclipseone.files.wordpress.com/2010/05/ctrl-page-down-example-editors.jpg"><img class="aligncenter size-full wp-image-1277" title="Ctrl Page Down Example Editors" src="http://eclipseone.files.wordpress.com/2010/05/ctrl-page-down-example-editors.jpg?w=468" alt=""   /></a></p>
<p>Moving between editors sequentially is sometimes useful, but the big drawback of it is that it doesn&#8217;t consider which editors you&#8217;ve been working on recently (in my experience, the more likely case) so can be slow in those scenarios.</p>
<p><strong>Bonus Tip:</strong> If you&#8217;re wondering how to move between different pages of a multipage editor (eg. plugin.xml below), then just press <strong>Alt+F7</strong> to move to the next page and <strong>Alt+Shift+F7</strong> for the previous page. Multipage editors used to &#8220;break&#8221; Ctrl+Page Down navigation in previous versions of Eclipse because they&#8217;d hijack the key preventing you from moving to the next editor. This has changed in Eclipse 3.5.</p>
<p><a href="http://eclipseone.files.wordpress.com/2010/05/multipage-editor-example.jpg"><img class="aligncenter size-full wp-image-1279" title="Multipage Editor Example" src="http://eclipseone.files.wordpress.com/2010/05/multipage-editor-example.jpg?w=468&#038;h=274" alt="" width="468" height="274" /></a></p>
<h3>Which one should I use when?</h3>
<p>Here are some recommendations on when to use what to work most efficiently:</p>
<ul>
<li>If you want to quickly move between the editors you&#8217;ve used recently, use editor cycling . This is such a common requirement, that this is probably the editor navigation I use the most. Remember to create an additional binding for it to Ctrl+Tab &#8211; it works a lot faster.</li>
<li>If you&#8217;ve got a large list of open editor (eg. 10+) then use the Quick Switch Editor. Editor cycling is a decent choice up until about 10 editors.</li>
<li>If you just quickly want to browse the editors one by one to scan through them (eg. you have a couple of XML files you want to scan briefly), then use the sequential navigation.</li>
</ul>
<p>In summary, focus on learning editor cycling, then using the Quick Switch Editor. After that, pick from some of the others depending on how you work.</p>
<h3>Quick mentions</h3>
<p>Here are a couple of other ways to navigate editors, but, although  they do come in handy sometimes, they may not be as efficient as the  ones above.</p>
<ul>
<li>While editing and navigating through editors, you&#8217;ll often want to go back to the last place you were editing. Just press <strong>Ctrl+Q</strong> and Eclipse will take you directly to the exact location where you were last editing. This way you don&#8217;t need to trace your steps to get back to your last edits. Even comes in handy when you have to scroll through the same file then go back to the last edit.</li>
<li>Use Eclipse&#8217;s History functionality to move back to previous  editors, similar to using a browser history. Press <strong>Alt+Left</strong> to go  back to the previous editor and <strong>Alt+Right</strong> to go forward. This is  useful when switching back and forth between 2 different editors or  when you want to an editor that you&#8217;ve closed, as the history also  reopens closed editors.</li>
<li>An overlooked-but-useful Eclipse feature is the most recently used list under  the <em>File</em> menu. Just press <strong>Alt+F, 1</strong> (or any other number  that&#8217;s indicated in the menu) to go to the most recently opened editor.  This is useful when you&#8217;ve accidentally closed an editor you still want to use.</li>
</ul>
<h3>Related Tips</h3>
<ul>
<li><a href="http://eclipseone.wordpress.com/2010/09/20/the-fastest-ways-to-open-editors-in-eclipse-using-the-keyboard/">The fastest ways to open editors in Eclipse using the keyboard</a></li>
<li><a href="http://eclipseone.wordpress.com/2010/01/08/switch-and-close-editors-faster-with-the-keyboard-using-eclipses-quick-switch-editor/">Switch and close editors faster with the keyboard using Eclipse’s Quick Switch Editor</a></li>
<li><a href="../2010/01/04/split-and-view-the-same-editor-side-by-side-in-eclipse/">Split  and view the same editor side by side in Eclipse</a></li>
<li><a href="http://eclipseone.wordpress.com/2010/02/15/the-fastest-ways-to-navigate-views-in-eclipse-using-the-keyboard/">The fastest ways to navigate views in Eclipse using the keyboard</a></li>
<li><a href="http://eclipseone.wordpress.com/2010/02/03/how-to-manage-keyboard-shortcuts-in-eclipse/">How to manage keyboard shortcuts in Eclipse and why you should</a></li>
<li>Here are more ways to <a href="http://eclipseone.wordpress.com/category/navigation-browsing/">navigate faster</a> and <a href="http://eclipseone.wordpress.com/category/editors/">use editors more efficiently</a> in Eclipse.</li>
</ul>
<h3>Share This Tip</h3>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/eclipseone.wordpress.com/1275/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/eclipseone.wordpress.com/1275/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/eclipseone.wordpress.com/1275/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/eclipseone.wordpress.com/1275/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/eclipseone.wordpress.com/1275/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/eclipseone.wordpress.com/1275/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/eclipseone.wordpress.com/1275/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/eclipseone.wordpress.com/1275/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/eclipseone.wordpress.com/1275/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/eclipseone.wordpress.com/1275/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/eclipseone.wordpress.com/1275/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/eclipseone.wordpress.com/1275/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/eclipseone.wordpress.com/1275/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/eclipseone.wordpress.com/1275/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eclipseone.wordpress.com&amp;blog=10678932&amp;post=1275&amp;subd=eclipseone&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://eclipseone.wordpress.com/2010/05/25/quick-ways-to-navigate-eclipse-editors-using-the-keyboard/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9af99e9ee23204988228aaf14316cbd1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Byron</media:title>
		</media:content>

		<media:content url="http://eclipseone.files.wordpress.com/2010/05/next-editor-example.jpg" medium="image">
			<media:title type="html">Next Editor Example</media:title>
		</media:content>

		<media:content url="http://eclipseone.files.wordpress.com/2010/01/quick-switch-editor-example1.jpg" medium="image">
			<media:title type="html">Quick Switch Editor  Example</media:title>
		</media:content>

		<media:content url="http://eclipseone.files.wordpress.com/2010/05/ctrl-page-down-example-editors.jpg" medium="image">
			<media:title type="html">Ctrl Page Down Example Editors</media:title>
		</media:content>

		<media:content url="http://eclipseone.files.wordpress.com/2010/05/multipage-editor-example.jpg" medium="image">
			<media:title type="html">Multipage Editor Example</media:title>
		</media:content>
	</item>
		<item>
		<title>Add comments and Javadocs in Eclipse with a single keystroke</title>
		<link>http://eclipseone.wordpress.com/2010/05/05/add-comments-and-javadocs-in-eclipse-with-a-single-keystroke/</link>
		<comments>http://eclipseone.wordpress.com/2010/05/05/add-comments-and-javadocs-in-eclipse-with-a-single-keystroke/#comments</comments>
		<pubDate>Wed, 05 May 2010 07:32:19 +0000</pubDate>
		<dc:creator>Byron</dc:creator>
				<category><![CDATA[Editing]]></category>
		<category><![CDATA[Keyboard Shortcuts]]></category>

		<guid isPermaLink="false">http://eclipseone.wordpress.com/?p=1238</guid>
		<description><![CDATA[When you want to work with comments in Eclipse, you could use the slow way of moving to the start of the line, pressing // and then repeating this for all the lines you have. Or you could use the quick way of adding a comment with a single keystroke no matter where the cursor&#8217;s [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eclipseone.wordpress.com&amp;blog=10678932&amp;post=1238&amp;subd=eclipseone&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>When you want to work with comments in Eclipse, you could use the slow way of moving to the start of the line, pressing // and then repeating this for all the lines you have.</p>
<p>Or you could use the quick way of adding a comment with a single keystroke no matter where the cursor&#8217;s positioned in the statement.</p>
<p>The same goes for Javadocs &#8211; there are just too many things to type before you can start commenting the good stuff. That&#8217;s why Eclipse also has a shortcut that let&#8217;s you add Javadoc to a field, method or class.</p>
<p><span id="more-1238"></span></p>
<h3>Keyboard shortcuts for comments and JavaDocs</h3>
<p>Here are the keyboard shortcuts for manipulating comments.</p>
<table style="border-collapse:collapse;border-style:solid;border-width:thin;padding:20px;" border="1" cellpadding="3">
<tbody>
<tr>
<td><strong>Shortcut<br />
</strong></td>
<td><strong>Command</strong></td>
<td><strong>Description</strong></td>
</tr>
<tr>
<td>Ctrl+/</td>
<td>Toggle Comment</td>
<td>Add/remove line comments (//&#8230;) from the current line. The position of the cursor can be <strong>anywhere</strong> on the line. Works with multiple selected lines as well.Alternatively, you can also use Ctrl+Shift+C, which probably works better on a QWERTZ keyboard (eg. German layout), or Ctrl+7.</td>
</tr>
<tr>
<td>Ctrl+Shift+/</td>
<td>Add Block Comment</td>
<td>Wrap the selected lines in a block comment (/*&#8230; */).</td>
</tr>
<tr>
<td>Ctrl+Shift+\</td>
<td>Remove Block Comment</td>
<td>Remove a block comment (/*&#8230; */) surrounding the selected lines.</td>
</tr>
<tr>
<td>Alt+Shift+J</td>
<td>Add Javadoc Comment</td>
<td>Add a Javadoc comment to the active field/method/class. See the notes below for more details on where to position the cursor.</td>
</tr>
</tbody>
</table>
<p>Bear the following in mind when using Add Javadoc comment (Alt+Shift+J):</p>
<ul>
<li>To add a comment to a field, position the cursor on the field declaration.</li>
<li>To add a comment to a method, position the cursor anywhere in the  method or on its declaration.</li>
<li>To add a comment to a class, the easiest is to position the cursor  on the class declaration. Also works if you&#8217;re in the class, but not in a method, field or nested type.</li>
<li>The Javadoc comment inserted is based on the Code Templates defined  under <strong>Window &gt; Preferences &gt; Java &gt; Code Style &gt; Code Templates</strong>. If you expand the Comments section, you can change the default for Fields, Methods, Types (eg. classes), etc.</li>
</ul>
<p>Here&#8217;s a video to give you an idea of how fast and easy it is to add/remove comments using these shortcuts. The video shows toggling of single line comments, block comments and also adding a Javadoc comment to the method and class.</p>
<span style="text-align:center; display: block;"><a href="http://eclipseone.wordpress.com/2010/05/05/add-comments-and-javadocs-in-eclipse-with-a-single-keystroke/"><img src="http://img.youtube.com/vi/CkP5yIsjPeg/2.jpg" alt="" /></a></span>
<p>Once I&#8217;ve commented out lines, I often find myself copying them and moving them around (eg. to try different variations of the code). You can do this faster by <a href="http://eclipseone.wordpress.com/2009/11/30/move-copy-delete-lines-with-a-single-keystroke/">moving and copying lines using with a single keystroke</a>.</p>
<p>You can also <a href="http://eclipseone.wordpress.com/2009/12/13/automatically-format-and-cleanup-code-every-time-you-save/">have Eclipse format the comments whenever you save</a>, saving you formatting time.</p>
<h3>Related Tips</h3>
<ul>
<li><a href="http://eclipseone.wordpress.com/2009/11/30/move-copy-delete-lines-with-a-single-keystroke/">Move, copy and delete lines with a single keystroke</a></li>
<li><a href="http://eclipseone.wordpress.com/2010/02/03/how-to-manage-keyboard-shortcuts-in-eclipse/">How to manage keyboard shortcuts in Eclipse and why you should</a></li>
<li><a href="http://eclipseone.wordpress.com/2009/12/13/automatically-format-and-cleanup-code-every-time-you-save/">Automatically format and cleanup code every time you save</a></li>
<li><a href="http://eclipseone.wordpress.com/2010/08/24/configure-tooltips-in-eclipse-to-only-popup-on-request/">Configure those annoying tooltips in Eclipse to only popup on request</a></li>
<li>More tips on <a href="http://eclipseone.wordpress.com/category/editing/">faster and easier code editing</a> and <a href="http://eclipseone.wordpress.com/category/keyboard-shortcuts/">useful keyboard shortcuts</a>.</li>
</ul>
<h3>Share This Tip</h3>
<p class="getsocial" style="text-align:left;"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1002.png?w=468" alt="" /><a title="Add to Facebook" rel="nofollow" href="http://www.facebook.com/sharer.php?u=http://eclipseone.wordpress.com/2010/05/05/add-comments-and-javadocs-in-eclipse-with-a-single-keystroke" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1012.png?w=468" alt="Add to Facebook" /></a><a title="Add to Digg" rel="nofollow" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F05%2F05%2Fadd-comments-and-javadocs-in-eclipse-with-a-single-keystroke&amp;title=Add%20comments%20and%20Javadocs%20in%20Eclipse%20with%20a%20single%20keystroke" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1022.png?w=468" alt="Add to Digg" /></a><a title="Add to Del.icio.us" rel="nofollow" href="http://del.icio.us/post?url=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F05%2F05%2Fadd-comments-and-javadocs-in-eclipse-with-a-single-keystroke&amp;title=Add%20comments%20and%20Javadocs%20in%20Eclipse%20with%20a%20single%20keystroke" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1032.png?w=468" alt="Add to Del.icio.us" /></a><a title="Add to Stumbleupon" rel="nofollow" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F05%2F05%2Fadd-comments-and-javadocs-in-eclipse-with-a-single-keystroke&amp;title=Add%20comments%20and%20Javadocs%20in%20Eclipse%20with%20a%20single%20keystroke" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1042.png?w=468" alt="Add to Stumbleupon" /></a><a title="Add to Reddit" rel="nofollow" href="http://reddit.com/submit?url=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F05%2F05%2Fadd-comments-and-javadocs-in-eclipse-with-a-single-keystroke&amp;title=Add%20comments%20and%20Javadocs%20in%20Eclipse%20with%20a%20single%20keystroke" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1052.png?w=468" alt="Add to Reddit" /></a><a title="Add to Blinklist" rel="nofollow" href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Description=&amp;Url=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F05%2F05%2Fadd-comments-and-javadocs-in-eclipse-with-a-single-keystroke&amp;Title=Add%20comments%20and%20Javadocs%20in%20Eclipse%20with%20a%20single%20keystroke" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1062.png?w=468" alt="Add to Blinklist" /></a><a title="Add to Twitter" rel="nofollow" href="http://twitter.com/home/?status=Add%20comments%20and%20Javadocs%20in%20Eclipse%20with%20a%20single%20keystroke+%40+http%3A%2F%2Fbit.ly%2Fa5RjDb" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1072.png?w=468" alt="Add to Twitter" /></a><a title="Add to Technorati" rel="nofollow" href="http://www.technorati.com/faves?add=http://eclipseone.wordpress.com/2010/05/05/add-comments-and-javadocs-in-eclipse-with-a-single-keystroke" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1082.png?w=468" alt="Add to Technorati" /></a><a title="Add to Yahoo Buzz" rel="nofollow" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F05%2F05%2Fadd-comments-and-javadocs-in-eclipse-with-a-single-keystroke&amp;headline=Add%20comments%20and%20Javadocs%20in%20Eclipse%20with%20a%20single%20keystroke" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1092.png?w=468" alt="Add to Yahoo Buzz" /></a><a title="Add to Newsvine" rel="nofollow" href="http://www.newsvine.com/_wine/save?u=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F05%2F05%2Fadd-comments-and-javadocs-in-eclipse-with-a-single-keystroke&amp;h=Add%20comments%20and%20Javadocs%20in%20Eclipse%20with%20a%20single%20keystroke" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1102.png?w=468" alt="Add to Newsvine" /></a><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1112.png?w=468" alt="" /></p>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:478px;width:1px;height:1px;overflow:hidden;">
<h2><a title="Configure those annoying tooltips in Eclipse to  only popup on request" rel="bookmark" href="../2010/08/24/configure-tooltips-in-eclipse-to-only-popup-on-request/">Configure those annoying tooltips in Eclipse to  only popup on request</a></h2>
</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/eclipseone.wordpress.com/1238/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/eclipseone.wordpress.com/1238/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/eclipseone.wordpress.com/1238/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/eclipseone.wordpress.com/1238/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/eclipseone.wordpress.com/1238/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/eclipseone.wordpress.com/1238/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/eclipseone.wordpress.com/1238/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/eclipseone.wordpress.com/1238/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/eclipseone.wordpress.com/1238/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/eclipseone.wordpress.com/1238/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/eclipseone.wordpress.com/1238/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/eclipseone.wordpress.com/1238/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/eclipseone.wordpress.com/1238/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/eclipseone.wordpress.com/1238/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eclipseone.wordpress.com&amp;blog=10678932&amp;post=1238&amp;subd=eclipseone&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://eclipseone.wordpress.com/2010/05/05/add-comments-and-javadocs-in-eclipse-with-a-single-keystroke/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9af99e9ee23204988228aaf14316cbd1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Byron</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1002.png" medium="image" />

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1012.png" medium="image">
			<media:title type="html">Add to Facebook</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1022.png" medium="image">
			<media:title type="html">Add to Digg</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1032.png" medium="image">
			<media:title type="html">Add to Del.icio.us</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1042.png" medium="image">
			<media:title type="html">Add to Stumbleupon</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1052.png" medium="image">
			<media:title type="html">Add to Reddit</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1062.png" medium="image">
			<media:title type="html">Add to Blinklist</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1072.png" medium="image">
			<media:title type="html">Add to Twitter</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1082.png" medium="image">
			<media:title type="html">Add to Technorati</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1092.png" medium="image">
			<media:title type="html">Add to Yahoo Buzz</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1102.png" medium="image">
			<media:title type="html">Add to Newsvine</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1112.png" medium="image" />
	</item>
		<item>
		<title>Get warnings about unused method arguments from Eclipse to keep code clean</title>
		<link>http://eclipseone.wordpress.com/2010/04/27/get-warnings-about-unused-method-arguments-from-eclipse/</link>
		<comments>http://eclipseone.wordpress.com/2010/04/27/get-warnings-about-unused-method-arguments-from-eclipse/#comments</comments>
		<pubDate>Tue, 27 Apr 2010 07:27:49 +0000</pubDate>
		<dc:creator>Byron</dc:creator>
				<category><![CDATA[Preferences]]></category>
		<category><![CDATA[Refactoring]]></category>

		<guid isPermaLink="false">http://eclipseone.wordpress.com/?p=1218</guid>
		<description><![CDATA[Unused variables and methods should alway be unwelcome. Removing them keeps the code cleaner and easier to read. Now, by default Eclipse warns you about unused private variables and methods, but it doesn&#8217;t warn you (by default) about unused method arguments. But there is a compiler setting in Eclipse that can warn you when you [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eclipseone.wordpress.com&amp;blog=10678932&amp;post=1218&amp;subd=eclipseone&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Unused variables and methods should alway be unwelcome. Removing them keeps the code cleaner and easier to read. Now, by default Eclipse warns you about unused private variables and methods, but it doesn&#8217;t warn you (by default) about unused method arguments.</p>
<p>But there is a compiler setting in Eclipse that can warn you when you don&#8217;t use an argument in a method. You can even handle arguments on inherited methods, especially useful when using 3rd party libraries.</p>
<p><span id="more-1218"></span></p>
<h3>Setup the compiler preferences</h3>
<p>To get warnings of unused arguments:</p>
<ol>
<li>Go to <strong>Window &gt; Preferences &gt; Java &gt; Compiler &gt; Errors/Warnings</strong>.</li>
<li>Open up the section <em>Unnecessary Code</em>.</li>
<li>Change the setting for <em>Parameter is never read</em> from Ignore to Warning.</li>
<li>(Recommended, but optional) Deselect <em>Ignore overriding and implementing methods</em>. I recommend deselecting this option. You can leave it selected if you want to, but the feature loses a bit of its usefulness. I discuss this option a bit more in the next section.</li>
</ol>
<p>Here&#8217;s what the preference should look like:</p>
<p><a href="http://eclipseone.files.wordpress.com/2010/04/unused-argument-warning-preference2.jpg"><img class="aligncenter size-full wp-image-1233" title="Unused Argument Warning Preference" src="http://eclipseone.files.wordpress.com/2010/04/unused-argument-warning-preference2.jpg?w=468" alt=""   /></a></p>
<p>And here&#8217;s an example of such a warning. In the example, the argument <em>capacity</em> isn&#8217;t used so is annotated as a warning.</p>
<h3><a href="http://eclipseone.files.wordpress.com/2010/04/unused-argument-warning-example.jpg"><img class="aligncenter size-full wp-image-1231" title="Unused Argument Warning Example" src="http://eclipseone.files.wordpress.com/2010/04/unused-argument-warning-example.jpg?w=468" alt=""   /></a></h3>
<p>What&#8217;s the easiest way to get rid of the warning? Well, just <a href="http://eclipseone.wordpress.com/2010/02/10/change-a-methods-arguments-across-multiple-classes-in-eclipse/">remove the argument using the Eclipse Change Method Signature refactoring</a>. This will remove the argument from the method declaration and any method callers in one go. However, if you can&#8217;t remove the argument from the method then read the next section.</p>
<p>On an old codebase you may get lots of warnings initially. I&#8217;d normally handle these on a class-by-class basis only for the classes I&#8217;m currently working on, unless the team has a specific cleanup project/task. Just something to bear in mind, especially if you share workspace settings across the team via SVN or similar.</p>
<h3>What about method signatures that can&#8217;t be changed?</h3>
<p>When you deselected <em>Ignore overriding and implementing methods,</em> you told Eclipse to warn you about unused arguments in implemented/overridden methods. It&#8217;s a good indicator that your superclass/interface method is passing in more than it needs to (ie. remove the argument from the method signature) or that you&#8217;re ignoring something important about the interface contract (ie. use it somewhere in your method).</p>
<p>But sometimes you can&#8217;t remove the argument because you don&#8217;t have control over inherited methods, especially if you implement/override a 3rd party library&#8217;s method or if the method is part of a bigger framework that&#8217;s difficult to change. Other times you won&#8217;t have any need for the argument in very isolated cases. So you don&#8217;t want a warning to appear for these.</p>
<p>That&#8217;s why you can use the <em>@SuppressWarning</em> compiler annotation to stop Eclipse from reporting the warning. Here&#8217;s an example:</p>
<p><pre class="brush: java; gutter: false;">
public String process(@SuppressWarnings(&quot;unused&quot;) int capacity, int max) {...}
</pre></p>
<p>You can apply SuppressWarning to an individual argument or the whole method. I&#8217;d recommend annotating only the argument that you want to ignore.</p>
<p>Eclipse makes it easy to add the compiler annotation. Just <a href="http://eclipseone.wordpress.com/2010/03/10/navigate-and-fix-errors-amp-warnings-in-a-class-with-eclipse-keyboard-shortcuts/">navigate to the warning</a>, press <strong>Ctrl+1</strong> and choose <em>Add @SuppressWarning &#8216;unused&#8217; to &#8216;variable&#8217;</em> (Quick Fix does its job again).</p>
<h3>Related Tips</h3>
<ul>
<li><a href="http://eclipseone.wordpress.com/2010/03/10/navigate-and-fix-errors-amp-warnings-in-a-class-with-eclipse-keyboard-shortcuts/">Navigate and fix errors and warnings in a class with Eclipse keyboard shortcuts</a></li>
<li><a href="http://eclipseone.wordpress.com/2010/02/10/change-a-methods-arguments-across-multiple-classes-in-eclipse/">Add, remove and reorder a method’s arguments instantly across multiple classes in Eclipse</a></li>
<li><a href="http://eclipseone.wordpress.com/2009/12/03/find-all-classes-that-overridereimplement-a-method/">Find all classes that override/reimplement a method</a></li>
<li><a href="http://eclipseone.wordpress.com/2009/12/13/automatically-format-and-cleanup-code-every-time-you-save/">Automatically format and cleanup code every time you save</a></li>
<li>More tips on <a href="http://eclipseone.wordpress.com/category/refactoring/">faster refactoring</a> and other <a href="http://eclipseone.wordpress.com/category/preferences/">useful preferences</a>.</li>
</ul>
<h3>Share This Tip</h3>
<p class="getsocial" style="text-align:left;"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1001.png?w=468" alt="" /><a title="Add to Facebook" rel="nofollow" href="http://www.facebook.com/sharer.php?u=http://eclipseone.wordpress.com/2010/04/27/get-warnings-about-unused-method-arguments-from-eclipse" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1011.png?w=468" alt="Add to Facebook" /></a><a title="Add to Digg" rel="nofollow" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F04%2F27%2Fget-warnings-about-unused-method-arguments-from-eclipse&amp;title=Get%20warnings%20about%20unused%20method%20arguments%20from%20Eclipse%20t..." target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1021.png?w=468" alt="Add to Digg" /></a><a title="Add to Del.icio.us" rel="nofollow" href="http://del.icio.us/post?url=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F04%2F27%2Fget-warnings-about-unused-method-arguments-from-eclipse&amp;title=Get%20warnings%20about%20unused%20method%20arguments%20from%20Eclipse%20to%20keep%20code%20clean" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1031.png?w=468" alt="Add to Del.icio.us" /></a><a title="Add to Stumbleupon" rel="nofollow" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F04%2F27%2Fget-warnings-about-unused-method-arguments-from-eclipse&amp;title=Get%20warnings%20about%20unused%20method%20arguments%20from%20Eclipse%20to%20keep%20code%20clean" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1041.png?w=468" alt="Add to Stumbleupon" /></a><a title="Add to Reddit" rel="nofollow" href="http://reddit.com/submit?url=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F04%2F27%2Fget-warnings-about-unused-method-arguments-from-eclipse&amp;title=Get%20warnings%20about%20unused%20method%20arguments%20from%20Eclipse%20to%20keep%20code%20clean" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1051.png?w=468" alt="Add to Reddit" /></a><a title="Add to Blinklist" rel="nofollow" href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Description=&amp;Url=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F04%2F27%2Fget-warnings-about-unused-method-arguments-from-eclipse&amp;Title=Get%20warnings%20about%20unused%20method%20arguments%20from%20Eclipse%20to%20keep%20code%20clean" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1061.png?w=468" alt="Add to Blinklist" /></a><a title="Add to Twitter" rel="nofollow" href="http://twitter.com/home/?status=Get%20warnings%20about%20unused%20method%20arguments%20from%20Eclipse%20to%20keep%20code%20clean+%40+http%3A%2F%2Fbit.ly%2FaFqVWj" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1071.png?w=468" alt="Add to Twitter" /></a><a title="Add to Technorati" rel="nofollow" href="http://www.technorati.com/faves?add=http://eclipseone.wordpress.com/2010/04/27/get-warnings-about-unused-method-arguments-from-eclipse" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1081.png?w=468" alt="Add to Technorati" /></a><a title="Add to Yahoo Buzz" rel="nofollow" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F04%2F27%2Fget-warnings-about-unused-method-arguments-from-eclipse&amp;headline=Get%20warnings%20about%20unused%20method%20arguments%20from%20Eclipse%20to%20keep%20code%20clean" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1091.png?w=468" alt="Add to Yahoo Buzz" /></a><a title="Add to Newsvine" rel="nofollow" href="http://www.newsvine.com/_wine/save?u=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F04%2F27%2Fget-warnings-about-unused-method-arguments-from-eclipse&amp;h=Get%20warnings%20about%20unused%20method%20arguments%20from%20Eclipse%20to%20keep%20code%20clean" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1101.png?w=468" alt="Add to Newsvine" /></a><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1111.png?w=468" alt="" /></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/eclipseone.wordpress.com/1218/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/eclipseone.wordpress.com/1218/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/eclipseone.wordpress.com/1218/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/eclipseone.wordpress.com/1218/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/eclipseone.wordpress.com/1218/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/eclipseone.wordpress.com/1218/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/eclipseone.wordpress.com/1218/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/eclipseone.wordpress.com/1218/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/eclipseone.wordpress.com/1218/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/eclipseone.wordpress.com/1218/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/eclipseone.wordpress.com/1218/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/eclipseone.wordpress.com/1218/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/eclipseone.wordpress.com/1218/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/eclipseone.wordpress.com/1218/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eclipseone.wordpress.com&amp;blog=10678932&amp;post=1218&amp;subd=eclipseone&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://eclipseone.wordpress.com/2010/04/27/get-warnings-about-unused-method-arguments-from-eclipse/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9af99e9ee23204988228aaf14316cbd1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Byron</media:title>
		</media:content>

		<media:content url="http://eclipseone.files.wordpress.com/2010/04/unused-argument-warning-preference2.jpg" medium="image">
			<media:title type="html">Unused Argument Warning Preference</media:title>
		</media:content>

		<media:content url="http://eclipseone.files.wordpress.com/2010/04/unused-argument-warning-example.jpg" medium="image">
			<media:title type="html">Unused Argument Warning Example</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1001.png" medium="image" />

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1011.png" medium="image">
			<media:title type="html">Add to Facebook</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1021.png" medium="image">
			<media:title type="html">Add to Digg</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1031.png" medium="image">
			<media:title type="html">Add to Del.icio.us</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1041.png" medium="image">
			<media:title type="html">Add to Stumbleupon</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1051.png" medium="image">
			<media:title type="html">Add to Reddit</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1061.png" medium="image">
			<media:title type="html">Add to Blinklist</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1071.png" medium="image">
			<media:title type="html">Add to Twitter</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1081.png" medium="image">
			<media:title type="html">Add to Technorati</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1091.png" medium="image">
			<media:title type="html">Add to Yahoo Buzz</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1101.png" medium="image">
			<media:title type="html">Add to Newsvine</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1111.png" medium="image" />
	</item>
		<item>
		<title>Extract constants from strings and numbers with Eclipse refactorings</title>
		<link>http://eclipseone.wordpress.com/2010/04/19/extract-constants-from-strings-and-numbers-with-eclipse-refactorings/</link>
		<comments>http://eclipseone.wordpress.com/2010/04/19/extract-constants-from-strings-and-numbers-with-eclipse-refactorings/#comments</comments>
		<pubDate>Mon, 19 Apr 2010 07:09:07 +0000</pubDate>
		<dc:creator>Byron</dc:creator>
				<category><![CDATA[Editing]]></category>
		<category><![CDATA[Quick Fixes]]></category>
		<category><![CDATA[Refactoring]]></category>

		<guid isPermaLink="false">http://eclipseone.wordpress.com/?p=1202</guid>
		<description><![CDATA[For readability&#8217;s sake, it&#8217;s almost always a good idea to replace magic numbers and string literals with constants. That&#8217;s all good, but it can take a bit of time to refactor these to constants, especially strings or parts of strings. For example, in the code below we want to refactor &#8220;shovel and spade&#8221; to a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eclipseone.wordpress.com&amp;blog=10678932&amp;post=1202&amp;subd=eclipseone&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>For readability&#8217;s sake, it&#8217;s almost always a good idea to replace magic numbers and string literals with constants. That&#8217;s all good, but it can take a bit of time to refactor these to constants, especially strings or parts of strings.</p>
<p>For example, in the code below we want to refactor &#8220;shovel and spade&#8221; to a private static final String called <em>TOOLS</em>. To do that manually would take some time. It goes even slower if we only want to extract &#8220;spade&#8221; to a constant because we first have to convert the string to a concatenation.</p>
<p><pre class="brush: java;">
String tools = &quot;shovel and spade&quot;;
...
String otherTools = &quot;shovel and spade&quot;;
</pre></p>
<p>Luckily, Eclipse has a couple of ways to instantly convert literals to constants. Coupled with tools to speed up string selection and to pick out part of a string, you have the ability to create a constant in about 2 seconds flat. I&#8217;ll discuss all these features below.</p>
<p><span id="more-1202"></span></p>
<h3>Extract a constant from a string/number</h3>
<p>There are 2 ways to extract a constant, the one uses a <em>quick fix</em> and the other a <em>refactoring</em>. I&#8217;ll show the quick fix method first and then the refactoring and discuss the (small) differences between the two. The example uses a string, but everything is true for numbers as well.</p>
<p>Follow these steps to use the quick fix:</p>
<ol>
<li>First select the string. The fastest way is to place the cursor on the string and press <strong>Alt+Shift+Up</strong> (Select Enclosing Element; a nifty shortcut that I discuss in <a href="http://eclipseone.wordpress.com/2009/12/20/select-entire-strings-and-methods-in-eclipse-with-a-single-keystroke/">Select strings and methods with a single keystroke</a>).</li>
<li>After selecting the string, press <strong>Ctr+1</strong> (Quick Fix) and then select <em>Extract to constant</em>. Eclipse will do the following: (a) Create a private final static variable of type String with a default name, (b) replace all occurrences of that string with the constant and (c) place the cursor on the constant&#8217;s declaration to give you a chance to change the name, type and visibility of the variable using placeholders that you can Tab through.</li>
<li>Once you&#8217;re happy with the constant details, press <strong>Enter</strong> to go back to the line on which you initiated the quick fix.</li>
</ol>
<p>Here&#8217;s a short video with an example of using quick fix. We&#8217;ll extract a constant (called <em>TOOLS) </em>from a string literal (&#8220;shovel and spade&#8221;) that&#8217;s used in two places.</p>
<span style="text-align:center; display: block;"><a href="http://eclipseone.wordpress.com/2010/04/19/extract-constants-from-strings-and-numbers-with-eclipse-refactorings/"><img src="http://img.youtube.com/vi/ea50KNFTvlU/2.jpg" alt="" /></a></span>
<p><strong>Note:</strong> You can use <strong>Tab </strong>to move from one placeholder to another and pressing Enter will get you back to your original line.</p>
<p>The other way to extract a constant is by using the <em>Extract Constant</em> refactoring. Again, select the string, then select <strong>Refactor &gt; Extract Constant&#8230;</strong> (<strong>Alt+T, A</strong>) from the application menu. A dialog appears prompting you for the constant&#8217;s name, its visibility and whether to replace all occurrences of the string with the constant. After you&#8217;ve entered the details, press Enter and you&#8217;ll have your constant defined.</p>
<p>Here&#8217;s a short video with an example using refactoring. We&#8217;ll use the same example as above.</p>
<span style="text-align:center; display: block;"><a href="http://eclipseone.wordpress.com/2010/04/19/extract-constants-from-strings-and-numbers-with-eclipse-refactorings/"><img src="http://img.youtube.com/vi/nyFDniI3Q-8/2.jpg" alt="" /></a></span>
<p>The differences between the two? Not much, the biggest difference being <em>when</em> you enter the details of the constant (ie. before the change is made or after). The refactoring dialog also provides an option to add the qualifying type name before the constant&#8217;s usage, but most of time this is redundant. I&#8217;d recommend using the quick fix, unless you&#8217;re more comfortable with dialogs.</p>
<p>BTW, you can <a href="http://eclipseone.wordpress.com/2010/02/03/how-to-manage-keyboard-shortcuts-in-eclipse/">assign custom keyboard shortcuts to</a> either command by mapping either <em>Quick Assist &#8211; Extract Constant</em> or the command <em>Extract Constant</em>.</p>
<h3>Pick out part of a string</h3>
<p>Sometimes you&#8217;ll want to break up a string into multiple parts and convert one of those parts into a constant. Eclipse can do this automatically.</p>
<p>Select the part of the string you want to pick out (don&#8217;t worry about quotes), press <strong>Ctrl+1</strong> and choose <em>Pick out selected part of String</em>. Eclipse will convert that part into a string with quotes, concatenate it to the rest of the string and select it. You can then use any of the Extract Constant tools above.</p>
<p>Here&#8217;s an example of how to use this feature. Notice how the string&#8217;s already selected so we can use the Extract Constant quick fix immediately.</p>
<span style="text-align:center; display: block;"><a href="http://eclipseone.wordpress.com/2010/04/19/extract-constants-from-strings-and-numbers-with-eclipse-refactorings/"><img src="http://img.youtube.com/vi/WCI822Cg4T4/2.jpg" alt="" /></a></span>
<h3>Related Tips</h3>
<ul>
<li><a href="http://eclipseone.wordpress.com/2009/12/20/select-entire-strings-and-methods-in-eclipse-with-a-single-keystroke/">Select entire strings and methods in Eclipse with a single keystroke</a></li>
<li><a href="http://eclipseone.wordpress.com/2010/01/27/convert-string-concatenations-into-stringbuilder-calls/">Convert string concatenations into StringBuilder or MessageFormat calls with Eclipse’s Quick Fix</a></li>
<li><a href="http://eclipseone.wordpress.com/2010/02/03/how-to-manage-keyboard-shortcuts-in-eclipse/">How to manage keyboard shortcuts in Eclipse and why you should</a></li>
<li><a href="http://eclipseone.wordpress.com/2010/01/19/joinsplit-if-statements-and-rearrange-expressions-using-eclipse-quick-fix/">Join/split if statements and rearrange expressions using Eclipse Quick Fix</a></li>
<li>More tips on using <a href="http://eclipseone.wordpress.com/category/quick-fixes/">quick fixes</a> and making <a href="http://eclipseone.wordpress.com/category/editing/">editing</a> faster.</li>
</ul>
<h3>Share This Tip</h3>
<p style="text-align:left;" class="getsocial"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1005.png?w=468" /><a title="Add to Facebook" href="http://www.facebook.com/sharer.php?u=http://eclipseone.wordpress.com/2010/04/19/extract-constants-from-strings-and-numbers-with-eclipse-refactorings" rel="nofollow" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1015.png?w=468" alt="Add to Facebook" /></a><a title="Add to Digg" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F04%2F19%2Fextract-constants-from-strings-and-numbers-with-eclipse-refactorings&amp;title=Extract%20constants%20from%20strings%20and%20numbers%20with%20Eclipse%20r..." rel="nofollow" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1025.png?w=468" alt="Add to Digg" /></a><a title="Add to Del.icio.us" href="http://del.icio.us/post?url=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F04%2F19%2Fextract-constants-from-strings-and-numbers-with-eclipse-refactorings&amp;title=Extract%20constants%20from%20strings%20and%20numbers%20with%20Eclipse%20refactorings" rel="nofollow" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1035.png?w=468" alt="Add to Del.icio.us" /></a><a title="Add to Stumbleupon" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F04%2F19%2Fextract-constants-from-strings-and-numbers-with-eclipse-refactorings&amp;title=Extract%20constants%20from%20strings%20and%20numbers%20with%20Eclipse%20refactorings" rel="nofollow" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1045.png?w=468" alt="Add to Stumbleupon" /></a><a title="Add to Reddit" href="http://reddit.com/submit?url=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F04%2F19%2Fextract-constants-from-strings-and-numbers-with-eclipse-refactorings&amp;title=Extract%20constants%20from%20strings%20and%20numbers%20with%20Eclipse%20refactorings" rel="nofollow" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1055.png?w=468" alt="Add to Reddit" /></a><a title="Add to Blinklist" href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Description=&amp;Url=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F04%2F19%2Fextract-constants-from-strings-and-numbers-with-eclipse-refactorings&amp;Title=Extract%20constants%20from%20strings%20and%20numbers%20with%20Eclipse%20refactorings" rel="nofollow" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1065.png?w=468" alt="Add to Blinklist" /></a><a title="Add to Twitter" href="http://twitter.com/home/?status=Extract%20constants%20from%20strings%20and%20numbers%20with%20Eclipse%20refactorings+%40+http%3A%2F%2Fbit.ly%2FcfIxtL" rel="nofollow" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1075.png?w=468" alt="Add to Twitter" /></a><a title="Add to Technorati" href="http://www.technorati.com/faves?add=http://eclipseone.wordpress.com/2010/04/19/extract-constants-from-strings-and-numbers-with-eclipse-refactorings" rel="nofollow" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1085.png?w=468" alt="Add to Technorati" /></a><a title="Add to Yahoo Buzz" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F04%2F19%2Fextract-constants-from-strings-and-numbers-with-eclipse-refactorings&amp;headline=Extract%20constants%20from%20strings%20and%20numbers%20with%20Eclipse%20refactorings" rel="nofollow" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1095.png?w=468" alt="Add to Yahoo Buzz" /></a><a title="Add to Newsvine" href="http://www.newsvine.com/_wine/save?u=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F04%2F19%2Fextract-constants-from-strings-and-numbers-with-eclipse-refactorings&amp;h=Extract%20constants%20from%20strings%20and%20numbers%20with%20Eclipse%20refactorings" rel="nofollow" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1105.png?w=468" alt="Add to Newsvine" /></a><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1115.png?w=468" /></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/eclipseone.wordpress.com/1202/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/eclipseone.wordpress.com/1202/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/eclipseone.wordpress.com/1202/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/eclipseone.wordpress.com/1202/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/eclipseone.wordpress.com/1202/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/eclipseone.wordpress.com/1202/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/eclipseone.wordpress.com/1202/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/eclipseone.wordpress.com/1202/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/eclipseone.wordpress.com/1202/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/eclipseone.wordpress.com/1202/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/eclipseone.wordpress.com/1202/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/eclipseone.wordpress.com/1202/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/eclipseone.wordpress.com/1202/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/eclipseone.wordpress.com/1202/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eclipseone.wordpress.com&amp;blog=10678932&amp;post=1202&amp;subd=eclipseone&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://eclipseone.wordpress.com/2010/04/19/extract-constants-from-strings-and-numbers-with-eclipse-refactorings/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9af99e9ee23204988228aaf14316cbd1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Byron</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1005.png" medium="image" />

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1015.png" medium="image">
			<media:title type="html">Add to Facebook</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1025.png" medium="image">
			<media:title type="html">Add to Digg</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1035.png" medium="image">
			<media:title type="html">Add to Del.icio.us</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1045.png" medium="image">
			<media:title type="html">Add to Stumbleupon</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1055.png" medium="image">
			<media:title type="html">Add to Reddit</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1065.png" medium="image">
			<media:title type="html">Add to Blinklist</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1075.png" medium="image">
			<media:title type="html">Add to Twitter</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1085.png" medium="image">
			<media:title type="html">Add to Technorati</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1095.png" medium="image">
			<media:title type="html">Add to Yahoo Buzz</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1105.png" medium="image">
			<media:title type="html">Add to Newsvine</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1115.png" medium="image" />
	</item>
		<item>
		<title>Categorise projects in the Package Explorer to reduce clutter in Eclipse</title>
		<link>http://eclipseone.wordpress.com/2010/04/08/categorise-projects-in-the-package-explorer-to-reduce-clutter-in-eclipse/</link>
		<comments>http://eclipseone.wordpress.com/2010/04/08/categorise-projects-in-the-package-explorer-to-reduce-clutter-in-eclipse/#comments</comments>
		<pubDate>Thu, 08 Apr 2010 07:30:39 +0000</pubDate>
		<dc:creator>Byron</dc:creator>
				<category><![CDATA[Maximise Screen Space]]></category>
		<category><![CDATA[Navigation & Browsing]]></category>
		<category><![CDATA[Views]]></category>

		<guid isPermaLink="false">http://eclipseone.wordpress.com/?p=1148</guid>
		<description><![CDATA[If you&#8217;ve been hanging onto one Eclipse workspace for the last couple of years, you&#8217;ll probably have dozens of projects cluttering up your workspace. If you&#8217;re an Eclipse RCP developer, you may be sitting with around 50+ projects easily. The thing is that you&#8217;ll often only work with 1 or 2 at a time, not [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eclipseone.wordpress.com&amp;blog=10678932&amp;post=1148&amp;subd=eclipseone&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve been hanging onto one Eclipse workspace for the last couple of years, you&#8217;ll probably have dozens of projects cluttering up your workspace. If you&#8217;re an Eclipse RCP developer, you may be sitting with around 50+ projects easily.</p>
<p>The thing is that you&#8217;ll often only work with 1 or 2 at a time, not the whole lot. And sometimes you want a convenient way of only browsing projects belonging to a specific product/feature/layer/any-other-grouping-that-makes-sense. Having all projects in a long list makes it difficult to manage and more difficult to browse.</p>
<p>That&#8217;s why the Package Explorer and Project Explorer have a nice feature that reduces the clutter and allows you to organise your project into categories that make sense. So instead of the Package Explorer looking unwieldy and flat like this,</p>
<p><a href="http://eclipseone.files.wordpress.com/2010/04/package-explorer-before-organising.jpg"><img class="aligncenter size-full wp-image-1157" title="Package Explorer Before Organising" src="http://eclipseone.files.wordpress.com/2010/04/package-explorer-before-organising.jpg?w=468" alt=""   /></a></p>
<p>it could look like this:</p>
<p><a href="http://eclipseone.files.wordpress.com/2010/04/package-explorer-after-organising.jpg"><img class="aligncenter size-full wp-image-1158" title="Package Explorer After Organising" src="http://eclipseone.files.wordpress.com/2010/04/package-explorer-after-organising.jpg?w=468" alt=""   /></a></p>
<p><span id="more-1148"></span></p>
<h3>How to categorise projects</h3>
<p>This feature works closely with another Eclipse feature called Working Sets. A working set is just a grouping of resources (ie. files, folders and projects). Each category is just a working set.</p>
<p>To categorise projects, we&#8217;ll first create some working sets and then enable the feature in the Package Explorer.</p>
<p>To create a working set do the following:</p>
<ol>
<li>Open the Package Explorer (or Project Explorer) and in the View Menu (triangle in the upper, right corner), click <strong>Select Working Set&#8230;</strong></li>
<li>Click <strong>New&#8230; </strong>in the Select Working Set dialog.</li>
<li>Select <em>Resource</em> working set type and click Next.</li>
<li>On the next page select all the projects you want to include in the working set and pick a descriptive name for your working set. Repeat the process for any other working sets you want.</li>
<li>Click Finish.</li>
</ol>
<p>Here&#8217;s an example of what the working set dialog should look like:</p>
<p><a href="http://eclipseone.files.wordpress.com/2010/04/select-working-set-dialog.jpg"><img class="aligncenter size-full wp-image-1177" title="Select Working Set Dialog" src="http://eclipseone.files.wordpress.com/2010/04/select-working-set-dialog.jpg?w=468" alt=""   /></a></p>
<p>Now to enable the grouping feature. Open the Package Explorer&#8217;s View Menu again and enable <strong>Top Level Elements &gt; Working Sets</strong>. If it&#8217;s the first time you do this, Eclipse will prompt you to configure working sets &#8211; a way to ask you which working sets to display in the Package Explorer. Select all the working sets you created and click Ok.</p>
<p>You should now see your working sets in the Package Explorer and if you expand it, all the projects you selected will be shown.</p>
<p>Here&#8217;s a quick video to give you an example of how this works and looks. In the example, there are 8 projects, 3 belonging to the UI and 3 to the model. The working sets will group them according to UI and Model. There are also 2 projects that are scratchpad projects, so for now they won&#8217;t be categorised.</p>
<span style="text-align:center; display: block;"><a href="http://eclipseone.wordpress.com/2010/04/08/categorise-projects-in-the-package-explorer-to-reduce-clutter-in-eclipse/"><img src="http://img.youtube.com/vi/PIMTUgAeq60/2.jpg" alt="" /></a></span>
<p><strong>Notes:</strong></p>
<ul>
<li>A project can <em>belong to as many working sets as you want</em>, so it can appear in a number of categories.</li>
<li>You can choose which working sets display in the Package Explorer by choosing <strong>Configure Working Sets</strong>&#8230; from the View Menu and then selecting/deselecting the relevant working sets. NB! This menu item is not available if you&#8217;re not in the Working Set layout.</li>
<li>To get back to the normal view, select <strong>Top Level Elements &gt; Projects</strong> from the View Menu.</li>
<li>Any project not assigned to a working set goes to a category called <em>Other Projects</em>. This isn&#8217;t really a working set, but a default category that Eclipse assigns to group unassigned projects.</li>
<li>You can reorder working sets by dragging and dropping them anywhere.</li>
<li>New projects can quickly be assigned to working sets by either dragging and dropping them onto the working set or right-clicking on the project and selecting <strong>Assign Working Sets</strong>.</li>
</ul>
<p><strong>Limitations:</strong> Although working sets help you organise resources, any new resources won&#8217;t automatically be added to a working set, <em>even if their parent already belongs to that working set</em>. In our case, this means that any new project needs to be explicitly added to a working set, otherwise it will appear in the Other Projects category. Normally you can do this on New Project wizards, so watch out for these.</p>
<h3>Some good reasons why you should categorise your projects</h3>
<p>Now that you know how to group projects, you might be wondering why you should.</p>
<p>Well, apart from just looking a lot cleaner and less cluttered, it also means that you can act on a group of projects at a time. For example, you can right-click on a working set in Package Explorer and open, close or refresh all projects in that working set. The same applies to Team commands (nice for selective updates).</p>
<p>Another reason is that you can now selectively search only those projects by telling Eclipse to only search certain working sets. Now you don&#8217;t have to pick up occurrences in test or scratchpad projects if you don&#8217;t want to. There are a host of other Eclipse commands that act only on individual working sets (eg. build, problems, etc).</p>
<p>And the last reason is that now it&#8217;s a lot easier to navigate the Package Explorer with the keyboard. Another reason to <a href="http://eclipseone.wordpress.com/2010/02/03/how-to-manage-keyboard-shortcuts-in-eclipse/">start learning Eclipse keyboard shortcuts</a> and also impress your colleagues.</p>
<h3>Related Tips</h3>
<ul>
<li><a title="Instantly show a class/file in the Package/Project Explorer in Eclipse" href="http://eclipseone.wordpress.com/2010/01/06/instantly-show-a-classfile-in-the-packageproject-explorer-in-eclipse/">Instantly show a class/file in the Package/Project Explorer in Eclipse</a></li>
<li><a title="Use Fast Views to maximise screen space" href="http://eclipseone.wordpress.com/2009/12/10/use-fast-views-to-maximise-screen-space/">Use Fast Views to maximise screen space</a></li>
<li><a href="http://eclipseone.wordpress.com/2010/02/15/the-fastest-ways-to-navigate-views-in-eclipse-using-the-keyboard/">The fastest ways to navigate views in Eclipse using the keyboard</a></li>
<li><a href="http://eclipseone.wordpress.com/2010/03/22/share-eclipse-perspective-layouts-across-multiple-workspaces/">Share Eclipse perspective layouts across multiple workspaces</a></li>
<li>More tips on <a href="http://eclipseone.wordpress.com/category/views/">managing views</a>, <a href="http://eclipseone.wordpress.com/category/maximise-screen-space/">maximising screen space</a> and <a href="http://eclipseone.wordpress.com/category/navigation-browsing/">navigating and browsing</a> files.</li>
</ul>
<h3>Share This Tip</h3>
<p style="text-align:left;" class="getsocial"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1001.png?w=468" /><a title="Add to Facebook" href="http://www.facebook.com/sharer.php?u=http://eclipseone.wordpress.com/2010/04/08/categorise-projects-in-the-package-explorer-to-reduce-clutter-in-eclipse" rel="nofollow" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1011.png?w=468" alt="Add to Facebook" /></a><a title="Add to Digg" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F04%2F08%2Fcategorise-projects-in-the-package-explorer-to-reduce-clutter-in-eclipse&amp;title=Categorise%20projects%20in%20the%20Package%20Explorer%20to%20reduce%20clu..." rel="nofollow" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1021.png?w=468" alt="Add to Digg" /></a><a title="Add to Del.icio.us" href="http://del.icio.us/post?url=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F04%2F08%2Fcategorise-projects-in-the-package-explorer-to-reduce-clutter-in-eclipse&amp;title=Categorise%20projects%20in%20the%20Package%20Explorer%20to%20reduce%20clutter%20in%20Eclipse" rel="nofollow" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1031.png?w=468" alt="Add to Del.icio.us" /></a><a title="Add to Stumbleupon" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F04%2F08%2Fcategorise-projects-in-the-package-explorer-to-reduce-clutter-in-eclipse&amp;title=Categorise%20projects%20in%20the%20Package%20Explorer%20to%20reduce%20clutter%20in%20Eclipse" rel="nofollow" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1041.png?w=468" alt="Add to Stumbleupon" /></a><a title="Add to Reddit" href="http://reddit.com/submit?url=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F04%2F08%2Fcategorise-projects-in-the-package-explorer-to-reduce-clutter-in-eclipse&amp;title=Categorise%20projects%20in%20the%20Package%20Explorer%20to%20reduce%20clutter%20in%20Eclipse" rel="nofollow" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1051.png?w=468" alt="Add to Reddit" /></a><a title="Add to Blinklist" href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Description=&amp;Url=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F04%2F08%2Fcategorise-projects-in-the-package-explorer-to-reduce-clutter-in-eclipse&amp;Title=Categorise%20projects%20in%20the%20Package%20Explorer%20to%20reduce%20clutter%20in%20Eclipse" rel="nofollow" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1061.png?w=468" alt="Add to Blinklist" /></a><a title="Add to Twitter" href="http://twitter.com/home/?status=Categorise%20projects%20in%20the%20Package%20Explorer%20to%20reduce%20clutter%20in%20Eclipse+%40+http%3A%2F%2Fbit.ly%2Fd4uGXv" rel="nofollow" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1071.png?w=468" alt="Add to Twitter" /></a><a title="Add to Technorati" href="http://www.technorati.com/faves?add=http://eclipseone.wordpress.com/2010/04/08/categorise-projects-in-the-package-explorer-to-reduce-clutter-in-eclipse" rel="nofollow" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1081.png?w=468" alt="Add to Technorati" /></a><a title="Add to Yahoo Buzz" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F04%2F08%2Fcategorise-projects-in-the-package-explorer-to-reduce-clutter-in-eclipse&amp;headline=Categorise%20projects%20in%20the%20Package%20Explorer%20to%20reduce%20clutter%20in%20Eclipse" rel="nofollow" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1091.png?w=468" alt="Add to Yahoo Buzz" /></a><a title="Add to Newsvine" href="http://www.newsvine.com/_wine/save?u=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F04%2F08%2Fcategorise-projects-in-the-package-explorer-to-reduce-clutter-in-eclipse&amp;h=Categorise%20projects%20in%20the%20Package%20Explorer%20to%20reduce%20clutter%20in%20Eclipse" rel="nofollow" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1101.png?w=468" alt="Add to Newsvine" /></a><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1111.png?w=468" /></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/eclipseone.wordpress.com/1148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/eclipseone.wordpress.com/1148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/eclipseone.wordpress.com/1148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/eclipseone.wordpress.com/1148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/eclipseone.wordpress.com/1148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/eclipseone.wordpress.com/1148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/eclipseone.wordpress.com/1148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/eclipseone.wordpress.com/1148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/eclipseone.wordpress.com/1148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/eclipseone.wordpress.com/1148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/eclipseone.wordpress.com/1148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/eclipseone.wordpress.com/1148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/eclipseone.wordpress.com/1148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/eclipseone.wordpress.com/1148/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eclipseone.wordpress.com&amp;blog=10678932&amp;post=1148&amp;subd=eclipseone&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://eclipseone.wordpress.com/2010/04/08/categorise-projects-in-the-package-explorer-to-reduce-clutter-in-eclipse/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9af99e9ee23204988228aaf14316cbd1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Byron</media:title>
		</media:content>

		<media:content url="http://eclipseone.files.wordpress.com/2010/04/package-explorer-before-organising.jpg" medium="image">
			<media:title type="html">Package Explorer Before Organising</media:title>
		</media:content>

		<media:content url="http://eclipseone.files.wordpress.com/2010/04/package-explorer-after-organising.jpg" medium="image">
			<media:title type="html">Package Explorer After Organising</media:title>
		</media:content>

		<media:content url="http://eclipseone.files.wordpress.com/2010/04/select-working-set-dialog.jpg" medium="image">
			<media:title type="html">Select Working Set Dialog</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1001.png" medium="image" />

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1011.png" medium="image">
			<media:title type="html">Add to Facebook</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1021.png" medium="image">
			<media:title type="html">Add to Digg</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1031.png" medium="image">
			<media:title type="html">Add to Del.icio.us</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1041.png" medium="image">
			<media:title type="html">Add to Stumbleupon</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1051.png" medium="image">
			<media:title type="html">Add to Reddit</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1061.png" medium="image">
			<media:title type="html">Add to Blinklist</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1071.png" medium="image">
			<media:title type="html">Add to Twitter</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1081.png" medium="image">
			<media:title type="html">Add to Technorati</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1091.png" medium="image">
			<media:title type="html">Add to Yahoo Buzz</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1101.png" medium="image">
			<media:title type="html">Add to Newsvine</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1111.png" medium="image" />
	</item>
		<item>
		<title>Quickly declare and initialise lists, maps and arrays with Eclipse templates</title>
		<link>http://eclipseone.wordpress.com/2010/03/30/declare-initialise-lists-maps-arrays-with-eclipse-templates/</link>
		<comments>http://eclipseone.wordpress.com/2010/03/30/declare-initialise-lists-maps-arrays-with-eclipse-templates/#comments</comments>
		<pubDate>Tue, 30 Mar 2010 07:24:45 +0000</pubDate>
		<dc:creator>Byron</dc:creator>
				<category><![CDATA[Templates]]></category>

		<guid isPermaLink="false">http://eclipseone.wordpress.com/?p=1117</guid>
		<description><![CDATA[Java has a lot of boilerplate code, although each new version tries to remove a bit more every time. One area particularly affected is when you have to declare and initialise lists, maps or sets (some of it hopefully simplified in Java 7). Here&#8217;s some sample code: To create any of these, you have to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eclipseone.wordpress.com&amp;blog=10678932&amp;post=1117&amp;subd=eclipseone&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Java has a lot of boilerplate code, although each new version tries to remove a bit more every time. One area particularly affected is when you have to declare and initialise lists, maps or sets (some of it hopefully simplified in Java 7). Here&#8217;s some sample code:</p>
<p><pre class="brush: java;">
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
...
Map&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();
List&lt;String&gt; list = new ArrayList&lt;String&gt;();
Set&lt;String&gt; set = new HashSet&lt;String&gt;();
String[] array = new String[] {};
</pre></p>
<p>To create any of these, you have to type a lot. Sometimes you make a mistake and have to retype. And half a minute later you&#8217;ve got one line of code that just declares a list. Also, you can <a href="http://eclipseone.wordpress.com/2009/12/13/automatically-format-and-cleanup-code-every-time-you-save/">have Eclipse automatically add imports when you save</a>, but Eclipse normally can&#8217;t guess the correct List, instead prompting you to choose between java.util.List and java.awt.List (why isn&#8217;t there an option to use the former as the default?).</p>
<p>But Eclipse templates can help you avoid the hassle. Not only will it create the correct import statements, but also remove the effort of typing out the same type in the interface and implementation collection. If you&#8217;re new to templates, then see <a href="../2009/11/26/kill-the-code-zombies-with-editor-templates/">this tip</a> to get an overview.</p>
<p><span id="more-1117"></span></p>
<h3>Import the templates automatically</h3>
<p>Download the templates below then <a href="http://eclipseone.wordpress.com/2009/11/29/how-to-tweak-eclipse-templates-to-suit-you#HowToImportExport">import them into Eclipse</a>.</p>
<ul>
<li><a href="http://www.box.net/shared/pi88fh7gih">Declaration templates</a>: This bundle includes:<br />
<strong>arraylist:</strong> A List declaration together with an ArrayList initialisation. Automatically imports the correct list (java.util.List).<br />
<strong>hashmap:</strong> A Map declaration together with a HashMap initialisation.<br />
<strong>hashset:</strong> A Set declaration together with a HashSet initialisation.</li>
<li><a href="http://www.box.net/shared/vsgpjexi56">Initialisation templates</a>: This bundle includes:<strong><br />
initarray:</strong> An array declaration together with an array initialisation block.<br />
<strong>initlist:</strong> A List declaration together with an <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Arrays.html">Arrays.asList()</a> call for easy list initialisation.<br />
<strong>initmap: </strong>A Map declaration together with a call to Apache Commons Lang&#8217;s <a href="http://commons.apache.org/lang/apidocs/index.html?org/apache/commons/lang/ArrayUtils.html">ArrayUtils.toMap()</a> that makes light work of map initialisation. Commons Lang is sometimes already a dependency of external libraries so you may already be dependent on it, but this can extend to any other collection library (eg. Google Collections). You may get an unchecked warning because the method <em>toMap() </em>doesn&#8217;t use generics. I normally just add a @SuppressWarning(&#8220;unchecked).</li>
</ul>
<h3>Related Tips</h3>
<p>Here are some more template-related tips to help you work faster:</p>
<ul>
<li>Check out the <a href="http://eclipseone.wordpress.com/category/templates/">list of all templates</a> that you can download and import into Eclipse.</li>
<li>You can get an <a href="http://eclipseone.wordpress.com/2009/11/26/kill-the-code-zombies-with-editor-templates/">overview of templates</a> to see what they are and how to use them.</li>
<li>Once you have the template, you can see how to <a href="http://eclipseone.wordpress.com/2009/11/29/how-to-tweak-eclipse-templates-to-suit-you/">import or change</a> it in Eclipse.</li>
</ul>
<h3>Share This Tip</h3>
<p class="getsocial" style="text-align:left;"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1004.png?w=468" alt="" /><a title="Add to Facebook" rel="nofollow" href="http://www.facebook.com/sharer.php?u=http://eclipseone.wordpress.com/2010/03/30/declare-initialise-lists-maps-arrays-with-eclipse-templates" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1014.png?w=468" alt="Add to Facebook" /></a><a title="Add to Digg" rel="nofollow" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F03%2F30%2Fdeclare-initialise-lists-maps-arrays-with-eclipse-templates&amp;title=Quickly%20declare%20and%20initialise%20lists%2C%20maps%20and%20arrays%20wit..." target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1024.png?w=468" alt="Add to Digg" /></a><a title="Add to Del.icio.us" rel="nofollow" href="http://del.icio.us/post?url=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F03%2F30%2Fdeclare-initialise-lists-maps-arrays-with-eclipse-templates&amp;title=Quickly%20declare%20and%20initialise%20lists%2C%20maps%20and%20arrays%20with%20Eclipse%20templates" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1034.png?w=468" alt="Add to Del.icio.us" /></a><a title="Add to Stumbleupon" rel="nofollow" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F03%2F30%2Fdeclare-initialise-lists-maps-arrays-with-eclipse-templates&amp;title=Quickly%20declare%20and%20initialise%20lists%2C%20maps%20and%20arrays%20with%20Eclipse%20templates" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1044.png?w=468" alt="Add to Stumbleupon" /></a><a title="Add to Reddit" rel="nofollow" href="http://reddit.com/submit?url=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F03%2F30%2Fdeclare-initialise-lists-maps-arrays-with-eclipse-templates&amp;title=Quickly%20declare%20and%20initialise%20lists%2C%20maps%20and%20arrays%20with%20Eclipse%20templates" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1054.png?w=468" alt="Add to Reddit" /></a><a title="Add to Blinklist" rel="nofollow" href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Description=&amp;Url=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F03%2F30%2Fdeclare-initialise-lists-maps-arrays-with-eclipse-templates&amp;Title=Quickly%20declare%20and%20initialise%20lists%2C%20maps%20and%20arrays%20with%20Eclipse%20templates" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1064.png?w=468" alt="Add to Blinklist" /></a><a title="Add to Twitter" rel="nofollow" href="http://twitter.com/home/?status=Quickly%20declare%20and%20initialise%20lists%2C%20maps%20and%20arrays%20with%20Eclipse%20templates+%40+http%3A%2F%2Fbit.ly%2FaSV7bZ" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1074.png?w=468" alt="Add to Twitter" /></a><a title="Add to Technorati" rel="nofollow" href="http://www.technorati.com/faves?add=http://eclipseone.wordpress.com/2010/03/30/declare-initialise-lists-maps-arrays-with-eclipse-templates" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1084.png?w=468" alt="Add to Technorati" /></a><a title="Add to Yahoo Buzz" rel="nofollow" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F03%2F30%2Fdeclare-initialise-lists-maps-arrays-with-eclipse-templates&amp;headline=Quickly%20declare%20and%20initialise%20lists%2C%20maps%20and%20arrays%20with%20Eclipse%20templates" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1094.png?w=468" alt="Add to Yahoo Buzz" /></a><a title="Add to Newsvine" rel="nofollow" href="http://www.newsvine.com/_wine/save?u=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F03%2F30%2Fdeclare-initialise-lists-maps-arrays-with-eclipse-templates&amp;h=Quickly%20declare%20and%20initialise%20lists%2C%20maps%20and%20arrays%20with%20Eclipse%20templates" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1104.png?w=468" alt="Add to Newsvine" /></a><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1114.png?w=468" alt="" /></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/eclipseone.wordpress.com/1117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/eclipseone.wordpress.com/1117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/eclipseone.wordpress.com/1117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/eclipseone.wordpress.com/1117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/eclipseone.wordpress.com/1117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/eclipseone.wordpress.com/1117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/eclipseone.wordpress.com/1117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/eclipseone.wordpress.com/1117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/eclipseone.wordpress.com/1117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/eclipseone.wordpress.com/1117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/eclipseone.wordpress.com/1117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/eclipseone.wordpress.com/1117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/eclipseone.wordpress.com/1117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/eclipseone.wordpress.com/1117/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eclipseone.wordpress.com&amp;blog=10678932&amp;post=1117&amp;subd=eclipseone&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://eclipseone.wordpress.com/2010/03/30/declare-initialise-lists-maps-arrays-with-eclipse-templates/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9af99e9ee23204988228aaf14316cbd1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Byron</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1004.png" medium="image" />

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1014.png" medium="image">
			<media:title type="html">Add to Facebook</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1024.png" medium="image">
			<media:title type="html">Add to Digg</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1034.png" medium="image">
			<media:title type="html">Add to Del.icio.us</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1044.png" medium="image">
			<media:title type="html">Add to Stumbleupon</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1054.png" medium="image">
			<media:title type="html">Add to Reddit</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1064.png" medium="image">
			<media:title type="html">Add to Blinklist</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1074.png" medium="image">
			<media:title type="html">Add to Twitter</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1084.png" medium="image">
			<media:title type="html">Add to Technorati</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1094.png" medium="image">
			<media:title type="html">Add to Yahoo Buzz</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1104.png" medium="image">
			<media:title type="html">Add to Newsvine</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1114.png" medium="image" />
	</item>
		<item>
		<title>Eclipse shortcuts for common SVN commands</title>
		<link>http://eclipseone.wordpress.com/2010/03/24/eclipse-shortcuts-for-common-svn-commands/</link>
		<comments>http://eclipseone.wordpress.com/2010/03/24/eclipse-shortcuts-for-common-svn-commands/#comments</comments>
		<pubDate>Wed, 24 Mar 2010 08:42:49 +0000</pubDate>
		<dc:creator>Byron</dc:creator>
				<category><![CDATA[Keyboard Shortcuts]]></category>
		<category><![CDATA[Navigation & Browsing]]></category>
		<category><![CDATA[Source Control & Team]]></category>

		<guid isPermaLink="false">http://eclipseone.wordpress.com/?p=1102</guid>
		<description><![CDATA[When working with SVN, CVS or any other repo, there are some things you&#8217;ll just do over and over again. Things like committing files, comparing files and viewing a file&#8217;s history are all commonplace actions. So you might be wondering where the keyboard shortcuts for these actions are, because,  as I mentioned before, you normally [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eclipseone.wordpress.com&amp;blog=10678932&amp;post=1102&amp;subd=eclipseone&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>When working with SVN, CVS or any other repo, there are some things you&#8217;ll just do over and over again. Things like committing files, comparing files and viewing a file&#8217;s history are all commonplace actions.</p>
<p>So you might be wondering where the keyboard shortcuts for these actions are, because,  <a href="http://eclipseone.wordpress.com/2010/02/03/how-to-manage-keyboard-shortcuts-in-eclipse/">as I mentioned before</a>, you normally work faster with keyboard shortcuts than jumping between the mouse and keyboard all the time. And often the longest part about working with repos is guiding your mouse through treacherous context menus and submenus.</p>
<p>The good news is that there are keyboard shortcuts in Eclipse for the most common repository commands (and not-so-common as well). The bad news is that most of them aren&#8217;t configured by default, so you need to set some of them up beforehand. But the 2 minutes spent configuring these may save you hours in the long run.</p>
<p>I&#8217;ll be using SVN as the example repository (using Subclipse) but these should apply to your favourite repository integrated into Eclipse (I know that the in-built CVS has these commands as well).</p>
<p><span id="more-1102"></span></p>
<h3>Common SVN keyboard shortcuts</h3>
<p>So, here are the keyboard shortcuts you can configure and some suggestions for what to set them to. In summary, go to <strong>Window &gt; Preferences &gt; General &gt; Keys</strong>, then use the Command colum below to search for the SVN command you&#8217;re interested in. But have a look at <a href="http://eclipseone.wordpress.com/2010/02/03/how-to-manage-keyboard-shortcuts-in-eclipse/">how to manage keyboard shortcuts</a> for more details about configuring shortcuts. If you don&#8217;t like the suggested shortcut, you can, of course, choose any shortcut you like.</p>
<p><strong>Note:</strong> <em>None</em> of these shortcuts are configured by default &#8211; you have to configure this yourself. Also, in the description, a <em>resource</em> can refer to a file, folder or project, including the active editor.</p>
<p>Also, Eclipse 3.6 (Helios) introduced a bug that disables the SVN keyboard commands by default. You have to enable these manually: Right-click on the toolbar and select <strong>Customize Perspective</strong>. Then go to <strong>Command Group Availability</strong> and in the <strong>Available command groups </strong>select the <strong>SVN</strong> option. This is probably still in 3.7 (see <a href="http://subclipse.tigris.org/issues/show_bug.cgi?id=1159">this Subclipse bug</a> and <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=306173">this Eclipse bug</a> for more details)<strong></strong>.</p>
<table style="border-collapse:collapse;border-style:solid;border-width:thin;padding:20px;" border="1" cellpadding="3">
<tbody>
<tr>
<td><strong>Suggested Shortcut</strong></td>
<td><strong>Command</strong></td>
<td><strong>Description</strong></td>
</tr>
<tr>
<td>Alt+Shift+Y, C</td>
<td>Commit</td>
<td>Opens the commit dialog so you can commit the selected resource. Combined with <a href="http://eclipseone.wordpress.com/2010/02/15/the-fastest-ways-to-navigate-views-in-eclipse-using-the-keyboard/">shortcuts for navigating to</a> and <a href="http://eclipseone.wordpress.com/2010/01/06/instantly-show-a-classfile-in-the-packageproject-explorer-in-eclipse/">opening selected resources in the Package Explorer</a>, you can commit anything easily using the keyboard.</td>
</tr>
<tr>
<td>Alt+Shift+Y, Y</td>
<td>Compare with Latest from Repository</td>
<td>Compares the selected resource with the latest version in SVN. I use this all the time.</td>
</tr>
<tr>
<td>Alt+Shift+Y, H</td>
<td>Show History</td>
<td>Opens the selected resource in the history view and displays the latest version control history for the resource. <em>Very, very</em> handy shortcut.</td>
</tr>
<tr>
<td>Alt+Shift+Y, S</td>
<td>Show View (View: Synchronize)</td>
<td>Navigates to the Synchronize View from where you can do updates and commits.</td>
</tr>
<tr>
<td>Alt+Shift+Y, U</td>
<td>Update</td>
<td>Updates the selected resource with the latest changes in SVN.</td>
</tr>
</tbody>
</table>
<p>Be sure to configure the shortcut for the right repository. Eg, in the image below, there are two entries for commit, one for each of the repositories registered with Eclipse. Since I&#8217;m using Subclipse, I&#8217;m interested in the SVN category.</p>
<p><a href="http://eclipseone.files.wordpress.com/2010/03/repository-keyboard-shortcuts.jpg"><img class="aligncenter size-full wp-image-1110" title="Repository Keyboard Shortcuts" src="http://eclipseone.files.wordpress.com/2010/03/repository-keyboard-shortcuts.jpg?w=468&#038;h=259" alt="" width="468" height="259" /></a></p>
<p>Depending on what you work with, you might want to consider other commands as well, such as Compare with Local Base Revision, Merge and Show Annotation.</p>
<h3>Shortcuts for doing comparisons</h3>
<p>Using shortcuts in the comparison editor can also make you work a lot faster. Note that you don&#8217;t have to configure the first two as they are configured by default.</p>
<table style="border-collapse:collapse;border-style:solid;border-width:thin;padding:20px;" border="1" cellpadding="3">
<tbody>
<tr>
<td><strong>Shortcut</strong></td>
<td><strong>Command</strong></td>
<td><strong>Description</strong></td>
</tr>
<tr>
<td>Ctrl+.</td>
<td>Next</td>
<td>Moves to the next change in the comparison editor. Also navigates to the next file in the Synchronize View but only if this view had focus initially when opening the comparison editor. <em>Already configured.</em><em> </em></td>
</tr>
<tr>
<td>Ctrl+,</td>
<td>Previous</td>
<td>Moves to the previous change in the comparison editor. The same note above about the Synchronize View applies. <em>Already configured.</em></td>
</tr>
<tr>
<td>Ctrl+Shift+&lt;</td>
<td>Copy from Right to Left</td>
<td>Copies the selected change from the right (normally repository file) to the left (normally your local file). <em>Not configured by default.</em></td>
</tr>
</tbody>
</table>
<p>These shortcuts replace the up/down arrows you&#8217;ll see in the comparison editor, eg. as in the image below. Pressing Ctrl+./Ctrl+, will move to the next change and select it so you can either edit it or copy the change from right to left.</p>
<p><a href="http://eclipseone.files.wordpress.com/2010/03/compare-editor-keyboard-shortcuts.jpg"><img class="aligncenter size-full wp-image-1112" title="Compare Editor Keyboard Shortcuts" src="http://eclipseone.files.wordpress.com/2010/03/compare-editor-keyboard-shortcuts.jpg?w=468&#038;h=240" alt="" width="468" height="240" /></a></p>
<h3>Related Tips</h3>
<p>These tips should help working with SVN and code in general a lot easier:</p>
<ul>
<li>Check out <a href="http://eclipseone.wordpress.com/2010/01/25/checkout-multiple-projects-automatically-into-your-eclipse-workspace/">how to checkout multiple projects automaticallyfrom SVN using team project sets</a>.</li>
<li>Use <a href="http://eclipseone.wordpress.com/category/keyboard-shortcuts/">many other keyboard shortcuts</a> in Eclipse to work faster and let go of the mouse. Especially check out <a href="http://eclipseone.wordpress.com/2010/02/03/how-to-manage-keyboard-shortcuts-in-eclipse/">how to manage keyboard shortcuts and why you should</a>.</li>
<li>A lot of other tips can help with <a href="http://eclipseone.wordpress.com/category/source-control-team/">working with source control</a> and also <a href="http://eclipseone.wordpress.com/category/navigation-browsing/">navigating Eclipse</a>.</li>
</ul>
<h3>Share This Tip</h3>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/eclipseone.wordpress.com/1102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/eclipseone.wordpress.com/1102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/eclipseone.wordpress.com/1102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/eclipseone.wordpress.com/1102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/eclipseone.wordpress.com/1102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/eclipseone.wordpress.com/1102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/eclipseone.wordpress.com/1102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/eclipseone.wordpress.com/1102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/eclipseone.wordpress.com/1102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/eclipseone.wordpress.com/1102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/eclipseone.wordpress.com/1102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/eclipseone.wordpress.com/1102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/eclipseone.wordpress.com/1102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/eclipseone.wordpress.com/1102/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eclipseone.wordpress.com&amp;blog=10678932&amp;post=1102&amp;subd=eclipseone&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://eclipseone.wordpress.com/2010/03/24/eclipse-shortcuts-for-common-svn-commands/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9af99e9ee23204988228aaf14316cbd1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Byron</media:title>
		</media:content>

		<media:content url="http://eclipseone.files.wordpress.com/2010/03/repository-keyboard-shortcuts.jpg" medium="image">
			<media:title type="html">Repository Keyboard Shortcuts</media:title>
		</media:content>

		<media:content url="http://eclipseone.files.wordpress.com/2010/03/compare-editor-keyboard-shortcuts.jpg" medium="image">
			<media:title type="html">Compare Editor Keyboard Shortcuts</media:title>
		</media:content>
	</item>
		<item>
		<title>Share Eclipse perspective layouts across multiple workspaces</title>
		<link>http://eclipseone.wordpress.com/2010/03/22/share-eclipse-perspective-layouts-across-multiple-workspaces/</link>
		<comments>http://eclipseone.wordpress.com/2010/03/22/share-eclipse-perspective-layouts-across-multiple-workspaces/#comments</comments>
		<pubDate>Mon, 22 Mar 2010 08:24:01 +0000</pubDate>
		<dc:creator>Byron</dc:creator>
				<category><![CDATA[Installation & Setup]]></category>
		<category><![CDATA[Preferences]]></category>
		<category><![CDATA[Views]]></category>
		<category><![CDATA[Window & Toolbar]]></category>

		<guid isPermaLink="false">http://eclipseone.wordpress.com/?p=1077</guid>
		<description><![CDATA[Once you&#8217;ve configured Eclipse preferences to your heart&#8217;s content, you&#8217;ll often want to share those preferences across multiple workspaces. Now normally you can go to File &#62; Export &#62; General &#62; Preferences to save your preferences to a properties file which you can then import into the other workspace. This will share settings such as [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eclipseone.wordpress.com&amp;blog=10678932&amp;post=1077&amp;subd=eclipseone&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Once you&#8217;ve configured Eclipse preferences to your heart&#8217;s content, you&#8217;ll often want to share those preferences across multiple workspaces. Now normally you can go to File &gt; Export &gt; General &gt; Preferences to save your preferences to a properties file which you can then import into the other workspace. This will share settings such as your customised keyboard shortcuts, formatting, repository settings, etc.</p>
<p>But, for some reason, Eclipse doesn&#8217;t save perspective/window layouts, such as which views are open and where they are placed in the perspective. So you&#8217;ll find yourself spending another half hour configuring the window to the way you like it. After the 3rd workspace you need to create, this becomes frustrating and just wastes time.</p>
<p>Fortunately there are ways to save and restore these settings automatically. The first is to save the perspective into the preferences and the other is to use Eclipse&#8217;s <em>Copy Settings</em> feature when opening the other workspace. I prefer the first option, but I&#8217;ll mention the second option and when to use the one over the other.</p>
<p><span id="more-1077"></span></p>
<h3>Method 1: Save the layout as a new perspective</h3>
<p>The first method is to save the perspective layout as another perspective, then export the preferences file as normal. The saved perspective&#8217;s settings will be included in the preferences file. When you&#8217;ve updated the layout,  just resave and overwrite the perspective and export the preferences again.</p>
<p>To save your perspective, select <strong>Window &gt; Save Perspective As&#8230;</strong> from the application menu. A dialog should popup (shown below), prompting you for a perspective name. Enter a name  that you&#8217;ll remember, eg. <em>My Java</em> or <em>Debug Jack</em>. Click Ok once you&#8217;ve entered a new name.</p>
<p><strong>Note</strong>: You can choose to overwrite one of the default perspectives, eg. <em>Java</em>, without fear. However, I prefer to leave these intact, so always choose a new name, but you can choose whatever works for you.</p>
<p><a href="http://eclipseone.files.wordpress.com/2010/03/save-perspective-as.jpg"><img class="aligncenter size-full wp-image-1079" title="Save Perspective As" src="http://eclipseone.files.wordpress.com/2010/03/save-perspective-as.jpg?w=468" alt=""   /></a></p>
<p>Now you can go through the normal routine of exporting the preferences to a properties file via <strong>File &gt; Export &gt; General &gt; Preferences</strong>. Then import the same  file in another workspace via <strong>File &gt; Import &gt; General &gt; Preferences</strong>. All you now have to do is switch over to the perspective you saved and all your layout settings will be restored. If you overwrote one of the default perspectives, you may have to select <strong>Window &gt; Reset Perspective&#8230;</strong> to restore the saved settings.</p>
<p>If you&#8217;ve chosen to create a new perspective, be sure to point your Run/Debug settings to the new perspective under <strong>Window &gt; Preferences &gt; Run/Debug &gt; Perspectives</strong>. For example, if you made a new perspective based on the Debug perspective, then you&#8217;ll need to change references to the <em>Debug</em> perspective to the <em>My Debug</em> for launchers you use. Luckily this is only required once as these settings are also saved when you export preferences (at least since Eclipse 3.5).</p>
<p><strong>Gotcha:</strong> I <a href="http://eclipseone.wordpress.com/2009/12/10/use-fast-views-to-maximise-screen-space/">use fast views a lot</a>, and for some reason the Fast View dock&#8217;s position isn&#8217;t restored automatically. But manually restoring this is as easy as moving the dock, so it&#8217;s not that bad. Toolbar settings aren&#8217;t saved either, but I haven&#8217;t tampered with these a lot anyway since I prefer using the keyboard and mouse gestures.</p>
<h3>Method 2: Use Copy Settings</h3>
<p>The other method of saving your window layout is to use the <em>Copy Settings</em> feature when switching to another workspace.</p>
<p>To use this feature, first open the workspace that contains your customised layout. Then select <strong>File &gt; Switch Workspace &gt; Other&#8230;</strong> which will open a dialog prompting you for an existing/new workspace. Select the workspace, then click the <em>Copy Settings</em> collapsible section. Select the <strong>Workbench Layout</strong> checkbox and click Ok. Your workspace will open and should reflect the customised layout of the previous workspace.</p>
<p>Here&#8217;s what the dialog looks like:</p>
<p><a href="http://eclipseone.files.wordpress.com/2010/03/switch-workspace-dialog1.jpg"><img class="aligncenter size-full wp-image-1082" title="Switch Workspace Dialog" src="http://eclipseone.files.wordpress.com/2010/03/switch-workspace-dialog1.jpg?w=468&#038;h=237" alt="" width="468" height="237" /></a></p>
<h3>Which method should I use?</h3>
<p>Well, as I said before, I prefer the first method for a number of reasons. If some of these apply to you then you might want to use the first method as well. Use this method if:</p>
<ul>
<li>You want to share layout settings across workspaces on different machines, eg. work and home. This method is a lot more portable because you only need one single properties file.</li>
<li>You spend 90% of your time in 1 or 2 perspectives (eg. Java &amp; Debug) then this method works well because you only have to manage those perspectives.</li>
<li>You make a lot temporary changes to perspectives that you don&#8217;t necessarily want shared. For example, if you&#8217;ve opened a number of views that you rarely use, you don&#8217;t want to clutter your new workspace with these views. I find that I have my &#8220;base&#8221; perspective layout, around which things will change depending on the context and I don&#8217;t want these to clutter my &#8220;base&#8221; layout.</li>
<li>You want to share preferences with a colleague/friend.</li>
</ul>
<p>Use the Copy Settings method if:</p>
<ul>
<li>You want to quickly create another workspace with the saved layout without having to export any preferences.</li>
<li>You have made a number of changes across many perspectives and you want to restore those settings.</li>
<li>You&#8217;re feeling lazy. With this method, Eclipse manages a lot more things, so it&#8217;s a bit easier to manage (in the short-term), but for the longer term, the first method is best.</li>
</ul>
<h3>Related Tips</h3>
<p>So now you know how to save window layouts, have a look at these other tips:</p>
<ul>
<li>You can <a href="http://eclipseone.wordpress.com/2009/12/10/use-fast-views-to-maximise-screen-space/">use fast views to maximise screen space</a>. Very handy for small screens.</li>
<li>And here are some <a href="http://eclipseone.wordpress.com/2010/02/15/the-fastest-ways-to-navigate-views-in-eclipse-using-the-keyboard/">fast ways to navigate between views using the keyboard</a>.</li>
<li>Sharing workspace settings is one thing, but you can also <a href="http://eclipseone.wordpress.com/2009/12/16/the-easy-way-to-reinstall-eclipse-and-share-plugins-across-multiple-installations/">share plugins across multiple Eclipse installations</a>.</li>
<li>Here are some <a href="http://eclipseone.wordpress.com/category/preferences/">tips on how to set some useful preferences</a>, so you can save and share them later.</li>
<li>Check out other handy tips on how to manage <a href="http://eclipseone.wordpress.com/category/views/">views</a> and the <a href="http://eclipseone.wordpress.com/category/window-toolbar/">window</a> in general.</li>
</ul>
<h3>Share This Tip</h3>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/eclipseone.wordpress.com/1077/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/eclipseone.wordpress.com/1077/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/eclipseone.wordpress.com/1077/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/eclipseone.wordpress.com/1077/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/eclipseone.wordpress.com/1077/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/eclipseone.wordpress.com/1077/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/eclipseone.wordpress.com/1077/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/eclipseone.wordpress.com/1077/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/eclipseone.wordpress.com/1077/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/eclipseone.wordpress.com/1077/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/eclipseone.wordpress.com/1077/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/eclipseone.wordpress.com/1077/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/eclipseone.wordpress.com/1077/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/eclipseone.wordpress.com/1077/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eclipseone.wordpress.com&amp;blog=10678932&amp;post=1077&amp;subd=eclipseone&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://eclipseone.wordpress.com/2010/03/22/share-eclipse-perspective-layouts-across-multiple-workspaces/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9af99e9ee23204988228aaf14316cbd1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Byron</media:title>
		</media:content>

		<media:content url="http://eclipseone.files.wordpress.com/2010/03/save-perspective-as.jpg" medium="image">
			<media:title type="html">Save Perspective As</media:title>
		</media:content>

		<media:content url="http://eclipseone.files.wordpress.com/2010/03/switch-workspace-dialog1.jpg" medium="image">
			<media:title type="html">Switch Workspace Dialog</media:title>
		</media:content>
	</item>
		<item>
		<title>Navigate and fix errors and warnings in a class with Eclipse keyboard shortcuts</title>
		<link>http://eclipseone.wordpress.com/2010/03/10/navigate-and-fix-errors-amp-warnings-in-a-class-with-eclipse-keyboard-shortcuts/</link>
		<comments>http://eclipseone.wordpress.com/2010/03/10/navigate-and-fix-errors-amp-warnings-in-a-class-with-eclipse-keyboard-shortcuts/#comments</comments>
		<pubDate>Wed, 10 Mar 2010 08:16:27 +0000</pubDate>
		<dc:creator>Byron</dc:creator>
				<category><![CDATA[Keyboard Shortcuts]]></category>
		<category><![CDATA[Navigation & Browsing]]></category>
		<category><![CDATA[Quick Fixes]]></category>

		<guid isPermaLink="false">http://eclipseone.wordpress.com/?p=1048</guid>
		<description><![CDATA[I really don&#8217;t like it when Eclipse shows errors/warnings annotations in a class. It&#8217;s sometimes nice to jump from one to the next and clean out a class one line at a time, but most of the time they&#8217;re just distractions, so I want to be able to find and fix them fast. So there [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eclipseone.wordpress.com&amp;blog=10678932&amp;post=1048&amp;subd=eclipseone&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I really don&#8217;t like it when Eclipse shows errors/warnings annotations in a class. It&#8217;s sometimes nice to jump from one to the next and clean out a class one line at a time, but most of the time they&#8217;re just distractions, so I want to be able to find and fix them fast.</p>
<p>So there must be a better way to jump between the errors/warnings  than to use the mouse or page down to the next error. These methods are not only slow but often frustrating because you tend to miss the annotation, especially if it&#8217;s a big class. And <a href="http://eclipseone.wordpress.com/2010/02/15/the-fastest-ways-to-navigate-views-in-eclipse-using-the-keyboard/">navigating to the Problems view using the keyboard</a> is ok, but sometimes overkill for just clearing out errors/warnings in one class.</p>
<p>A good thing then that Eclipse offers keyboard shortcuts that take you to the next/previous annotation in the class. And it does so in a way that selects the annotation immediately, allowing you to use Quick Fix (Ctrl+1) to fix it fast. So here&#8217;s how to use these shortcuts to navigate between the error/warning annotations and fix some of the errors easily.</p>
<p><span id="more-1048"></span></p>
<h3>How to jump between errors and warnings</h3>
<p>Below are the keys you can use to go to the next/previous annotation and to initiate quick fix.</p>
<table style="border-collapse:collapse;border-style:solid;border-width:thin;padding:20px;" border="1" cellpadding="3">
<tbody>
<tr>
<td><strong>Shortcut<br />
</strong></td>
<td><strong>Description</strong></td>
</tr>
<tr>
<td>Ctrl+.</td>
<td>Next Annotation. Moves to the next warning/error in the class.</td>
</tr>
<tr>
<td>Ctrl+,</td>
<td>Previous Annotation. Moves to the previous warning/error in the class.</td>
</tr>
<tr>
<td>Ctrl+1</td>
<td>Quick Fix. A fast way to resolve certain warnings/errors automatically, but also <a href="http://eclipseone.wordpress.com/category/quick-fixes/">useful for automating common editing tasks</a>.</td>
</tr>
</tbody>
</table>
<p>To see how fast the next annotation/quick fix combo works, I&#8217;ve set up an example in the following video that shows a class with multiple errors/warnings and how using the next/previous annotation and Quick Fix combo can make you work faster. There&#8217;s 1 warning (an unused variable, <em>message</em>, that should die) and 2 errors (not wrapping a FileOutputStream call in a try-catch and not initialising a local variable <em>output</em>).</p>
<span style="text-align:center; display: block;"><a href="http://eclipseone.wordpress.com/2010/03/10/navigate-and-fix-errors-amp-warnings-in-a-class-with-eclipse-keyboard-shortcuts/"><img src="http://img.youtube.com/vi/gySOxMvWj4A/2.jpg" alt="" /></a></span>
<p>Obviously not all errors are going to be solvable by Quick Fix, but some are: Adding a missing cast, filling in types for generics and adding the @SuppressWarning or @Override annotations.  And for the rest, at least you&#8217;ll be able to get to them easily. <strong>Bonus Tip</strong>: Also see how to <a href="http://eclipseone.wordpress.com/2009/12/13/automatically-format-and-cleanup-code-every-time-you-save/">cleanup some of these warnings automatically every time you save</a>.</p>
<p>You can, of course, remap any of these keyboard shortcuts if they&#8217;re inconvenient. Have a look at <a href="http://eclipseone.wordpress.com/2010/02/03/how-to-manage-keyboard-shortcuts-in-eclipse/">how to manage your keyboard shortcuts</a>, specifically looking out for the commands <em>Next</em>, <em>Previous</em> (yes, for some reason they&#8217;re just called Next and Previous) and <em>Quick Fix</em>.</p>
<h3>Only jumping between errors</h3>
<p>You might sometimes want to tell Eclipse to only move between errors (and not warnings) when you press the next/previous annotation command. Well, this is controlled by a Next/Previous Annotation dropdown menu in the toolbar (as shown in the image below). As you press the next/previous annotation key (either the keyboard shortcut or toolbar button), Eclipse will move to whatever annotations are checked in the dropdown.</p>
<p><a href="http://eclipseone.files.wordpress.com/2010/03/next-annotation-dropdown-menu.jpg"><img class="aligncenter size-full wp-image-1051" title="Next Annotation Dropdown Menu" src="http://eclipseone.files.wordpress.com/2010/03/next-annotation-dropdown-menu.jpg?w=468" alt=""   /></a></p>
<p>Eclipse&#8217;s default only has Errors and Warnings selected (which is a reasonably good default, for once). You could disable Warnings if you only want to move between Errors, or vice versa.</p>
<p><strong>Bonus Tip: </strong>The other selection you might want to enable is <em>Occurrences</em>. An occurrence is when you stand on a variable/method and Eclipse highlights it and its declaration and usages within the class. If you select Occurrences, pressing the next/previous annotation keys will also jump to the variable&#8217;s/method&#8217;s declaration and usages. This is nice when you want to quickly move to the variable&#8217;s usage in a long class. It&#8217;s optional if you want this on, so play around and see if it works for you.</p>
<h3>Related Tips</h3>
<p>Have a look at the following tips that may help you edit and fix code fast:</p>
<ul>
<li>You can <a href="http://eclipseone.wordpress.com/2010/02/15/the-fastest-ways-to-navigate-views-in-eclipse-using-the-keyboard/">navigate between views using the keyboard</a> to quickly jump to the Problems view. This is another (slightly slower) way to fix errors using the keyboard.</li>
<li>Knowing how to <a href="http://eclipseone.wordpress.com/2009/12/13/automatically-format-and-cleanup-code-every-time-you-save/">automatically format and cleanup code every time you save</a> can eliminate some errors/warnings automatically, eg. adding imports, removing unused imports and private members, etc.</li>
<li>Check out this <a href="http://eclipseone.wordpress.com/category/keyboard-shortcuts/">raft of keyboard shortcuts</a> that can make you work faster.</li>
<li>Knowing <a href="http://eclipseone.wordpress.com/category/quick-fixes/">how to use Quick Fix to make editing faster</a> will make life a lot easier, so have a look.</li>
<li>Also have a look at other tips that <a href="http://eclipseone.wordpress.com/category/editing/">make editing faster</a> and <a href="http://eclipseone.wordpress.com/category/navigation-browsing/">navigating Eclipse easier</a>.</li>
<li>Look at <a href="http://eclipseone.wordpress.com/tips-archive/">the Tips Archive for <em>all</em> the tips ever posted on Eclipse On E</a>. There&#8217;s sure to be one that will help you work faster.</li>
</ul>
<h3>Share This Tip</h3>
<p class="getsocial" style="text-align:left;"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1003.png?w=468" alt="" /><a title="Add to Facebook" rel="nofollow" href="http://www.facebook.com/sharer.php?u=http://eclipseone.wordpress.com/2010/03/10/navigate-and-fix-errors-amp-warnings-in-a-class-with-eclipse-keyboard-shortcuts" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1013.png?w=468" alt="Add to Facebook" /></a><a title="Add to Digg" rel="nofollow" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F03%2F10%2Fnavigate-and-fix-errors-amp-warnings-in-a-class-with-eclipse-keyboard-shortcuts&amp;title=Navigate%20and%20fix%20errors%20and%20warnings%20in%20a%20class%20with%20Ecli..." target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1023.png?w=468" alt="Add to Digg" /></a><a title="Add to Del.icio.us" rel="nofollow" href="http://del.icio.us/post?url=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F03%2F10%2Fnavigate-and-fix-errors-amp-warnings-in-a-class-with-eclipse-keyboard-shortcuts&amp;title=Navigate%20and%20fix%20errors%20and%20warnings%20in%20a%20class%20with%20Eclipse%20keyboard%20shortcuts" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1033.png?w=468" alt="Add to Del.icio.us" /></a><a title="Add to Stumbleupon" rel="nofollow" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F03%2F10%2Fnavigate-and-fix-errors-amp-warnings-in-a-class-with-eclipse-keyboard-shortcuts&amp;title=Navigate%20and%20fix%20errors%20and%20warnings%20in%20a%20class%20with%20Eclipse%20keyboard%20shortcuts" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1043.png?w=468" alt="Add to Stumbleupon" /></a><a title="Add to Reddit" rel="nofollow" href="http://reddit.com/submit?url=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F03%2F10%2Fnavigate-and-fix-errors-amp-warnings-in-a-class-with-eclipse-keyboard-shortcuts&amp;title=Navigate%20and%20fix%20errors%20and%20warnings%20in%20a%20class%20with%20Eclipse%20keyboard%20shortcuts" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1053.png?w=468" alt="Add to Reddit" /></a><a title="Add to Blinklist" rel="nofollow" href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Description=&amp;Url=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F03%2F10%2Fnavigate-and-fix-errors-amp-warnings-in-a-class-with-eclipse-keyboard-shortcuts&amp;Title=Navigate%20and%20fix%20errors%20and%20warnings%20in%20a%20class%20with%20Eclipse%20keyboard%20shortcuts" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1063.png?w=468" alt="Add to Blinklist" /></a><a title="Add to Twitter" rel="nofollow" href="http://twitter.com/home/?status=Navigate%20and%20fix%20errors%20and%20warnings%20in%20a%20class%20with%20Eclipse%20keyboard%20shortcuts+%40+http%3A%2F%2Fbit.ly%2FdC4UNS" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1073.png?w=468" alt="Add to Twitter" /></a><a title="Add to Technorati" rel="nofollow" href="http://www.technorati.com/faves?add=http://eclipseone.wordpress.com/2010/03/10/navigate-and-fix-errors-amp-warnings-in-a-class-with-eclipse-keyboard-shortcuts" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1083.png?w=468" alt="Add to Technorati" /></a><a title="Add to Yahoo Buzz" rel="nofollow" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F03%2F10%2Fnavigate-and-fix-errors-amp-warnings-in-a-class-with-eclipse-keyboard-shortcuts&amp;headline=Navigate%20and%20fix%20errors%20and%20warnings%20in%20a%20class%20with%20Eclipse%20keyboard%20shortcuts" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1093.png?w=468" alt="Add to Yahoo Buzz" /></a><a title="Add to Newsvine" rel="nofollow" href="http://www.newsvine.com/_wine/save?u=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F03%2F10%2Fnavigate-and-fix-errors-amp-warnings-in-a-class-with-eclipse-keyboard-shortcuts&amp;h=Navigate%20and%20fix%20errors%20and%20warnings%20in%20a%20class%20with%20Eclipse%20keyboard%20shortcuts" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1103.png?w=468" alt="Add to Newsvine" /></a><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1113.png?w=468" alt="" /></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/eclipseone.wordpress.com/1048/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/eclipseone.wordpress.com/1048/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/eclipseone.wordpress.com/1048/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/eclipseone.wordpress.com/1048/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/eclipseone.wordpress.com/1048/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/eclipseone.wordpress.com/1048/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/eclipseone.wordpress.com/1048/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/eclipseone.wordpress.com/1048/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/eclipseone.wordpress.com/1048/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/eclipseone.wordpress.com/1048/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/eclipseone.wordpress.com/1048/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/eclipseone.wordpress.com/1048/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/eclipseone.wordpress.com/1048/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/eclipseone.wordpress.com/1048/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eclipseone.wordpress.com&amp;blog=10678932&amp;post=1048&amp;subd=eclipseone&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://eclipseone.wordpress.com/2010/03/10/navigate-and-fix-errors-amp-warnings-in-a-class-with-eclipse-keyboard-shortcuts/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9af99e9ee23204988228aaf14316cbd1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Byron</media:title>
		</media:content>

		<media:content url="http://eclipseone.files.wordpress.com/2010/03/next-annotation-dropdown-menu.jpg" medium="image">
			<media:title type="html">Next Annotation Dropdown Menu</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1003.png" medium="image" />

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1013.png" medium="image">
			<media:title type="html">Add to Facebook</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1023.png" medium="image">
			<media:title type="html">Add to Digg</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1033.png" medium="image">
			<media:title type="html">Add to Del.icio.us</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1043.png" medium="image">
			<media:title type="html">Add to Stumbleupon</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1053.png" medium="image">
			<media:title type="html">Add to Reddit</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1063.png" medium="image">
			<media:title type="html">Add to Blinklist</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1073.png" medium="image">
			<media:title type="html">Add to Twitter</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1083.png" medium="image">
			<media:title type="html">Add to Technorati</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1093.png" medium="image">
			<media:title type="html">Add to Yahoo Buzz</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1103.png" medium="image">
			<media:title type="html">Add to Newsvine</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1113.png" medium="image" />
	</item>
		<item>
		<title>Generate class constructors in Eclipse based on fields or superclass constructors</title>
		<link>http://eclipseone.wordpress.com/2010/03/08/generate-class-constructors-in-eclipse-based-on-fields-or-superclass-constructors/</link>
		<comments>http://eclipseone.wordpress.com/2010/03/08/generate-class-constructors-in-eclipse-based-on-fields-or-superclass-constructors/#comments</comments>
		<pubDate>Mon, 08 Mar 2010 08:22:55 +0000</pubDate>
		<dc:creator>Byron</dc:creator>
				<category><![CDATA[Editing]]></category>
		<category><![CDATA[Quick Fixes]]></category>

		<guid isPermaLink="false">http://eclipseone.wordpress.com/?p=1021</guid>
		<description><![CDATA[You&#8217;ll often need to add a constructor to a class based on some/all of its fields or even based on constructors of its superclass. Take the following code: That&#8217;s 5 lines of code (lines 5-9) just to have a constructor. You could write them all by hand, but writing a constructor that accepts and initialises [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eclipseone.wordpress.com&amp;blog=10678932&amp;post=1021&amp;subd=eclipseone&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>You&#8217;ll often need to add a constructor to a class based on some/all of its fields or even based on constructors of its superclass. Take the following code:</p>
<p><pre class="brush: java;">
public class Contact {
    private String name, surname;
    private int age;

    public Contact(String name, String surname, int age) {
        this.name = name;
        this.surname = surname;
        this.age = age;
    }
}
</pre></p>
<p>That&#8217;s 5 lines of code (lines 5-9) just to have a constructor. You could write them all by hand, but writing a constructor that accepts and initialises each field takes a lot of time and becomes irritating after a while. And creating constructors from a superclass can take even longer because the superclass can define multiple constructors that you need to reimplement.</p>
<p>That is why Eclipse has two features to help you generate these constructor instantly: <em>Generate Constructor using Field</em> and <em>Generate Constructor from Superclass</em>. Both features will generate a constructor in seconds, freeing you up to get to the exciting code. You&#8217;ll also see how to add/remove/reorder arguments of an existing constructor based on fields defined in the class.</p>
<p><span id="more-1021"></span></p>
<h3>Generate a constructor from fields</h3>
<p>The fastest way to generate a constructor based on fields is to press <strong>Alt+Shift+S, O</strong> (alternatively select <strong>Source &gt; Generate Constructor using Fields&#8230;</strong> from the application menu). This pops up a dialog where you can select the fields you want to include in the constructor arguments. Once you&#8217;ve selected the fields you want, just click Ok and you&#8217;re done. BTW, Alt+Shif+S is the shortcut to display a shortened Source menu, allowing Java source editing commands.</p>
<p>The following video shows an example of how much time this feature can save you. We&#8217;ll create a constructor for the class Message.</p>
<span style="text-align:center; display: block;"><a href="http://eclipseone.wordpress.com/2010/03/08/generate-class-constructors-in-eclipse-based-on-fields-or-superclass-constructors/"><img src="http://img.youtube.com/vi/I7JsKhArYe8/2.jpg" alt="" /></a></span>
<p><strong>Notes:</strong></p>
<ul>
<li>You can additionally call a superclass constructor with a subset of the fields by changing the dropdown <em>Select super constructor to invoke</em> at the top of the dialog. This creates a <em>super(&#8230;)</em> call with the relevant arguments and initialising code for the rest of the arguments on your subclass&#8217;s constructor.</li>
<li>If you don&#8217;t want the JavaDoc for the constructor, disable the checkbox <em>Generate constructor comments</em> on the dialog.</li>
<li>You can include/exclude the calls to super() using the checkbox <em>Omit call to default constructor super()</em>, on the dialog.</li>
<li>You have to be positioned in a class to invoke this command.</li>
</ul>
<p>If you use frequently use this command, you can <a href="http://eclipseone.wordpress.com/2010/02/03/how-to-manage-keyboard-shortcuts-in-eclipse/">remap its keyboard shortcut by changing the key binding</a> for the command <em>Generate Getters and Setters.</em></p>
<h3>Generate constructor(s) from a superclass</h3>
<p>Sometimes you&#8217;ll want to reimplement some/all of a superclass&#8217;s constructors, especially as part of the contract.</p>
<p>To generate constructor(s) from a superclass, just press <strong>Alt+Shift+S, C </strong>(or alternatively select <strong>Source &gt; Generate Constructor from Superclass&#8230;</strong> from the application menu). A dialog pops up allowing you to select the constructor(s) you&#8217;d like to create. Once you click Ok, Eclipse generates the constructor, together with a super() call.</p>
<p>Here&#8217;s an example of how to create a constructor in SecretMessage, that inherits from the class <em>Message</em>. Message has three constructors: a default one, one that accepts one String (<em>content</em>) and another that accepts three Strings (<em>content</em>, <em>fromAddress</em> and <em>toAddress</em>). SecretMessage should only expose the last two constructors.</p>
<span style="text-align:center; display: block;"><a href="http://eclipseone.wordpress.com/2010/03/08/generate-class-constructors-in-eclipse-based-on-fields-or-superclass-constructors/"><img src="http://img.youtube.com/vi/Hk7e07eOrlA/2.jpg" alt="" /></a></span>
<p><strong>Note:</strong> You have to be positioned in a class to invoke this command.</p>
<p>If you use this command frequently, you can <a href="http://eclipseone.wordpress.com/2010/02/03/how-to-manage-keyboard-shortcuts-in-eclipse/">remap its keyboard shortcut by changing the key binding</a> for the command <em>Generate constructors from superclass</em>.</p>
<h3>Add, reorder and remove fields on existing constructors</h3>
<p>If you have an existing constructor and want to <strong>reorder</strong> its arguments or <strong>remove</strong> some of them, have a look at <a href="http://eclipseone.wordpress.com/2010/02/10/change-a-methods-arguments-across-multiple-classes-in-eclipse/">the Change Method Signature refactoring</a> that does that in a jiffy.</p>
<p>If you want to <strong>add </strong>a single field to an existing constructor, have a look at the next video that uses Eclipse&#8217;s Quick Fix (Ctrl+1) to do that easily. I&#8217;ll add a field <em>createdDate</em> to an existing constructor in Message by choosing <em>Assign parameter to field</em> from the Quick Fix menu while positioned on the field.</p>
<span style="text-align:center; display: block;"><a href="http://eclipseone.wordpress.com/2010/03/08/generate-class-constructors-in-eclipse-based-on-fields-or-superclass-constructors/"><img src="http://img.youtube.com/vi/7HLNFS7rehk/2.jpg" alt="" /></a></span>
<h3>Related Tips</h3>
<p>Now that creating constructors is as easy as making lunch, have a look at some other tips that help you generate boilerplate code faster.</p>
<ul>
<li>The <a href="http://eclipseone.wordpress.com/2010/02/10/change-a-methods-arguments-across-multiple-classes-in-eclipse/">Change Method Signature refactoring</a> comes in handy when you want to reorder/remove arguments from a constructor.</li>
<li>Have a look at <a href="http://eclipseone.wordpress.com/category/editing/">other ways to make editing classes easier and faster</a>.</li>
<li>You can <a href="http://eclipseone.wordpress.com/2009/11/26/kill-the-code-zombies-with-editor-templates/">use templates to generate boilerplate code faster</a>. Also see <a href="http://eclipseone.wordpress.com/category/templates/">a list of some useful templates</a>, such as those for <a href="http://eclipseone.wordpress.com/2010/01/12/log4j-logging-made-easier-with-eclipse-templates/">log4j</a> and <a href="http://eclipseone.wordpress.com/2010/02/24/junit-testing-made-easier-with-eclipse-templates/">JUnit</a>.</li>
<li>Eclipse&#8217;s Quick Fix can do <a href="http://eclipseone.wordpress.com/category/quick-fixes/">a lot of other things</a> for you. For example, have a look at how to <a href="http://eclipseone.wordpress.com/2010/01/19/joinsplit-if-statements-and-rearrange-expressions-using-eclipse-quick-fix/">join/split if statements faster</a> or <a href="http://eclipseone.wordpress.com/2010/01/27/convert-string-concatenations-into-stringbuilder-calls/">how to convert a string concatenation into a call to StringBuilder or MessageFormat</a> using Quick Fix.</li>
</ul>
<h3>Share This Tip</h3>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/eclipseone.wordpress.com/1021/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/eclipseone.wordpress.com/1021/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/eclipseone.wordpress.com/1021/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/eclipseone.wordpress.com/1021/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/eclipseone.wordpress.com/1021/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/eclipseone.wordpress.com/1021/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/eclipseone.wordpress.com/1021/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/eclipseone.wordpress.com/1021/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/eclipseone.wordpress.com/1021/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/eclipseone.wordpress.com/1021/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/eclipseone.wordpress.com/1021/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/eclipseone.wordpress.com/1021/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/eclipseone.wordpress.com/1021/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/eclipseone.wordpress.com/1021/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eclipseone.wordpress.com&amp;blog=10678932&amp;post=1021&amp;subd=eclipseone&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://eclipseone.wordpress.com/2010/03/08/generate-class-constructors-in-eclipse-based-on-fields-or-superclass-constructors/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9af99e9ee23204988228aaf14316cbd1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Byron</media:title>
		</media:content>
	</item>
		<item>
		<title>JUnit testing made easier with Eclipse templates</title>
		<link>http://eclipseone.wordpress.com/2010/02/24/junit-testing-made-easier-with-eclipse-templates/</link>
		<comments>http://eclipseone.wordpress.com/2010/02/24/junit-testing-made-easier-with-eclipse-templates/#comments</comments>
		<pubDate>Wed, 24 Feb 2010 07:47:25 +0000</pubDate>
		<dc:creator>Byron</dc:creator>
				<category><![CDATA[Templates]]></category>

		<guid isPermaLink="false">http://eclipseone.wordpress.com/?p=965</guid>
		<description><![CDATA[When you&#8217;re writing JUnit tests, you&#8217;ll often find yourself repeating the same boilerplate code. Take the following code: If you want to add a test, you have to somehow add lines 3, 11, 12 and 14 before you even get to the actual test. The same holds for setup and teardown code. We know that [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eclipseone.wordpress.com&amp;blog=10678932&amp;post=965&amp;subd=eclipseone&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>When you&#8217;re writing JUnit tests, you&#8217;ll often find yourself repeating the same boilerplate code. Take the following code:</p>
<p><pre class="brush: java; wrap-lines: false;">
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class EngineTest {
    @Before
    public void setup() {
        ...
    }

    @Test
    public void test() throws Exception {
        ...
    }

    @After
    public void tearDown() {
        ...
    }
}
</pre></p>
<p>If you want to add a test, you have to somehow add lines 3, 11, 12 and 14 before you even get to the actual test. The same holds for setup and teardown code. We know that Eclipse can help with <a href="http://eclipseone.wordpress.com/2009/12/13/automatically-format-and-cleanup-code-every-time-you-save/">adding imports automatically when you save</a> or autocomplete, but it still takes time to get everything in place.</p>
<p>Eclipse templates can help take away the drudgery by adding all this boilerplate code automatically. It can automatically add a test, setup and teardown methods together with calls to assertEquals, assertTrue and others. I&#8217;m assuming JUnit 4 in all the templates. If you&#8217;re new to templates, then see <a href="http://eclipseone.wordpress.com/2009/11/26/kill-the-code-zombies-with-editor-templates/">this tip</a> to get an overview.</p>
<p><span id="more-965"></span></p>
<h3>Import the templates automatically</h3>
<p>Download the template below then <a href="http://eclipseone.wordpress.com/2009/11/29/how-to-tweak-eclipse-templates-to-suit-you#HowToImportExport">import it into Eclipse</a>.</p>
<ul>
<li><a href="http://www.box.net/shared/vdy3l8vsrc">JUnit_templates</a>: This bundle includes:<br />
<strong>test4:</strong> Creates a test method together with the @Test annotation and its import. NB: The 4 at the end is to distinguish it from two other  Eclipse built-in templates called <em>test</em> and <em>Test</em>.<br />
<strong>setup4: </strong>Creates a setup method with the @Before annotation and its import.<br />
<strong>teardown4:</strong> Creates a teardown method (called tearDown) with an @After annotation and its import.<br />
<strong>asequals:</strong> A call to assertEquals with its static import. The expected an actual default to locally available objects, but can easily be changed.<br />
<strong>astrue &amp; asfalse: </strong>A call to assertTrue/assertFalse and its static import. The argument defaults to the nearest boolean but can easily be changed.<br />
<strong>asnull</strong> <strong>&amp; asnotnull:</strong> A call to assertNull/assertNotNull and its static import. The argument defaults to the nearest object, but can easily be changed.</li>
</ul>
<p>If you want to create the templates manually, open the template XML in your favourite XML editor, then see <a href="http://eclipseone.wordpress.com/2009/11/29/how-to-tweak-eclipse-templates-to-suit-you#HowToAdd">this tip</a>, taking the values from the relevant fields in the XML.</p>
<h3>Related Tips</h3>
<p>Here are some more templated-related tips to help speed up coding:</p>
<ul>
<li><a href="http://eclipseone.wordpress.com/2010/02/01/generate-static-imports-in-eclipse-on-autocomplete/">Automatically generate static imports when you use autocomplete</a> on JUnit methods such as assertEquals.</li>
<li>Have a look at <a href="http://eclipseone.wordpress.com/2010/01/14/rundebug-a-class-in-eclipse-as-a-junit-test-or-java-app-with-a-single-keystroke/">how to run JUnit tests using only the keyboard</a>.</li>
<li>Here&#8217;s how to <a href="http://eclipseone.wordpress.com/2010/02/15/the-fastest-ways-to-navigate-views-in-eclipse-using-the-keyboard/">quickly navigate to and from the JUnit view using the keyboard</a>.</li>
<li>Check out the <a href="http://eclipseone.wordpress.com/category/templates/">list of all templates</a> that you can download and import into Eclipse.</li>
<li>You can get an <a href="http://eclipseone.wordpress.com/2009/11/26/kill-the-code-zombies-with-editor-templates/">overview of templates</a> to see what they are and how to use them.</li>
<li>Once you have the template, you can see how to <a href="http://eclipseone.wordpress.com/2009/11/29/how-to-tweak-eclipse-templates-to-suit-you/">import or change</a> it in Eclipse.</li>
</ul>
<h3>Share This Tip</h3>
<p class="getsocial" style="text-align:left;"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1002.png?w=468" alt="" /><a title="Add to Facebook" rel="nofollow" href="http://www.facebook.com/sharer.php?u=http://eclipseone.wordpress.com/2010/02/24/junit-testing-made-easier-with-eclipse-templates" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1012.png?w=468" alt="Add to Facebook" /></a><a title="Add to Digg" rel="nofollow" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F02%2F24%2Fjunit-testing-made-easier-with-eclipse-templates&amp;title=JUnit%20testing%20made%20easier%20with%20Eclipse%20templates" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1022.png?w=468" alt="Add to Digg" /></a><a title="Add to Del.icio.us" rel="nofollow" href="http://del.icio.us/post?url=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F02%2F24%2Fjunit-testing-made-easier-with-eclipse-templates&amp;title=JUnit%20testing%20made%20easier%20with%20Eclipse%20templates" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1032.png?w=468" alt="Add to Del.icio.us" /></a><a title="Add to Stumbleupon" rel="nofollow" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F02%2F24%2Fjunit-testing-made-easier-with-eclipse-templates&amp;title=JUnit%20testing%20made%20easier%20with%20Eclipse%20templates" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1042.png?w=468" alt="Add to Stumbleupon" /></a><a title="Add to Reddit" rel="nofollow" href="http://reddit.com/submit?url=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F02%2F24%2Fjunit-testing-made-easier-with-eclipse-templates&amp;title=JUnit%20testing%20made%20easier%20with%20Eclipse%20templates" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1052.png?w=468" alt="Add to Reddit" /></a><a title="Add to Blinklist" rel="nofollow" href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Description=&amp;Url=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F02%2F24%2Fjunit-testing-made-easier-with-eclipse-templates&amp;Title=JUnit%20testing%20made%20easier%20with%20Eclipse%20templates" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1062.png?w=468" alt="Add to Blinklist" /></a><a title="Add to Twitter" rel="nofollow" href="http://twitter.com/home/?status=JUnit%20testing%20made%20easier%20with%20Eclipse%20templates+%40+http%3A%2F%2Fbit.ly%2F8XIdxt" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1072.png?w=468" alt="Add to Twitter" /></a><a title="Add to Technorati" rel="nofollow" href="http://www.technorati.com/faves?add=http://eclipseone.wordpress.com/2010/02/24/junit-testing-made-easier-with-eclipse-templates" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1082.png?w=468" alt="Add to Technorati" /></a><a title="Add to Yahoo Buzz" rel="nofollow" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F02%2F24%2Fjunit-testing-made-easier-with-eclipse-templates&amp;headline=JUnit%20testing%20made%20easier%20with%20Eclipse%20templates" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1092.png?w=468" alt="Add to Yahoo Buzz" /></a><a title="Add to Newsvine" rel="nofollow" href="http://www.newsvine.com/_wine/save?u=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F02%2F24%2Fjunit-testing-made-easier-with-eclipse-templates&amp;h=JUnit%20testing%20made%20easier%20with%20Eclipse%20templates" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1102.png?w=468" alt="Add to Newsvine" /></a><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1112.png?w=468" alt="" /></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/eclipseone.wordpress.com/965/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/eclipseone.wordpress.com/965/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/eclipseone.wordpress.com/965/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/eclipseone.wordpress.com/965/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/eclipseone.wordpress.com/965/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/eclipseone.wordpress.com/965/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/eclipseone.wordpress.com/965/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/eclipseone.wordpress.com/965/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/eclipseone.wordpress.com/965/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/eclipseone.wordpress.com/965/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/eclipseone.wordpress.com/965/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/eclipseone.wordpress.com/965/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/eclipseone.wordpress.com/965/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/eclipseone.wordpress.com/965/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eclipseone.wordpress.com&amp;blog=10678932&amp;post=965&amp;subd=eclipseone&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://eclipseone.wordpress.com/2010/02/24/junit-testing-made-easier-with-eclipse-templates/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9af99e9ee23204988228aaf14316cbd1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Byron</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1002.png" medium="image" />

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1012.png" medium="image">
			<media:title type="html">Add to Facebook</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1022.png" medium="image">
			<media:title type="html">Add to Digg</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1032.png" medium="image">
			<media:title type="html">Add to Del.icio.us</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1042.png" medium="image">
			<media:title type="html">Add to Stumbleupon</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1052.png" medium="image">
			<media:title type="html">Add to Reddit</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1062.png" medium="image">
			<media:title type="html">Add to Blinklist</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1072.png" medium="image">
			<media:title type="html">Add to Twitter</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1082.png" medium="image">
			<media:title type="html">Add to Technorati</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1092.png" medium="image">
			<media:title type="html">Add to Yahoo Buzz</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1102.png" medium="image">
			<media:title type="html">Add to Newsvine</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1112.png" medium="image" />
	</item>
		<item>
		<title>Automatically place a semicolon at the end of Java statements in Eclipse</title>
		<link>http://eclipseone.wordpress.com/2010/02/22/place-a-semicolon-at-the-end-of-a-java-statement-in-eclipse/</link>
		<comments>http://eclipseone.wordpress.com/2010/02/22/place-a-semicolon-at-the-end-of-a-java-statement-in-eclipse/#comments</comments>
		<pubDate>Mon, 22 Feb 2010 08:39:26 +0000</pubDate>
		<dc:creator>Byron</dc:creator>
				<category><![CDATA[Editing]]></category>
		<category><![CDATA[Preferences]]></category>

		<guid isPermaLink="false">http://eclipseone.wordpress.com/?p=884</guid>
		<description><![CDATA[We all know that Java statements are terminated by a semicolon (;), but they&#8217;re a bit of a pain to add to the end of a line. One way would be to press End (to move to the end of the line) then press semicolon, but this is tedious. Because this is something that you [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eclipseone.wordpress.com&amp;blog=10678932&amp;post=884&amp;subd=eclipseone&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>We all know that Java statements are terminated by a semicolon (;), but they&#8217;re a bit of a pain to add to the end of a line. One way would be to press End (to move to the end of the line) then press semicolon, but this is tedious. Because this is something that you do often it&#8217;s worth learning how to do this faster.</p>
<p>It&#8217;s a good thing Eclipse can automatically put the semicolon at the end of the line, no matter where you are in the statement. It&#8217;s as easy as setting one preference <em>and </em>there&#8217;s a bonus preference for adding braces to the correct position as well. For something so small, it saves a lot of time.</p>
<p>So in the example below, if you imagine that your cursor is placed after the word <em>blue</em> since you were editing the string. Pressing semicolon will cause Eclipse to place the semicolon after the closing bracket at the end. Nice.</p>
<p><pre class="brush: java; gutter: false;">

System.out.println(&quot;The house is blue&quot;)

</pre></p>
<p><span id="more-884"></span></p>
<h3>How to set the semicolon preference</h3>
<p>The preference is disabled by default, so you have to enable it. Go to <strong>Window &gt; Preferences &gt; Java &gt; Typing</strong>. Then enable <em>Semicolons</em> under the section <em>Automatically insert at correct position</em>.</p>
<p>Now when you press semicolon from anywhere in a statement, Eclipse adds a semicolon to the end of the line and places the cursor right after the semicolon so you can start editing the next line.</p>
<p>The preference should look like this:</p>
<p><a href="http://eclipseone.files.wordpress.com/2010/02/automatically-add-semicolon-preference.jpg"><img class="aligncenter size-full wp-image-945" title="Automatically Add Semicolon Preference" src="http://eclipseone.files.wordpress.com/2010/02/automatically-add-semicolon-preference.jpg?w=468&#038;h=231" alt="" width="468" height="231" /></a></p>
<p><strong>Notes:</strong></p>
<ul>
<li>Sometimes you&#8217;d want to add a semicolon to a string literal instead of at the end of the line. Eclipse caters for this by allowing you to press <strong>Backspace</strong> after you pressed semicolon. Pressing Backspace will remove the semicolon from the end of the line, move your cursor to the original position in the string and add the semicolon to the string.</li>
<li>If there&#8217;s already a semicolon at the end of the line, Eclipse won&#8217;t try to add another to the end. It will just add the semicolon to wherever you placed it.</li>
<li>Eclipse is smart enough to know that for <em>for</em> loops you&#8217;d want to add the semicolon to the middle of the statement (eg. when editing the initialiser, condition and increment code).</li>
</ul>
<p><strong>Bonus Tip:</strong> You can also add braces automatically at the correct position by selecting the <em>Braces</em> option on the preference page. This comes in handy when your coding standards require braces to be on the same line as the control structure statement. For example, when adding a <em>for</em> or <em>while </em>loop, you can type { at any place in the first line and Eclipse will insert it at the end of the line.</p>
<h3>Related Tips</h3>
<ul>
<li><a href="http://eclipseone.wordpress.com/2009/12/13/automatically-format-and-cleanup-code-every-time-you-save/">Automatically format and cleanup code every time you save</a></li>
<li><a href="http://eclipseone.wordpress.com/2009/12/20/select-entire-strings-and-methods-in-eclipse-with-a-single-keystroke/">Select entire strings and methods in Eclipse with a single keystroke</a></li>
<li><a href="http://eclipseone.wordpress.com/2009/12/09/jump-to-the-start-and-end-of-methods-loops-blocks-and-xml-tags/">Jump to the start and end of methods, loops, blocks and XML tags</a></li>
<li>If you <a href="http://eclipseone.wordpress.com/category/templates/">use templates</a>, you won&#8217;t have to add semicolons to boilerplate code as they&#8217;ll be part of the template.</li>
</ul>
<h3>Share This Tip</h3>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/eclipseone.wordpress.com/884/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/eclipseone.wordpress.com/884/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/eclipseone.wordpress.com/884/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/eclipseone.wordpress.com/884/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/eclipseone.wordpress.com/884/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/eclipseone.wordpress.com/884/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/eclipseone.wordpress.com/884/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/eclipseone.wordpress.com/884/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/eclipseone.wordpress.com/884/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/eclipseone.wordpress.com/884/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/eclipseone.wordpress.com/884/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/eclipseone.wordpress.com/884/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/eclipseone.wordpress.com/884/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/eclipseone.wordpress.com/884/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eclipseone.wordpress.com&amp;blog=10678932&amp;post=884&amp;subd=eclipseone&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://eclipseone.wordpress.com/2010/02/22/place-a-semicolon-at-the-end-of-a-java-statement-in-eclipse/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9af99e9ee23204988228aaf14316cbd1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Byron</media:title>
		</media:content>

		<media:content url="http://eclipseone.files.wordpress.com/2010/02/automatically-add-semicolon-preference.jpg" medium="image">
			<media:title type="html">Automatically Add Semicolon Preference</media:title>
		</media:content>
	</item>
		<item>
		<title>The fastest ways to navigate views in Eclipse using the keyboard</title>
		<link>http://eclipseone.wordpress.com/2010/02/15/the-fastest-ways-to-navigate-views-in-eclipse-using-the-keyboard/</link>
		<comments>http://eclipseone.wordpress.com/2010/02/15/the-fastest-ways-to-navigate-views-in-eclipse-using-the-keyboard/#comments</comments>
		<pubDate>Mon, 15 Feb 2010 08:25:37 +0000</pubDate>
		<dc:creator>Byron</dc:creator>
				<category><![CDATA[Editors]]></category>
		<category><![CDATA[Keyboard Shortcuts]]></category>
		<category><![CDATA[Navigation & Browsing]]></category>
		<category><![CDATA[Views]]></category>

		<guid isPermaLink="false">http://eclipseone.wordpress.com/?p=907</guid>
		<description><![CDATA[With so many views in Eclipse (around 50 for a default install), it can become difficult to navigate them all, especially when you don&#8217;t want to reach for the mouse all the time. As I&#8217;ve mentioned in a previous post on how to manage keyboard shortcuts, learning how to use the keyboard efficiently can save [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eclipseone.wordpress.com&amp;blog=10678932&amp;post=907&amp;subd=eclipseone&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>With so many views in Eclipse (around 50 for a default install), it can become difficult to navigate them all, especially when you don&#8217;t want to reach for the mouse all the time. As I&#8217;ve mentioned in a previous post on <a href="http://eclipseone.wordpress.com/2010/02/03/how-to-manage-keyboard-shortcuts-in-eclipse/">how to manage keyboard shortcuts</a>, learning how to use the keyboard efficiently can save you oodles of time later on.</p>
<p>Fortunately, Eclipse has a number of ways to navigate between views using only the keyboard. I&#8217;ll discuss the Show View shortcuts, the Show Views dialog, Quick Access and then view cycling, with some advice on when to use which one. There&#8217;s also a bonus tip on how to activate the editor with the keyboard once you&#8217;re done with a view.</p>
<p><span id="more-907"></span></p>
<h3>Navigate between views using shortcuts</h3>
<p>The fastest way to get around views, is to use the Show View keyboard shortcuts that take you directly to a view, no matter where you are in the window. The Show View commands are activated by pressing <strong>Alt+Shift+Q</strong>, then the letter for the relevant view, eg. to navigate to the Package Explorer, press Alt+Shift+Q, P.</p>
<p>The Show View command opens the view if it&#8217;s not opened in the current perspective, makes it visible then activates the view. So you can even open views that aren&#8217;t already open in the perspective.</p>
<p>Here&#8217;s a list of common views that you&#8217;ll probably use every day as a Java developer:</p>
<table style="border-collapse:collapse;border-style:solid;border-width:thin;padding:20px;" border="1" cellpadding="3">
<tbody>
<tr>
<td><strong>Shortcut<br />
</strong></td>
<td style="width:80%;"><strong>View</strong></td>
</tr>
<tr>
<td>Alt+Shift+Q, P</td>
<td>Package Explorer</td>
</tr>
<tr>
<td>Alt+Shift+Q, C</td>
<td>Console</td>
</tr>
<tr>
<td>Alt+Shift+Q, O</td>
<td>Outline View</td>
</tr>
<tr>
<td>Alt+Shift+Q, X</td>
<td>Problems View</td>
</tr>
<tr>
<td>Alt+Shift+Q, S</td>
<td>Search View</td>
</tr>
<tr>
<td>Alt+Shift+Q, T</td>
<td>Type Hierarchy</td>
</tr>
<tr>
<td>Alt+Shift+Q, Y</td>
<td>Synchronise View</td>
</tr>
</tbody>
</table>
<p>You may want to <a href="http://eclipseone.wordpress.com/2010/02/03/how-to-manage-keyboard-shortcuts-in-eclipse/">change the shortcut</a> for a view that you use often to open it faster (eg. make Alt+Shift+P navigate to the Package Explorer). On the Keys preference dialog, search for <em>Show View</em>. Eclipse will list all views that are registered with the workbench. You can now reassign the key to your favourite view.</p>
<p>Some views don&#8217;t have shortcuts assigned to them, only waiting for you to do the honours. Again, you can use the Keys preference dialog to assign a shortcut to an unassigned view.</p>
<p>As always for the forgetful, to quickly get a list of all available Show View shortcuts, press Alt+Shift+Q, release it and wait for the list to appear in the lower right corner of the screen. It should look something like this:</p>
<p style="text-align:center;"><a href="http://eclipseone.files.wordpress.com/2010/02/show-view-sequence-list.jpg"><img class="aligncenter size-full wp-image-957" title="Show View Sequence List" src="http://eclipseone.files.wordpress.com/2010/02/show-view-sequence-list.jpg?w=468" alt=""   /></a></p>
<h3>Show views dialog</h3>
<p>The next fastest way to navigate views is to press <strong>Alt+Shift+Q, Q</strong>. This pops up a dialog with a list of all views Eclipse knows about. The dialog is grouped by category and comes with a handy search box for you to easily find the view you want. The search box supports wildcards &#8212; a handy feature if you don&#8217;t know the exact name of the view you&#8217;re looking for. Once you&#8217;ve chosen the appropriate view, just press <strong>Enter</strong>.</p>
<p>Here&#8217;s an example of what the dialog looks like when you use the search feature:</p>
<p><a href="http://eclipseone.files.wordpress.com/2010/02/show-views-dialog1.jpg"><img class="aligncenter size-full wp-image-929" title="Show Views Dialog" src="http://eclipseone.files.wordpress.com/2010/02/show-views-dialog1.jpg?w=468" alt=""   /></a></p>
<p>You can also use the arrow keys to move to the view of your choice: Up/Down to move to the next folder grouping or view and Left/Right to open a folder. But I would recommend getting used to the search box as it&#8217;s faster to get to the view you want.</p>
<p><strong>Tip:</strong> If the view you want is at the top of the list, you don&#8217;t have to press Down to select it. Pressing <strong>Enter</strong> will select the first view in the list and then pressing <strong>Enter</strong> again will confirm your selection.</p>
<h3>Navigate views using Quick Access (Ctrl+3)</h3>
<p>Quick Access is a way to navigate to anywhere or invoke anything in Eclipse. By pressing <strong>Ctrl+3</strong>, Eclipse pops up a searchable list of all perspectives, views, preferences, commands, etc. that it knows about. It sounds far-fetched, but try it out yourself to see what I mean.</p>
<p>You can navigate to a view by typing its name in the search bar. The search supports implicit wildcards, so you don&#8217;t have to type an asterisk to do a wildcard search. So to navigate to the Package Explorer, you can type <em>Package</em> in the search bar.</p>
<p>This is an example of what you&#8217;ll see when you use this dialog&#8217;s search feature:</p>
<p><a href="http://eclipseone.files.wordpress.com/2010/02/quick-access-package-explorer.jpg"><img class="aligncenter size-full wp-image-919" title="Quick Access - Package Explorer" src="http://eclipseone.files.wordpress.com/2010/02/quick-access-package-explorer.jpg?w=468" alt=""   /></a></p>
<p>Unfortunately you may get a lot of other entries that match the word Package since other things like commands and preferences may contain the same word. This gives the Show Views dialog a slight edge over Quick Access when it comes to navigating views since it only shows views.</p>
<h3>Cycle views (Ctrl+F7)</h3>
<p>This is probably the slowest and most frustrating way to navigate views. By pressing Ctrl+F7 (Next View), Eclipse pops up a list of all open views in the current perspective. To cycle through the list, hold down Ctrl and press F7 repeatedly.</p>
<p>Here&#8217;s what the list looks like:</p>
<p><a href="http://eclipseone.files.wordpress.com/2010/02/view-cycling.jpg"><img class="aligncenter size-full wp-image-925" title="View Cycling" src="http://eclipseone.files.wordpress.com/2010/02/view-cycling.jpg?w=468" alt=""   /></a></p>
<p>There are 2 big problems with view cycling, though, which makes it one of my least favourite commands:</p>
<ol>
<li>If the view you want is at the bottom of the list, it takes a while to reach it. And if you accidentally move past it, you need to wrap around and try and hit it again, or you have to swap over to Ctrl+Shift+F7 to move backwards in the list. Definitely not nice.</li>
<li>The list only shows <em>open</em> views in the <em>current</em> perspective. Not usable if you want to open an infrequently used view.</li>
</ol>
<p>However, this shortcut does come in handy when you&#8217;re constantly swapping between two views (eg. doing a side-by-side comparison). By pressing Ctrl+F7 once, Eclipse switches between the currently active and last active view.</p>
<h3>Activate the editor using the keyboard</h3>
<p>You may want to know how to use your keyboard to give the editor focus once you&#8217;re done with a view, especially helpful if you&#8217;re avoiding the mouse.</p>
<p>To activate the editor from any view, press <strong>F12</strong>. This means that you don&#8217;t have to reach for the mouse to start editing. This command is called Activate Editor and can be changed to any shortcut you want. F12 is not the most convenient key on most keyboards, so you may want to change it if it doesn&#8217;t suit you.</p>
<h3>So, when should you use one or the other?</h3>
<p>I would recommend the following to start off with:</p>
<ul>
<li>For frequently used views, learn the Show View keyboard shortcut (eg. Alt+Shift+Q, P) for the Package Explorer. It&#8217;s the fastest and most direct way to get to a view.</li>
<li>For infrequently used views, learn to use the Show Views dialog, or alternatively Quick Access. The Show Views dialog is better because it only contains a list of views, so it makes things a bit simpler than the Quick Access dialog.</li>
<li>Use Next View (Ctrl+F7) only when you&#8217;re constantly swapping between two views. Avoid it for other scenarios.</li>
</ul>
<h3>Related Tips</h3>
<p>So now that navigating views is a bit easier, here are some other tips that may come in handy:</p>
<ul>
<li><a href="http://eclipseone.wordpress.com/2010/05/25/quick-ways-to-navigate-eclipse-editors-using-the-keyboard/">Quick ways to navigate Eclipse editors using the keyboard</a></li>
<li><a href="http://eclipseone.wordpress.com/2010/09/20/the-fastest-ways-to-open-editors-in-eclipse-using-the-keyboard/">The fastest ways to open editors in Eclipse using the keyboard</a></li>
<li><a href="http://eclipseone.wordpress.com/2010/04/08/categorise-projects-in-the-package-explorer-to-reduce-clutter-in-eclipse/">Categorise projects in the Package Explorer to reduce clutter in Eclipse</a></li>
<li><a href="http://eclipseone.wordpress.com/2009/12/10/use-fast-views-to-maximise-screen-space/">Use Fast Views to maximise screen space</a></li>
<li><a href="http://eclipseone.wordpress.com/2010/01/04/split-and-view-the-same-editor-side-by-side-in-eclipse/">Split and view the same editor side by side in Eclipse</a></li>
<li><a href="http://eclipseone.wordpress.com/2010/01/08/switch-and-close-editors-faster-with-the-keyboard-using-eclipses-quick-switch-editor/">Switch and close editors faster with the keyboard using Eclipse’s Quick Switch Editor</a></li>
<li><a href="http://eclipseone.wordpress.com/2010/02/03/how-to-manage-keyboard-shortcuts-in-eclipse/">How to manage keyboard shortcuts in Eclipse and why you should</a></li>
</ul>
<p>&nbsp;</p>
<h3>Share This Tip</h3>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/eclipseone.wordpress.com/907/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/eclipseone.wordpress.com/907/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/eclipseone.wordpress.com/907/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/eclipseone.wordpress.com/907/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/eclipseone.wordpress.com/907/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/eclipseone.wordpress.com/907/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/eclipseone.wordpress.com/907/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/eclipseone.wordpress.com/907/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/eclipseone.wordpress.com/907/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/eclipseone.wordpress.com/907/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/eclipseone.wordpress.com/907/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/eclipseone.wordpress.com/907/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/eclipseone.wordpress.com/907/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/eclipseone.wordpress.com/907/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eclipseone.wordpress.com&amp;blog=10678932&amp;post=907&amp;subd=eclipseone&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://eclipseone.wordpress.com/2010/02/15/the-fastest-ways-to-navigate-views-in-eclipse-using-the-keyboard/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9af99e9ee23204988228aaf14316cbd1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Byron</media:title>
		</media:content>

		<media:content url="http://eclipseone.files.wordpress.com/2010/02/show-view-sequence-list.jpg" medium="image">
			<media:title type="html">Show View Sequence List</media:title>
		</media:content>

		<media:content url="http://eclipseone.files.wordpress.com/2010/02/show-views-dialog1.jpg" medium="image">
			<media:title type="html">Show Views Dialog</media:title>
		</media:content>

		<media:content url="http://eclipseone.files.wordpress.com/2010/02/quick-access-package-explorer.jpg" medium="image">
			<media:title type="html">Quick Access - Package Explorer</media:title>
		</media:content>

		<media:content url="http://eclipseone.files.wordpress.com/2010/02/view-cycling.jpg" medium="image">
			<media:title type="html">View Cycling</media:title>
		</media:content>
	</item>
		<item>
		<title>Add, remove and reorder a method&#8217;s arguments instantly across multiple classes in Eclipse</title>
		<link>http://eclipseone.wordpress.com/2010/02/10/change-a-methods-arguments-across-multiple-classes-in-eclipse/</link>
		<comments>http://eclipseone.wordpress.com/2010/02/10/change-a-methods-arguments-across-multiple-classes-in-eclipse/#comments</comments>
		<pubDate>Wed, 10 Feb 2010 08:29:56 +0000</pubDate>
		<dc:creator>Byron</dc:creator>
				<category><![CDATA[Editing]]></category>
		<category><![CDATA[Refactoring]]></category>

		<guid isPermaLink="false">http://eclipseone.wordpress.com/?p=307</guid>
		<description><![CDATA[When refactoring, one thing that sometimes changes is a method&#8217;s signature (ie. its return type, number of arguments, argument types and order). For some it may not happen that often, but the job becomes difficult when you have a dozen or more classes that call that method. All of them need to be changed to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eclipseone.wordpress.com&amp;blog=10678932&amp;post=307&amp;subd=eclipseone&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>When refactoring, one thing that sometimes changes is a method&#8217;s signature (ie. its return type, number of arguments, argument types and order).</p>
<p>For some it may not happen that often, but the job becomes difficult when you have a dozen or more classes that call that method. All of them need to be changed to match the new signature and this can take a long time to change.</p>
<p>Fortunately, Eclipse has a refactoring called <em>Change Method Signature</em> that makes this easy, allowing a signature change in almost no time across any number of classes. This can be a huge timesaver when you need it and save you hours of frustration trying to fix red crosses in Eclipse.</p>
<p><span id="more-307"></span></p>
<h3>How to change a method signature</h3>
<p>The refactoring is easy to invoke. The fastest way to do this is to position the cursor on the method&#8217;s declaration or any of it&#8217;s calls and then press <strong>Alt+Shift+C</strong> (or alternatively select <strong>Refactor &gt; Change Method Signature</strong> from the application menu). This can only be invoked on methods for which you own the code.</p>
<p>In the next video I show an example of adding a new String argument called <em>message </em>to the method <em>process</em> as the second argument. Notice how Eclipse automatically shifts all other arguments up by one. Then we&#8217;ll remove the <em>int</em> argument. The two affected classes are below each other so you can see the magic in action.</p>
<span style="text-align:center; display: block;"><a href="http://eclipseone.wordpress.com/2010/02/10/change-a-methods-arguments-across-multiple-classes-in-eclipse/"><img src="http://img.youtube.com/vi/dRJP7_uKuKA/2.jpg" alt="" /></a></span>
<p><strong>Notes:</strong></p>
<ul>
<li>To reorder the arguments, just press the Up/Down buttons.</li>
<li>You can specify a default value for the new argument. This is the default value that Eclipse will give all method calls. Normally <em>null</em> or another sensible default will do.</li>
<li>You can preview the changes before you accept them. Eclipse shows you all affected classes and allows you to compare the current and soon-to-be code.</li>
<li>Eclipse has Content Assist inside the refactoring dialog, meaning that you can press Ctrl+Space in the Type column to see a list of object types that match the name you&#8217;ve typed.</li>
<li>You can change the return type and even the name of the method. If you just want to rename a method, rather use the Rename refactoring (Alt+Shift+R).</li>
</ul>
<h3>Related Tips</h3>
<p>Here are some other tips that might interest you:</p>
<ul>
<li>The example video shows two editors below each other. You can find out how to <a href="../2010/01/04/split-and-view-the-same-editor-side-by-side-in-eclipse/">see the same editor side by side</a> in Eclipse.</li>
<li>While you&#8217;re refactoring code, check out <a href="http://eclipseone.wordpress.com/category/refactoring/">some other refactorings</a> that Eclipse provides that could help you. You can also have a look at <a href="http://eclipseone.wordpress.com/category/editing/">other editing tips</a> that may interest you.</li>
<li>You can <a href="http://eclipseone.wordpress.com/2010/02/03/how-to-manage-keyboard-shortcuts-in-eclipse/">remap the keyboard shortcut</a> if you find Alt+Shift+C doesn&#8217;t work for you (the command&#8217;s name is <em>Change Method Signature</em>). There are also <a href="http://eclipseone.wordpress.com/category/keyboard-shortcuts/">other keyboard shortcuts</a> you can check out as well to make coding a lot faster, meaning you don&#8217;t have to reach for that mouse to refactor you code.</li>
</ul>
<p class="getsocial" style="text-align:left;"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1005.png?w=468" alt="" /><a title="Add to Facebook" rel="nofollow" href="http://www.facebook.com/sharer.php?u=http://eclipseone.wordpress.com/2010/02/10/change-a-methods-arguments-across-multiple-classes-in-eclipse" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1015.png?w=468" alt="Add to Facebook" /></a><a title="Add to Digg" rel="nofollow" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F02%2F10%2Fchange-a-methods-arguments-across-multiple-classes-in-eclipse&amp;title=Add%2C%20remove%20and%20reorder%20a%20method%27s%20arguments%20instantly%20ac..." target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1025.png?w=468" alt="Add to Digg" /></a><a title="Add to Del.icio.us" rel="nofollow" href="http://del.icio.us/post?url=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F02%2F10%2Fchange-a-methods-arguments-across-multiple-classes-in-eclipse&amp;title=Add%2C%20remove%20and%20reorder%20a%20method%27s%20arguments%20instantly%20across%20multiple%20classes%20in%20Eclipse" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1035.png?w=468" alt="Add to Del.icio.us" /></a><a title="Add to Stumbleupon" rel="nofollow" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F02%2F10%2Fchange-a-methods-arguments-across-multiple-classes-in-eclipse&amp;title=Add%2C%20remove%20and%20reorder%20a%20method%27s%20arguments%20instantly%20across%20multiple%20classes%20in%20Eclipse" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1045.png?w=468" alt="Add to Stumbleupon" /></a><a title="Add to Reddit" rel="nofollow" href="http://reddit.com/submit?url=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F02%2F10%2Fchange-a-methods-arguments-across-multiple-classes-in-eclipse&amp;title=Add%2C%20remove%20and%20reorder%20a%20method%27s%20arguments%20instantly%20across%20multiple%20classes%20in%20Eclipse" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1055.png?w=468" alt="Add to Reddit" /></a><a title="Add to Blinklist" rel="nofollow" href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Description=&amp;Url=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F02%2F10%2Fchange-a-methods-arguments-across-multiple-classes-in-eclipse&amp;Title=Add%2C%20remove%20and%20reorder%20a%20method%27s%20arguments%20instantly%20across%20multiple%20classes%20in%20Eclipse" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1065.png?w=468" alt="Add to Blinklist" /></a><a title="Add to Twitter" rel="nofollow" href="http://twitter.com/home/?status=Add%2C%20remove%20and%20reorder%20a%20method%27s%20arguments%20instantly%20across%20multiple%20classes%20in%20Eclipse+%40+http%3A%2F%2Ftinyurl.com%2Fyfanwbt" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1075.png?w=468" alt="Add to Twitter" /></a><a title="Add to Technorati" rel="nofollow" href="http://www.technorati.com/faves?add=http://eclipseone.wordpress.com/2010/02/10/change-a-methods-arguments-across-multiple-classes-in-eclipse" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1085.png?w=468" alt="Add to Technorati" /></a><a title="Add to Yahoo Buzz" rel="nofollow" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F02%2F10%2Fchange-a-methods-arguments-across-multiple-classes-in-eclipse&amp;headline=Add%2C%20remove%20and%20reorder%20a%20method%27s%20arguments%20instantly%20across%20multiple%20classes%20in%20Eclipse" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1095.png?w=468" alt="Add to Yahoo Buzz" /></a><a title="Add to Newsvine" rel="nofollow" href="http://www.newsvine.com/_wine/save?u=http%3A%2F%2Feclipseone.wordpress.com%2F2010%2F02%2F10%2Fchange-a-methods-arguments-across-multiple-classes-in-eclipse&amp;h=Add%2C%20remove%20and%20reorder%20a%20method%27s%20arguments%20instantly%20across%20multiple%20classes%20in%20Eclipse" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1105.png?w=468" alt="Add to Newsvine" /></a><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/08/gs1115.png?w=468" alt="" /></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/eclipseone.wordpress.com/307/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/eclipseone.wordpress.com/307/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/eclipseone.wordpress.com/307/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/eclipseone.wordpress.com/307/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/eclipseone.wordpress.com/307/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/eclipseone.wordpress.com/307/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/eclipseone.wordpress.com/307/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/eclipseone.wordpress.com/307/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/eclipseone.wordpress.com/307/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/eclipseone.wordpress.com/307/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/eclipseone.wordpress.com/307/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/eclipseone.wordpress.com/307/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/eclipseone.wordpress.com/307/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/eclipseone.wordpress.com/307/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eclipseone.wordpress.com&amp;blog=10678932&amp;post=307&amp;subd=eclipseone&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://eclipseone.wordpress.com/2010/02/10/change-a-methods-arguments-across-multiple-classes-in-eclipse/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9af99e9ee23204988228aaf14316cbd1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Byron</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1005.png" medium="image" />

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1015.png" medium="image">
			<media:title type="html">Add to Facebook</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1025.png" medium="image">
			<media:title type="html">Add to Digg</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1035.png" medium="image">
			<media:title type="html">Add to Del.icio.us</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1045.png" medium="image">
			<media:title type="html">Add to Stumbleupon</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1055.png" medium="image">
			<media:title type="html">Add to Reddit</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1065.png" medium="image">
			<media:title type="html">Add to Blinklist</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1075.png" medium="image">
			<media:title type="html">Add to Twitter</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1085.png" medium="image">
			<media:title type="html">Add to Technorati</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1095.png" medium="image">
			<media:title type="html">Add to Yahoo Buzz</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1105.png" medium="image">
			<media:title type="html">Add to Newsvine</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/08/gs1115.png" medium="image" />
	</item>
	</channel>
</rss>
