01: package net.refractions.udig.style.sld.editor.internal;
02:
03: import net.refractions.udig.ui.graphics.SLDs;
04:
05: import org.eclipse.jface.viewers.ITreeContentProvider;
06: import org.eclipse.jface.viewers.Viewer;
07: import org.geotools.styling.FeatureTypeStyle;
08: import org.geotools.styling.Rule;
09: import org.geotools.styling.Style;
10:
11: public class StyleTreeContentProvider implements ITreeContentProvider {
12:
13: private static final Object[] EMPTY_ARRAY = new Object[0];
14:
15: public void dispose() {
16: }
17:
18: public void inputChanged(Viewer viewer, Object oldInput,
19: Object newInput) {
20: }
21:
22: public Object[] getChildren(Object parentElement) {
23: if (parentElement == null)
24: return EMPTY_ARRAY;
25: if (parentElement instanceof Style) {
26: Style style = (Style) parentElement;
27: Rule[] rule = SLDs.rules(style);
28: return rule; //return rules
29: } else if (parentElement instanceof FeatureTypeStyle) {
30: FeatureTypeStyle fts = (FeatureTypeStyle) parentElement;
31: return fts.getRules();
32: }
33: return EMPTY_ARRAY;
34: }
35:
36: public Object getParent(Object element) {
37: return null;
38: }
39:
40: public boolean hasChildren(Object element) {
41: return false;
42: }
43:
44: public Object[] getElements(Object inputElement) {
45: return getChildren(inputElement);
46: }
47:
48: }
|