Skip to content

Commit 1744de0

Browse files
committed
Eclipse IDE code completion example added
1 parent 929ec09 commit 1744de0

File tree

5 files changed

+125
-0
lines changed

5 files changed

+125
-0
lines changed

com.vogella.ide.todo/.classpath

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src"/>
4+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
5+
<classpathentry kind="output" path="bin"/>
6+
</classpath>

com.vogella.ide.todo/.project

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>com.vogella.ide.todo</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.jdt.core.javanature</nature>
16+
</natures>
17+
</projectDescription>
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package com.vogella.ide.todo;
2+
3+
import java.util.Date;
4+
5+
public class Todo {
6+
7+
private long id;
8+
private String summary = "";
9+
private String description = "";
10+
private boolean done = false;
11+
private Date dueDate;
12+
13+
public Todo(long id, String summary, String description, boolean done, Date dueDate) {
14+
super();
15+
this.id = id;
16+
this.summary = summary;
17+
this.description = description;
18+
this.done = done;
19+
this.dueDate = dueDate;
20+
}
21+
22+
public long getId() {
23+
return id;
24+
}
25+
26+
public void setId(long id) {
27+
this.id = id;
28+
}
29+
30+
public String getSummary() {
31+
return summary;
32+
}
33+
34+
public void setSummary(String summary) {
35+
this.summary = summary;
36+
}
37+
38+
public String getDescription() {
39+
return description;
40+
}
41+
42+
public void setDescription(String description) {
43+
this.description = description;
44+
}
45+
46+
public boolean isDone() {
47+
return done;
48+
}
49+
50+
public void setDone(boolean done) {
51+
this.done = done;
52+
}
53+
54+
public Date getDueDate() {
55+
return dueDate;
56+
}
57+
58+
public void setDueDate(Date dueDate) {
59+
this.dueDate = dueDate;
60+
}
61+
62+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.vogella.ide.todo;
2+
3+
import java.util.ArrayList;
4+
import java.util.Date;
5+
import java.util.List;
6+
7+
public class TodoProvider {
8+
private static int current = 0;
9+
10+
// example data, change if you like
11+
public static List<Todo> createInitialModel() {
12+
ArrayList<Todo> list = new ArrayList<Todo>();
13+
list.add(createTodo("SWT", "Learn Widgets"));
14+
list.add(createTodo("JFace", "Especially Viewers!"));
15+
list.add(createTodo("DI", "@Inject looks interesting"));
16+
list.add(createTodo("OSGi", "Services"));
17+
list.add(createTodo("Compatibility Layer", "Run Eclipse 3.x"));
18+
return list;
19+
}
20+
21+
private static Todo createTodo(String summary, String description) {
22+
return new Todo(current++, summary, description, false, new Date());
23+
}
24+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.vogella.ide.todo;
2+
3+
import java.util.List;
4+
5+
public class TodoProviderTest {
6+
7+
public static void main(String[] args) {
8+
List<Todo> model = TodoProvider.createInitialModel();
9+
if (model.size()!=5){
10+
throw new RuntimeException("size should be 5");
11+
} else {
12+
System.out.println("Correct");
13+
}
14+
}
15+
16+
}

0 commit comments

Comments
 (0)