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

Wednesday, April 13, 2011

Shipping API Jars Without The Associated JavaDoc: An Antipattern

I just tried out the RSA 8.0.2 release and tried to create a new SCA Project. To my surprise, I was missing any and all documentation for the org.osoa.sca* packages. What's the point of including SCA support if you don't include the corresponding JavaDoc?

Here is the solution:
  1. Highlight one of the imports
  2. Control-click / press f3 to go to the declaration
  3. Click 'Link with Editor' on the Package Explorer view
  4. Right-click->Properties / press Alt+Enter on the parent jar (org.apache.tuscany.sca.api.jar)
  5. Select 'Javadoc Location'
  6. Set the Javadoc URL to http://tuscany.apache.org/doc/javadoc/java-sca-1.6.1/sca-api/
  7. Validate the location to be sure you didn't accidentally include index.html at the end (which I always screw up)

Thursday, December 18, 2008

Custom Shortcuts in Eclipse

In the past I've posted on my favorite built-in key-bindings.  But with Eclipse you can actually bind any key combination to any 'command' using the eclipse platform command framework.

Here are some of the custom ones I like to set:
control + ; => next view
control + shift + ; => previous view

control + alt + W => close view

control + tab => next editor
control + shift + tab => previous editor

control + O in Task View => Open Remote Task

control + shift + ?

Editing Templates

You can also write a plugin to offer your own commands and templates.  Here are a couple I've written in the past.  If I'm feeling adventurous one day, I'll try to get back to this post and update it with the details.

Creating a Custom Template

sysout proposal for selected text (wrap the selected string in a System.out.println() ).

Creating a Custom Command

control+alt+L hack => goto line and select it

Previously, this required 3 separate actions:
Goto Line
End => goto line end
Shift + Home => highlight to line beginning

Thursday, November 6, 2008

Mylyn Tip

Use lots of workspaces? Tired of creating mylyn queries for each workspace? Try using a shared mylyn folder by setting the Data directory under the Advanced section of the Tasks Preference page.




More fun with p2

It's been a few months since I performed my pooled Eclipse Ganymede installations and since then the Eclipse train has continued to roll with the 3.4.1 Maintenance Release as well as the first three milestones of the 3.5 stream (Galileo).

One of the touted benefits of the new provisioning system is that it allows users to upgrade from one Eclipse release to another (in place). However, I had a few problems with my work install (leaving it in a seemingly endless cycle of unresolved dependencies) and so I have decided to see if I could recreate them in a more controlled environment (and document that process here of course).

When I tried to upgrade from my Ganymede install to the latest 3.5M3, I was hit with the following error:

Cannot complete the request. See the details.
Eclipse SDK is already installed, so an update will be performed instead.
Cannot find a solution satisfying the following requirements Match[requiredCapability: org.eclipse.equinox.p2.iu/org.eclipse.ltk.core.refactoring/[3.4.100.v20080806-1800,3.4.100.v20080806-1800]].

When I tried installing the same IU to the other (minimal) eclipse 3.4 instance, I received to errors/warning but hit the following error during downloads:

An error occurred while collecting items to be installed
No repository found containing: org.eclipse.ant.core/osgi.bundle/3.2.100.v20080721
A quick retry seemed to get past this one and the update quickly finished without error.

Friday, August 29, 2008

Keyboard Shortcuts - Eclipse

Whether you call them Keyboard Shortcuts, Key Bindings, Hotkeys, or what-have-you the Eclipse IDE contains a great number of useful keyboard shortcuts...from general navigation to coding/editing and running/debugging. In fact, beneath the surface lies an entirely extensible command and binding framework, which I have only briefly investigated.

One simple shortcut for displaying a list of these shortcuts is
  • Ctrl + Shift + L => Show Key Assist
This same feature is available in some Eclipse RCP products as well, including Lotus Notes 8. Unfortunately, I don't find such a list all that useful...especially if I am looking for one binding/command in particular. Fortunately, in the Eclipse IDE at least, hitting Ctrl+Shift+L again will open the key binding preferences page, found in Preferences under General->Keys. This page contains a long list of all the key bindings in your system and is also equipped with a fancy filtering search function which is VERY useful for finding both commands and shortcuts...as well as letting you set your own custom bindings.

Here is a list of some of the most useful Eclipse shortcuts I use:
Disclaimer: my shortcuts are very Java(JDT)/Plug-in(PDE) focused. Similar shortcuts are probably available in CDT or other packages, especially given the ongoing work to provide JDT-like functionality via projects such as the DLTK.

Common
There is something to be said for de facto shortcuts which work across all types of programs. Eclipse does a good job in this respect by implementing some shortcuts that are common to many programs. Such shortcuts include
  • [update: I thought Ctrl+Tab was used to tab through the open editors, but I see now the default for this command is Ctrl+F6. Another command I would find useful is a next tab command for navigating the bottom tabs found in editors such as the Plug-in Manifest Editor.]
  • Ctrl + W => Close Tab
  • Ctrl + N => New (Other...)
Navigation
One of the tasks which led to my constant use of the mouse in Eclipse was the simple navigation between views/perspectives/editors/etc. While each of these tasks has its own set of commands (Alt+Shift+Q was particularly useful for me to open/navigate to different views), I recently discovered the master of all shortcuts
  • Ctrl + 3 => Quick Access
Or as I like to call it, the "find whatever I'm looking for" command. This one command will give you a filtered search for perspectives, views, wizards, command, etc. The thing that makes this command even more useful is that it caches your command choice to provide a customized list of your common commands. While I still use Ctrl+E to activate an editor and Ctrl+N to launch the New->Other... wizard (I find it tricky to filter between those options), this is definitely one of my favorite shortcuts.

Most people I know are familiar with some common navigation shortcuts such as
  • F3 => Open Declaration
  • F2 => Open Tooltip
but they are nonetheless worth mentioning. Similar functionality is available using Ctrl+click.

Eclipse provides some useful views for navigation, including the type hierarchy and outline views, but instead of letting these views clog your precious screen real-estate, you can use their quick command options instead:
  • Ctrl + O => Quick Outline (x2 to toggle show/hide inherited members)
  • Ctrl + T => Type Hierarchy (x2 to toggle between supertype/subtype hierarchies)
In additional to the normal Find/Replace (Ctrl+F) command, Eclipse provides an advanced extensible search feature, which provides customizable scoped searches for particular resources such as Java Search, Plug-in Search, and standard global search.
  • Ctrl + H => Search
Although this feature provides powerful queries for all sorts of resources, I primarily use it for doing global/workspace file searches based on text and file type. It is also worth pointing out that the file search provides a global Replace... button as well if you look for it. For Java-specific searches, I usually find myself using some other useful bindings instead:
  • Ctrl + G => Declarations in Workspace
  • Ctrl + Shift + G => References in Workspace
Somewhat related, the call hierachy view is a very useful way to figure out who calls a method
  • Ctrl + Alt + H => Call Hierarchy
Another command I use religiously, is the open resource command
  • Ctrl + Shift + R => Open Resource
Similarly, the open type and open plug-in artifact commands are very useful when you know which type of resource you are looking for.
  • Ctrl + Shift + T => open type
  • Ctrl + Shift + A => open plug-in artifact*
Editing
Eclipse also provides some useful commands for use while programming. Perhaps the best know example would be the content assist (Ctrl+Space) feature. This binding will also rotate through a list of (customizable) templates/proposals if you press it more than once.

Another prevalent shortcut is the quick fix. This command seems to get better with each version of eclipse (especially for OSGi-related issues). I also use the lesser know quick assist command for assigning statements to fields (Ctrl+2, F) and local variables (Ctrl+2, L).
  • Ctrl + 1 => Quick Fix
  • Ctrl + 2 => Quick Assist (Assign To)
Another useful editing shortcut is the formatting command
  • Ctrl + Shift + F => format
For the longest time I used Ctrl+I to fix indentation issue, in part because I found the format option too extreme. However, after investing a little time in learning the formatting preferences, I now tend to format just about everything.

Eclipse is also chock full of refactoring/source assistance. Although each of these menus is available via shortcut (Alt+Shift+T and Alt+Shift+S), my favorite refactoring shortcuts are:
  • Alt + Shift + R => Rename
  • Alt + Shift + Z => Surround With
  • Alt + Shift + M => Extract Method
Both Surround With (try/catch, loops, etc) and Extract Method are quite useful for optimizing common tasks. However, the Rename shortcut in particular has been a real time-saver for me.

Run/Debug
Finally I would be remiss to list my favorite run/debug shortcuts, though I think these are fairly self-explanatory:
  • F11 => Run
  • Ctrl + F11 => Debug
  • F5 => Step Into
  • F6 => Step Over
  • F7 => Step Return
  • F8 => Resume
  • Ctrl + R => Run to Line
  • Ctrl + click => Step Into Method
  • Ctrl + F2 => Terminate
One thing worth noting here is that the F11 run/debug command used to always launch the previously launched app...but it will now default to whatever project is associated with the selected resource/active editor. To edit this preference, check out the Launch Operation section of Preferences->Run/Debug->Launching.

Conclusion
The combination of key bindings and filtering text boxes is awesomely powerful.
Learning to use Alt, Ctrl, and Shift on both sides of keyboard is vital (maybe its just me, but I previously used my left hand for all these keys...proving problematic for bindings like Alt+Shift+R).
In general, I am not a big fan of Fx (x=1-12) shortcuts as I find them awkward to type (though I do use them and have even listed a few).

Here is a slightly condensed list of the most useful bindings I've seen people miss:
  • Ctrl + Shift + L (x2) => Key Bindings Preferences
  • Ctrl + 3 => Quick Access List
  • Ctrl + O => Quick Outline (x2 to toggle show/hide inherited members)
  • Ctrl + T => Type Hierarchy (x2 to toggle between supertype/subtype hierarchies)
  • Ctrl + H => Search (File Search)
  • Ctrl + G => Declarations in Workspace
  • Ctrl + Shift + G => References in Workspace
  • Ctrl + Alt + H => Call Hierarchy
  • Ctrl + Shift + R => Open Resource
  • Ctrl + Shift + T => Open Type
  • Ctrl + Shift + F => Format
  • Alt + Shift + F1 => Plug-in Spy
  • Alt + Shift + R => Rename
  • F11 => Run
  • Ctrl + F11 => Debug
  • Ctrl + R => Run to Line
There are also a couple of custom bindings I usually set, but I will leave those for another day. There are PLENTY of commands which I left off this list, so let me know if I missed one of your favorites!

*new in Ganymede

Sunday, July 13, 2008

Bug Reporting

If you use open source software...its your duty.

As I have become more involved with open source, one of the largest revelations I've had is the usefulness of bug reporting. When I first started contributing, I was very nervous about opening a new bug...often neglecting to do so and sometime forgetting the problem altogether until I hit it the next time. For bugs which occur frequently, these annoyances tend to build up and significantly detract from my overall experience with the product.

I think there were a number of factors for this apprehension,
  • I assumed all the problems I hit were probably already reported
  • I didn't want to sound stupid for reporting something that wasn't really a bug, or had been dealt with in the past
  • I felt that opening a bug was like asking the developers for a favor
  • I assumed the amount of time it would take me to properly research the topic and investigate all similar problems would probably outweigh the limited loss of time/productivity from the bug in question
I realize that this issue likely varies by personality (I tend to be a bit shy before I have established relationships), but from talking with friends and coworkers I think that my feelings are shared by many.

One of the things which helped me most is the leadership I've received from coworkers at IBM. In particular, I recall one such coworker speaking with me on the importance of bug reporting...this was the first I had heard of this referred to as my duty. You are not asking for a favor when you open a bug, you are documenting a known limitation or problem and helping to make a better product for everyone.

Another important factor in my progress has been the ease with which I can produce high quality bug reports. For this reason, the Mylyn bug reporting feature (since Eclipse 3.3) has long been one of my favorites. I am not sure when they started including this in the main Eclipse Packages, but I am very happy to report it is included with at least the Ganymede JEE and RCP/Plug-in packages (I feel it should be in every Eclipse IDE package). If it isn't included in your build, you can get it from the Ganymede update site by installing Mylyn Connector: Bugzilla and Mylyn Bridge: Eclipse IDE.
When installed, the dialog can be found at Help->Report Bug or Enhancement...

Included with Ganymede, Mylyn 3.0 provides a nice improvement on this feature. Namely, when you create a new bug report, it will automatically be placed in the "Unsubmitted" category in your task list. This simple feature drastically improves my productivity and effectively lowers the barrier to bug submission (in older releases I don't think it was possible to save working drafts of bugs). In an open source community, I feel this 'lowering of the walls' is one of the most important keys to success. After all, this user involvement is one of the keys to cultivating a strong community (active users beget contributors beget committers).

With the latest feature I can open a new report every time I encounter a problem or think of a neat enhancement. If I do not have the time to investigate at present, the issue is at least documented for me so that I can finish my investigation when I do have the time. For me, this process usually looks something like:
  1. Hit a bug or think of a cool enhancement and open a new report
  2. Forget about it for a while
  3. Come back to my list of bugs/enhancements
  4. Try to reproduce the problem and document the steps in the bug
  5. Perform a google search for others with the same problem/workarounds
  6. Perform a bugzilla search on all open bugs for that component/project
  7. Search the list and open all related bugs in tabs
  8. Browse throught the tabs and copy the most relevent ones to my bug report
  9. Finish filling in the details and submit the report
  10. Respond to addition questions/responses on the bug report

Now that I have been able to get beyond my initial fears, I have been most impressed with the speed and quality with which most Eclipse projects (and most other high-quality open source projects for that matter) respond to my issues. This level of involvement has helped me to feel included in the Eclipse community and greatly improved my experience with the Eclipse Platform.

There certainly is a delicate balance between properly researching a suspected bug and blindly submitting every subtlety you find (otherwise committers would be hit with endless streams of duplicates and low-quality bugs). For me, this balance has trended toward submitting reports early and often...what process do you use to submit high quality bugs with minimal investment?

Thursday, July 10, 2008

Fun With p2



This walkthrough is intended chronicle my experiences with the Equinox provisioning platform Admin UI. I was able to glean most of the info needed from the Admin UI wiki at http://wiki.eclipse.org/Equinox_p2_Getting_Started_Admin_UI.
I tried http://wiki.eclipse.org/Equinox_p2_Admin_UI_Users_Guide
first, but it wasn't very helpful.

Download the equinox p2 agent and unzip to a good location (I used /opt/p2). Note that due to p2 limitations it is painful to move the agent around after provisioning multiple profiles.
It seems to take a few moments [too long] to start up (and why does it add a workspace directory to my Desktop?!).
It is also possible to run the Admin UI from within Eclipse by installing the Equinox Provisioning Agent Feature.

Add Metadata and Artifact Repositories for at least http://download.eclipse.org/releases/ganymede/ and http://download.eclipse.org/eclipse/updates/3.4milestones/.
Whoa, it looks like the first add gets displayed many times (see picture) [1].
Where is that nice drag and drop from the Software Update... feature [2]?

Drill down into the Metadata Repositories.
I find it nicer to group the Installable Units (IU) by category (Window->Preferences).

In the Profiles view there is an EquinoxProvisioningUI profile corresponding to the agent itself. Add a new profile for the Eclipse SDK and set the location and bundle pool location.
"/home/lee/user" seems like a poor default [3].
I would have like to set a global bundle pool for all users, but didn't want to run as root, so the bundle pool location I chose was /home/lee/.p2 [4].

Drag and drop the org.eclipse.sdk.ide feature from install list.
I tried installs with org.eclipse.platform.ide and org.eclipse.platform.sdk and they both installed but failed to start.

Approve the installations and proceed to Finish.
Check out some of the improved equinox security features at http://wiki.eclipse.org/Trusted_Bundles.
I had some problems taking a screen shot of the downloads, possibly due to my humble AMD Sempron 2800+ 1.6GHz CPU being pegged.
After about 10 minutes (for my 6.6 Mb/s connection--according to http://speedtest.net/) the install should complete and the IU should be displayed in the profile.

Navigate to the install location and launch your new Eclipse instance.
If you select Help->About Eclipse and click the Configuration button, you will notice one of the limiting factors of the agent...for some reason each install points back to the p2 agent for their p2 metadata [5].

Create a new profile in the Admin UI with the same bundle pool location (/home/lee/.p2) and install the Eclipse SDK IU to this profile.
Notice that this time, the install is only 4KB and will take about 10 seconds.
Way cool.

Launch your new Eclipse instance and open Help -> Software Updates...
You will notice the only Installed unit listed is the Eclipse SDK itself.
Lets install a new feature (the SCA tools feature from the STP project looks pretty interesting).
Using the filter list to narrow down installable units would be useful but it seems very slow [6].
The SCA tools install took me about 4 minutes.
Looks like the install button is missing its uppermost pixels, but that seems to have gone away now.

Restart Eclipse and be sure the plugins were properly installed
If you installed the SCA tools like me, create a new SCA example project using the wizard and note that the errors will go away when you point the tooling at an apache tuscany distribution.

Next, install the same feature to your original Eclipse Profile instance and you should see that it finds the plugins from your bundle pool.
My SCA Tools install took about 15 seconds this time

Back in the Admin UI, you can refresh the Profiles view but for some reason it can't see the newly installed features (after a quick restart they will magically appear) [7].
Next, lets install another Ganymede IU for good measure.
This time I went with the JavaScript Development Toolkit

Notice that directly after the install, the new IU shows up under "Installed Software" from you Eclipse instance. However, like installing plugins normally, it may require a restart to take effect.
At least you can use File -> Restart now instead of a manual stop and start (I used Switch Workspace -> Other for this in previous releases).
If you open the other Eclipse Profile installation, you can verify that it does not contain the newly installed feature.

Now suppose we would like to remove the SCA tooling feature from one of our profiles. In the Admin UI, there is no way to uninstall features.
This was very annoying when I installed the org.eclipse.platform.sdk feature and it wouldn't work...basically I had to remove the whole profile and delete the files manually.

However, if you have a working Eclipse install, it should still be possible to revert to a previous configuration by selecting the Revert Configuration... button in the Update Software... dialog.
Once again, the Admin UI will require a restart to notice the change in profile.

Overall, the p2 experience is very promising, despite the numerous annoying bugs left to solve. I am impressed with how this all came together, especially given some of the p2 criticism I heard near the end game for Ganymede.

[1]https://bugs.eclipse.org/bugs/show_bug.cgi?id=240472
[2]https://bugs.eclipse.org/bugs/show_bug.cgi?id=240600
[3]https://bugs.eclipse.org/bugs/show_bug.cgi?id=229699
[4]https://bugs.eclipse.org/bugs/show_bug.cgi?id=222130
[5]https://bugs.eclipse.org/bugs/show_bug.cgi?id=240601
[6]https://bugs.eclipse.org/bugs/show_bug.cgi?id=240603
[7]https://bugs.eclipse.org/bugs/show_bug.cgi?id=240602

Tuesday, July 1, 2008

Eclipse Ganymede Review

The latest Eclipse release train, Ganymede, has arrived(on time as usual) and comes loaded with 23 projects and a whole host of improved features (even for the Platform project alone) that I have been looking forward to since EclipseCon. Tops on my list are:
  1. The OSGi and Eclipse run configurations are sporting a shiny new filter box. This alone was worth the upgrade for me...no more hunting through the hundreds of bundles in my target to add a bundle that was missing and not "required" (target platforms are still the way to go to limit the number of bundles in this list).
  2. PDE has added a spiffy feature called the plug-in spy...simply click ALT+SHIFT+F1 over any active window and it will pop up with useful info like the active View class and the contributing plugin. This is so useful I retrofitted it to my 3.3 instance as well.
  3. The Plug-in Registry view now allows you to start/stop, enable/disable, and diagnose individual bundles (toggle the Show Advanced Operations menu item to turn them on).
  4. Improved String matching in Find/Replace dialog (esp. with newlines). That used to drive me nuts.
  5. Improved Share Project wizard. It was a real pain to share each of my projects individually in the past, and the addition of the "use the project name as the module name and place it under the selected module" option would have been really handy for me last month :-) update: I just tried this out and it wasn't that special...still have to share each project individually, you just have a nicer wizard to tell you that.
(I was hoping to add links from these items to their location in the New and Noteworthy doc, but it doesn't seem to offer anchors for that purpose)
update: this was an oversite on my part

Overall I have been very impressed with the stability of the new release...even after loading it with all kinds of Ganymede plugins it seems to be performing splendidly on my underpowered (1.6 Gh, 512MB) Linux box.

However, the project/feature I am most excited for is the new provisioning platform (p2). I have read an interesting review at Ekkes Corner and also began to play with the new "Software Updates..." feature. I was also able to set up a working pooled Eclipse install using the p2 admin ui agent (as apposed to the installer) to provision my SDK. I hope to document this experience here shortly...