1 package net.sourceforge.phpdt.externaltools.internal.ui;
3 /**********************************************************************
4 Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
5 This file is made available under the terms of the Common Public License v1.0
6 which accompanies this distribution, and is available at
7 http://www.eclipse.org/legal/cpl-v10.html
8 **********************************************************************/
10 import java.util.ArrayList;
11 import java.util.Arrays;
12 import java.util.List;
14 import org.eclipse.jface.viewers.IStructuredContentProvider;
15 import org.eclipse.jface.viewers.IStructuredSelection;
16 import org.eclipse.jface.viewers.TableViewer;
17 import org.eclipse.jface.viewers.Viewer;
20 * Content provider that maintains a generic list of objects which are shown in
23 public class ExternalToolsContentProvider implements IStructuredContentProvider {
24 protected List elements = new ArrayList();
26 protected TableViewer viewer;
28 public void add(Object o) {
29 if (elements.contains(o)) {
36 public void dispose() {
39 public Object[] getElements(Object inputElement) {
40 return (Object[]) elements.toArray(new Object[elements.size()]);
43 public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
44 this.viewer = (TableViewer) viewer;
46 if (newInput != null) {
47 if (newInput instanceof List) {
48 elements.addAll((List) newInput);
50 elements.addAll(Arrays.asList((Object[]) newInput));
55 public void remove(Object o) {
60 public void remove(IStructuredSelection selection) {
61 Object[] array = selection.toArray();
62 elements.removeAll(Arrays.asList(array));