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
9 * IBM - Initial API and implementation
10 **********************************************************************/
11 package net.sourceforge.phpeclipse.webbrowser.internal;
13 import java.util.ArrayList;
14 import java.util.Iterator;
15 import java.util.List;
17 import net.sourceforge.phpeclipse.webbrowser.IWebBrowser;
19 import org.eclipse.jface.viewers.IStructuredContentProvider;
20 import org.eclipse.jface.viewers.Viewer;
23 * Monitor content provider.
25 public class BrowserContentProvider implements IStructuredContentProvider {
27 * BrowserContentProvider constructor comment.
29 public BrowserContentProvider() {
34 * Disposes of this content provider. This is called by the viewer when it
37 public void dispose() {
41 * Returns the elements to display in the viewer when its input is set to
42 * the given element. These elements can be presented as rows in a table,
43 * items in a list, etc. The result is not modified by the viewer.
47 * @return the array of elements to display in the viewer
49 public Object[] getElements(Object inputElement) {
50 List list = new ArrayList();
51 Iterator iterator = BrowserManager.getInstance().getWebBrowsers()
53 while (iterator.hasNext()) {
54 IWebBrowser browser = (IWebBrowser) iterator.next();
57 return list.toArray();
61 * Notifies this content provider that the given viewer's input has been
62 * switched to a different element.
64 * A typical use for this method is registering the content provider as a
65 * listener to changes on the new input (using model-specific means), and
66 * deregistering the viewer from the old input. In response to these change
67 * notifications, the content provider propagates the changes to the viewer.
73 * the old input element, or <code>null</code> if the viewer
74 * did not previously have an input
76 * the new input element, or <code>null</code> if the viewer
77 * does not have an input
79 public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {