blob: b0c57bc44b009f9b1788a1cdedde830da1bedfc1 [file] [log] [blame]
//------------------------------------------------------------------------------
// Copyright (c) 2005, 2006 IBM Corporation and others.
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// which accompanies this distribution, and is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// Contributors:
// IBM Corporation - initial implementation
//------------------------------------------------------------------------------
package org.eclipse.epf.importing.wizards;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.eclipse.epf.importing.services.ElementDiffTree;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
/**
* The content provider for the diff report.
*
* @author Jinhua Xi
* @since 1.0
*/
public class DiffReportContentProvider implements ITreeContentProvider {
public DiffReportContentProvider() {
}
public Object[] getElements(Object inputElement) {
if (inputElement instanceof ElementDiffTree) {
List items = ((ElementDiffTree) inputElement).getChildren();
if (items != null) {
List dirtyItems = new ArrayList();
for (Iterator it = items.iterator(); it.hasNext();) {
ElementDiffTree item = (ElementDiffTree) it.next();
if (!item.isOldOnly()) {
dirtyItems.add(item);
}
}
return dirtyItems.toArray();
}
}
return new Object[] {};
}
public void dispose() {
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
public Object[] getChildren(Object parentElement) {
return getElements(parentElement);
}
public Object getParent(Object element) {
if (element instanceof ElementDiffTree) {
return ((ElementDiffTree) element).getParent();
}
return null;
}
public boolean hasChildren(Object element) {
if (element instanceof ElementDiffTree) {
return ((ElementDiffTree) element).hasChildren();
}
return false;
}
}