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-2000 Sun
 * Microsystems, Inc. All Rights Reserved.
 */

package org.netbeans.modules.vcscore.settings;

import org.openide.options.SystemOption;
import org.openide.util.NbBundle;
import java.io.*;
import org.openide.util.SharedClassObject;


/**
 * The settings for all VCS filesystems.
 * @author  Milos Kleint, Martin Entlicher
 */
public class VcsSettings extends SystemOption {

    
    private static final int AUTO_REFRESH_NO_REFRESH = 0;
    private static final int AUTO_REFRESH_ON_DIR_OPEN = 1;
    private static final int AUTO_REFRESH_ON_MOUNT = 2;
    private static final int AUTO_REFRESH_ON_RESTART = 3;
    private static final int AUTO_REFRESH_ON_MOUNT_AND_RESTART = 4;
    
    private static final String DEFAULT_CVS_EXEC = "cvs";   // NO I18N
    private static final String DEFAULT_SHELL_EXEC = "sh";  // NO I18N

    private static boolean useGlobal = true;

    private static boolean offLine = false;

    private static int autoRefresh = AUTO_REFRESH_ON_DIR_OPEN;

    private static boolean hideShadowFiles = false;
    
    private static String wizardCvsCommandPath;
    
    private static String wizardShellCommandPath;
    
    private static java.util.LinkedList wizardDirectoryCache;
    
    static final long serialVersionUID = 2366734217889995634L;
    /** Creates new VcsSettings */
    public VcsSettings() {
    }

    /** Get human presentable name */
    public String displayName() {
        return NbBundle.getBundle(VcsSettings.class).getString("CTL_VcsSettings");
    }
    
    public void readExternal(ObjectInput in)
     throws IOException, ClassNotFoundException {
        super.readExternal(in);
        GeneralVcsSettings settings = (GeneralVcsSettings)SharedClassObject.findObject(
                                       GeneralVcsSettings.class, true);         
// for back compat. only..
        settings.setUseGlobal(useGlobal);
        settings.setOffLine(offLine);
        settings.setHome(new File(getHome()));
        settings.setHideShadowFiles(hideShadowFiles);
        settings.setAutoRefresh(autoRefresh);
    }
    
    /** Whether these settings overide the filesystem settings.
     */
    public boolean isUseGlobal() {
        return useGlobal;
    }

    /** Set whether these settings overide the filesystem settings.
     */
    public void setUseGlobal(boolean global) {
           useGlobal = global;
   }
    
    /** Getter for property offLine.
     * @return Value of property offLine.
     */
    public boolean isOffLine() {
        return offLine;
    }
    
    /** Setter for property offLine.
     * @param offLine New value of property offLine.
     */
    public void setOffLine(boolean newOffLine) {
            offLine = newOffLine;
    }
    
    /** Getter for property autoRefresh.
     * @return Value of property autoRefresh.
     */
    public int getAutoRefresh() {
        return autoRefresh;
    }
    
    /** Setter for property autoRefresh.
     * @param autoRefresh New value of property autoRefresh.
     */
    public void setAutoRefresh(int newAutoRefresh) {
            autoRefresh = newAutoRefresh;
    }
    
    public String getHome() {
        String home = System.getProperty("Env-HOME");
        if (home == null && org.openide.util.Utilities.isWindows()) {
            String homeDrive = System.getProperty("Env-HOMEDRIVE");
            String homeDir = System.getProperty("Env-HOMEPATH");
            if (homeDrive != null && homeDir != null) {
                home = homeDrive + homeDir;
            }
        }
        return home;
    }
    
    public void setHome(String home) {
        if (home == null) return ;
        System.setProperty("Env-HOME", home);
        System.setProperty("env-home", home.toLowerCase());
        if (org.openide.util.Utilities.isWindows()) {
            int index = home.indexOf(':');
            if (index > 0) {
                String homeDrive = home.substring(0, index + 1);
                String homeDir = (index + 1 < home.length()) ? home.substring(index + 1) : "\\";
                System.setProperty("Env-HOMEDRIVE", homeDrive);
                System.setProperty("env-homedrive", homeDrive.toLowerCase());
                System.setProperty("Env-HOMEPATH", homeDir);
                System.setProperty("env-homepath", homeDir.toLowerCase());
            }
        }
    }
    
    /**
     * If true, hides all shadow files in the filesystems. 
     * "Shadow" means files that don't exist in working directory.
     * Usually these are Locally-Removed, Needs-Checkout files
     */
    public void setHideShadowFiles(boolean hide) {
            hideShadowFiles = hide;
    }

    /**
     * If true, hides all shadow files in the filesystems. 
     * "Shadow" means files that don't exist in working directory.
     * Usually these are Locally-Removed, Needs-Checkout files
     */
    public boolean isHideShadowFiles() {
        return hideShadowFiles;
    }
    
}
... 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.