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();
25 protected TableViewer viewer;
27 public void add(Object o) {
28 if (elements.contains(o)) {
35 public void dispose() {
38 public Object[] getElements(Object inputElement) {
39 return (Object[]) elements.toArray(new Object[elements.size()]);
42 public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
43 this.viewer = (TableViewer) viewer;
45 if (newInput != null) {
46 if (newInput instanceof List) {
47 elements.addAll((List) newInput);
49 elements.addAll(Arrays.asList((Object[]) newInput));
54 public void remove(Object o) {
59 public void remove(IStructuredSelection selection) {
60 Object[] array= selection.toArray();
61 elements.removeAll(Arrays.asList(array));