intial source from http://www.sf.net/projects/wdte
[phpeclipse.git] / net.sourceforge.phpeclipse.webbrowser / src / net / sourceforge / phpeclipse / webbrowser / internal / BrowserContentProvider.java
1 /**********************************************************************
2  * Copyright (c) 2003 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  *
8  * Contributors:
9  *    IBM - Initial API and implementation
10  **********************************************************************/
11 package net.sourceforge.phpeclipse.webbrowser.internal;
12
13 import java.util.*;
14
15 import net.sourceforge.phpeclipse.webbrowser.IWebBrowser;
16
17 import org.eclipse.jface.viewers.Viewer;
18 import org.eclipse.jface.viewers.IStructuredContentProvider;
19
20 /**
21  * Monitor content provider.
22  */
23 public class BrowserContentProvider implements IStructuredContentProvider {
24         /**
25          * BrowserContentProvider constructor comment.
26          */
27         public BrowserContentProvider() {
28                 super();
29         }
30
31         /**
32          * Disposes of this content provider.  
33          * This is called by the viewer when it is disposed.
34          */
35         public void dispose() { }
36
37         /**
38          * Returns the elements to display in the viewer 
39          * when its input is set to the given element. 
40          * These elements can be presented as rows in a table, items in a list, etc.
41          * The result is not modified by the viewer.
42          *
43          * @param inputElement the input element
44          * @return the array of elements to display in the viewer
45          */
46         public Object[] getElements(Object inputElement) {
47                 List list = new ArrayList();
48                 Iterator iterator = BrowserManager.getInstance().getWebBrowsers().iterator();
49                 while (iterator.hasNext()) {
50                         IWebBrowser browser = (IWebBrowser) iterator.next();
51                         list.add(browser);
52                 }
53                 return list.toArray();
54                 }
55
56         /**
57          * Notifies this content provider that the given viewer's input
58          * has been switched to a different element.
59          * <p>
60          * A typical use for this method is registering the content provider as a listener
61          * to changes on the new input (using model-specific means), and deregistering the viewer 
62          * from the old input. In response to these change notifications, the content provider
63          * propagates the changes to the viewer.
64          * </p>
65          *
66          * @param viewer the viewer
67          * @param oldInput the old input element, or <code>null</code> if the viewer
68          *   did not previously have an input
69          * @param newInput the new input element, or <code>null</code> if the viewer
70          *   does not have an input
71          */
72         public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
73 }