Showing posts with label eclipse. Show all posts
Showing posts with label eclipse. Show all posts

Friday, January 8, 2010

Eclipse Templates: Commons Logging

For mostly my own benefit, but if you gain something out of this...awesome!!!

Here is a template that I use in Eclipse and I always have to recreate the syntax for when at another developer's workstation....


private static final Log logger = LogFactory.getLog(${primary_type_name}.class);
${:import(org.apache.commons.logging.Log,org.apache.commons.logging.LogFactory)}

Wednesday, January 21, 2009

Eclipse Templates - Iterating Over a Map

Here is another code template. This one, I cannot take the credit for, but I have added it to my toolbox of great Eclipse Templates. It will give you the ability to iterate over a Map using the Map.Entry. Enjoy:

for (Iterator<Map.Entry<${type},${type2}>> it = ${variableName:var(java.util.Map)}.entrySet().iterator(); it.hasNext();) {  
    Map.Entry<${type},${type2}> entry = it.next();  
       ${type} key = entry.getKey();  
       ${type2} value = entry.getValue();  
       // do something with the key and the value  
}

Monday, January 19, 2009

Eclipse Templates - Jakarta Commons ToString, HashCode, Equals

Hey everyone,

I just wanted to take the time to share with you a code template that I created that has been very helpful in a project that I am currently working on. This template will give you the ability to create the toString(), equals(), hashCode() methods using the Jakarta Commons library. Enjoy:



${:import(org.apache.commons.lang.builder.EqualsBuilder,org.apache.commons.lang.builder.HashCodeBuilder,org.apache.commons.lang.builder.ReflectionToStringBuilder)}
@Override
public boolean equals(Object obj) {
return EqualsBuilder.reflectionEquals(this, obj);
}

@Override
public String toString() {
return ReflectionToStringBuilder.toString(this);
}

@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}

Friday, December 19, 2008

Eclipse Code Templates - toString, equals, hashCode

Finally I decided to write a code template that I can use in order to create those infamous methods that should be a part of everyone's DTO. Those methods are toString(), equals(), and hashCode().

The template does assume that you are using the commons-lang library. Feel free to use it and pay it forward:


${:import(org.apache.commons.lang.builder.EqualsBuilder,
org.apache.commons.lang.builder.HashCodeBuilder,
org.apache.commons.lang.builder.ReflectionToStringBuilder)} @Override public boolean equals(Object obj) { return EqualsBuilder.reflectionEquals(this, obj); } @Override public String toString() { return ReflectionToStringBuilder.toString(this); } @Override public int hashCode() { return HashCodeBuilder.reflectionHashCode(this); }
Enjoy.

Wednesday, October 22, 2008

Eclipse - Bringing Back Run Last Launched

If you upgraded to the Eclipse 3.4, you may have noticed that the shortcut key for Running the Last Launched does not work properly. In older versions of Eclipse, CTRL+F11 used to run the last launched application or Junit test. By default, in Eclipse 3.4, this is used to run the *.java file that currently has focus.

If you would like to change this functionality back, just follow these instructions:

1. Open Eclipse Preferences by Navigating to Window -> Preferences
2. Using the Tree, Navigate to Run/Debug -> Launching
3. Here you will find the group called Launch Operation
4. Choose the option that says Always launch the previously launched application

Enjoy and pay it forward!!!

Friday, July 11, 2008

Eclipse Tip: Static Imports

One of the great features of Java 1.5 is Static Imports. In order to configure Eclipse to search for static imports in a particular class, you have to perform the following steps:

  1. Navigate to Preferences by clicking on the Window -> Preferences Menu Item
  2. Navigate to Java -> Editor -> Content Assist -> Favorites using the menu tree (or search for Favorites using the search bar at the top)
  3. Click the New Type button
  4. Type in the name of the Class that has static methods that you would like to be used when using Eclipse's Content Assist / Code Completion (eg Assert)
  5. Click on the Browse button which will bring up the Open Type Dialog using what you entered previously as the search criteria
  6. Find the class that you would like to add, and then click Okay on the Open Type Dialog
  7. Then Click Okay on the New Type Favorite Dialog.
Now when you are editing Java code, instead of typing Assert.assertEquals, you only need to type assertEquals, with Ctrl-Space, and the Assert Type will be searched for in order to resolve the static import.

If this helps, pay it forward....

Friday, July 4, 2008

Goodbye P2, Welcome Back Update Manager

Well, I gave it a good go. I tried my best to wrap my arms and my head around P2. It wasn't until I read this blog, that I finally understood how to get P2 to work the way that I wanted it to work - complete with bundle pooling. However, I felt that there were just too many steps necessary in order to get it up and running in that fashion. Combine that with the limited documentation, I have reverted Ganymede to use the old Update Manager using these instructions.

I still do believe that P2 is a step in the right direction, however the learning curve is just too steep for me at this point. I hope to see improvement in P2's user experience in the future, at which time, I will give it another try.

Thursday, June 26, 2008

Fixing Eclipse Ganymede Startup Problems

If by chance, you are like me, and the first time that you ran Eclipse Ganymede, you were greeted with an exception screen like this one:



Here are the steps necessary to resolve that issue:

1.) Navigate to your $ECLIPSE_HOME directory (the directory where you installed Eclipse)
2.) Copy your eclipse.ini file, for backup purposes
3.) Open your eclipse.ini file and modify it to look similar to this:




4.) Try to start up Eclipse again, and hopefully your problem should be solved

The main problem seems to be that the initial settings does not allocate enough memory for Eclipse to run. By adjusting the memory settings, by using the example eclipse.ini file that I have shown, you are giving Eclipse enough memory to start up.

This interesting thing is that this issue does not seem to affect all installations. The "vanilla" Eclipse Ganymede that I obtained from Eclipse worked on one of my machines, but not on another.

If this helps, please pay it forward.

Thanks

Wednesday, June 25, 2008

Eclipse Ganymede Released Today

Well, the the Eclipse Community has done it again. Today is the day that they will be releasing their annual simultaneous release of the Eclipse Platform. Sticking with the moons of Jupiter, this year's simultaneous release, code named Ganymede, will include 23 seperate projects - not that you have to download and use all 23 projects, it is just that you can be assured that these projects are compatible with each other.

One of the biggest features / enhancements to the Eclipse Platform is the introduction of P2. P2 is the new provisioning platform that is used to manage OSGi bundles / Eclipse plugins, and the replacement for the Update Manager. There has been a lot of discussion with varying views on P2 - some in favor, others not.

I have not used it enough to form an official opinion, but at first glance I can say that the Update Manager was narrowly scoped in that it's purpose was really surrounding Eclipse Plugins. The idea of p2 is to not only be used to manage Eclipse Plugins, but also to manage OSGi bundles as a whole, which means that it can be used for any OSGi based application. I am also interested in trying their bundle pooling approach to managing Eclipse plugins versus the extension location approach, which I have been using up until now.

Here is information on how to Get Started with p2.

Here is where you will be able to download Eclipse Ganymede...as soon as the link is enabled.

Happy Coding!!!

Friday, May 2, 2008

Eclipse Hack :- Change the Splash Screen

Hey everyone,

Inspired by a recent posting on Planet Eclipse, I thought that I would share with you a hack that I have used to change the splash screen that is used when Eclipse starts. Enjoy.

Changing the Splash Screen:
1.) Navigate to the directory where you installed Eclipse, which I will now refer to as $ECLIPSE_HOME
2.) Move to the following directory $ECLIPSE_HOME/plugins/org.eclipse.platform_xxxxxx
3.) There you will find a file called splash.bmp
4.) Rename this file to splash.bmp.bak in order to keep the original file.
5.) Create your new bitmap file and place it in this directory as splash.bmp

And that is all there is to it.

Note: I am currently using eclipse-rcp-europa-winter-win32, so the directory on my machine that contains the splash.bmp file is org.eclipse.platform_3.3.3.r33x_r20080129. If you are using a different version of Eclipse, it may be something different, but it should at least start with the org.eclipse.platform.

Enjoy.

Monday, December 31, 2007

Eclipse Startup Options: showlocation

If you are like me, then you probably have multiple installations of Eclipse installed on your computer. For example, I have one install for all of my JEE development, and another for my RCP development. One of the hardest things that I have found is distinguishing between which instance I am currently running.

Recently, I learned about the Running Eclipse startup option called "showlocation". By leveraging this startup option, you will always know which version of eclipse you are running because it will show you your workspace in the Eclipse title bar. Even better, if you are using at least Eclipse 3.2 - which was last year's Callisto's release, you can pass a String to describe the instance that you are currently running, and that will be shown in the Eclipse Title bar instead of the workspace.

Here is how I have my shortcuts currently configured:

JEE version
C:\myPrograms\Eclipse\eclipse-jee-europa-win32\eclipse\eclipse.exe -showlocation JEE -refresh -vmargs -Xms256M -Xmx256M

RCP version
C:\myPrograms\Eclipse\eclipse-rcp-europa-fall2-win32\eclipse\eclipse.exe -showlocation RCP -refresh -vmargs -Xms256M -Xmx256M

Share and enjoy...

Tuesday, July 3, 2007

Eclipse Europa - the Good and the Bad

After using Eclipse Europa for the past couple of days, I thought that it would be a good idea to share my thoughts on this latest release.

the Good...
This new version of Eclipse has many wonderful and new features and shortcuts. My two top features are the CTRL+3 and the View folding.

CTRL+3 allows you to search across the entire Eclipse platform, matching on Views, Menu Items, and other parts of the Eclipse system. I am a huge fan of keyboard shortcuts. I believe that through their use, you can save lots of time and increase productivity. If you do not believe me, think about the time that it takes to move your hand from the keyboard to the mouse and click on a menu item. It may not seem like a lot of time, but how many times do you do this during the day? week? month? This shortcut just adds to my arsenal of productivity boosts.



The other enhancement that I am enjoying is the folding of the Views. In the older versions of Eclipse, when you collapsed a view stack that resided on the left portion of the screen, they would leave a thin collapsed view on the screen. Now, when collapsing views, they completely collapse and minimize to the left most portion of the screen. This leaves much more room for the work that you are actually focusing on.

the Bad...
Yes, believe it or not, there is something that I do not like about the new version. It goes back to my earlier statement of short-cut keys and committing them to memory to boost productivity. In Eclipse 3.2, I often found myself needing to surround code with a try catch block. I did it so often that I found a shortcut key that would do it for me. That shortcut key was Alt+Shift+Z, 4, as shown by the screen capture.





For some reason, in the Europa version, they decided to change this. Instead of it being Alt+Shift+Z, 4 it is now Alt+Shift+Z, 6. I know that this may seem minor, however when you get used to using something, like a short-cut, I don't think that you should ever change it. It makes me wonder what else they may change in the future.



Overall...
Overall, my impression of the new version of Eclipse is absolutely great. I have enjoyed this release thus far, and I am looking forward to learning more about it in the future.




Friday, June 29, 2007

Eclipse Europa Releases Today...

We are one hour away from the annual simultaneous release of many Eclipse Projects. This year's release is titled Eclipse Europa, which will include 21 different Eclipse Projects. Hats off to the Eclipse Team and Community for coordinating such an effort.

Unlike the iPhone, which also releases today, this is the product that I am sure to acquire. Speaking of the iPhone, here is a list of highly anticipated features as reported by the Onion.

Enjoy.

Saturday, June 9, 2007

Eclipse Europa Releases Soon...

Has it been a year already? Is it really that time again?

The annual release of the Eclipse projects, is just 20 days away. This years release, titled Europa, is sure to clog the "series of tubes" (Senator Ted Stevens) that the internet is, due to the massive downloading that will be taking place.

To learn more about this release:

http://www.eclipse.org/europa/

Congratulations and thank you to all of those whose efforts have made this possible.