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

/*
 * ExplorerAction.java
 *
 * Created on 12 July 2001 1517 MDT
 */

package com.example.nb.tutorial.chapter_4;

import org.openide.TopManager;
import org.openide.nodes.Node;
import org.openide.util.HelpCtx;
import org.openide.util.actions.CallableSystemAction;
import org.openide.windows.WindowManager;
import org.openide.windows.Workspace;

/**
 *
 * @author  adams
 * @version 1.0
 */
public class ExplorerAction extends CallableSystemAction
{

    /** Creates new ExplorerAction */
    public ExplorerAction() {
    }

    public String getName() 
    {
        return "Pop Explorer Now!"; //NOI18N
    }

    public HelpCtx getHelpCtx()
    {
        return HelpCtx.DEFAULT_HELP;
    }

    protected String iconResource()
    {
        return "/com/example/nb/tutorial/chapter_4/explore16.gif"; //NOI18N
    }
    
    /**
     * This method will do nothing more than pop an explorer
     * for now.  more to come later!
     */
    public void performAction () 
    {
        // almost always need one of these:
        TopManager tm = TopManager.getDefault();

        // switch to the tutorial workspace 
        // before popping the explorer:
        WindowManager wm = tm.getWindowManager();
        Workspace tutorial = wm.findWorkspace("tutorial"); //NOI18N
        if (tutorial != null)
        {
            tutorial.activate();
        }
        
        // get a node to explore (see OpenAPI javadocs), then call
        // convenience method in TopManager.NodeOperation to explore:
        Node nodeToExplore = tm.getPlaces().nodes().repository();
        tm.getNodeOperation().explore(nodeToExplore);
        
    }
}
... 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.