intial source from http://www.sf.net/projects/wdte
[phpeclipse.git] / net.sourceforge.phpeclipse.ui / src / net / sourceforge / phpeclipse / ui / views / preview / BrowserPreview.java
diff --git a/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/views/preview/BrowserPreview.java b/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/views/preview/BrowserPreview.java
new file mode 100644 (file)
index 0000000..f4e0247
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2004 Christopher Lenz and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ * 
+ * Contributors:
+ *     Christopher Lenz - initial API and implementation
+ * 
+ * $Id: BrowserPreview.java,v 1.1 2004-09-02 18:26:31 jsurfer Exp $
+ */
+
+package net.sourceforge.phpeclipse.ui.views.preview;
+
+import net.sourceforge.phpeclipse.ui.internal.WebUIMessages;
+
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.part.IPage;
+import org.eclipse.ui.part.IPageBookViewPage;
+import org.eclipse.ui.part.MessagePage;
+import org.eclipse.ui.part.PageBook;
+import org.eclipse.ui.part.PageBookView;
+
+/**
+ * 
+ */
+public class BrowserPreview extends PageBookView {
+
+       /* 
+        * @see PageBookView#createDefaultPage(org.eclipse.ui.part.PageBook)
+        */
+       protected IPage createDefaultPage(PageBook book) {
+               MessagePage page = new MessagePage();
+               page.createControl(book);
+               page.setMessage(WebUIMessages.getString(
+                               "BrowserPreview.notAvailable")); //$NON-NLS-1$);
+               return page;
+       }
+
+       /* 
+        * @see PageBookView#doCreatePage(org.eclipse.ui.IWorkbenchPart)
+        */
+       protected PageRec doCreatePage(IWorkbenchPart part) {
+               // Try to get an outline page.
+               Object adapter = part.getAdapter(IBrowserPreviewPage.class);
+               if (adapter instanceof IBrowserPreviewPage) {
+                       IBrowserPreviewPage page = (IBrowserPreviewPage) adapter;
+                       if (page instanceof IPageBookViewPage) {
+                               initPage((IPageBookViewPage) page);
+                       }
+                       page.createControl(getPageBook());
+                       return new PageRec(part, page);
+               }
+               // There is no preview
+               return null;
+       }
+
+       /* 
+        * @see PageBookView#doDestroyPage(IWorkbenchPart, PageBookView.PageRec)
+        */
+       protected void doDestroyPage(IWorkbenchPart part, PageRec pageRecord) {
+               IBrowserPreviewPage page = (IBrowserPreviewPage) pageRecord.page;
+               page.dispose();
+               pageRecord.dispose();
+       }
+
+       /* 
+        * @see PageBookView#getBootstrapPart()
+        */
+       protected IWorkbenchPart getBootstrapPart() {
+               IWorkbenchPage page = getSite().getPage();
+               if (page != null) {
+                       return page.getActiveEditor();
+               }
+               return null;
+       }
+
+       /* 
+        * @see PageBookView#isImportant(IWorkbenchPart)
+        */
+       protected boolean isImportant(IWorkbenchPart part) {
+               return (part instanceof IEditorPart);
+       }
+
+}