tag:blogger.com,1999:blog-15577801843579272412024-03-14T14:33:29.798+05:30Eclipse Tips - Prakash G.R.Tips and Tricks for Eclipse Plug-in DevelopmentPrakash G.R.http://www.blogger.com/profile/13046268367318873066noreply@blogger.comBlogger111125tag:blogger.com,1999:blog-1557780184357927241.post-59321158454524300752011-03-24T01:04:00.000+05:302011-03-24T01:04:36.075+05:30A short tutorial on Intro / WelcomeWelcome page in Eclipse provides you a unique way to introduce your product to the new users. Its very flexible and can be extended by other plugins. You can create the entire Welcome view by yourself by extending the org.eclipse.ui.intro and provide all the contents you want. That is little tedius, and in this tutorial, we are going to explore an easier one - the CustomizableIntroPart.<br />
<br />
<a href="http://www.eclipse-tips.com/tutorials/40-a-short-tutorial-on-introwelcome">Read More ...</a>Prakash G.R.http://www.blogger.com/profile/13046268367318873066noreply@blogger.com5tag:blogger.com,1999:blog-1557780184357927241.post-50172170204371355882011-02-04T01:05:00.000+05:302011-02-04T01:05:29.860+05:30Adding a new editorAction for OrionIn case you have not heard it yet, <a href="http://wiki.eclipse.org/Orion" style="color: #ed8130; text-decoration: none;" target="_blank">Orion</a> is the new Web IDE from Eclipse. In a blog entry <a href="http://blog.eclipse-tips.com/2011/01/web-is-name-of-game.html" style="color: #ed8130; text-decoration: none;" target="_blank">introducing Orion</a>, I said that this one is going to stand out from the crowd and going to rule the world. Why can't the other Web IDEs do that? Because, Orion, walking in the path of Eclipse, will provide the ability to customize and extend. Now with Orion 0.2 M5, you can extend the editor and provide your own editorAction. This is the first and only "extension point" available, but for sure, more will follow.<br />
<br />
For this tip, we are going to add a Dictionary look up action to the editor. The action will open up Google Dictionary in a popup window for the selected text in the editor. Yes, popup windows are so ugly, and a div would be lot better, I'll do the beautification later, so for now disable your popup blockers.<br />
<br />
<a href="http://eclipse-tips.com/tips/38-adding-a-new-editoraction-for-orion">Read More...</a>Prakash G.R.http://www.blogger.com/profile/13046268367318873066noreply@blogger.com0tag:blogger.com,1999:blog-1557780184357927241.post-18116098583528008562011-01-17T14:49:00.000+05:302011-01-17T14:49:30.947+05:30Beware of Plagiarism ...Thanks to one of the readers of my blog, I came across this entry: <a href="http://eclipse-perspectivecustomization.blogspot.com/2011/01/top-10-mistakes-in-eclipse-plug-in.html" rel="nofollow">http://eclipse-perspectivecustomization.blogspot.com/2011/01/top-10-mistakes-in-eclipse-plug-in.html</a> That was a complete copy-paste from my <a href="http://blog.eclipse-tips.com/2009/01/top-10-mistakes-in-eclipse-plug-in.html">top 10 mistakes blog entry</a>. I did a little search and found all of the blog entries are copy-pasted from elsewhere.<br />
<br />
<ul><li><a href="http://eclipse-perspectivecustomization.blogspot.com/2010/12/perpective-customization.html" rel="nofollow">http://eclipse-perspectivecustomization.blogspot.com/2010/12/perpective-customization.html</a> is copied from <a href="http://www.eclipse.org/articles/using-perspectives/PerspectiveArticle.html">Eclipse Articles</a> itself.</li>
</ul><ul><li><a href="http://eclipse-perspectivecustomization.blogspot.com/2011/01/using-eclipse-efficiently-using.html" rel="nofollow">http://eclipse-perspectivecustomization.blogspot.com/2011/01/using-eclipse-efficiently-using.html</a> is copied from <a href="http://blog.oogly.co.uk/java/eclipse-shortcut-keys">Jonathan's blog entry</a>.</li>
</ul><ul><li><a href="http://eclipse-perspectivecustomization.blogspot.com/2010/12/product-customization-using.html" rel="nofollow">http://eclipse-perspectivecustomization.blogspot.com/2010/12/product-customization-using.html</a> is copied from <a href="http://blog.balfes.net/?p=1725">Bob Balfe's blog entry</a>.</li>
</ul>Wonder what would be the intention of having such a blog :-(Prakash G.R.http://www.blogger.com/profile/13046268367318873066noreply@blogger.com4tag:blogger.com,1999:blog-1557780184357927241.post-39115370995598086422011-01-13T10:20:00.000+05:302011-01-13T10:20:01.889+05:30"Web" is the name of the game ...For a long time, there are multiple efforts for the concept of "single sourcing": One code base; runs on Web and Desktop without any/much change. I've always strongly rejected the idea of it. Checking out the promising demos of the technology, the pointy-haired Boss simply dreams of the 50% cut in his development cost by choosing the technology. He can be easily convinced that the users don't have to be trained for two different UIs to achieve the same thing right, resulting in cutting cost in documentation, training, bug-fixing etc. Well, fact is far beyond that and the Dilbert in you will understand the practical difficulties.<br />
<br />
Web and Desktop are two different beasts. What does it mean for a right click in the browser? Or what does it means for a Back/Refresh button in the Desktop? Both the platforms have their own metaphor. You can't simply throw a Web UI to the Desktop or vice-versa. That's why whenever someone shows me demo of "the brand new framework" for creating both UIs with single source, I would say, "wait for an year for this framework to die". Within an year, there would be an another framework attempting the same.<br />
<br />
<a href="http://wiki.eclipse.org/Orion">Orion </a>is different. Its the Web IDE from Eclipse, yet it doesn't try to "leverage" the existing Existing IDE code and present the same UI. Instead its written from the group up. Few months back, when I saw a demo for the StyledText for the web, I was thoroughly impressed. It could handle huge files with ease - which is the bottleneck of other online IDEs. Now that its out to the public as Orion, I'm seeing a lot of +ve reviews and few -ve questions as well. One of the primary question is "How many developers need a Web IDE?". Well, I don't have an exact count. But take away is simple. The market for Web based IDEs is brewing up (eg: <a href="https://mozillalabs.com/skywriter/">Skywriter</a>, <a href="http://www.cloud9ide.com/">Cloud 9</a>) and you would see many more of these in the near future. Just as Eclipse became *the* IDE, Orion is going to be *the* Web IDE. Period.Prakash G.R.http://www.blogger.com/profile/13046268367318873066noreply@blogger.com4tag:blogger.com,1999:blog-1557780184357927241.post-10511383697620470632010-12-03T13:30:00.000+05:302010-12-03T13:30:37.983+05:30Contributing Workbench Wizards thru CommandsYou must have been used this JDT toolbar quite often. <br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3sKKS_Pwt6sLDXjIhrN7V7awOdfjBKJsSyV897ZYnmyZGRNq_1qFndOlutKAORZ3oYUtvNQM-mtwhnkXtCDJDAw7DkzmgcaZBWuMH3ri2RVvxFt4UkfE8dRr3bpHlZ2h-SX8NiUZr1vI/s800/JDTToolBar.png" /><br />
<br />
The New Class tool item is contributed as an Action in <a href="http://dev.eclipse.org/viewcvs/viewvc.cgi/org.eclipse.jdt.ui/plugin.xml?view=markup">plugin.xml</a> (id "org.eclipse.jdt.ui.actions.NewTypeDropDown"), and then the Menu on the Action is contributed via <a href="http://dev.eclipse.org/viewcvs/viewvc.cgi/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/NewTypeDropDownAction.java?view=markup">code</a>. In this tip, let us see how to do the same via command framework and without any code.<br />
<br />
<a href="http://eclipse-tips.com/tips/37-contributing-workbench-wizards-thru-commands">Read More... </a>Prakash G.R.http://www.blogger.com/profile/13046268367318873066noreply@blogger.com3tag:blogger.com,1999:blog-1557780184357927241.post-63179875149068965802010-10-18T11:53:00.000+05:302010-10-18T11:53:00.400+05:30New features on Mac<u><b><span style="font-size: large;">Windowless application:</span></b></u><br />
<br />
SWT now supports an application level menu, so now its possible for an app to have a MenuBar without any Shell<br />
<br />
Here is the code sample:<br />
<br />
<pre class="brush: java; collapse: true">package com.eclipse_tips.mac.sample;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.Shell;
public class WindowlessApp {
private static int windowCount;
public static void main(String[] args) {
final Display display = new Display();
Menu appMenuBar = display.getAppMenuBar();
final MenuItem windowMenu = new MenuItem(appMenuBar, SWT.CASCADE);
windowMenu.setText("Window");
Menu windowSubMenu = new Menu(null, SWT.DROP_DOWN);
windowMenu.setMenu(windowSubMenu);
createNWMenuItem(display, windowSubMenu);
while (!display.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
private static Shell createNewWindow(final Display display) {
windowCount++;
Shell shell = new Shell(display);
Menu bar = new Menu(shell, SWT.BAR);
shell.setMenuBar(bar);
shell.setText("Window #" + windowCount);
MenuItem fileItem = new MenuItem(bar, SWT.CASCADE);
fileItem.setText("&File" + windowCount);
Menu submenu = new Menu(shell, SWT.DROP_DOWN);
fileItem.setMenu(submenu);
MenuItem item = new MenuItem(submenu, SWT.PUSH);
item.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
System.out.println("Select All");
}
});
item.setText("Select All");
createNWMenuItem(display, submenu);
return shell;
}
private static void createNWMenuItem(final Display display, Menu submenu) {
MenuItem newWindowItem = new MenuItem(submenu, SWT.PUSH);
newWindowItem.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
Shell window = createNewWindow(display);
window.setSize(300, 200);
window.open();
}
});
newWindowItem.setText("New Window");
}
}
</pre><br />
<br />
<span style="font-size: large;"><b><u>Native ToolBar:</u></b></span><br />
<br />
The native toolBar is now supported and it looks awesome. Here is the modified <a href="http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet58.java">SWT ToolBar snippet</a> in action:<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><img border="0" height="158" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjeUHHoXdfVs_t83FwNWq7T90skoMVBhasq_kIBVhuSApfo2XOHXcqfCJygre5DHo6aZGwNPsvfq1utUooTQnbLF2SspYK4765xg0d_BvSs3wpegAWiHF4HO5IyMG7XHJbMXpMt2ywtAtg/s320/NativeToolBar.png" style="margin-left: auto; margin-right: auto;" width="320" /></td></tr>
<tr><td class="tr-caption" style="text-align: center;">SWT Native Toolbar on Mac</td></tr>
</tbody></table><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjeUHHoXdfVs_t83FwNWq7T90skoMVBhasq_kIBVhuSApfo2XOHXcqfCJygre5DHo6aZGwNPsvfq1utUooTQnbLF2SspYK4765xg0d_BvSs3wpegAWiHF4HO5IyMG7XHJbMXpMt2ywtAtg/s1600/NativeToolBar.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><span id="goog_1720987871"></span><span id="goog_1720987872"></span></a></div><br />
<span style="font-size: small;"><u><b>Window menu items:</b></u></span><br />
<br />
Eclipse adds support to the standard 'Minimize', 'Zoom' & 'Bring All to Front' menu items in the Window menu:<br />
<br />
<span id="goog_1720987877"></span><br />
<span id="goog_1720987886"></span><span id="goog_1720987896"></span><br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgcpe0ZNa0fxfKC5ChY_2IdVgy1hI0qwtXqyMJEkczImLWnbIIEINoSSyzYXi-Tu1kAsJym2qYBKfw9SlqKYrZABWuvbisjuOhkrn7APLhWtnIM1fofn-5ZopkinKKWD2hf9R9rc1TGs8/s320/MacWindowMenu.png" style="margin-left: auto; margin-right: auto;" width="242" /></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Mac standard menu items in Window menu</td></tr>
</tbody></table><br />
<div class="separator" style="clear: both; text-align: center;"></div><br />
<span style="font-size: large;"><u><b>Proxy Icon:</b></u></span><br />
<br />
Eclipse now supports <a href="http://www.tuaw.com/2007/05/04/mac-101-dragging-and-dropping-from-the-title-bar/">proxy icons</a> in the window title. You can drag those icons to other apps or Cmd+click to directly navigate any folder in the file's hierarchy:<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><img border="0" height="106" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMYYlvav5SuETFMwD8rDyJlkkv9SdjXo_gsHXbPLf7RkxhccVRDQzYUm0P_sIKjYJfdo_ilqJEOi_QDkziXfTGsuIB2KYY4IWJzgmOMPMZy08jBqNmPk6lwe92GGk2lj1sfFldl6qn9tY/s400/MacProxyIcon-1.png" style="margin-left: auto; margin-right: auto;" width="400" /></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Proxy Icon in Eclipse Workbench</td></tr>
</tbody></table><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMYYlvav5SuETFMwD8rDyJlkkv9SdjXo_gsHXbPLf7RkxhccVRDQzYUm0P_sIKjYJfdo_ilqJEOi_QDkziXfTGsuIB2KYY4IWJzgmOMPMZy08jBqNmPk6lwe92GGk2lj1sfFldl6qn9tY/s1600/MacProxyIcon-1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"></a></div><br />
<br />
Note, these are available in the latest Nightly builds of 3.7 and are subjected to change before the release :-)Prakash G.R.http://www.blogger.com/profile/13046268367318873066noreply@blogger.com7tag:blogger.com,1999:blog-1557780184357927241.post-32094510046317538092010-06-14T13:16:00.000+05:302010-06-14T13:16:52.195+05:30Top 3 things I want in Eclipse 3.7 (Indigo)3.6 packages are coming to the mirror servers near you, and the <a href="http://www.eclipse.org/helios/blogathon/reviews.php">reviews</a> are hitting the Planet Eclipse already. Moving on to 3.7, what are the top most features I would love to see in Indigo?<br />
<br />
<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=285089">3) Deprecate Actions framework</a><br />
<br />
Commands are powerful,flexible and better than Actions in many different ways. Actions are simple enough and useful if don't need the flexibility in an RCP application. But for a bigger and extensible app like IDE, Commands make sense. Would be lot better if we get rid of Actions and make all the contributions thru Commands.<br />
<br />
<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=57349">2) Packaging in Mac</a><br />
<br />
The first impression on Eclipse for a Mac user is that its distributed as zip file - not a dmg. Unzipping it does has a Eclipse.app, but it has no features of a Mac Application. Packing it as a complete .app would be a great thing (and giving the ability to pack RCP apps in a similar way) A non-Mac user will have no idea of why/how useful this feature is, and so they don't really care about it :-(<br />
<br />
<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=227055">1) PDE Custom Attribute</a><br />
<br />
The custom attribute in the Manifest editor is a boon to every plug-in developer. It opens up a number of opportunities. The two images are might show off what is possible:<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://bugs.eclipse.org/bugs/attachment.cgi?id=117595" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="137" src="https://bugs.eclipse.org/bugs/attachment.cgi?id=117595" width="320" /></a></div><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://bugs.eclipse.org/bugs/attachment.cgi?id=117511" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="214" src="https://bugs.eclipse.org/bugs/attachment.cgi?id=117511" width="320" /></a></div><br />
Thats just my wish list. Whats yours?Prakash G.R.http://www.blogger.com/profile/13046268367318873066noreply@blogger.com8tag:blogger.com,1999:blog-1557780184357927241.post-48634500037324225562010-04-27T23:16:00.002+05:302010-04-28T08:52:59.637+05:30Eclipse Day India<div class="separator" style="clear: both; text-align: center;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0ZXDNlD2Lz2zWKeFSoOcomr2K65FOHaiL_Atel7FHORs7JbUver_DD_CR3qu-OPDRrkzdOQ94EVrhyphenhyphen5AiI0Rz3pXSGrB25kLb1kritkhWfOxQSTUir-8wQT5yYa3bZq0upeDU9xRMlN8/s1600/Eclipse_Day.png" /></div><br />
It was one hell of a ride. Finalizing the website for registration to designing of the schedule, all the choices were carefully evaluated. No wonder the professional event organizers are paid that much. Despite Murphy's laws being proved few times and issues like halls in different floors, most of the people whom I've met over Eclipse Day India were quite happy about the event. People were pinging me (despite my "rude" status in IM) & Ankur and asking how can they help in this event. Thanks for everyone for sponsoring, helping and attending the event. A special thanks goes to <a href="http://dev.eclipse.org/blogs/lynngo/">Lynn</a> from the foundation for patiently answering all our queries and helping us.<br />
<br />
I presented the two talks. An hour long OSGi tutorial and a lightning talk on <a href="http://eclipse-tips.com/tips/3-top-10-mistakes-in-eclipse-plug-in-development">Top 10 mistakes in Eclipse plug-in development</a>. Many people said the OSGi tutorial was good. They liked the part that most of it were hands on session instead of slides & bullet points. I've uploaded my presentation and more slides from the presentation will be available from <a href="http://www.slideshare.net/event/eclipse-day-india-2010">here</a>. On a slightly different note, the people who gave correct answer for the question in the Top 10 presentation were very experienced people. What's happening to the younger generation of developers?<br />
<br />
<div id="__ss_3869535" style="width: 425px;"><b style="display: block; margin: 12px 0pt 4px;"><a href="http://www.slideshare.net/grprakash/osgi-tutorial" title="OSGi tutorial">OSGi tutorial</a></b><object height="355" width="425"><param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=osgitutorial-100427061637-phpapp02&stripped_title=osgi-tutorial" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=osgitutorial-100427061637-phpapp02&stripped_title=osgi-tutorial" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object><br />
<div style="padding: 5px 0pt 12px;">View more <a href="http://www.slideshare.net/">presentations</a> from <a href="http://www.slideshare.net/grprakash">grprakash</a>.</div></div><br />
<br />
<div id="__ss_3869502" style="width: 425px;"><b style="display: block; margin: 12px 0pt 4px;"><a href="http://www.slideshare.net/grprakash/top-10-mistakes-in-eclipse-plug-in-development" title="Top 10 mistakes in eclipse plug in development">Top 10 mistakes in eclipse plug in development</a></b><object height="355" width="425"><param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=top10mistakesineclipseplug-indevelopment-100427061250-phpapp02&stripped_title=top-10-mistakes-in-eclipse-plug-in-development" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=top10mistakesineclipseplug-indevelopment-100427061250-phpapp02&stripped_title=top-10-mistakes-in-eclipse-plug-in-development" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object><br />
<div style="padding: 5px 0pt 12px;">View more <a href="http://www.slideshare.net/">presentations</a> from <a href="http://www.slideshare.net/grprakash">grprakash</a>.</div></div>Prakash G.R.http://www.blogger.com/profile/13046268367318873066noreply@blogger.com0tag:blogger.com,1999:blog-1557780184357927241.post-30046792142233520282010-03-12T18:34:00.001+05:302010-03-25T22:58:38.936+05:30API Tooling TutorialDo you know that adding a new field to an interface or adding a new non-default constructor to a class can break the binary compatibility of your API? There are so many other things like these that can possibly break the compatibility. Either you can spend a lot of your time reviewing all the new added/modified API for breaking changes (before that, you need to spend more amount of time in finding them) or simply use PDE's API tooling to do it for you as you develop.<br />
<br />
The tutorial gives an introduction about what API Tooling is and how to setup and use for you project. Click here to read the <a href="http://eclipse-tips.com/tutorials/26-api-tooling-tutorial">API Tooling Tutorial</a>.Prakash G.R.http://www.blogger.com/profile/13046268367318873066noreply@blogger.com0tag:blogger.com,1999:blog-1557780184357927241.post-82331637645478975842010-02-08T11:07:00.000+05:302010-02-08T11:07:28.888+05:30Eclipse Day in Bangalore - registrations openToday the registrations open for Eclipse Day in Bangalore. The entry is *free*, but you have to register to get the ticket. The tickets are limited, <a href="http://eclipsedayindia.eventbrite.com/">so hurry up</a>.<br />
<br />
The deadline for talk submissions are fast approaching and you have only one week left. Again, <a href="http://bit.ly/EclipseDay2010">hurry up</a> :-)<br />
<br />
We also have a calendar published in the <a href="http://wiki.eclipse.org/Eclipse_Day_India">wiki</a>. You can subscribe to it in your calendar, so you won't miss any dates.Prakash G.R.http://www.blogger.com/profile/13046268367318873066noreply@blogger.com0tag:blogger.com,1999:blog-1557780184357927241.post-34320421226808725042010-01-23T00:03:00.001+05:302010-01-23T00:21:11.550+05:30Launching www.eclipse-tips.com ...Its due for a long time :-) Ever since I purchased this domain, I wanted to create a site as a resource for Eclipse Plug-in developers. With little bit of hacking over the two weekends, the website is up and running with bare minimum content. I'll be adding more content from this blog and elsewhere, meanwhile you can check out the layout and other stuff.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYbq5-zEVOUwUvH86wa-BVmEksfSim2vp8bT_JOfiIVJlMzeJQKi762VKRYW7osndDDggIvWnm1bGVUXcqtQS_R2yB0UCEdyLHmMqgPvzZ7sxN4g8OiG_nJdR-1iLSRxlst1XpTBmSzC4/s1600-h/EclipseTipsSite.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="455" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYbq5-zEVOUwUvH86wa-BVmEksfSim2vp8bT_JOfiIVJlMzeJQKi762VKRYW7osndDDggIvWnm1bGVUXcqtQS_R2yB0UCEdyLHmMqgPvzZ7sxN4g8OiG_nJdR-1iLSRxlst1XpTBmSzC4/s640/EclipseTipsSite.png" width="640" /></a><br />
</div><br />
<br />
Coolest and most useful thing for the visitors would be Eclipse Search. Even though the results portion occupies a significant space in the prime area, I decided to have it because its very handy if you want to search for something. And the whole interface is very nice (courtesy: Google Ajax APIs) Whether you want to search for a particular class in the repository or search for an xml editor plugin or a blog entry about Tray Item, its available in few clicks.<br />
<br />
Every article has a pdf & print icon. So if you need an offline copy, its available. This was not possible earlier with this blog.<br />
<br />
And last, but not the least, for international visitors, the translate option is available in the bottom bar. With just two clicks you can translate to a language of your choice - without reloading the page. Again, done thru Google Ajax APIs. (you got to love this web stuff - esp when you can implement a feature without writing a single line of code :-) )<br />
<br />
Mail me/leave a comment if you have any comments/suggestionsPrakash G.R.http://www.blogger.com/profile/13046268367318873066noreply@blogger.com3tag:blogger.com,1999:blog-1557780184357927241.post-64917966568548012142010-01-19T10:58:00.001+05:302010-01-19T12:05:17.522+05:30Eclipse Day in Bangalore<i><b>About</b></i><br />
<br />
Last year we had a successful <a href="http://wiki.eclipse.org/Eclipse_DemoCamps_November_2009/Bangalore">Eclipse Demo Camp in Bangalore</a>. In a post-event survey, many people said that they are willing to attend a full day event, and here we are.<br />
<br />
Me and Ankur are planning for <a href="http://wiki.eclipse.org/Eclipse_Day">an Eclipse Day</a> in Bangalore on April 9th. This year's theme would be "Eclipse Plug-in Development". It will be a full day event. Unlike the Demo Camp, there will be three types of talks (Long talk, Short talk and Lightning talk) and we have a committee (<a href="http://ketan.padegaonkar.name/">Ketan</a> from ThoughtWorks, <a href="http://www.devmarch.com/eclipsesummit/2009/speakers.html#Jain">Anshu Jain</a> from IBM & <a href="http://eclipse-info.blogspot.com/">Madhu</a>, an Independent Eclipse Consultant) to review the proposals. So you will get to attend only the best out of the proposals. <br />
<br />
<i><b>Want to attend?</b></i><br />
<br />
Just like the Demo Camp, the entry is free. However you have to pre-register and the registrations open on Feb 1st. There are only 100 seats available, so you want to register as soon as its opens. Registrations can be done from <a href="http://eclipsedayindia.eventbrite.com/">here</a>.<br />
<br />
<i><b>Interested in presenting?</b></i><br />
<br />
Fill in <a href="http://bit.ly/EclipseDay2010">this form</a> and submit your proposals. The review team will get back to you.<br />
<br />
<i><b>Sponsoring:</b></i><br />
<br />
Last but not least, sponsors. We are reaching out various companies for sponsorship. Your company can support the event by sponsoring it. It also had added advantage of:<br />
<br />
* 5 reserved attendee seats<br />
* One lightning talk<br />
* Ads & stall space in the venue (banners and contact booth at sponsor's cost. We will help provide as much space possible.)<br />
* Mention in various promotions on Eclipse websites as mentioned <a href="http://wiki.eclipse.org/Eclipse_Day#Promotional_Opportunities_Checklist">here</a>. <br />
<br />
Do contact <a href="mailto:grprakash+EclipseDay@gmail.com">me</a> or <a href="mailto:ankur_sharma@in.ibm.com">Ankur</a> if you have any questions.Prakash G.R.http://www.blogger.com/profile/13046268367318873066noreply@blogger.com0Bengaluru, Karnataka, India12.971606 77.59437612.6370475 77.127456999999993 13.3061645 78.061295tag:blogger.com,1999:blog-1557780184357927241.post-82845353377136908492009-12-21T22:36:00.002+05:302009-12-21T23:05:40.623+05:30Toggle Commands the toggle other contributionsFound <a href="http://philondev.blogspot.com/2009/12/toggle-commands-toggle-other.html">this one</a> on <a href="http://philondev.blogspot.com">Phil's blog</a>. Republishing it with his permission. Thanks Phil!<br />
<br />
<h2>Introduction</h2>This is a follow up to <a href="http://blog.eclipse-tips.com/2009/03/commands-part-6-toggle-radio-menu.html">Commands Part 6: Toggle & Radio menu contributions</a> of fellow blogger <a href="http://blog.eclipse-tips.com/">Prakash G.R.</a>. He described how to use command toggle and radio states. Here I will show you how to drive other contributions in the Eclipse Workbench using a toggle command.<br />
<br />
<h2>What we want to achieve</h2>I needed to show another toolbar button when a certain toggle command was executed. Imagine something like "Show clock" that will show or hide a little clock in the worbench window status bar.<br />
Such contribution can be easily added using a <span style="font-family: courier new;">menuContribution</span> for the trim area. First create a toolbar in the trim area and then contribute controls/commands to this toolbar also using the <span style="font-family: courier new;">menuContribution</span> extension point.<br />
Since we want the clock contribution<br />
<br />
<br />
<pre class="brush: xml;"><menucontribution locationuri="toolbar:mytoolbar">
<control class="test.ui.clocl.internal.ClockControlContribution" id="test.ui.clock">
<visiblewhen checkenabled="false">
<with variable="activeWorkbenchWindow">
<test args="test.ui.clock.ToggleCommand"
forcepluginactivation="true"
property="org.eclipse.core.commands.toggle"
value="true"/>
</with>
</visiblewhen>
</control>
</menucontribution>
</pre><br />
That will create a toolbar contribution that is only visible when the <span style="font-family: courier new;">test.ui.clock.ToggleCommand</span> is in the "<span style="font-family: courier new;">true</span>" state, when its checked.<br />
<br />
Lets define the command:<br />
<pre class="brush: xml;"><command defaulthandler="org.eclipse.core.commands.extender.ToggleCommandHandler" id="test.ui.clock.ToggleCommand" name="Show clock">
<state
class="org.eclipse.ui.handlers.RegistryToggleState:true"
id="org.eclipse.ui.commands.toggleState">
</state>
</command>
</pre><br />
How this command works and what the state is you have already read in Prakash's blog entry. The default handler for this command does a little more than the one in the latter mentioned blog entry. It is defined like this:<br />
<br />
<pre class="brush: java;">/**
* Generic command that toggles the executed command and re-evaluates property testers for the
* <code>org.eclipse.core.commands.toggle</code> property.
*
*/
public class ToggleCommandHandler extends AbstractHandler {
public Object execute(final ExecutionEvent event) throws ExecutionException {
HandlerUtil.toggleCommandState(event.getCommand());
final IWorkbenchWindow ww = HandlerUtil.getActiveWorkbenchWindowChecked(event);
final IEvaluationService service = (IEvaluationService) ww.getService(IEvaluationService.class);
if (service != null) {
service.requestEvaluation("org.eclipse.core.commands.toggle");
}
return null;
}
}
</pre><br />
<h2>How do toggle the visibility of the clock contribution</h2><br />
The connection between toggling the command and making the clock contribution visible is hidden in a property tester, that the clock contribution uses:<br />
<br />
<pre class="brush: java;">public class CommandsPropertyTester extends PropertyTester {
public static final String NAMESPACE = "org.eclipse.core.commands"; //$NON-NLS-1$
public static final String PROPERTY_BASE = NAMESPACE + '.';
public static final String TOGGLE_PROPERTY_NAME = "toggle"; //$NON-NLS-1$
public static final String TOGGLE_PROPERTY = PROPERTY_BASE + TOGGLE_PROPERTY_NAME;
public boolean test(final Object receiver, final String property, final Object[] args, final Object expectedValue) {
if (receiver instanceof IServiceLocator && args.length == 1 && args[0] instanceof String) {
final IServiceLocator locator = (IServiceLocator) receiver;
if (TOGGLE_PROPERTY_NAME.equals(property)) {
final String commandId = args[0].toString();
final ICommandService commandService = (ICommandService)locator.getService(ICommandService.class);
final Command command = commandService.getCommand(commandId);
final State state = command.getState(RegistryToggleState.STATE_ID);
if (state != null) {
return state.getValue().equals(expectedValue);
}
}
}
return false;
}
}
</pre><br />
It is defined in plugin.xml like this:<br />
<pre class="brush: xml;"><propertytester
class="org.eclipse.core.commands.extender.internal.CommandsPropertyTester"
id="org.eclipse.core.expressions.testers.CommandsPropertyTester"
namespace="org.eclipse.core.commands"
properties="toggle"
type="org.eclipse.ui.services.IServiceLocator"/>
</pre><br />
That means we define a new property for the namespace "<span style="font-family: courier new;">org.eclipse.core.command</span>" and the property is named "toggle". It will operate on<span style="font-family: courier new;"> IServiceLocator</span> variables. Such variable that is an <span style="font-family: courier new;">IServiceLocator</span> is the "<span style="font-family: courier new;">activeWorkbenchWindow</span>" variable. Now you should understand the <span style="font-family: courier new;">visibleWhen</span> expression of the clock contribution. It should be only visible when the toggle for the clock toggle command is "true". The re-evaluation of the property testers is triggered by the generic <span style="font-family: courier new;">ToggleCommand</span>.<br />
<br />
<br />
<h2>A little tip at the end</h2>If you put the <span style="font-family: courier new;">ToggleCommand</span> and property tester in a seperate bundle for easier re-use in all your projects and other bundles make sure you either start the bundle at the beginning or set the "test" expressions "<span style="font-family: courier new;">forcePluginActivation</span>" to true to let the Eclipse expression framework activate the bundle for you. Otherwise the property tester is completly ignored and the clock would be always visible.<br />
<br />
<h2>Bonus</h2>Since the state of the toggle is preserved in an instance preference value the visibility of all associated contributions that use the property tester to check for the toggle state of the command.<br />
<br />
Of course you can also reverse the test expression for your contributions if you have a toggle command that says something like "Hide clock".<br />
<br />
<a href="http://philondev.blogspot.com/2009/12/toggle-commands-toggle-other.html">Click here for the original entry.</a>Prakash G.R.http://www.blogger.com/profile/13046268367318873066noreply@blogger.com0tag:blogger.com,1999:blog-1557780184357927241.post-5020733176947994792009-12-02T00:30:00.001+05:302009-12-02T00:34:14.549+05:30Reload your plugins without restarting EclipseWhen you are developing Eclipse plugins, sometimes its annoying that the changes in the plugin.xml won't reflect immediately. You need to restart the target Eclipse to see the changes. This will be painful if you are playing with trial-n-error stuff like the menu urls. In this tip, I'll explain how to make Eclipse reread your plugin.xml without restarting the target.<br />
<br />
<br />
<ul><li>Create a plugin, launch as an Eclipse Application (you don't even need to Debug, just Run would do) <br />
</li>
<li>Check the UI contributions of your plugin.</li>
<li>Make the desired change in your plugin.xml. Right now, I've changed a Command's name; added a Command contribution to an existing menu; added a new view and made changes to an existing perspective</li>
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5lKAjsGHPfeRS_8rlktZ3yMwzipCdJ2nrFfubStgrgOssunOzRWN8TLteY5RrINQDiHNPEbkUiXyKWPFdHHYbidgmPng9-7WJpIFuB2MKH_Ar91j3Qqg3KOTBF_Zc-C1InbdXLfJc-fc/s1600/Changes.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5lKAjsGHPfeRS_8rlktZ3yMwzipCdJ2nrFfubStgrgOssunOzRWN8TLteY5RrINQDiHNPEbkUiXyKWPFdHHYbidgmPng9-7WJpIFuB2MKH_Ar91j3Qqg3KOTBF_Zc-C1InbdXLfJc-fc/s400/Changes.png" /></a>
</div>
<li>In your target, open the Plug-ins Registry view and in the pull down menu, check the 'Show Advanced Operations'</li>
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiTg8S7iLw11AOyTGwhAOjYfIxNKON-LhHupKlBdSXV0-oJJF795aEQhLzLHXKzdZftoyCFFo9432RE-IGh97NdsPm348zYVoLsh_n7gfMUT8Ytx4nIWYeFNzRNrxLgXotrH6xRfzSWu1E/s1600/Enable%20Advance%20Operations.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiTg8S7iLw11AOyTGwhAOjYfIxNKON-LhHupKlBdSXV0-oJJF795aEQhLzLHXKzdZftoyCFFo9432RE-IGh97NdsPm348zYVoLsh_n7gfMUT8Ytx4nIWYeFNzRNrxLgXotrH6xRfzSWu1E/s1600/Enable%20Advance%20Operations.png" /></a>
</div>
<li>Right click your plugin and select Disable. </li>
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDGEv2ez9DXT_EsHoAONb1oiawpBMMwtcPj3DdirXCuvLUlgXLLpQYsrgs6R4hV-ccCv6e6g9UeamswhOWUocssknKmZXhRlZ_zz_cOM-OX8K45so2OVNbGkqr3bOLiOhMUiEz_g9liB0/s1600/Disable.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDGEv2ez9DXT_EsHoAONb1oiawpBMMwtcPj3DdirXCuvLUlgXLLpQYsrgs6R4hV-ccCv6e6g9UeamswhOWUocssknKmZXhRlZ_zz_cOM-OX8K45so2OVNbGkqr3bOLiOhMUiEz_g9liB0/s640/Disable.png" /></a>
</div>
<li>Then right click again and select Enable.</li>
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZNa1MDBC5vINgEtqdH4mq5zQasTyru4ieIEiSg7em70B-YaO3QBXCRj4TGU_R6g50wkoiu7GhG4pl0JbKDzoQWYd8JO3kzwWn2nYXnRnpwqBtaEQRs2XivP5kfv7gm7-eI-ndAtMq0lg/s1600/Enable.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZNa1MDBC5vINgEtqdH4mq5zQasTyru4ieIEiSg7em70B-YaO3QBXCRj4TGU_R6g50wkoiu7GhG4pl0JbKDzoQWYd8JO3kzwWn2nYXnRnpwqBtaEQRs2XivP5kfv7gm7-eI-ndAtMq0lg/s640/Enable.png" /></a>
</div>
<li>Since you have made changes to the current perspective by adding a view, you would be greeted with this Dialog.</li>
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6OGME6KqyqzrAlsXpoNQmCBnv9DCHpwvqJ_BqHliRCCPJAxe9VWm4QI8zbmqp5mfjPHs7Pf5wsz3bjgxqXy9AP8F3flnxWdtGVatj_1rVgFNc2P8rMEo9W5g-03qY8yf0mNVUfUqt3QY/s1600/PerspectiveChanges.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6OGME6KqyqzrAlsXpoNQmCBnv9DCHpwvqJ_BqHliRCCPJAxe9VWm4QI8zbmqp5mfjPHs7Pf5wsz3bjgxqXy9AP8F3flnxWdtGVatj_1rVgFNc2P8rMEo9W5g-03qY8yf0mNVUfUqt3QY/s640/PerspectiveChanges.png" /></a>
</div>
<li>Say Yes. There you go. Now all the changes in the plugin.xml would reflect in the UI</li>
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMt_BD5zPmut2px_Vfmd3nYzzttSYg5aqQBA6L78dCwf1YC-Lp1IIH3PJD18aXuTZlUJoyRYsm4-zEtJDcFLnr2M8JJedhXJj7ALS7gYJiUPzQl7sz0QfQ2OMJMLOsY59TTwrj3_3BRzk/s1600/UI_Changes.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMt_BD5zPmut2px_Vfmd3nYzzttSYg5aqQBA6L78dCwf1YC-Lp1IIH3PJD18aXuTZlUJoyRYsm4-zEtJDcFLnr2M8JJedhXJj7ALS7gYJiUPzQl7sz0QfQ2OMJMLOsY59TTwrj3_3BRzk/s640/UI_Changes.png" /></a>
</div>
</ul><br />
<br />
<br />
While this may not be applicable for all the changes you make in plugin.xml, this should cover up for most the changes.Prakash G.R.http://www.blogger.com/profile/13046268367318873066noreply@blogger.com4tag:blogger.com,1999:blog-1557780184357927241.post-61269100747106283782009-11-10T00:31:00.007+05:302009-12-30T19:26:30.410+05:30e4: First e4 RCP ApplicationThe next big thing in Eclipse is Eclipse 4.0 dubbed as e4. It will be released in 2010. That doesn't mean that the 3.x stream will be deprecated or discontinued. The 3.x releases will go on for "few" years till everyone boards the 4.0. But clearly the future of Eclipse is e4 and its already <a href="http://download.eclipse.org/e4/downloads/">here</a>. I'll be writing a series of blog posts on e4 and this will be the first. You can follow this blog in <a href="http://feeds.feedburner.com/cypal">RSS</a>, or <a href="http://bit.ly/2mfGXa">email</a> or even in <a href="http://twitter.com/Eclipse_Tips">twitter</a>. I'm still learning about e4, so feel free to correct me if you find any mistakes :-)<br />
<br />
First set up your e4 Environment:<br />
<br />
1) Download <a href="http://download.eclipse.org/e4/downloads/drops/S-1.0M1-200910131430/index.html">e4 1.0 M1</a><br />
2) Click e4->Generate e4 Example Project<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgphNzEJCarIbx3mFU2rGWU4EOQ4wvoOy_8keCWprSd0eXTMPmDNm6AqPGOoE6eqtxgTopkfAbx3aYgy9f_TTWM5mSbgF_MbH3vYvQoxY8gPBdEvVsEcbMAKc4cV61NqeNV1g3ZAZaU1WQ/s1600-h/e4_generate_samples.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgphNzEJCarIbx3mFU2rGWU4EOQ4wvoOy_8keCWprSd0eXTMPmDNm6AqPGOoE6eqtxgTopkfAbx3aYgy9f_TTWM5mSbgF_MbH3vYvQoxY8gPBdEvVsEcbMAKc4cV61NqeNV1g3ZAZaU1WQ/s400/e4_generate_samples.png" /></a><br />
</div><br />
3) Right click e4-examples.psf and click 'Import Project Set'. This should import the contacts and the photo projects from the CVS to your workspace<br />
4) Open the contacts.product file and click the "Launch an Eclipse Application" link in the Overview page<br />
5) Thats it. You should be running the Contacts demo.<br />
<br />
You can play around with the css theme or code and check out the effects. When you are done, lets start an app from the scratch. The first app will have nothing more than a view (something like the 'RCP Application with a View', created by PDE Wizard). Note: If you find it hard to work with e4, you can grab <a href="http://download.eclipse.org/eclipse/downloads/">a latest 3.6 build</a> and set the e4 as the target platform and proceed with the following steps)<br />
<br />
<i><b>Step 1:</b></i><br />
Use the New Plug-in wizard and create a new plugin. (No RCP - just plain old plugin)<br />
<br />
<b><i>Step 2:</i></b><br />
You don't need an Activator. In the Overview tab, remove the Activator class and also delete the Activator.java file from the sources.<br />
<br />
<b><i>Step 3:</i></b><br />
The default dependencies of this would have o.e.core.runtime and o.e.ui. In e4, we still need the core.runtime in e4, but not the o.e.ui. Remove it. Now add the following dependencies:<br />
<ul><li>org.eclipse.swt,</li>
<li>org.eclipse.jface,</li>
<li>org.eclipse.e4.ui.workbench</li>
<li>org.eclipse.e4.ui.workbench.swt</li>
</ul><b><i>Step 4:</i></b><br />
Lets create a view. Instead of o.e.ui.views, now we have to use org.eclipse.e4.workbench.parts extension (which should now serve both the editors and views). The extension point would look like<br />
<br />
<pre class="brush: xml;"><extension point="org.eclipse.e4.workbench.parts">
<part class="com.eclipse_tips.e4.firstapp.MyFirstView" />
</extension>
</pre><br />
The implementation class would be:<br />
<br />
<pre class="brush: java; collapse: true">public class MyFirstView {
public MyFirstView(Composite parent){
// this shouldn't be there ideally, investigating
if(parent.getLayout() == null)
parent.setLayout(new FillLayout());
Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new FillLayout());
Button button = new Button(composite, SWT.PUSH);
button.setText("Hello World");
button.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
MessageDialog.openInformation(new Shell(), "e4", "Hello e4 World!");
}
});
}
}</pre><br />
Yes, what you are seeing it correct. It doesn't implement the IWorkbenchView or extend ViewPart. Further more, it appears that I've done <a href="http://blog.eclipse-tips.com/2009/01/top-10-mistakes-in-eclipse-plug-in.html">one of the top 10 mistakes</a> by not having a default constructor. Don't worry, e4 is smart. When it instantiates an object like this thru reflection, it identifies the parameters for the constructor and will pass them from the context. If more than one constructor is present, it can even identify the right one to use (more on this later)<br />
<br />
<b><i>Step 5:</i></b><br />
Now, we have the view, lets create an RCP product that will use this view. Fire up the New Wizard and create a Product Configuration file with the basic settings. In the Product Configuration editor, give it some name and click the New for the Product. Specify some id and select 'org.eclipse.e4.ui.workbench.swt.application' for Application.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgq5IqkoJTvatrXPDRdTInQzunaJUnAVDvyuprnOrznM-9PyoB9EXe9oNgMZwnZVughZwU9jq9Wito2jrBwRe6DWZEjI6fu7JZ9mBQZEKdyCA73CrnFem2MCWQ6wTUJU5XLp18srKyw1XY/s1600-h/e4_rcp_product_configuration.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgq5IqkoJTvatrXPDRdTInQzunaJUnAVDvyuprnOrznM-9PyoB9EXe9oNgMZwnZVughZwU9jq9Wito2jrBwRe6DWZEjI6fu7JZ9mBQZEKdyCA73CrnFem2MCWQ6wTUJU5XLp18srKyw1XY/s640/e4_rcp_product_configuration.png" /></a><br />
</div><br />
<br />
<b><i>Step 6:</i></b><br />
Go back to your plugin.xml. You should see the newly created application there. Now lets create the missing link between the product and the view - the UI model. In a typical 3.x RCP, you would have specified an application that has a run method, an initial perspective id, the layout for that perspective, the views, menus, actions thru the ActionFactory constants etc. This whole setup would require a little bit of both java coding and plugin.xml configuration. In e4, you can specify the entire UI in a model. Thats the applicationXMI. It can get as complex as your UI can be, but the simplest one looks like this:<br />
<br />
<pre class="brush: xml;"><?xml version="1.0" encoding="ASCII"?>
<application:MApplication xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:application="http://www.eclipse.org/ui/2008/Application">
<windows name="Main Window" width="200" height="100">
<children xsi:type="application:MContributedPart"
id="MyView"
iconURI="platform:/plugin/com.eclipse-tips.e4.firstApp/icons/sample.gif"
URI="platform:/plugin/com.eclipse-tips.e4.firstApp/com.eclipse_tips.e4.firstapp.MyFirstView"/>
</windows>
</application:MApplication>
</pre><br />
There is nothing much to explain. It has got nothing more than a window and a view in it. (no menus,no tool bars, no status lines and even no stacks to hold the view) Specify this file in the parameter of the product extension:<br />
<br />
<pre class="brush: xml;"><extension
id="rcpProduct"
point="org.eclipse.core.runtime.products">
<product
application="org.eclipse.e4.ui.workbench.swt.application"
name="My First e4 RCP">
<property
name="applicationXMI"
value="com.eclipse-tips.e4.firstApp/App.xmi">
</property>
</product>
</extension>
</pre><br />
<br />
<b><i>Step 7:</i></b><br />
You are all set to go. Switch to the Dependencies tab of the Product Editor and add your plugin. Click 'Add Required plugins' and launch. The launch will fail, because we have not included few more plugins that are required, but not specified in the dependencies (from databinding beans to renderers will be missing) The simplest way to get thru the error, is to edit the launch configuration and launch with 'all workspace and enabled target plugins'.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzmYI9XP6ZnR8NhiOlnzvhMHEddnOjPnQtB9gEnb2_hMsZ-Jub_44-vylBc1l-dFN3Qj4aS3dsbquY3wRLGHjufm71Yya1mPU8AcfwPbj7MS4hXtHMDXWPAETHfCx8NytR5XfMAp_Z6TM/s1600-h/E4_RCP_launch_config.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzmYI9XP6ZnR8NhiOlnzvhMHEddnOjPnQtB9gEnb2_hMsZ-Jub_44-vylBc1l-dFN3Qj4aS3dsbquY3wRLGHjufm71Yya1mPU8AcfwPbj7MS4hXtHMDXWPAETHfCx8NytR5XfMAp_Z6TM/s640/E4_RCP_launch_config.png" /></a><br />
</div><br />
<br />
Now launch again, voila - there comes your first e4 RCP!<br />
<br />
So what has happened till now? With the product & launch configuration, we are basically running the org.eclipse.e4.ui.workbench.swt.application. The application looks for the model of the UI in the applicationXMI parameter. It creates the Workbench, and asks it to render the UI from that model. Recursively, an appropriate renderer for every element in the XMI file is found, and its asked to create the UI. Finally you get the app:<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_Ibz-QXZJAkOFBZzJlef5JXfsDAJwyQQDaau_gQ4W92cmW5duMRnrjrFwLO21C9JNVDDg_X9G8NMmcwZpvNlRBrXCpTQ6izeLQEhPSbQsa_EErGE4Am8e1Sm4DWNrw9iG8VlbjEPT90Q/s320/e4_first_rcp.png" /></div>Prakash G.R.http://www.blogger.com/profile/13046268367318873066noreply@blogger.com3tag:blogger.com,1999:blog-1557780184357927241.post-17236053059345964892009-11-03T15:20:00.000+05:302009-11-03T15:20:16.832+05:30Eclipse Tips on Twitter !Get (a different set of) Eclipse Tips in twitter: <a href="http://twitter.com/Eclipse_Tips">@Eclipse_Tips</a>. If you are still in the RSS reader era, get the feed <a href="http://twitter.com/statuses/user_timeline/85313393.rss">here</a>.Prakash G.R.http://www.blogger.com/profile/13046268367318873066noreply@blogger.com0tag:blogger.com,1999:blog-1557780184357927241.post-63151238585447390692009-10-28T00:29:00.001+05:302009-10-28T00:41:31.827+05:30Associating a Command with a JobEarlier we saw how to <a href="http://blog.eclipse-tips.com/2008/08/adding-iaction-to-job.html">associate an Action with a Job</a>. Now you can associate a Command. Its very similar - use the constant to set a property on the job:<br />
<br />
<pre class="brush: java;">ICommandService service = (ICommandService) serviceLocator.getService(ICommandService.class);
Command command = service.getCommand(commandId);
ParameterizedCommand parameterizedCommand = new ParameterizedCommand(command, null);
job.setProperty(IProgressConstants.COMMAND_PROPERTY, parameterizedCommand);
</pre><br />
You have to specify either the ACTION_PROPERTY or COMMAND_PROPERTY, but not both. If you specify both, neither of them will get executed.<br />
<br />
Note: You need a 3.6 M3 or a latest I-Build for this to work.Prakash G.R.http://www.blogger.com/profile/13046268367318873066noreply@blogger.com2tag:blogger.com,1999:blog-1557780184357927241.post-41849949616039575652009-09-23T11:24:00.000+05:302009-09-23T11:24:41.057+05:30Eclipse Demo Camp, BangaloreIts back :-)<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIoyLHqFmW1sbkZZsLqJs6iu7Y8SSNgUZijy5586HVbEOghAz1JA6AWmUj1RDfqZ6vZ8I0aWHBMgh-LPr9dbCku26JimzN60K1PdSNh3p7coyrT6RQEsS5MlXe5yigGbjJ_WJowsPpDOE/s1600-h/Eclipse-camp.gif" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIoyLHqFmW1sbkZZsLqJs6iu7Y8SSNgUZijy5586HVbEOghAz1JA6AWmUj1RDfqZ6vZ8I0aWHBMgh-LPr9dbCku26JimzN60K1PdSNh3p7coyrT6RQEsS5MlXe5yigGbjJ_WJowsPpDOE/s320/Eclipse-camp.gif" /></a><br />
</div>We are planning to organize a Demo Camp sometime in November. Date, time and venue to be decided. Since IBM's Eclipse team has grown since last Demo Camp, this time, you get a very good opportunity to learn right from the source, on whats coming up. From <a href="http://wiki.eclipse.org/Equinox/p2">p2</a> to <a href="http://wiki.eclipse.org/PDE/Incubator/b3/Proposal">b3</a> and <a href="http://wiki.eclipse.org/E4">e4</a> (Am I the only one who thinks that things can be named better?) we can give a good number of demos/presentations. But we don't want to make it as the Big Blue show, so we need few contributions from the community as well. We are glad that <a href="http://eclipse-info.blogspot.com/">Madhu</a> and <a href="http://anilgudise.blogspot.com/">Anil</a> have already signed up with some topics. I would encourage you to add a demo on what you are working on. Even if not sign up as an attendee, its a nice chance to meet other Eclipse plug-in developers and see what they are building with Eclipse.<br />
<a href="http://draft.blogger.com/goog_1253637096834"><br />
</a><br />
<a href="http://wiki.eclipse.org/Eclipse_DemoCamps_November_2009/Bangalore">http://wiki.eclipse.org/Eclipse_DemoCamps_November_2009/Bangalore</a>Prakash G.R.http://www.blogger.com/profile/13046268367318873066noreply@blogger.com0Bengaluru, Karnataka, India12.971606 77.59437612.6370475 77.127456999999993 13.3061645 78.061295tag:blogger.com,1999:blog-1557780184357927241.post-49322186688462853472009-09-22T12:51:00.007+05:302009-09-22T14:47:51.805+05:30Catching up with Milestones and I-BuildsHelios M2 is released. Now the biggest problem for the early adopters would be how to catch up with these milestones. Every time, you have to download the milestone build, and then update it with all your required plugins (svn, mylyn, etc). If you are on the I builds, then you have to do this on every week. If you feel that its a painful process, here is a tip. <br />
<br />
The p2 repos for Eclipse are not only for the stable releases, <a href="http://wiki.eclipse.org/Eclipse_Project_Update_Sites">but also for the Milestones, I Builds and Nightly builds</a>. <br />
<br />
<a href="http://download.eclipse.org/eclipse/updates/3.6milestones">Milestones: http://download.eclipse.org/eclipse/updates/3.6milestones</a><br />
<a href="http://download.eclipse.org/eclipse/updates/3.6-I-builds">I-Builds: http://download.eclipse.org/eclipse/updates/3.6-I-builds</a><br />
<a href="http://download.eclipse.org/eclipse/updates/3.6-N-builds">Nightly Builds: http://download.eclipse.org/eclipse/updates/3.6-N-builds</a><br />
<br />
The <a href="http://www.eclipse.org/eclipse/platform-releng/buildSchedule.html">build schedule is available here</a>.<br />
<br />
Go to your Preferences and add the required repo in your Available Software Site preferences (and disable all others, it will be slow to update).<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><img border="0" height="351" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiA-8NKrQE0cLgwsVsK6OiQNiCsaZJTiosyUcAfBoZrozFuuxxA19C1GWHqOXcsv1erPwiz9fqkVRloFxYq54e-nfFr_Ty-NfBWkUkbcihl-yowFvFoNh6hP-mHxbMaYospfgSg6dCv4bA/s800/Available_Software_Sites.png" width="662" /><br />
</div><br />
<br />
Also enable the automatic updates. You are done. Whenever there is a new Milestone (or an I-Build), then your Eclipse gets updated automatically to it and you don't have to worry about installing other required plug-ins.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><img border="0" height="406" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgcd5_QIZXZWBMqojm7GjreqE79qycUsucNcHtYUHL-QAm9BLeRMZ254LJpsZrbKZZ3VB_pOeDAs-uHS6ddL3K3-_WSQ2PNmxr3OlJYhPBGsgxQ_wBwDlHm60uvKF1K7wlMBgqPSm-8qPs/s800/Automatic_updates.png" width="492" /><br />
</div><br />
Enjoy with the latest and greatest without any pains :-)Prakash G.R.http://www.blogger.com/profile/13046268367318873066noreply@blogger.com2tag:blogger.com,1999:blog-1557780184357927241.post-76101435363040991062009-09-15T22:39:00.002+05:302009-09-15T22:40:58.026+05:30Back to the basics: Display, Shell, Window ...Every Eclipse plugin developer has to deal with Shell and Window, but sometimes doesn't understand the difference between these two. In this tip, I'm trying to explain the basic things: Display, Shell, Window, Dialog, Workbench, WorkbenchPart, WorkbenchSite and WorkbenchPage. Yeah, I know, its probably the boring post you can read in this blog, if you are little bit experienced in these areas.<br />
<h4><a href="http://help.eclipse.org/stable/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/widgets/Display.html">Display</a>:</h4>This class is the link between SWT and the underlying OS. It manages the interaction between widgets and the OS. The primary task for this class is to maintain the event loop (<a href="http://help.eclipse.org/stable/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/widgets/Display.html#readAndDispatch%28%29">readAndDispatch()</a>). Unless you are writing a plain SWT app, you won't be using that. The most common methods you would be using in this class are <a href="http://help.eclipse.org/stable/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/widgets/Display.html#asyncExec%28java.lang.Runnable%29">asyncExec()</a>, <a href="http://help.eclipse.org/stable/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/widgets/Display.html#syncExec%28java.lang.Runnable%29">syncExec()</a> and <a href="http://help.eclipse.org/stable/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/widgets/Display.html#timerExec%28int,%20java.lang.Runnable%29">timerExec()</a>, which allows you to run a piece of code in the UI thread. (aka user interface thread or display thread)<br />
<br />
<h4><a href="http://help.eclipse.org/stable/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/widgets/Shell.html">Shell</a>:</h4>Shell is the "window" that you see in your desktop. The one that has a title, maximize, minimize, restore and close buttons. A shell can be either a top-level shell (no parent shell) or can be a secondary shell (will have a parent shell). The style that is passed in the constructor defines which of the above mentioned buttons are displayed and also whether the Shell is modal or not. If you are on a pure SWT app, then you should be create a Shell; create controls in it; open it; run the event loop; and dispose it. Speaking in code:<br />
<br />
<pre class="brush: java">Shell shell = new Shell(display);
// set layout and create widgets
shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
</pre><br />
<br />
<h4><a href="http://help.eclipse.org/stable/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/jface/window/Window.html">Window</a>:</h4><br />
If you are developing plugins/JFace applications, its better to use Window rather than Shells directly, because it manages the above things for you. It is not, but think it of as a wrapper for Shell. When you use a Window, a Shell is not created until the open() method is called. Since the Shell is not created till the Window is open and windows can be reopened (yes, you can reopen it), configuration of the Shell should be done in the configureShell() method. Remember, this is an abstract class and so you cannot directly use it. You must either use Dialog or ApplicationWindow or your own concrete class.<br />
<br />
<h4><a href="http://help.eclipse.org/stable/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/jface/dialogs/Dialog.html">Dialog</a>:</h4><br />
When you need a specialized communication with the user, you should be using Dialogs. In all other cases, you will be using ApplicationWindow. Dialog are more of helper windows that are attached to another main window. PreferenceDialog, PropertyDialog, ErrorDialog, InputDialog & WizardDialog are some frequently used dialogs.<br />
<br />
<h4><a href="http://help.eclipse.org/stable/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/jface/window/ApplicationWindow.html">ApplicationWindow</a>:</h4><br />
Window + menu support + toolbar support + coolbar support + status line support = ApplicationWindow :-) <br />
<br />
<h4><a href="http://help.eclipse.org/stable/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/ui/IWorkbenchWindow.html">IWorkbenchWindow</a>:</h4><br />
WorkbenchWindow is Eclipse specific ApplicationWindow, which adds few services and a set of IWorkbenchPages to the ApplicationWindow. Although the javadoc says "Each workbench window has a collection of 0 or more pages", in reality it has only one page. I believe this is due to backward compatibility with Eclipse 1.0. <br />
<br />
<h4><a href="http://help.eclipse.org/stable/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/ui/IWorkbenchPage.html">IWorkbenchPage</a>:</h4><br />
The area that lies between the toolbar and the status line of the WorkbenchWindow is known as WorkbenchPage. Simply put, this is the body of the WorkbenchWindow, where all the editors and views are showed. IWorkbenchPage contains IWorkbenchParts, which are the the visual representation of the Views and Editors. Both IViewPart and IEditorPart derive from <a href="http://help.eclipse.org/stable/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/ui/IWorkbenchPart.html">IWorkbenchPart</a><br />
<br />
<h4><a href="http://help.eclipse.org/stable/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/ui/IWorkbenchSite.html">IWorkbenchSite</a>:</h4> IWorkbenchPart resides inside the IWorkbenchPage. So it has no direct access to the workbench itself. So when it needs to interact with the workbench, then it needs the IWorkbenchSite. For example to get the shell inside a view, you call getSite().getShell().Prakash G.R.http://www.blogger.com/profile/13046268367318873066noreply@blogger.com5tag:blogger.com,1999:blog-1557780184357927241.post-29502864924381253932009-09-10T12:19:00.001+05:302009-09-10T14:18:18.949+05:30Excluding a view from Properties ViewIn a previous tip, we saw how to make a <a href="http://blog.eclipse-tips.com/2009/05/creating-custom-property-view.html">Properties View to respond only to a particular View</a> or Editor. In this tip, we are going to see how to exclude a particular View or Editor from the Properties View. This will be very helpful in RCP apps, where they don't want the generic view like Outline view or an editor that contributes to the Properties View. Last time we extended the Properties View to create our own view and added some code. But this time its simple. You just have to use the org.eclipse.ui.propertiesView extension point.<br />
<br />
<pre class="brush: xml;"><extension
point="org.eclipse.ui.propertiesView">
<excludeSources
id="org.eclipse.ui.views.ContentOutline">
</excludeSources>
<excludeSources
id="com.eclipse_tips.editors.MyOwnEditor">
</excludeSources>
</extension>
</pre><br />
Yes, its that simple :-) Don't try with Galileo, you would need Helios (3.6) M2 to get this working.Prakash G.R.http://www.blogger.com/profile/13046268367318873066noreply@blogger.com0tag:blogger.com,1999:blog-1557780184357927241.post-84129587587490860552009-08-06T23:31:00.001+05:302009-08-06T23:36:43.460+05:30Remember the StateAs a rule of thumb, your application should try to remember the state across sessions. So when a user hits the close button and then opens it after few mins/days, it should present exactly in the same way where he left. In this tip, I'm going to explain few things of how this could be achieved.<br />
<br />
The first and foremost thing is the number of windows opened and current perspective and its state in each window. If you are writing a plugin for the IDE, you need not worry about this. Eclipse does that for you. If you are an RCP app, you have to do it yourself. You have to do it in the WorkbenchAdvisor.initialize() method:<br />
<br />
<pre class="brush: java;">public class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor {
@Override
public void initialize(IWorkbenchConfigurer configurer) {
super.initialize(configurer);
configurer.setSaveAndRestore(true);
}
// other methods ...
}
</pre><br />
Now this will take care of lot of things - the number of windows that are opened; location & size of those windows; perspective of each window; view & editors in each perspective; their locations,... All by setting that one boolean variable!<br />
<br />
Now that our views and editors are restored by Eclipse, we need to ensure the state of them. Most of the views will be tree/table based. In these cases, the current selection is an important one to restore. <br />
<br />
To store these items and anyother stuff you want to, Eclipse provides IMemento. An instance of this IMemento is passed to the view when its initialized and when workbench is closed. The information can be stored hierarchically with string keys and it will be persisted as an XML. If you are wondering why can't it be as simple as passing a Serializable Java object and the workbench persisting it, the answer is simple. The same class may not be there when Eclipse starts next time or even if the same class is available, it might have changed. IMemento avoids this problem by persisting the stae as an XML string.<br />
<br />
So how do we use it? In the view, you have to override the init() and saveState() methods:<br />
<br />
<pre class="brush: java">@Override
public void init(IViewSite site, IMemento memento) throws PartInitException {
this.memento = memento;
super.init(site, memento);
}
public void createPartControl(Composite parent) {
// create the viewer
restoreSelection();
}
private void restoreSelection() {
if (memento != null) {
IMemento storedSelection = memento.getChild("StoredSelection");
if (storedSelection != null) {
// create a structured selection from it
viewer.setSelection(selection);
}
}
}
@Override
public void saveState(IMemento memento) {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
if (!selection.isEmpty()) {
IMemento storedSelection = memento.createChild("StoredSelection");
// store the selection under storedSelection
}
}
</pre><br />
Not just the selection, we can store any other information (which of the tree nodes are expanded, sorter & filter settings etc) which will be useful to restore the state.<br />
<br />
Great. Now moving on from the views, the next item would be dialogs. Similar to the workbench windows, you can store the size, location and other elements of a dialog as well. The functionality for size and location is available by default, but you need to enable it by overriding the Dialog.getDialogBoundsSettings() method. The Dialog class stores & retrieves the size and location from IDialogSettings returned from that method. The original implementation returns null, so nothing is saved. We need to create an instanceof IDialogSettings and return it. Your plugin's Activator simplifies that. When required, it creates a dialog_settings.xml under your plugin's data area and store the dialog settings of all the dialogs. You have to create a separate section for each dialog.<br />
<br />
<pre class="brush: java">private static final String MY_DIALOG_SETTINGS = "MY_DIALOG_SETTINGS";
@Override
protected IDialogSettings getDialogBoundsSettings() {
IDialogSettings settings = Activator.getDefault().getDialogSettings();
IDialogSettings section = settings.getSection(MY_DIALOG_SETTINGS);
if (section == null) {
section = settings.addNewSection(MY_DIALOG_SETTINGS);
}
return section;
}</pre><br />
In case you want to store only the location or size, you can specify it by overriding the getDialogBoundsStrategy() method.<br />
<br />
Much like the IMemento, the IDialogSettings basically organizes the key-value strings in an hierarchical way. So along with the size & location, you can store any other information in this IDialogSettings. Its a good practice to store the values of the widgets (which radion button is selecte, checked state of a check box, etc) in the dialog, so its faster for an user who frequently repeats an operation.<br />
<br />
Talking about the widgets, the trickier one is Combo. When the list of options are predefined and the user can't enter a new value, then its easy. But in places where the user can enter the values, (like File/Directory selection, search boxes), remembering them is not straight forward.<br />
<br />
We shouldn't be storing every single value the user enters, but only the recently used ones. Probably with a limit of 5 or 10 items only. This can be done with the help of LinkedHashSet. It guarantees the order of the element, so whenever the user enters a new values, put the current value first in the set then add the rest of the elements (even if the first element is repeated, it won't change the position). Then take the first N elements and store it.<br />
<br />
<pre class="brush: java;">private static final String COMBO_STATE="COMBO_STATE";
private static final int HISTORY_SIZE = 5;
private String []comboState;
private void restoreComboState(IDialogSettings settings) {
comboState = settings.getArray(COMBO_STATE);
if(comboState ==null)
comboState = new String[0];
for (String value : comboState) {
myCombo.add(value);
}
}
private void saveComboState(IDialogSettings settings) {
// use LinkedHashSet to have the recently entered ones
LinkedHashSet<String> newState = new LinkedHashSet<String>();
newState.add(myCombo.getText());
newState.addAll(Arrays.asList(comboState));
// now convert it to the array of required size
int size = Math.min(HISTORY_SIZE, newState.size());
String[] newStateArray = new String[size];
newState.toArray(newStateArray);
// store
settings.put(COMBO_STATE, newStateArray);
}
</pre><br />
One last piece. Look at this dialog:<br />
<div class="separator" style="clear: both; text-align: center;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUdV_rs_cqzw8iAuM4EzWUqT8HgabnDI3asn0_poghZMcKbGQIoi0YOK3aC473oXO21VIbQVojY7jYL-rwjmJZ5W-cWJD2PbyrCe-HCRtw9Y_rE9P5i8ZyBkWSxHh4Sw7ORbbTAJOy7aI/s800/Open_Perspective_Question.png" /></div><br />
<br />
Sometimes only for the first time you want to ask the question to the user. Thereafter if the user prefers, you can use the same answer. To simplify this, you can use the MessageDialogWithToggle. You need to pass the preference store and the key for the preference value. When the user selects the check box, the value will be stored. From the next time onwards, you can check the value from the preference and use it.<br />
<br />
<pre class="brush: java">MessageDialogWithToggle.openYesNoQuestion(shell, "Remember me", "Is this tip useful?",
"Don't bug me with this question again", true,
Activator.getDefault().getPreferenceStore(), "BUG_USER_KEY");
</pre><br />
There you go:<br />
<div class="separator" style="clear: both; text-align: center;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYjDWX9vO-EGiiqAZzv-E65B49P5wCAGpmabesT24p0a_ZUlOCy48V8o7llVIOLqjDZfyD7mYbkHTMRDYvjj8N_RtROO_I_7sKJs_DmoD9guj5Od120uyY2bh_spIVaFpklHBWZvI2A7o/s800/Tip_Useful_Question.png" /></div><br />
:-)Prakash G.R.http://www.blogger.com/profile/13046268367318873066noreply@blogger.com5tag:blogger.com,1999:blog-1557780184357927241.post-43031285137574941692009-07-18T22:37:00.001+05:302009-07-18T22:38:39.985+05:30Eclipse Summit India - Day 2The second day, I was a little late and missed the Oracle's Plenary session. I was in time for IBM's session. Being an IBM-er nothing new for me there to see RAD or websphere. It was good.<br />
<br />
The first session I took was by Ilya Shinkarenko. More than half of the hall had repeated audience. It was nice, just as yesterday. This time, I was able to attend till the end. After a heavy lunch, I felt very sleepy in the afternoon session. The presenter was partly responsible for that ;-) Then I moved to Anshu Jain's session called 'Eclipse as framework of frameworks', which was simply awesome. To quote Ankur, "a lot of meat added with a perfect aroma, the presentation was a feast". Of the ones I've attended, that was the best. Next was networking in the corridor. After many questions on Eclipse startup to command invocation, that marked the end of the day for me.<br />
<br />
Some afterthoughts:<br />
<br />
(*) The good thing about this conference is the focus. This is not an all-in-conference, which targets all the CEOs, CTOs, Managers, decision makers, IT guys and your office boys. This has complete focus on Eclipse plug-in developers and almost all of these sessions are well aligned towards this.<br />
<br />
(*) Parallel tracks are good, but they could have been specific tracks like OSGi, EMF etc. Also there were instances like both the OSGi sessions were held in parallel, so if someone is interested in OSGi, they have to choose between these two. Probably the next time, it gets better.<br />
<br />
(*) The venue was also much better, center of the city and well accessible. No need to talk about the food, it was great :-)<br />
<br />
I believe that the photos, videos and the slides will be uploaded online soon. I'll post a link once its done.Prakash G.R.http://www.blogger.com/profile/13046268367318873066noreply@blogger.com0tag:blogger.com,1999:blog-1557780184357927241.post-76565745434057457552009-07-17T14:44:00.002+05:302009-07-17T14:54:56.486+05:30Eclipse Summit India - Day 1Before I start, a question: How do you know you are in troubled economic times?<br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSeMcNnqFZnWVuuRxT3e4ktpNIQtoRaCm5T4Vtb1-bSdxn45qlON0Lvwn6YVbhoD2l7apP1jcHu-NvkGghR0VF5dyNY9zGBCn5m9bH8vSbJXWkK2r61_bWsjcCiDzK0JT6zkpsHgKeTBE/s1600/EclipseSummitIndiaLogo.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSeMcNnqFZnWVuuRxT3e4ktpNIQtoRaCm5T4Vtb1-bSdxn45qlON0Lvwn6YVbhoD2l7apP1jcHu-NvkGghR0VF5dyNY9zGBCn5m9bH8vSbJXWkK2r61_bWsjcCiDzK0JT6zkpsHgKeTBE/s200/EclipseSummitIndiaLogo.png" /></a>Today is the first day of Eclipse Summit India. Luckily, even after screwing up by taking a wrong road and going in a different direction, I did make it well before the keynote by Microsoft. Yes, Microsoft. They are one of the Platinum sponsors. Just like me, everyone was wondering what are they doing there, the answer told was "interoperability". I'm not going to summarize any of the topics presented, so I'll leave you to guess what how he positioned M$ in that.One thing that was interesting is they have PHP as a first class citizen in their IIS. That was surprising for me. Additionally they have some thing called a 'One Installer' which will download all that you want for a web site and install it on your server - not just PHP module for IIS or the latest .Net runtime, but Wordpress and Drupal as well! Wow!<br />
<br />
After that it was Ilya Shinkarenko's workshop. It was good. Started a little slow and the pace moved up during the session. I've to cut it in the middle and rush to the other room. Adobe guys were just finishing their presentation. Both of them had a black Mac book and even before I said another 'wow', I noticed it was a windows machine with an Apple sticker. Good idea, I should say. The presentation was mine, and I hope it went well. I did get some good feedback during the lunch. Its definitely troubled ecomony now, but the buffet was good :-)<br />
<br />
Post lunch, yeah, I'm in the EMF workshop and blogging this (yeah, we got free wi-fi). Got to run for Ankur's Presentation. Rest of the sessions in the evening/tomorrow.<br />
<br />
Before I sign out, the answer: In the free goodies for attendees, you get a pencil instead of a pen ;-)Prakash G.R.http://www.blogger.com/profile/13046268367318873066noreply@blogger.com4tag:blogger.com,1999:blog-1557780184357927241.post-79898498806175450972009-06-26T13:10:00.000+05:302009-06-26T13:10:41.178+05:30Keyboard accessibility thru Command FrameworkKeyboard shortcuts is usually much speedier than reaching out your mouse, moving it, pointing it to something and clicking. But there are some things which cannot be done that easily by keyboard shortcuts. For me, one of them is finding out a closed project and open it. Unfortunately, I've quite a large set of projects in my workspace and try to keep most them closed, when not used. In addition to that in the Package Explorer, I've the 'Closed Projects' filter on. So if I need to open a project, I've use the pull down menu, uncheck 'Closed Projects' navigate thru the working sets to find the right project and double click it. To enable keyboard access to this regular task, I decided to make use of <a href="http://wiki.eclipse.org/Platform_Command_Framework">Commands Framework</a>.<br />
<br />
The solution is to add a <a href="http://blog.eclipse-tips.com/2008/12/commands-part-3-parameters-for-commands.html">parameterized command</a>, and in the values, I compute the projects which are closed. So when I press the awesome shortcut (Ctrl+3) it would display me the list of closed projects. With few keys, I can navigate to the project I want and open it. Lets see how to do it. First step is the command with the parameter:<br />
<br />
<pre class="brush: xml"><extension point="org.eclipse.ui.commands">
<command
defaultHandler="com.eclipse_tips.handlers.OpenProjectHandler"
id="com.eclipse-tips.openProject.command"
name="Open Project">
<commandParameter
id="com.eclipse-tips.openProject.projectNameParameter"
name="Name"
optional="false"
values="com.eclipse_tips.handlers.ProjectNameParameterValues">
</commandParameter>
</command>
</extension>
</pre><br />
And the handler:<br />
<br />
<pre class="brush: java;">public Object execute(ExecutionEvent event) throws ExecutionException {
String projectName = event.getParameter("com.eclipse-tips.openProject.projectNameParameter");
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IProject project = root.getProject(projectName);
try {
project.open(null);
} catch (CoreException e) {
throw new ExecutionException("Error occured while open project", e);
}
return null;
}
</pre><br />
For the parameter values, I look for closed projects and return them:<br />
<br />
<pre class="brush: java;">public Map<String, String> getParameterValues() {
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IProject[] projects = root.getProjects();
Map<String, String> paramValues = new HashMap<String, String>();
for (IProject project : projects) {
if (project.exists() && !project.isOpen()) {
paramValues.put(project.getName(), project.getName());
}
}
return paramValues;
}
</pre><br />
<br />
So finally, When I press Ctrl+3 and type OPN, I get the list:<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEieZPIYCTYX794mEMgA2YBOh8ApjT1bNKwGUzJFyIMN6eQxWvCEtdi4ivG7gDZNME-eOR84x4n3AcBz0_pGwCjomk41RoHQXhnv4ZH_-PHD_d9szY4ISQ4A-fZwVJr5UagSxTuUSCcAoRI/s1600-h/KeyboardCommands.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEieZPIYCTYX794mEMgA2YBOh8ApjT1bNKwGUzJFyIMN6eQxWvCEtdi4ivG7gDZNME-eOR84x4n3AcBz0_pGwCjomk41RoHQXhnv4ZH_-PHD_d9szY4ISQ4A-fZwVJr5UagSxTuUSCcAoRI/s400/KeyboardCommands.png" /></a> </div><div class="separator" style="clear: both; text-align: center;"></div><br />
This idea can be extended to provide keyboard accessibility to many functionalities. Say in an RCP mail application, you can add a command like 'Go To Mail' with parameter as the Subject/Sender:<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6aNAhc7v_ptPSpbfu2d4DMyPasKU3P9Xs_huPDoYPhskeyh5ZubyVqN4NVoQ9GCFE_MBZ4iFQa11IU__GonvL2PMTDfiPKqWcCXJQAHtQ-m0t2qv41UpeTROaDSvMj0Acp9zRAst4brw/s1600-h/KeyboardCommands1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6aNAhc7v_ptPSpbfu2d4DMyPasKU3P9Xs_huPDoYPhskeyh5ZubyVqN4NVoQ9GCFE_MBZ4iFQa11IU__GonvL2PMTDfiPKqWcCXJQAHtQ-m0t2qv41UpeTROaDSvMj0Acp9zRAst4brw/s400/KeyboardCommands1.png" /></a></div><br />
Hmmm, if only the 'Built On Eclipse' mail app that I *have* to use, knows the existence of threads other than the UI thread :-(Prakash G.R.http://www.blogger.com/profile/13046268367318873066noreply@blogger.com2