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

/*
 *                 Sun Public License Notice
 * 
 * The contents of this file are subject to the Sun Public License
 * Version 1.0 (the "License"). You may not use this file except in
 * compliance with the License. A copy of the License is available at
 * http://www.sun.com/
 * 
 * The Original Code is NetBeans. The Initial Developer of the Original
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun
 * Microsystems, Inc. All Rights Reserved.
 */

package org.netbeans.examples.modules.globalactions;

import org.openide.NotifyDescriptor;
import org.openide.DialogDisplayer;
import org.openide.cookies.OpenCookie;
import org.openide.nodes.Node;
import org.openide.util.HelpCtx;
import org.openide.util.NbBundle;
import org.openide.util.actions.CookieAction;

/** An example of a service action.
* Note that it is installed (and uninstalled) entirely by the manifest entry.
* 

Any node, menu item, etc. providing {@link org.openide.actions.ToolsAction} * will display it (at least when it is enabled). So for example, nodes by default * will display this action in the popup menu if they can be opened somehow. * Ditto for a group selection of nodes, all of which can be opened. * Also shown in main Tools menu. */ public class TestServiceAction extends CookieAction { // generated private static final long serialVersionUID =-3122862332875637686L; public String getName () { return NbBundle.getBundle (TestServiceAction.class).getString ("LBL_TestServiceAction"); } public HelpCtx getHelpCtx () { return HelpCtx.DEFAULT_HELP; } protected String iconResource () { return "org/netbeans/examples/modules/globalactions/testAction.gif"; } /** Be sensitive to objects which can be opened. */ protected Class[] cookieClasses () { return new Class[] { OpenCookie.class }; } /** Require that all selected objects be openable. */ protected int mode () { return MODE_ALL; } /** Open the selected files, after asking for user confirmation. */ protected void performAction (Node[] nodes) { if (NotifyDescriptor.OK_OPTION == DialogDisplayer.getDefault ().notify (new NotifyDescriptor.Confirmation (NbBundle.getBundle (TestServiceAction.class).getString ("MSG_really_open"), NotifyDescriptor.OK_CANCEL_OPTION))) for (int i = 0; i < nodes.length; i++) { OpenCookie cookie = (OpenCookie) nodes[i].getCookie (OpenCookie.class); if (cookie != null) cookie.open (); } } }

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 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.