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

package com.example.nb.tutorial.chapter_4;

import org.openide.TopManager;
import org.openide.modules.ModuleInstall;
import org.openide.windows.WindowManager;
import org.openide.windows.Workspace;

/** Manages the lifecycle of our 'chapter_4' tutorial module.
 *
 * @author adams
 */
public class TestModuleInstaller extends ModuleInstall {

    /**
     * Do the "one-off" functions, then called restored().
     */
    public void installed() 
    {
        // create the Workspace:
        TopManager tm = TopManager.getDefault();
        WindowManager wm = tm.getWindowManager();
        Workspace newWs = wm.createWorkspace("tutorial", "Tutorial"); //NOI18N
        
        // to make the Workspace visible, get an array of the 
        // existing Workspaces, add our new Workspace, then 
        // set the Workspaces with the new array:
        Workspace oldArray[] = wm.getWorkspaces();
        Workspace newArray[] = new Workspace[oldArray.length + 1];
        System.arraycopy(oldArray, 0, newArray, 0, oldArray.length);
        newArray[oldArray.length] = newWs;
        wm.setWorkspaces(newArray);
        
        // now call restored, which we are not currently overriding:
        restored ();
    }

    /**
     * Remove the "Tutorial" Workspace we installed.
     */
    public void uninstalled() 
    {
        // get a TopManager, then the WindowManager:
        TopManager tm = TopManager.getDefault();
        WindowManager wm = tm.getWindowManager();
        
        // remove the workspace from the list.  be smart
        // if it's not there, mostly because we're creating
        // a new smaller array if it is:
        Workspace oldArray[] = wm.getWorkspaces();
        int j = -1;
        for (int i=0; i -1)
        {
            Workspace newArray[] = new Workspace[oldArray.length - 1];
            int newCtr = 0;
            for (int i=0; i
... 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.