Free tutorials for Java, Eclipse and Web programming



Follow me on twitter

3. Model

Create the following model class.

			
package de.vogella.dnd.jface.model;

public class Todo {
	private String shortDescription;
	private String longDescription;
	
	public String getShortDescription() {
		return shortDescription;
	}
	public void setShortDescription(String shortDescription) {
		this.shortDescription = shortDescription;
	}
	public String getLongDescription() {
		return longDescription;
	}
	public void setLongDescription(String longDescription) {
		this.longDescription = longDescription;
	}
}

		

Create the following content providers (Singletons).

			
package de.vogella.dnd.jface.model;

import java.util.ArrayList;
import java.util.List;

public enum ContentProvider {
	INSTANCE;
	
	public List<Todo> getModel(){
		List<Todo> list = new ArrayList<Todo>();
		Todo todo = new Todo("Java", "Learn the Closure proposal");
		list.add(todo);
		todo = new Todo("Eclipse", "Learn more about the RCP platform");
		list.add(todo);
		return list;
	}
}

		

			
package de.vogella.dnd.jface.model;

import java.util.ArrayList;
import java.util.List;

public enum ContentProviderTree {
	INSTANCE;
	List<String> list = new ArrayList<String>();
	
	private ContentProviderTree() {
		list.add("Branch1");
		list.add("Branch1");
	}
	
	public List<String> getModel(){
		return list;
	}
}