2 * Copyright (c) 2003-2004 Christopher Lenz and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * Christopher Lenz - initial API and implementation
11 * $Id: CssOutlineContentProvider.java,v 1.1 2004-09-02 18:11:49 jsurfer Exp $
14 package net.sourceforge.phpeclipse.css.ui.internal.outline;
16 import net.sourceforge.phpeclipse.css.core.model.IRule;
17 import net.sourceforge.phpeclipse.css.core.model.IStyleSheet;
19 import org.eclipse.jface.viewers.ITreeContentProvider;
20 import org.eclipse.jface.viewers.Viewer;
23 * Content provider for the CSS outline page.
25 public class CssOutlineContentProvider implements ITreeContentProvider {
27 // Instance Variables ------------------------------------------------------
30 * The parsed style sheet.
32 private IStyleSheet styleSheet;
34 // ITreeContentProvider Implementation -------------------------------------
37 * ITreeContentProvider#getChildren(Object)
39 public Object[] getChildren(Object parentElement) {
40 if (parentElement instanceof IRule) {
41 return ((IRule) parentElement).getChildren();
47 * @see ITreeContentProvider#getParent(Object)
49 public Object getParent(Object element) {
50 if (element instanceof IRule) {
51 return ((IRule) element).getParent();
57 * @see ITreeContentProvider#hasChildren(Object)
59 public boolean hasChildren(Object element) {
60 return getChildren(element).length > 0;
64 * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(Object)
66 public Object[] getElements(Object inputElement) {
67 if (styleSheet != null) {
68 return styleSheet.getRules();
74 * @see org.eclipse.jface.viewers.IContentProvider#dispose()
76 public void dispose() {
81 * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(Viewer, Object, Object)
83 public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
84 if (oldInput != newInput) {
85 if (oldInput instanceof IStyleSheet) {
88 if (newInput instanceof IStyleSheet) {
89 IStyleSheet newStyleSheet = (IStyleSheet) newInput;
90 styleSheet = newStyleSheet;