2 * Copyright (c) 2004 Christopher Lenz 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 * Christopher Lenz - initial implementation
11 * $Id: HTMLPreviewPage.java,v 1.1 2004-09-02 18:13:31 jsurfer Exp $
14 package net.sourceforge.phpeclipse.html.ui.internal.preview;
18 import org.eclipse.swt.SWT;
19 import org.eclipse.swt.browser.Browser;
20 import org.eclipse.swt.browser.LocationAdapter;
21 import org.eclipse.swt.browser.LocationEvent;
22 import org.eclipse.swt.layout.FillLayout;
23 import org.eclipse.swt.widgets.Composite;
24 import org.eclipse.swt.widgets.Control;
25 import org.eclipse.ui.part.Page;
26 import org.eclipse.ui.texteditor.IUpdate;
28 import net.sourceforge.phpeclipse.ui.views.preview.IBrowserPreviewPage;
31 * Provides a HTML preview page based on the SWT browser control.
33 public class HTMLPreviewPage extends Page
34 implements IBrowserPreviewPage, IUpdate {
36 // Instance Variables ------------------------------------------------------
38 /** The browser widget. */
39 private Browser browser;
41 /** The URL of the resource to preview. */
44 // Constructors ------------------------------------------------------------
49 * @param location the URL of the resource to preview
51 public HTMLPreviewPage(URL location) {
52 this.location = location;
55 // IPage Implementation ----------------------------------------------------
58 * @see org.eclipse.ui.part.IPage#createControl(Composite)
60 public void createControl(Composite parent) {
61 browser = new Browser(parent, SWT.NONE);
62 browser.setLayout(new FillLayout());
63 browser.setUrl(location.toString());
64 browser.addLocationListener(new LocationAdapter() {
65 public void changing(LocationEvent event) {
66 if (event.location != null) {
74 * @see org.eclipse.ui.part.IPage#getControl()
76 public Control getControl() {
81 * @see org.eclipse.ui.part.IPage#setFocus()
83 public void setFocus() {
87 // IUpdate Implementation --------------------------------------------------
90 * @see IUpdate#update()
92 public void update() {