01: package org.drools.eclipse.core.ui;
02:
03: import org.drools.eclipse.core.DroolsElement;
04: import org.eclipse.jface.viewers.ITreeContentProvider;
05: import org.eclipse.jface.viewers.Viewer;
06:
07: /**
08: * Content provider for Drools model elements.
09: *
10: * @author <a href="mailto:kris_verlaenen@hotmail.com">kris verlaenen </a>
11: */
12: public class DroolsContentProvider implements ITreeContentProvider {
13:
14: public Object[] getChildren(Object parentElement) {
15: if (parentElement instanceof DroolsElement) {
16: return ((DroolsElement) parentElement).getChildren();
17: }
18: return new Object[0];
19: }
20:
21: public Object getParent(Object element) {
22: if (element instanceof DroolsElement) {
23: return ((DroolsElement) element).getParent();
24: }
25: return null;
26: }
27:
28: public boolean hasChildren(Object element) {
29: return getChildren(element).length > 0;
30: }
31:
32: public Object[] getElements(Object inputElement) {
33: return getChildren(inputElement);
34: }
35:
36: public void dispose() {
37: // do nothing
38: }
39:
40: public void inputChanged(Viewer viewer, Object oldInput,
41: Object newInput) {
42: // do nothing
43: }
44:
45: }
|