001: /*******************************************************************************
002: * Copyright (c) 2000, 2006 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.ui.views.markers.internal;
011:
012: import org.eclipse.jface.viewers.ITreeContentProvider;
013: import org.eclipse.jface.viewers.TreeViewer;
014: import org.eclipse.jface.viewers.Viewer;
015:
016: /**
017: * The MarkerTreeContentProvider is the content provider for the marker trees.
018: *
019: * @since 3.2
020: *
021: */
022: public class MarkerTreeContentProvider implements ITreeContentProvider {
023:
024: TreeViewer viewer;
025:
026: boolean hierarchalMode = true;
027:
028: private MarkerAdapter adapter;
029:
030: /**
031: * Create a new content provider for the view.
032: */
033: MarkerTreeContentProvider() {
034: }
035:
036: /*
037: * (non-Javadoc)
038: *
039: * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
040: */
041: public Object[] getChildren(Object parentElement) {
042: if (parentElement instanceof MarkerNode) {
043: return ((MarkerNode) parentElement).getChildren();
044: }
045: return Util.EMPTY_MARKER_ARRAY;
046: }
047:
048: /*
049: * (non-Javadoc)
050: *
051: * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
052: */
053: public Object getParent(Object element) {
054: if (element instanceof MarkerNode) {
055: return ((MarkerNode) element).getParent();
056: }
057: return null;
058: }
059:
060: /*
061: * (non-Javadoc)
062: *
063: * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
064: */
065: public boolean hasChildren(Object element) {
066: if (element instanceof MarkerNode) {
067: return ((MarkerNode) element).getChildren().length > 0;
068: }
069: return false;
070: }
071:
072: /*
073: * (non-Javadoc)
074: *
075: * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
076: */
077: public Object[] getElements(Object inputElement) {
078: return adapter.getElements();
079: }
080:
081: /*
082: * (non-Javadoc)
083: *
084: * @see org.eclipse.jface.viewers.IContentProvider#dispose()
085: */
086: public void dispose() {
087: // Nothing to do here.
088: }
089:
090: /*
091: * (non-Javadoc)
092: *
093: * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer,
094: * java.lang.Object, java.lang.Object)
095: */
096: public void inputChanged(Viewer viewer, Object oldInput,
097: Object newInput) {
098: this .viewer = (TreeViewer) viewer;
099: adapter = (MarkerAdapter) newInput;
100:
101: }
102: }
|