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.modules.cvsclient;

import org.openide.modules.ModuleInstall;
import org.openide.util.SharedClassObject;
import org.netbeans.modules.javacvs.JavaCvsFileSystem;
import org.netbeans.modules.javacvs.caching.*;
import org.netbeans.modules.vcscore.cache.*;
import org.openide.options.SystemOption;
import org.netbeans.modules.vcscore.settings.GeneralVcsSettings;
import org.openide.filesystems.*;
import java.util.Iterator;
import java.util.LinkedList;
import org.openide.windows.TopComponent;
import org.openide.windows.WindowManager;

/**
 *
 * @author  Milos Kleint
 */
public class JavaCvsModuleInstall extends ModuleInstall {
    private static long serialVersionUID = -5817622809928676346L;
    
    /** Creates new JavaCvsModuleInstall */
    public JavaCvsModuleInstall() {
    }

    /**
     * Called when the module is uninstalled (from a running IDE).
     * Should remove whatever functionality from the IDE that it had registered.
     */
    public void uninstalled() {
/*        JavaCvsSettings settings = (JavaCvsSettings)SharedClassObject.findObject(
                                       JavaCvsSettings.class, false); 
        GeneralVcsSettings general = (GeneralVcsSettings)SharedClassObject.findObject(
                                       GeneralVcsSettings.class, true); 
        if (settings != null) {
            general.removeOption(settings);
        } 
        Repository repos = TopManager.getDefault().getRepository();
        FileSystem[] arr = repos.toArray();
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] instanceof org.netbeans.modules.javacvs.JavaCvsFileSystem) {
                repos.removeFileSystem(arr[i]);
            }
        }
 */
        super.uninstalled();
        // close all opened javacvs top components.
        Iterator it = WindowManager.getDefault().getRegistry().getOpened().iterator();
        LinkedList myList = new LinkedList();
        while (it.hasNext()) {
            TopComponent comp = (TopComponent)it.next();
            if (comp.getClass().getName().startsWith("org.netbeans.modules.cvsclient")) { //NOI18N
                myList.add(comp);
            }
        }
        it = myList.iterator();
        while (it.hasNext()) {
            TopComponent c = (TopComponent)it.next();
            c.close();
        }
        CacheHandler.getInstance().unregistedType(JavaCvsCache.JAVA_CACHE_NAME);
/*        CvsClientAction clientAction = (CvsClientAction)org.openide.util.SharedClassObject.findObject(CvsClientAction.class);
        if (clientAction != null) {
            clientAction.clearSharedData();
        }
 */
        FsCommandFactory.uninstall();
        
        
    }
    
    /**
     * Called when the module is first installed into the IDE.
     * Should perform whatever setup functions are required.
     * The default implementation calls restored.
     * 

Typically, would do one-off functions, and then also call {@link #restored}. */ public void installed() { /* JavaCvsSettings settings = (JavaCvsSettings)SharedClassObject.findObject( JavaCvsSettings.class, true); GeneralVcsSettings general = (GeneralVcsSettings)SharedClassObject.findObject( GeneralVcsSettings.class, true); general.addOption(settings); */ super.installed(); } /** * Called when an already-installed module is restored (at IDE startup time). * Should perform whatever initializations are required. */ public void restored() { super.restored(); /* JavaCvsSettings settings = (JavaCvsSettings)SharedClassObject.findObject( JavaCvsSettings.class, true); GeneralVcsSettings general = (GeneralVcsSettings)SharedClassObject.findObject( GeneralVcsSettings.class, true); SystemOption[] options = general.getOptions(); boolean doAdd = true; if (options == null || options.length == 0) { doAdd = true; } else { for (int i = 0; i < options.length; i++) { if (options[i] == settings) { doAdd = false; break; } } } if (doAdd) { general.addOption(settings); } */ } /* should not be nessesary since we store the cache when it changes now.. public void close() { super.close(); CacheHandler handler = CacheHandler.getInstance(); JavaCvsCache cache = (JavaCvsCache)handler.getCache(JavaCvsCache.JAVA_CACHE_NAME); if (cache != null) { if (!cache.isWrittenToDisk()) { cache.writeAllToDisk(); } } } */ }

... 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.