Archive for March, 2009

* Eclipse Plugin Q&A

Posted on March 25th, 2009 by Dave Johnson. Filed under Web, phonegap, programming.

If you are one of the unfortunate few that has decided to, for profit or insanity, write an Eclipse plugin here are a few of the questions that I had during my ordeal and the answer or closest thing to an answer that I can come up with.

Q: How should I get started with Eclipse plug-ins?

A: Read a book. I did not do this and really regret it now I think. There are few different ones available that I assume explain all the intricacies. The Google can only help so much. Having said that, the approach that I took was to look at the code of another Eclipse plug-in and borrow from that :) Some of the better links I put up on Delicious.

Q: How do I make my plugin show up in the new project list?

A: This one seems like it should be easy to find out how to do but it actually wasn’t that easy. So it is pretty easy to get started using one of the samples in Eclipse like the file editor sample that creates a “New file” wizard. While that wizard does not launch from the “New project” menu it can be augmented to be a project creation wizard pretty easily. The important bit is setting project=”true” on your wizard in the plugin.xml file for the Eclipse newWizards extension.

<extension point="org.eclipse.ui.newWizards">
    project="true" ... />

Q: Now that I have a new project wizard how do I know that a project was created using that wizard or is that type of project so that you can create debug or run configurations accordingly?

A: This is where project “Natures” come in. A project can have different natures associated with it to support different functionality in Eclipse. You need to create a class that implements the IProjectNature interface.

public class PhoneGapProjectNature implements IProjectNature

You can reference that project Nature from the plugin.xml through the org.eclipse.core.resources.natures extension point.

<extension id="com.phonegap.phonegapnature" name="PhoneGap Nature"
    <run class="com.phonegap.project.PhoneGapProjectNature"/>
  <builder id="com.phonegap.phonegapbuilder"></builder>

This enables one to connect certain builders to a nature - in the case of PhoneGap we don’t actually use a builder since it is just HTML and JavaScript but we do set and read the nature from the plug-in code.

To set the nature of the project when it is created in the new project wizard we can set the project nature(s) on the project description like this:

IWorkspace workspace = ResourcesPlugin.getWorkspace();
final IProjectDescription description =
description.setNatureIds(new String[] { PhoneGapPlugin.PHONEGAP_NATURE_ID });

In the case of PhoneGap, we use this project nature information in the properties of the Run and Debug configurations such that a developer can create configurations and choose the project that the configuration should launch when they click Run or Debug. In the configuration we iterate over the projects collection of the workspace and check if each project has the PhoneGap nature, if it does we add it to a combo box.

boolean bb = projects[i].hasNature(PhoneGapPlugin.PHONEGAP_NATURE_ID);
if (projects[i].hasNature(PhoneGapPlugin.PHONEGAP_NATURE_ID)) {

Q: How do I store preferences and configuration default values?

A: In your AddLaunch method of the LaunchAdder, which you call from the createProject method of your NewProjecWizard class like this:

  projectHandle.getName(), "");

you will need have some code like this:

ILaunchConfigurationWorkingCopy wc = DebugPlugin.getDefault()
.newInstance(null, DebugPlugin.getDefault()
wc.setAttribute("KEY", "value");
final ILaunchConfiguration config = wc.doSave();

Q: How do I access resources like files to populate a new project with?

A: Put any files that you will want to copy to a project into a namespace like com.phonegap.resources then you can access it like this:

String rootContent = StreamUtils.readContent(
this.getClass().getResourceAsStream("/com/phonegap/resources/root.html"), null

Where StreamUtils is just a wrapper for doing the stream reading.

Q: I am getting a “class not found” error when I debug what should I do?

A: Get Eclipse 3.4 if you don’t already have it.

Q: I want to support the debug / run menus but to do that I need org.eclipse.debug.ui/core references - where do I find those?

A: Add them to the dependcies list in the plugin.xml visual editor. First add core then the ui one will be available.

That’s about all I can muster for the moment but will try to put up some more tips later!

Tags: , , , , , .

* PhoneGap Project

Posted on March 24th, 2009 by Dave Johnson. Filed under phonegap, programming.

So I started putting together some wireframes for my first real PhoneGap project tonight. I have become sort of bored playing with BlackBerry and Android native development and figured it was about time to actually build something on top of the platform. The only problem I am having is that I can’t currently do offline apps on BlackBerry so am really looking forward to the next version of the RIM OS as I hear they may have fixed some of my gripes.

In the mean time I have been working on the PhoneGap simulator and Eclipse plugin as well that should be ready very soon - I actually have the simulator launching from my Eclipse PhoneGap project which is pretty cool.

Tags: , , .

* On Dell and Social Media

Posted on March 14th, 2009 by Dave Johnson. Filed under Uncategorized.

Yes Twitter can be good for your company. There are of course soon to be urban legends about companies like Dell that made over $1 million during the recent holiday season by using Twitter but what about the sales they lost because of Twitter? I would wager that it could easily be north of $1 million.

Just a quick search on Twitter reveals tweets like this one:

dell laptop locked up two or three times in the last half hour, only button that responded was the powerbutton. Maybe I should send it back

While there may be some good coming from Twitter through marketing opportunities, there is clearly some bad along with that. I think that this is the double edge sword of social media that one must be careful with.

Then there are companies like Mozilla and VMWare or, more specifically, products like Firefox, VMWare Fusion and Harvest that have teams of people constantly watching Twitter and actually responding to your tweets. One time when I was having some VMWare problems @vmwarefusion responded to me almost immediately:

@davejohnson It’s easy enough to find the real culprit. Go to Activity Monitor, and click “Show All Processes.”

not that it ultimately helped much but it’s the thought that counts. To properly take advantage of social media tools like Twitter and get the most out of them this is an important step; it’s about the community engagement rather than leaving them to their own devices. Even though Firefox still crashes on an almost daily basis it does make me feel better when someone reaches out to help. Companies like Dell should be doing the same if they want to see a net benefit from tools like Twitter.

This type of involvement on Twitter really makes sense and it makes the tool more useful even just socially. However, I can see a future in which Twitter could be taken over by people using it more for business relationships using their Twitter network to mine data rather be social. It would get pretty annoying if your Twitter friends starting asking you questions on a daily basis about this product or that, or if companies engage you in a Twitter conversation as a sales tool.

So companies should get out there and engage but don’t be phony about it and be careful not to inundate people with messages.

And, for the record, I am very happy with Dell :)

Tags: , , , , .