alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

What this is

This file is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Other links

The source code

<?xml version="1.0" encoding="UTF-8"?>
<cheatsheet title="Create the Eclipse Browser view">
   <intro>
      <description>
         This cheat sheet will demonstrate how to create and deploy a plug-in that extends the Eclipse Browser product.
      </description>
   </intro>
   <item title="Create a new plug-in project" dialog="true" skip="false">
      <description>
         To create a new plug-in project, perform the following steps:
      </description>
      <subitem label="Select "File->New->Project..." from the main menu to bring up the "New Project" wizard.  Expand the "Plug-in Development" category, choose "Plug-in Project" and press "Next"." skip="false">
      </subitem>
      <subitem label="Input "com.example.xyz" into the "Project Name" text box.  Accept all defaults and press "Next"." skip="false">
      </subitem>
      <subitem label="Accept all default values on the "Plug-in Content" page and press "Finish".  A new plug-in project will be created and the plug-in manifest editor will open automatically." skip="false">
      </subitem>
   </item>
   <item title="Add an HTML Browser extension" dialog="true" skip="false">
      <description>
         To add an HTML Browser extension, perform the following steps:
      </description>
      <subitem label="Open the com.example.xyz/plugin.xml file." skip="true">
         <command serialization="org.eclipse.ui.navigate.openResource(filePath=org.eclipse.browser/plugin.xml)" confirm="false">
         </command>
      </subitem>
      <subitem label="On the "Extensions" page of the plug-in manifest editor, press the "Add..." button to open the "New Extension" wizard." skip="false">
      </subitem>
      <subitem label="Deselect the checkbox labeled "Show only extension points from the required plug-ins"." skip="false">
      </subitem>
      <subitem label="Select "org.eclipse.browser.htmlBrowsers" from the "Extension Points" list box and press "Finish"." skip="false">
      </subitem>
      <subitem label="Choose "Yes" when prompted "Do you want to add plug-in org.eclipsecon.browser, declaring the htmlBrowsers extension point, to the list of plug-in dependencies?"." skip="false">
      </subitem>
      <subitem label="(Eclipse 3.2 Only) Right-click on the "org.eclipse.browser.htmlBrowsers" node and select "New->browser" from the context menu." skip="true">
      </subitem>
      <subitem label="Replace the content of the "id" text box under "Extension Element Details" with "com.example.xyz.externalBrowser"." skip="false">
      </subitem>
      <subitem label="Replace the content of the "name" text box under "Extension Element Details" with "External Browser"." skip="false">
      </subitem>
      <subitem label="Replace the content of the "class" text box under "Extension Element Details" with "com.example.xyz.ExternalBrowser"." skip="false">
      </subitem>
      <subitem label="Save the file via "File > Save" from the main menu." skip="false">
      </subitem>
   </item>
   <item title="Implement the browser extension" dialog="true" skip="false">
      <description>
         To implement the browser extension, perform the following steps:
      </description>
      <subitem label="Click on the "class" link in the "Extension Element Details" section to bring up the "New Java Class" wizard." skip="false">
      </subitem>
      <subitem label="Accept all defaults in the wizard, and press Finish.  This will create and open an ExternalBrowser.java file." skip="false">
      </subitem>
      <subitem label="In the ExternalBrowser.java file, implement the body of the run() method as follows:  try { 	IWorkbenchBrowserSupport support = 			PlatformUI.getWorkbench().getBrowserSupport(); IWebBrowser browser = support.getExternalBrowser(); browser.openURL(url); } catch (PartInitException e) { }" skip="false">
      </subitem>
      <subitem label="Save the ExternalBrowser.java file via "File > Save" from the main menu." skip="false">
      </subitem>
   </item>
   <item title="Export the plug-in" dialog="true" skip="false">
      <description>
         To export the plug-in, perform the following steps:
      </description>
      <subitem label="Select File > Export...> Plug-in Development > Deployable plug-ins and fragments from the main menu." skip="false">
      </subitem>
      <subitem label="Select the "com.example.xyz" plug-in." skip="false">
      </subitem>
      <subitem label="On the "Destination" tab, make sure the "Directory option is selected." skip="true">
      </subitem>
      <subitem label="Input the location of the root directory of the Eclipse Browser product, e.g. "C:\destination\browser"." skip="false">
      </subitem>
      <subitem label="Press Finish." skip="false">
      </subitem>
   </item>
   <item title="Launch the product" dialog="true" skip="false">
      <description>
         To launch the product and observe the new plug-in in action, perform the following steps:
      </description>
      <subitem label="Navigate to the Eclipse Browser product root directory, and double-click on the browser executable." skip="false">
      </subitem>
      <subitem label="When the application starts, note how the Browser view now has a drop down menu." skip="false">
      </subitem>
      <subitem label="Press the view's drop down arrow to see the content of the drop down menu." skip="false">
      </subitem>
      <subitem label="Observe how it contains two items:  "External Browser" (contributed by the com.example.xyz plug-in) and "Internal Browser" contributed by the org.eclipse.browser plug-in." skip="false">
      </subitem>
      <subitem label="Toggle back and forth between the two browser options, and observe how the browser setting is honored when you double-click on a node in the tree to open the website." skip="false">
      </subitem>
      <subitem label="Close the application via "File > Exit" from the main menu." skip="false">
      </subitem>
   </item>
</cheatsheet>
... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.