LaunchBrowser.java Sample
This topic inludes the source code for the LaunchBrowser.java Sample.
Sample Location
This sample is located in the following directory in your WebLogic Workshop installation:
BEA_HOME/weblogic81/samples/workshop/ExtensionDevKit/IdeDevKit/ToolbarButton/src/ideExtensions/toolbarButton/
Sample Source Code
01 package ideExtensions.toolbarButton;
02
03 import com.bea.ide.actions.DefaultAction;
04 import com.bea.ide.ui.browser.BrowserSvc;
05 import com.bea.ide.ui.frame.FrameSvc;
06 import com.bea.ide.core.MessageSvc;
07
08 import java.awt.event.ActionEvent;
09 import java.net.URL;
10
11 /**
12 * An action behind a toolbar button. The button simply launches
13 * a browser with the URL in the code below. This class extends DefaultAction,
14 * which in turn implements IAction. Action extensions such as menu
15 * commands and toolbar buttons implement the IAction interface's actionPerformed
16 * method to provide logic for the action. The IDE calls actionPerformed
17 * when the command is selected by the IDE's user.
18 *
19 * The extension.xml file provided in the META-INF folder of the ToolbarButton
20 * sample specifies this class as the handler for the button action.
21 */
22 public class LaunchBrowser extends DefaultAction
23 {
24 /**
25 * Launches a browser to the URL given in code. This method is
26 * called by the IDE when the user clicks the "Favorites" button.
27 *
28 * @param e The menu click event that occurred in the IDE.
29 */
30 public void actionPerformed(ActionEvent e)
31 {
32 try
33 {
34 BrowserSvc.get().invokeBrowser(new URL("http://dev2dev.bea.com"), true);
35 }
36 catch(Exception ex)
37 {
38 // Display a debugging message in the IDE's Output window.
39 MessageSvc.get().debugLog("Error while displaying favorite: "
40 + ex.getLocalizedMessage());
41 }
42 }
43 }
|