Archive for January, 2010

Getting the Eclipse Build ID

Thursday, January 21st, 2010

Eclipse Bugzilla ask you for your Eclipse Build ID. As I learned from Paul Webster in Bug 300260 you can use the following to put this build ID into the clipboard:

CTRL+3 cbi (Copy Build Id)

Seems like Eclipse has a command for everything. :-)

Google the location of a plugin in Eclipse cvs

Tuesday, January 19th, 2010

If you want to find the cvs location of a certain Eclipse plugin you can use Google site search using site:”dev.eclipse.org/viewsvn”.

For example if you are looking for the cvs location of the plugin “org.eclipse.e4.tools.ui” you can run the following Google search:

“org.eclipse.e4.tools.ui” site:dev.eclipse.org/viewsvn

Thanks to Tom Seidel for sharing this tip via twitter.

Google App Engine – Low level API for storing objects

Monday, January 18th, 2010

Google App Engine for Java permits three ways of storing your data: JDO, JPA and the low-level API. All data is ultimately stored in Bigtable. This blog post will give a little example how you can store data via the low-level API.

The low-level API allows to store entities with their properties directly into the application datastore. Your object which is the database entry will be stored in a row of Bigtable. The fields in your object are represented as properties of the row.

In the low-level API your object is represented by a key, a type (called kind) and a list of key value pairs for the properties. The low-level API allows you use the methods get(), put() and query() on an object called DatastoreService to save and retrieve entities. DatastoreService can be created by the DatastoreServiceFactory.

An entry is identified by its key. To retrieve saved entries you can recreate your key via the method KeyFactory.createKey(kind, value) there kind represent your data type and value the key of this object.

Lets have a look at an example. The following assumes that you have already basic knowledge about web development on the Google App Engine .

Create a new project “de.vogella.gae.java.persistence.lowlevel” and create the following two servlets. The first will create one entry in the datastore the second will retrieve the data.

package de.vogella.gae.java.persistence.lowlevel;

import java.io.IOException;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.appengine.api.datastore.DatastoreService;
import com.google.appengine.api.datastore.DatastoreServiceFactory;
import com.google.appengine.api.datastore.Entity;

@SuppressWarnings("serial")
public class SaveDataServlet extends HttpServlet {
	public void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws IOException {
		Entity entity = new Entity("Todo", "Todo1");
		// Alternatively use
		// Key todoKey = KeyFactory.createKey("Todo", "Todo1");
		// Entity entity = new Entity(todoKey);
		entity.setProperty("summary", "This is my summary");
		DatastoreService datastore = DatastoreServiceFactory
				.getDatastoreService();
		datastore.put(entity);

		resp.setContentType("text/plain");
		resp.getWriter().println("Saved data");
	}
}
package de.vogella.gae.java.persistence.lowlevel;

import java.io.IOException;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.appengine.api.datastore.DatastoreService;
import com.google.appengine.api.datastore.DatastoreServiceFactory;
import com.google.appengine.api.datastore.Entity;
import com.google.appengine.api.datastore.EntityNotFoundException;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;

@SuppressWarnings("serial")
public class GetDataServlet extends HttpServlet {
	public void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws IOException {
		DatastoreService datastore = DatastoreServiceFactory
				.getDatastoreService();
		Key todoKey = KeyFactory.createKey("Todo", "Todo1");
		Entity entity;
		try {
			entity = datastore.get(todoKey);
			String summary = (String) entity.getProperty("summary");

			resp.setContentType("text/plain");
			resp.getWriter()
					.println("Got the todo with the summary " + summary);
		} catch (EntityNotFoundException e) {
			resp.setContentType("text/plain");
			resp.getWriter().println("Entry not found.");
		}

	}
}

If you run this project and hit the URL you mapped the Save servlet to then an entry will get created. If you hit the URL of the get servlet this entries will be read from the datastore.

For another example have a look at my Google App Engine Tutorial. You can also follow me on Twitter here.

vogella.de news

Monday, January 18th, 2010

I received the feedback that my overview pages are difficult to read. I recently spent some time to enhance the usability of http://www.vogella.de.

Before the change the page looked like this:

I introducted now sub-categories which are used to structure the articles in a logical way.

Now it looks like this:

My hope is that this improves the readability and helps to find articles more quickly.

Let me know what you think. Are there other improvements you would like to see?

Eclipse e4 tutorial – Update

Saturday, January 16th, 2010

I had several l requests to update Create your first Eclipse e4 application to the latest changes.

I have written an updated version of this description Eclipse e4 tutorial. It should be compliant with the Eclipse e4 Milestone 3.

Like the blog entry this is currently only creating a very simple example. I’m planning to extend this tutorial over time to demonstrate the advantages of dependency injection, css styling, different renderes, etc.

Hope this helps getting started with Eclipse e4.

Let me know what you think about e4 and what e4 functionality should be also be the tutorial.

TreetableViewer Example

Wednesday, January 13th, 2010

In regards to my JFace Table Tutorial I got the question how to create a TreeTableViewer in the vogella Google Group .

Friedmut Hill was kind enough to point to the following Wiki entry with TreeTableViewer example which gives a very nice and concise example.

Thanks to Friedmut for sharing this information!


Switch to our mobile site