diff options
Diffstat (limited to 'examples/org.eclipse.swt.examples.ole.win32')
21 files changed, 0 insertions, 1378 deletions
diff --git a/examples/org.eclipse.swt.examples.ole.win32/.classpath b/examples/org.eclipse.swt.examples.ole.win32/.classpath deleted file mode 100755 index 065ac06e19..0000000000 --- a/examples/org.eclipse.swt.examples.ole.win32/.classpath +++ /dev/null @@ -1,7 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<classpath> - <classpathentry kind="src" path="src"/> - <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> - <classpathentry kind="output" path="bin"/> -</classpath> diff --git a/examples/org.eclipse.swt.examples.ole.win32/.cvsignore b/examples/org.eclipse.swt.examples.ole.win32/.cvsignore deleted file mode 100755 index c5e82d7458..0000000000 --- a/examples/org.eclipse.swt.examples.ole.win32/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -bin
\ No newline at end of file diff --git a/examples/org.eclipse.swt.examples.ole.win32/.project b/examples/org.eclipse.swt.examples.ole.win32/.project deleted file mode 100644 index ff00f68d20..0000000000 --- a/examples/org.eclipse.swt.examples.ole.win32/.project +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<projectDescription> - <name>org.eclipse.swt.examples.ole.win32</name> - <comment></comment> - <projects> - </projects> - <buildSpec> - <buildCommand> - <name>org.eclipse.jdt.core.javabuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>org.eclipse.pde.ManifestBuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>org.eclipse.pde.SchemaBuilder</name> - <arguments> - </arguments> - </buildCommand> - </buildSpec> - <natures> - <nature>org.eclipse.jdt.core.javanature</nature> - <nature>org.eclipse.pde.PluginNature</nature> - </natures> -</projectDescription> diff --git a/examples/org.eclipse.swt.examples.ole.win32/.settings/org.eclipse.jdt.core.prefs b/examples/org.eclipse.swt.examples.ole.win32/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index aaad86939f..0000000000 --- a/examples/org.eclipse.swt.examples.ole.win32/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,12 +0,0 @@ -#Mon Dec 11 15:13:54 EST 2006 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.4 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning -org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning -org.eclipse.jdt.core.compiler.source=1.3 diff --git a/examples/org.eclipse.swt.examples.ole.win32/about.html b/examples/org.eclipse.swt.examples.ole.win32/about.html deleted file mode 100644 index 460233046e..0000000000 --- a/examples/org.eclipse.swt.examples.ole.win32/about.html +++ /dev/null @@ -1,28 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml"> -<head> -<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/> -<title>About</title> -</head> -<body lang="EN-US"> -<h2>About This Content</h2> - -<p>June 2, 2006</p> -<h3>License</h3> - -<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise -indicated below, the Content is provided to you under the terms and conditions of the -Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available -at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>. -For purposes of the EPL, "Program" will mean the Content.</p> - -<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is -being redistributed by another party ("Redistributor") and different terms and conditions may -apply to your use of any object code in the Content. Check the Redistributor's license that was -provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise -indicated below, the terms and conditions of the EPL still apply to any source code in the Content -and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p> - -</body> -</html>
\ No newline at end of file diff --git a/examples/org.eclipse.swt.examples.ole.win32/build.properties b/examples/org.eclipse.swt.examples.ole.win32/build.properties deleted file mode 100755 index bfe7608add..0000000000 --- a/examples/org.eclipse.swt.examples.ole.win32/build.properties +++ /dev/null @@ -1,20 +0,0 @@ -############################################################################### -# Copyright (c) 2000, 2003 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# IBM Corporation - initial API and implementation -############################################################################### -bin.includes = doc-html/,\ - icons/,\ - plugin.properties,\ - plugin.xml,\ - about.html,\ - *.jar - -src.includes = about.html - -source.olewin32.jar = src/ diff --git a/examples/org.eclipse.swt.examples.ole.win32/doc-html/swt_ole_ex.html b/examples/org.eclipse.swt.examples.ole.win32/doc-html/swt_ole_ex.html deleted file mode 100755 index d27da8ef51..0000000000 --- a/examples/org.eclipse.swt.examples.ole.win32/doc-html/swt_ole_ex.html +++ /dev/null @@ -1,37 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> -<html> -<head> -<meta name="copyright" content="Copyright (c) IBM Corporation and others 2000, 2005. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page." > - <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> - <title>SWT - OLE Web Browser</title> -</head> -<body> - -<h2>SWT example - OLE Web Browser</h2> - -<p> -This example shows how to embed an Active X control into an SWT application or an Eclipse view. -</p> -<p> -When the view is opened, it will create an instance of the Windows Internet Explorer -control. The OLE web browser has -<strong>Back</strong> and <strong>Forward</strong> buttons to take you to recently visited pages. The browser also contains -a <strong>Home</strong> button to take you to the web browser's home page, a <strong>Stop</strong> button which stops the -current transfer, a <strong>Search</strong> button which will search for text typed in the <strong>Address</strong> text field, and -a <strong>Refresh</strong> button which re-draws the contents of the currently displayed page. There is also a -<strong>Go</strong> button which, when clicked, will attempt to load the page specified in the <strong>Address</strong> field. -</p> - -<h3>Running the example</h3> - -<p> -From Eclipse's <strong>Window</strong> menu select <strong>Show View</strong> > <strong>Other</strong>. -In the <strong>Show View</strong> dialog, expand <strong>SWT Examples</strong> and select -the view named <strong>OLE Web Browser (win32)</strong>. A view containing a web browser will appear. -</p> -<p> -This example can also be run using the <a href="../../org.eclipse.swt.examples.launcher/doc-html/swt_launcher_ex.html">Example Launcher</a>. -Select the <strong>OLE Web Browser</strong> item from the <strong>Win32 only</strong> category and click <strong>Run</strong>. -</p> -</body> -</html> diff --git a/examples/org.eclipse.swt.examples.ole.win32/icons/backward_nav.gif b/examples/org.eclipse.swt.examples.ole.win32/icons/backward_nav.gif Binary files differdeleted file mode 100755 index 5fcf41b783..0000000000 --- a/examples/org.eclipse.swt.examples.ole.win32/icons/backward_nav.gif +++ /dev/null diff --git a/examples/org.eclipse.swt.examples.ole.win32/icons/forward_nav.gif b/examples/org.eclipse.swt.examples.ole.win32/icons/forward_nav.gif Binary files differdeleted file mode 100755 index 3b9b6af9b1..0000000000 --- a/examples/org.eclipse.swt.examples.ole.win32/icons/forward_nav.gif +++ /dev/null diff --git a/examples/org.eclipse.swt.examples.ole.win32/icons/home_nav.gif b/examples/org.eclipse.swt.examples.ole.win32/icons/home_nav.gif Binary files differdeleted file mode 100755 index 77a2306ed2..0000000000 --- a/examples/org.eclipse.swt.examples.ole.win32/icons/home_nav.gif +++ /dev/null diff --git a/examples/org.eclipse.swt.examples.ole.win32/icons/refresh_nav.gif b/examples/org.eclipse.swt.examples.ole.win32/icons/refresh_nav.gif Binary files differdeleted file mode 100755 index e270e18bde..0000000000 --- a/examples/org.eclipse.swt.examples.ole.win32/icons/refresh_nav.gif +++ /dev/null diff --git a/examples/org.eclipse.swt.examples.ole.win32/icons/search_nav.gif b/examples/org.eclipse.swt.examples.ole.win32/icons/search_nav.gif Binary files differdeleted file mode 100755 index 73ac91bddb..0000000000 --- a/examples/org.eclipse.swt.examples.ole.win32/icons/search_nav.gif +++ /dev/null diff --git a/examples/org.eclipse.swt.examples.ole.win32/icons/stop_nav.gif b/examples/org.eclipse.swt.examples.ole.win32/icons/stop_nav.gif Binary files differdeleted file mode 100755 index 653d347b57..0000000000 --- a/examples/org.eclipse.swt.examples.ole.win32/icons/stop_nav.gif +++ /dev/null diff --git a/examples/org.eclipse.swt.examples.ole.win32/icons/webbrowser_example.gif b/examples/org.eclipse.swt.examples.ole.win32/icons/webbrowser_example.gif Binary files differdeleted file mode 100755 index 895e22110d..0000000000 --- a/examples/org.eclipse.swt.examples.ole.win32/icons/webbrowser_example.gif +++ /dev/null diff --git a/examples/org.eclipse.swt.examples.ole.win32/plugin.properties b/examples/org.eclipse.swt.examples.ole.win32/plugin.properties deleted file mode 100755 index d4c362fac8..0000000000 --- a/examples/org.eclipse.swt.examples.ole.win32/plugin.properties +++ /dev/null @@ -1,68 +0,0 @@ -############################################################################### -# Copyright (c) 2000, 2007 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# IBM Corporation - initial API and implementation -############################################################################### -providerName = Eclipse.org -plugin.SWTOLEExample.name = SWT OLE Example Plugin (Win32) -category.SWTExamples.name = SWT Examples -view.OLEWebBrowserExample.name = OLE Web Browser (Win32) - -launchcategory.SWTWin32OnlyExamples.name = Win32 only -launchcategory.SWTWin32OnlyExamples.description = \ - A collection of Standard Widget Toolkit examples for Windows systems only. - -launchitem.OLEWebBrowserExample.name = OLE Web Browser -launchitem.OLEWebBrowserExample.description = \ - This example demonstrates how to embed an Active X control into an SWT application or an Eclipse view.\n\n\ - When the view is opened, it will create an instance of the Windows Internet Explorer \ - control. The OLE Web Browser has \ - Back and Forward buttons to take you to recently visited pages. The browser also contains \ - a Home button to take you to the web browser's home page, a Stop button which stops the \ - current transfer, a Search button which will search for text typed in the Address text field, and \ - a Refresh button which re-draws the contents of the currently displayed page. There is also a \ - Go button which, when clicked, will attempt to load the page specified in the Address field. - -browser.Back.text = Backward -browser.Back.tooltip = Go to previous Web site in the history list - -browser.Forward.text = Forward -browser.Forward.tooltip = Go to next Web site in the history list - -browser.Home.text = Home -browser.Home.tooltip = Go to home Web site - -browser.Stop.text = Stop -browser.Stop.tooltip = Stop loading current Web site - -browser.Refresh.text = Refresh -browser.Refresh.tooltip = Refresh current Web site - -browser.Search.text = Search -browser.Search.tooltip = Search the Web - -browser.Address.label = Address : - -browser.Go.text = Go - -browser.State.Uninitialized.text = Not ready. -browser.State.Loading.text = Loading Web site... -browser.State.Loaded.text = Ready. -browser.State.Interactive.text = Loading Web site... -browser.State.Complete.text = Done. - -error.CouldNotLoadResources = Unable to load resources -error.CouldNotCreateBrowserControl = Unable to create <<Browser Control>> - -launchitem.OLEExample.name=OLE Example -launchitem.OLEExample.description=\ - The OLE example demonstrates how to embed an Active X control into \ - an SWT application.\n\n\ - - - diff --git a/examples/org.eclipse.swt.examples.ole.win32/plugin.xml b/examples/org.eclipse.swt.examples.ole.win32/plugin.xml deleted file mode 100755 index d8e7f5e0e0..0000000000 --- a/examples/org.eclipse.swt.examples.ole.win32/plugin.xml +++ /dev/null @@ -1,70 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<?eclipse version="3.0"?> -<!-- File written by PDE 1.0 --> -<plugin - id="org.eclipse.swt.examples.ole.win32" - name="%plugin.SWTOLEExample.name" - version="3.1.100.qualifier" - provider-name="%providerName" - class="org.eclipse.swt.examples.ole.win32.OlePlugin"> -<!-- Required plugins --> -<requires> - <import plugin="org.eclipse.ui.ide"/> - <import plugin="org.eclipse.ui.views"/> - <import plugin="org.eclipse.jface.text"/> - <import plugin="org.eclipse.ui.workbench.texteditor"/> - <import plugin="org.eclipse.ui.editors"/> - <import plugin="org.eclipse.core.runtime"/> - <import plugin="org.eclipse.core.resources"/> - <import plugin="org.eclipse.ui"/> - <import plugin="org.eclipse.swt"/> -</requires> - -<!-- Runtime --> -<!-- Runtime --> -<runtime> - <library name="olewin32.jar"> - </library> -</runtime> - -<!-- Extensions --> -<!-- Extension points --> -<extension - point="org.eclipse.ui.views"> - <view - name="%view.OLEWebBrowserExample.name" - icon="icons/webbrowser_example.gif" - category="org.eclipse.swt.examples.category" - class="org.eclipse.swt.examples.ole.win32.OleBrowserView" - id="org.eclipse.swt.examples.ole.win32.browserView"> - </view> -</extension> -<extension - point="org.eclipse.swt.examples.launcher.launchItems"> - <category - name="%launchcategory.SWTWin32OnlyExamples.name" - description="%launchcategory.SWTWin32OnlyExamples.description" - id="org.eclipse.swt.examples.launchWin32OnlyCategory"> - </category> - <item - name="%launchitem.OLEWebBrowserExample.name" - icon="icons/webbrowser_example.gif" - description="%launchitem.OLEWebBrowserExample.description" - category="org.eclipse.swt.examples.launchWin32OnlyCategory" - id="org.eclipse.swt.examples.ole.win32.viewlauncher"> - <view - viewId="org.eclipse.swt.examples.ole.win32.browserView"> - </view> - </item> - <item - name="%launchitem.OLEExample.name" - description="%launchitem.OLEExample.description" - category="org.eclipse.swt.examples.launchWin32OnlyCategory" - id="org.eclipse.swt.examples.ole.win32.standalonelauncher"> - <program - pluginId="org.eclipse.swt.examples.ole.win32" - mainClass="org.eclipse.swt.examples.ole.win32.OLEExample"> - </program> - </item> -</extension> -</plugin> diff --git a/examples/org.eclipse.swt.examples.ole.win32/src/import.properties b/examples/org.eclipse.swt.examples.ole.win32/src/import.properties deleted file mode 100644 index 8241dacfa2..0000000000 --- a/examples/org.eclipse.swt.examples.ole.win32/src/import.properties +++ /dev/null @@ -1,14 +0,0 @@ -############################################################################### -# Copyright (c) 2000, 2003 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# IBM Corporation - initial API and implementation -############################################################################### -# Persist project settings for later import -natures = org.eclipse.jdt.core.javanature; org.eclipse.pde.PluginNature -builders = org.eclipse.jdt.core.javabuilder; org.eclipse.pde.ManifestBuilder; org.eclipse.pde.SchemaBuilder -var.ECLIPSE_PLUGINS = <<ECLIPSE_PLUGINS>> diff --git a/examples/org.eclipse.swt.examples.ole.win32/src/org/eclipse/swt/examples/ole/win32/OLEExample.java b/examples/org.eclipse.swt.examples.ole.win32/src/org/eclipse/swt/examples/ole/win32/OLEExample.java deleted file mode 100644 index 00382ed994..0000000000 --- a/examples/org.eclipse.swt.examples.ole.win32/src/org/eclipse/swt/examples/ole/win32/OLEExample.java +++ /dev/null @@ -1,306 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.swt.examples.ole.win32; - -import java.io.*; - -import org.eclipse.swt.*; -import org.eclipse.swt.events.*; -import org.eclipse.swt.layout.*; -import org.eclipse.swt.ole.win32.*; -import org.eclipse.swt.widgets.*; - -/** - * OLEExample is an example that uses <code>org.eclipse.swt</code> - * libraries to implement a simple SWT window that can host different Active X - * controls. - * - * @since 3.3 - */ -public class OLEExample { - - OleClientSite clientSite; - OleFrame oleFrame; - Button closeButton; - - public static void main(String[] args) { - Display display = new Display(); - OLEExample example = new OLEExample(); - example.open(display); - display.dispose(); - } - - /** - * Create a file Exit menu item - */ - void addFileMenu(OleFrame frame) { - final Shell shell = frame.getShell(); - Menu menuBar = shell.getMenuBar(); - if (menuBar == null) { - menuBar = new Menu(shell, SWT.BAR); - shell.setMenuBar(menuBar); - } - MenuItem fileMenu = new MenuItem(menuBar, SWT.CASCADE); - fileMenu.setText("&File"); - Menu menuFile = new Menu(fileMenu); - fileMenu.setMenu(menuFile); - frame.setFileMenus(new MenuItem[] { fileMenu }); - - MenuItem menuFileExit = new MenuItem(menuFile, SWT.CASCADE); - menuFileExit.setText("Exit"); - menuFileExit.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - shell.dispose(); - } - }); - } - - void disposeClient() { - if (clientSite != null) - clientSite.dispose(); - clientSite = null; - } - - /** - * Prompt the user for a file and try to open it with some known ActiveX controls. - */ - void fileOpen() { - Shell shell = oleFrame.getShell(); - FileDialog dialog = new FileDialog(shell, SWT.OPEN); - String fileName = dialog.open(); - if (fileName == null) return; - - disposeClient(); - - // try opening a .doc file using Word - if (clientSite == null) { - int index = fileName.lastIndexOf('.'); - if (index != -1) { - String fileExtension = fileName.substring(index + 1); - if (fileExtension.equalsIgnoreCase("doc") || - fileExtension.equalsIgnoreCase("rtf") || - fileExtension.equalsIgnoreCase("txt")) { - try { - clientSite = new OleClientSite(oleFrame, SWT.NONE, "Word.Document", new File(fileName)); - } catch (SWTException error2) { - disposeClient(); - } - } - } - } - - // try opening a xls file with Excel - if (clientSite == null) { - int index = fileName.lastIndexOf('.'); - if (index != -1) { - String fileExtension = fileName.substring(index + 1); - if (fileExtension.equalsIgnoreCase("xls")) { - try { - clientSite = new OleClientSite(oleFrame, SWT.NONE, "Excel.Sheet", new File(fileName)); - } catch (SWTException error2) { - disposeClient(); - } - } - } - } - - // try opening a media file with MPlayer - if (clientSite == null) { - int index = fileName.lastIndexOf('.'); - if (index != -1) { - String fileExtension = fileName.substring(index + 1); - if (fileExtension.equalsIgnoreCase("mpa")) { - try { - clientSite = new OleClientSite(oleFrame, SWT.NONE, "MPlayer", new File(fileName)); - } catch (SWTException error2) { - disposeClient(); - } - } - } - } - - // try opening with wmv, mpg, mpeg, avi, asf, wav with WMPlayer - if (clientSite == null) { - int index = fileName.lastIndexOf('.'); - if (index != -1) { - String fileExtension = fileName.substring(index + 1); - if (fileExtension.equalsIgnoreCase("wmv") - || fileExtension.equalsIgnoreCase("mpg") - || fileExtension.equalsIgnoreCase("mpeg") - || fileExtension.equalsIgnoreCase("avi") - || fileExtension.equalsIgnoreCase("asf") - || fileExtension.equalsIgnoreCase("wav")) { - try { - clientSite = new OleClientSite(oleFrame, SWT.NONE, "WMPlayer.OCX"); - OleAutomation player = new OleAutomation(clientSite); - int playURL[] = player.getIDsOfNames(new String[] { "URL" }); - if (playURL != null) { - boolean suceeded = player.setProperty(playURL[0], new Variant(fileName)); - if (!suceeded) - disposeClient(); - } else { - disposeClient(); - } - player.dispose(); - } catch (SWTException error2) { - disposeClient(); - } - } - } - } - - // try opening a PDF file with Acrobat reader - if (clientSite == null) { - int index = fileName.lastIndexOf('.'); - if (index != -1) { - String fileExtension = fileName.substring(index + 1); - if (fileExtension.equalsIgnoreCase("pdf")) { - try { - clientSite = new OleClientSite(oleFrame, SWT.NONE, "PDF.PdfCtrl.5"); - clientSite.doVerb(OLE.OLEIVERB_INPLACEACTIVATE); - OleAutomation pdf = new OleAutomation (clientSite); - int loadFile[] = pdf.getIDsOfNames (new String [] {"LoadFile"}); - if (loadFile != null) { - Variant result = pdf.invoke(loadFile[0], new Variant[] {new Variant(fileName)}); - if (result == null) - disposeClient(); - else - result.dispose(); - } else { - disposeClient(); - } - pdf.dispose(); - } catch (SWTException error2) { - disposeClient(); - } - } - } - } - - // try opening with Explorer - if (clientSite == null) { - try { - clientSite = new OleClientSite(oleFrame, SWT.NONE, "Shell.Explorer"); - OleAutomation explorer = new OleAutomation(clientSite); - int[] navigate = explorer.getIDsOfNames(new String[]{"Navigate"}); - - if (navigate != null) { - Variant result = explorer.invoke(navigate[0], new Variant[] {new Variant(fileName)}); - if (result == null) - disposeClient(); - else - result.dispose(); - } else { - disposeClient(); - } - explorer.dispose(); - } catch (SWTException error2) { - disposeClient(); - } - } - - if (clientSite != null){ - clientSite.doVerb(OLE.OLEIVERB_INPLACEACTIVATE); - } - } - - void newClientSite(String progID) { - disposeClient(); - try { - clientSite = new OleClientSite(oleFrame, SWT.NONE, progID); - } catch (SWTException error) { - - } - if (clientSite != null) - clientSite.doVerb(OLE.OLEIVERB_INPLACEACTIVATE); - } - - public void open(Display display) { - Shell shell = new Shell(display); - shell.setText("OLE Example"); - shell.setLayout(new FillLayout()); - - Composite parent = new Composite(shell, SWT.NONE); - parent.setLayout(new GridLayout(4, true)); - - Composite buttons = new Composite(parent, SWT.NONE); - buttons.setLayout(new GridLayout()); - GridData gridData = new GridData(SWT.BEGINNING, SWT.FILL, false, false); - buttons.setLayoutData(gridData); - - Composite displayArea = new Composite(parent, SWT.BORDER); - displayArea.setLayout(new FillLayout()); - displayArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1)); - - Button excelButton = new Button(buttons, SWT.RADIO); - excelButton.setText("New Excel Sheet"); - excelButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - if (((Button) e.widget).getSelection()) - newClientSite("Excel.Sheet"); - } - }); - Button mediaPlayerButton = new Button(buttons, SWT.RADIO); - mediaPlayerButton.setText("New MPlayer"); - mediaPlayerButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - if (((Button) e.widget).getSelection()) - newClientSite("MPlayer"); - } - }); - Button powerPointButton = new Button(buttons, SWT.RADIO); - powerPointButton.setText("New PowerPoint Slide"); - powerPointButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - if (((Button) e.widget).getSelection()) - newClientSite("PowerPoint.Slide"); - } - }); - Button wordButton = new Button(buttons, SWT.RADIO); - wordButton.setText("New Word Document"); - wordButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - if (((Button) e.widget).getSelection()) - newClientSite("Word.Document"); - } - }); - new Label(buttons, SWT.NONE); - Button openButton = new Button(buttons, SWT.RADIO); - openButton.setText("Open file..."); - openButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - if (((Button) e.widget).getSelection()) - fileOpen(); - } - }); - new Label(buttons, SWT.NONE); - closeButton = new Button(buttons, SWT.RADIO); - closeButton.setText("Close file"); - closeButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - if (((Button) e.widget).getSelection()) - disposeClient(); - } - }); - closeButton.setSelection(true); - - oleFrame = new OleFrame(displayArea, SWT.NONE); - addFileMenu(oleFrame); - - shell.setSize(800, 600); - shell.open(); - - while (!shell.isDisposed()) { - if (!display.readAndDispatch()) - display.sleep(); - } - } -} diff --git a/examples/org.eclipse.swt.examples.ole.win32/src/org/eclipse/swt/examples/ole/win32/OleBrowserView.java b/examples/org.eclipse.swt.examples.ole.win32/src/org/eclipse/swt/examples/ole/win32/OleBrowserView.java deleted file mode 100755 index e9ba5d4c2d..0000000000 --- a/examples/org.eclipse.swt.examples.ole.win32/src/org/eclipse/swt/examples/ole/win32/OleBrowserView.java +++ /dev/null @@ -1,370 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.swt.examples.ole.win32; - - -import org.eclipse.swt.*; -import org.eclipse.swt.events.*; -import org.eclipse.swt.layout.*; -import org.eclipse.swt.ole.win32.*; -import org.eclipse.swt.widgets.*; -import org.eclipse.ui.part.*; - -/** - * Ole uses <code>org.eclipse.swt</code> to demonstrate Win32 OLE / ActiveX - * integration. - * - * @see ViewPart - */ -public class OleBrowserView extends ViewPart { - - private Composite displayArea; - - private OleFrame webFrame; - private OleWebBrowser webBrowser; - private Text webUrl; - private OleControlSite webControlSite; - private ProgressBar webProgress; - private Label webStatus; - private Button webNavigateButton; - - private ToolItem webCommandBackward; - private ToolItem webCommandForward; - private ToolItem webCommandHome; - private ToolItem webCommandStop; - private ToolItem webCommandRefresh; - private ToolItem webCommandSearch; - - private boolean activated = false; - - private static final int DISPID_AMBIENT_DLCONTROL = -5512; - private static final int DLCTL_NO_SCRIPTS = 0x80; - - /** - * Constructs the OLE browser view. - */ - public OleBrowserView() { - OlePlugin.initResources(); - } - - /** - * Creates the example. - * - * @see ViewPart#createPartControl - */ - public void createPartControl(Composite parent) { - displayArea = new Composite(parent, SWT.NONE); - - GridLayout gridLayout = new GridLayout(); - gridLayout.numColumns = 3; - displayArea.setLayout(gridLayout); - - createToolbar(); - createBrowserFrame(); - createStatusArea(); - createBrowserControl(); - } - - /** - * Cleanup - */ - public void dispose() { - if (activated) { - webControlSite.deactivateInPlaceClient(); - activated = false; - } - if (webBrowser != null) webBrowser.dispose(); - webBrowser = null; - super.dispose(); - } - - /** - * Called when we must grab focus. - * - * @see org.eclipse.ui.part.ViewPart#setFocus - */ - public void setFocus() { - webUrl.setFocus(); - } - - /** - * Creates the Web browser toolbar. - */ - private void createToolbar() { - // Add a toolbar - ToolBar bar = new ToolBar(displayArea, SWT.NONE); - GridData gridData = new GridData(GridData.FILL_HORIZONTAL); - gridData.horizontalSpan = 3; - bar.setLayoutData(gridData); - - // Add a button to navigate backwards through previously visited web sites - webCommandBackward = new ToolItem(bar, SWT.NONE); - webCommandBackward.setToolTipText(OlePlugin.getResourceString("browser.Back.tooltip")); - webCommandBackward.setText(OlePlugin.getResourceString("browser.Back.text")); - webCommandBackward.setImage(OlePlugin.images[OlePlugin.biBack]); - webCommandBackward.setEnabled(false); - webCommandBackward.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - if (webBrowser == null) return; - webBrowser.GoBack(); - } - }); - - // Add a button to navigate forward through previously visited web sites - webCommandForward = new ToolItem(bar, SWT.NONE); - webCommandForward.setToolTipText(OlePlugin.getResourceString("browser.Forward.tooltip")); - webCommandForward.setText(OlePlugin.getResourceString("browser.Forward.text")); - webCommandForward.setImage(OlePlugin.images[OlePlugin.biForward]); - webCommandForward.setEnabled(false); - webCommandForward.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - if (webBrowser == null) return; - webBrowser.GoForward(); - } - }); - - // Add a separator - new ToolItem(bar, SWT.SEPARATOR); - - // Add a button to navigate to the Home page - webCommandHome = new ToolItem(bar, SWT.NONE); - webCommandHome.setToolTipText(OlePlugin.getResourceString("browser.Home.tooltip")); - webCommandHome.setText(OlePlugin.getResourceString("browser.Home.text")); - webCommandHome.setImage(OlePlugin.images[OlePlugin.biHome]); - webCommandHome.setEnabled(false); - webCommandHome.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - if (webBrowser == null) return; - webBrowser.GoHome(); - } - }); - - // Add a button to abort web page loading - webCommandStop = new ToolItem(bar, SWT.NONE); - webCommandStop.setToolTipText(OlePlugin.getResourceString("browser.Stop.tooltip")); - webCommandStop.setText(OlePlugin.getResourceString("browser.Stop.text")); - webCommandStop.setImage(OlePlugin.images[OlePlugin.biStop]); - webCommandStop.setEnabled(false); - webCommandStop.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - if (webBrowser == null) return; - webBrowser.Stop(); - } - }); - - // Add a button to refresh the current web page - webCommandRefresh = new ToolItem(bar, SWT.NONE); - webCommandRefresh.setToolTipText(OlePlugin.getResourceString("browser.Refresh.tooltip")); - webCommandRefresh.setText(OlePlugin.getResourceString("browser.Refresh.text")); - webCommandRefresh.setImage(OlePlugin.images[OlePlugin.biRefresh]); - webCommandRefresh.setEnabled(false); - webCommandRefresh.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - if (webBrowser == null) return; - webBrowser.Refresh(); - } - }); - - // Add a separator - new ToolItem(bar, SWT.SEPARATOR); - - // Add a button to search the web - webCommandSearch = new ToolItem(bar, SWT.NONE); - webCommandSearch.setToolTipText(OlePlugin.getResourceString("browser.Search.tooltip")); - webCommandSearch.setText(OlePlugin.getResourceString("browser.Search.text")); - webCommandSearch.setImage(OlePlugin.images[OlePlugin.biSearch]); - webCommandSearch.setEnabled(false); - webCommandSearch.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - if (webBrowser == null) return; - webBrowser.GoSearch(); - } - }); - - // Add a text area for Users to enter a url - Composite addressBar = new Composite(displayArea, SWT.NONE); - gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL); - gridData.horizontalSpan = 3; - addressBar.setLayoutData(gridData); - GridLayout gridLayout = new GridLayout(); - gridLayout.numColumns = 3; - addressBar.setLayout(gridLayout); - - Label addressLabel = new Label(addressBar, SWT.NONE); - gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL); - addressLabel.setLayoutData(gridData); - addressLabel.setText(OlePlugin.getResourceString("browser.Address.label")); - addressLabel.setFont(OlePlugin.browserFont); - - webUrl = new Text(addressBar, SWT.SINGLE | SWT.BORDER); - webUrl.setFont(OlePlugin.browserFont); - gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL); - webUrl.setLayoutData(gridData); - webUrl.addFocusListener(new FocusAdapter() { - public void focusGained(FocusEvent e) { - webNavigateButton.getShell().setDefaultButton(webNavigateButton); - } - }); - - // Add a button to navigate to the web site specified in the Text area defined above - webNavigateButton = new Button(addressBar, SWT.PUSH); - gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL); - webNavigateButton.setLayoutData(gridData); - webNavigateButton.setText(OlePlugin.getResourceString("browser.Go.text")); - webNavigateButton.setFont(OlePlugin.browserFont); - webNavigateButton.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event event) { - if (webBrowser == null) return; - webBrowser.Navigate(webUrl.getText()); - } - }); - } - - /** - * Creates the Web browser OleFrame. - */ - private void createBrowserFrame() { - // Every control must have an associated OleFrame: - webFrame = new OleFrame(displayArea, SWT.NONE); - GridData gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL); - gridData.horizontalSpan = 3; - webFrame.setLayoutData(gridData); - } - - /** - * Creates the Web browser status area. - */ - private void createStatusArea() { - // Add a progress bar to display downloading progress information - webProgress = new ProgressBar(displayArea, SWT.BORDER); - GridData gridData = new GridData(); - gridData.horizontalAlignment = GridData.BEGINNING; - gridData.verticalAlignment = GridData.FILL; - webProgress.setLayoutData(gridData); - - // Add a label for displaying status messages as they are received from the control - webStatus = new Label(displayArea, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER); - gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL); - gridData.horizontalSpan = 2; - webStatus.setLayoutData(gridData); - webStatus.setFont(OlePlugin.browserFont); - } - - /** - * Creates Web browser control. - */ - private void createBrowserControl() { - try { - // Create an Automation object for access to extended capabilities - webControlSite = new OleControlSite(webFrame, SWT.NONE, "Shell.Explorer"); - Variant download = new Variant(DLCTL_NO_SCRIPTS); - webControlSite.setSiteProperty(DISPID_AMBIENT_DLCONTROL, download); - OleAutomation oleAutomation = new OleAutomation(webControlSite); - webBrowser = new OleWebBrowser(oleAutomation); - } catch (SWTException ex) { - // Creation may have failed because control is not installed on machine - Label label = new Label(webFrame, SWT.BORDER); - OlePlugin.logError(OlePlugin.getResourceString("error.CouldNotCreateBrowserControl"), ex); - label.setText(OlePlugin.getResourceString("error.CouldNotCreateBrowserControl")); - return; - } - - // Respond to ProgressChange events by updating the Progress bar - webControlSite.addEventListener(OleWebBrowser.ProgressChange, new OleListener() { - public void handleEvent(OleEvent event) { - Variant progress = event.arguments[0]; - Variant maxProgress = event.arguments[1]; - if (progress == null || maxProgress == null) - return; - webProgress.setMaximum(maxProgress.getInt()); - webProgress.setSelection(progress.getInt()); - } - }); - - // Respond to StatusTextChange events by updating the Status Text label - webControlSite.addEventListener(OleWebBrowser.StatusTextChange, new OleListener() { - public void handleEvent(OleEvent event) { - Variant statusText = event.arguments[0]; - if (statusText == null) return; - String text = statusText.getString(); - if (text != null) - webStatus.setText(text); - } - }); - - // Listen for changes to the ready state and print out the current state - webControlSite.addPropertyListener(OleWebBrowser.DISPID_READYSTATE, new OleListener() { - public void handleEvent(OleEvent event) { - if (event.detail == OLE.PROPERTY_CHANGING) return; - int state = webBrowser.getReadyState(); - switch (state) { - case OleWebBrowser.READYSTATE_UNINITIALIZED: - webStatus.setText( - OlePlugin.getResourceString("browser.State.Uninitialized.text")); - webCommandBackward.setEnabled(false); - webCommandForward.setEnabled(false); - webCommandHome.setEnabled(false); - webCommandRefresh.setEnabled(false); - webCommandStop.setEnabled(false); - webCommandSearch.setEnabled(false); - break; - case OleWebBrowser.READYSTATE_LOADING: - webStatus.setText( - OlePlugin.getResourceString("browser.State.Loading.text")); - webCommandHome.setEnabled(true); - webCommandRefresh.setEnabled(true); - webCommandStop.setEnabled(true); - webCommandSearch.setEnabled(true); - break; - case OleWebBrowser.READYSTATE_LOADED: - webStatus.setText( - OlePlugin.getResourceString("browser.State.Loaded.text")); - webCommandStop.setEnabled(true); - break; - case OleWebBrowser.READYSTATE_INTERACTIVE: - webStatus.setText( - OlePlugin.getResourceString("browser.State.Interactive.text")); - webCommandStop.setEnabled(true); - break; - case OleWebBrowser.READYSTATE_COMPLETE: - webStatus.setText( - OlePlugin.getResourceString("browser.State.Complete.text")); - webCommandStop.setEnabled(false); - break; - } - } - }); - - // Listen for changes to the active command states - webControlSite.addEventListener(OleWebBrowser.CommandStateChange, new OleListener() { - public void handleEvent(OleEvent event) { - if (event.type != OleWebBrowser.CommandStateChange) return; - final int commandID = - (event.arguments[0] != null) ? event.arguments[0].getInt() : 0; - final boolean commandEnabled = - (event.arguments[1] != null) ? event.arguments[1].getBoolean() : false; - - switch (commandID) { - case OleWebBrowser.CSC_NAVIGATEBACK: - webCommandBackward.setEnabled(commandEnabled); - break; - case OleWebBrowser.CSC_NAVIGATEFORWARD: - webCommandForward.setEnabled(commandEnabled); - break; - } - } - }); - - // in place activate the ActiveX control - activated = (webControlSite.doVerb(OLE.OLEIVERB_INPLACEACTIVATE) == OLE.S_OK); - if (activated) webBrowser.GoHome(); - } -} diff --git a/examples/org.eclipse.swt.examples.ole.win32/src/org/eclipse/swt/examples/ole/win32/OlePlugin.java b/examples/org.eclipse.swt.examples.ole.win32/src/org/eclipse/swt/examples/ole/win32/OlePlugin.java deleted file mode 100755 index a55c2e3674..0000000000 --- a/examples/org.eclipse.swt.examples.ole.win32/src/org/eclipse/swt/examples/ole/win32/OlePlugin.java +++ /dev/null @@ -1,189 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.swt.examples.ole.win32; - - -import java.io.*; -import java.net.*; -import java.text.*; -import java.util.*; - -import org.eclipse.core.runtime.*; -import org.eclipse.swt.*; -import org.eclipse.swt.graphics.*; -import org.eclipse.ui.plugin.*; -import org.osgi.framework.*; - -/** - * The main plugin class to be used in the desktop. - */ -public class OlePlugin extends AbstractUIPlugin { - //The shared instance. - private static OlePlugin plugin; - private static ResourceBundle resourceBundle; - - static final int - biBack = 0, - biForward = 1, - biHome = 2, - biStop = 3, - biRefresh = 4, - biSearch = 5; - static final String[] imageLocations = { - "icons/backward_nav.gif", - "icons/forward_nav.gif", - "icons/home_nav.gif", - "icons/stop_nav.gif", - "icons/refresh_nav.gif", - "icons/search_nav.gif" }; - static Image images[]; - static Font browserFont; - - /** - * Constructs an OLE plugin. - */ - public OlePlugin() { - super(); - plugin = this; - } - - public void start(BundleContext context) throws Exception { - super.start(context); - resourceBundle = Platform.getResourceBundle(getBundle()); - } - - /** - * Clean up - */ - public void stop(BundleContext context) throws Exception { - freeResources(); - super.stop(context); - } - - /** - * Returns the shared instance. - */ - public static OlePlugin getDefault() { - return plugin; - } - - /** - * Returns a string from the resource bundle. - * We don't want to crash because of a missing String. - * Returns the key if not found. - */ - public static String getResourceString(String key) { - try { - return resourceBundle.getString(key); - } catch (MissingResourceException e) { - return key; - } catch (NullPointerException e) { - return "!" + key + "!"; - } - } - - /** - * Returns a string from the resource bundle and binds it - * with the given arguments. If the key is not found, - * return the key. - */ - public static String getResourceString(String key, Object[] args) { - try { - return MessageFormat.format(getResourceString(key), args); - } catch (MissingResourceException e) { - return key; - } catch (NullPointerException e) { - return "!" + key + "!"; - } - } - - /** - * Log an error to the ILog for this plugin - * - * @param message the localized error message text - * @param exception the associated exception, or null - */ - public static void logError(String message, Throwable exception) { - plugin.getLog().log(new Status( - IStatus.ERROR, plugin.getBundle().getSymbolicName(), 0, message, exception)); - } - - /** - * Loads the resources. - */ - public static void initResources() { - if (images == null) { - images = new Image[imageLocations.length]; - - for (int i = 0; i < imageLocations.length; ++i) { - images[i] = getImageFromPlugin(plugin.getBundle(), imageLocations[i]); - if (images[i] == null) { - freeResources(); - logError(getResourceString("error.CouldNotLoadResources"), null); - throw new IllegalStateException(); - } - } - } - if (browserFont == null) { - try { - browserFont = new Font (null, "MS Sans Serif", 8, SWT.NULL); - } catch (Throwable ex) { - } - } - if (images == null || browserFont == null) { - freeResources(); - logError(getResourceString("error.CouldNotLoadResources"), null); - throw new IllegalStateException(); - } - } - - /** - * Frees the resources - */ - public static void freeResources() { - if (images != null) { - for (int i = 0; i < images.length; ++i) { - final Image image = images[i]; - if (image != null) image.dispose(); - } - images = null; - } - if (browserFont != null) browserFont.dispose (); - browserFont = null; - } - - /** - * Gets an image from a path relative to the plugin install directory. - * - * @param pd the plugin descriptor for the plugin with the image - * @param iconPath the path relative to the install directory - * @return the image, or null if not found - */ - private static Image getImageFromPlugin(Bundle bundle, String iconPath) { - InputStream is = null; - try { - URL installUrl = bundle.getEntry("/"); - URL url = new URL(installUrl, iconPath); - is = url.openConnection().getInputStream(); - ImageData source = new ImageData(is); - ImageData mask = source.getTransparencyMask(); - Image image = new Image(null, source, mask); - return image; - } catch (Throwable ex) { - return null; - } finally { - try { - if (is != null) is.close(); - } catch (IOException e) { - } - } - } -} diff --git a/examples/org.eclipse.swt.examples.ole.win32/src/org/eclipse/swt/examples/ole/win32/OleWebBrowser.java b/examples/org.eclipse.swt.examples.ole.win32/src/org/eclipse/swt/examples/ole/win32/OleWebBrowser.java deleted file mode 100755 index 4498813c2b..0000000000 --- a/examples/org.eclipse.swt.examples.ole.win32/src/org/eclipse/swt/examples/ole/win32/OleWebBrowser.java +++ /dev/null @@ -1,228 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.swt.examples.ole.win32; - - -import org.eclipse.swt.ole.win32.*; - -/** - * Wrapper for an OleAutomation object used to send commands - * to a Win32 "Shell.Explorer" OLE control. - * - * Instances of this class manage the setup, typical use and teardown of - * a simple web browser. - */ -class OleWebBrowser { - /* See the Windows Platform SDK documentation for more information about the - * OLE control used here and its usage. - */ - // Generated from typelib filename: shdocvw.dll - - // Constants for WebBrowser CommandStateChange - public static final int CSC_UPDATECOMMANDS = -1; - public static final int CSC_NAVIGATEFORWARD = 1; - public static final int CSC_NAVIGATEBACK = 2; - - // COnstants for Web Browser ReadyState - public static final int READYSTATE_UNINITIALIZED = 0; - public static final int READYSTATE_LOADING = 1; - public static final int READYSTATE_LOADED = 2; - public static final int READYSTATE_INTERACTIVE = 3; - public static final int READYSTATE_COMPLETE = 4; - - // Web Browser Control Events - public static final int BeforeNavigate = 100; // Fired when a new hyperlink is being navigated to. - public static final int NavigateComplete = 101; // Fired when the document being navigated to becomes visible and enters the navigation stack. - public static final int StatusTextChange = 102; // Statusbar text changed. - public static final int ProgressChange = 108; // Fired when download progress is updated. - public static final int DownloadComplete = 104; // Download of page complete. - public static final int CommandStateChange = 105; // The enabled state of a command changed - public static final int DownloadBegin = 106; // Download of a page started. - public static final int NewWindow = 107; // Fired when a new window should be created. - public static final int TitleChange = 113; // Document title changed. - public static final int FrameBeforeNavigate = 200; // Fired when a new hyperlink is being navigated to in a frame. - public static final int FrameNavigateComplete = 201; // Fired when a new hyperlink is being navigated to in a frame. - public static final int FrameNewWindow = 204; // Fired when a new window should be created. - public static final int Quit = 103; // Fired when application is quiting. - public static final int WindowMove = 109; // Fired when window has been moved. - public static final int WindowResize = 110; // Fired when window has been sized. - public static final int WindowActivate = 111; // Fired when window has been activated. - public static final int PropertyChange = 112; // Fired when the PutProperty method has been called. - - // Web Browser properties - public static final int DISPID_READYSTATE = -525; - - private OleAutomation oleAutomation; - - /** - * Creates a Web browser control. - * <p> - * Typical use:<br> - * <code> - * OleControlSite oleControlSite = new OleControlSite(oleFrame, style, "Shell.Explorer");<br> - * OleAutomation oleAutomation = new OleAutomation(oleControlSite);<br> - * OleWebBrowser webBrowser = new OleWebBrowser(oleControlSite, oleAutomation);<br> - * </code> - * - * @param oleAutomation the OleAutomation object for this control. - * @param oleControlSite the OleControlSite object for this control. - */ - public OleWebBrowser(OleAutomation oleAutomation) { - this.oleAutomation = oleAutomation; - } - - - /** - * Disposes of the Web browser control. - */ - public void dispose() { - if (oleAutomation != null) oleAutomation.dispose(); - oleAutomation = null; - } - - /* - * Interact with the Control via OLE Automation - * - * Note: You can hard code the DISPIDs if you know them beforehand - * this is of course the fastest way, but you increase coupling - * to the control. - */ - - /** - * Returns the current web page title. - * - * @return the current web page title String - */ - public String getLocationName() { - // dispid=210, type=PROPGET, name="LocationName" - int[] rgdispid = oleAutomation.getIDsOfNames(new String[]{"LocationName"}); - int dispIdMember = rgdispid[0]; - Variant pVarResult = oleAutomation.getProperty(dispIdMember); - if (pVarResult == null || pVarResult.getType() != OLE.VT_BSTR) return null; - return pVarResult.getString(); - } - - /** - * Returns the current URL. - * - * @return the current URL String - */ - public String getLocationURL() { - // dispid=211, type=PROPGET, name="LocationURL" - int[] rgdispid = oleAutomation.getIDsOfNames(new String[]{"LocationURL"}); - int dispIdMember = rgdispid[0]; - - Variant pVarResult = oleAutomation.getProperty(dispIdMember); - if (pVarResult == null || pVarResult.getType() != OLE.VT_BSTR) return null; - return pVarResult.getString(); - } - - /** - * Returns the current state of the control. - * - * @return the current state of the control, one of: - * READYSTATE_UNINITIALIZED; - * READYSTATE_LOADING; - * READYSTATE_LOADED; - * READYSTATE_INTERACTIVE; - * READYSTATE_COMPLETE. - */ - public int getReadyState() { - // dispid=4294966771, type=PROPGET, name="ReadyState" - int[] rgdispid = oleAutomation.getIDsOfNames(new String[]{"ReadyState"}); - int dispIdMember = rgdispid[0]; - - Variant pVarResult = oleAutomation.getProperty(dispIdMember); - if (pVarResult == null || pVarResult.getType() != OLE.VT_I4) return -1; - return pVarResult.getInt(); - } - - /** - * Navigates backwards through previously visited web sites. - */ - public void GoBack() { - - // dispid=100, type=METHOD, name="GoBack" - int[] rgdispid = oleAutomation.getIDsOfNames(new String[]{"GoBack"}); - int dispIdMember = rgdispid[0]; - oleAutomation.invoke(dispIdMember); - } - - /** - * Navigates backwards through previously visited web sites. - */ - public void GoForward() { - - // dispid=101, type=METHOD, name="GoForward" - int[] rgdispid = oleAutomation.getIDsOfNames(new String[]{"GoForward"}); - int dispIdMember = rgdispid[0]; - oleAutomation.invoke(dispIdMember); - } - - /** - * Navigates to home page. - */ - public void GoHome() { - // dispid=102, type=METHOD, name="GoHome" - int[] rgdispid = oleAutomation.getIDsOfNames(new String[]{"GoHome"}); - int dispIdMember = rgdispid[0]; - oleAutomation.invoke(dispIdMember); - } - - /** - * Navigates to user-specified Web search gateway. - */ - public void GoSearch() { - // dispid=103, type=METHOD, name="GoSearch" - int[] rgdispid = oleAutomation.getIDsOfNames(new String[]{"GoSearch"}); - int dispIdMember = rgdispid[0]; - oleAutomation.invoke(dispIdMember); - } - - /** - * Navigates to a particular URL. - */ - public void Navigate(String url) { - // dispid=104, type=METHOD, name="Navigate" - int[] rgdispid = oleAutomation.getIDsOfNames(new String[]{"Navigate", "URL"}); - int dispIdMember = rgdispid[0]; - - Variant[] rgvarg = new Variant[1]; - rgvarg[0] = new Variant(url); - int[] rgdispidNamedArgs = new int[1]; - rgdispidNamedArgs[0] = rgdispid[1]; // identifier of argument - oleAutomation.invoke(dispIdMember, rgvarg, rgdispidNamedArgs); - } - - /** - * Refreshes the currently viewed page. - * - * @return the platform-defined result code for the "Refresh" method invocation - */ - public void Refresh(){ - // dispid= 4294966746, type=METHOD, name="Refresh" - int[] rgdispid = oleAutomation.getIDsOfNames(new String[]{"Refresh"}); - int dispIdMember = rgdispid[0]; - oleAutomation.invokeNoReply(dispIdMember); - } - - /** - * Aborts loading of the currnet page. - * - * @return the platform-defined result code for the "Stop" method invocation - */ - public void Stop() { - // dispid=106, type=METHOD, name="Stop" - int[] rgdispid = oleAutomation.getIDsOfNames(new String[]{"Stop"}); - int dispIdMember = rgdispid[0]; - oleAutomation.invoke(dispIdMember); - } -} |