Updated build.properties, build.xml for release build
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / externaltools / internal / ui / ExternalToolsContentProvider.java
1 package net.sourceforge.phpdt.externaltools.internal.ui;
2
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 **********************************************************************/
9
10 import java.util.ArrayList;
11 import java.util.Arrays;
12 import java.util.List;
13
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;
18
19 /**
20  * Content provider that maintains a generic list of objects which are shown in
21  * a table viewer.
22  */
23 public class ExternalToolsContentProvider implements IStructuredContentProvider {
24         protected List elements = new ArrayList();
25         protected TableViewer viewer;
26
27         public void add(Object o) {
28                 if (elements.contains(o)) {
29                         return;
30                 }
31                 elements.add(o);
32                 viewer.add(o);
33         }
34
35         public void dispose() {
36         }
37
38         public Object[] getElements(Object inputElement) {
39                 return (Object[]) elements.toArray(new Object[elements.size()]);
40         }
41
42         public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
43                 this.viewer = (TableViewer) viewer;
44                 elements.clear();
45                 if (newInput != null) {
46                         if (newInput instanceof List) {
47                                 elements.addAll((List) newInput);
48                         } else {
49                                 elements.addAll(Arrays.asList((Object[]) newInput));
50                         }
51                 }
52         }
53
54         public void remove(Object o) {
55                 elements.remove(o);
56                 viewer.remove(o);
57         }
58         
59         public void remove(IStructuredSelection selection) {
60                 Object[] array= selection.toArray();
61                 elements.removeAll(Arrays.asList(array));
62                 viewer.remove(array);
63         }
64 }