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

/**
 *
 * @author  mkleint
 * @version 
 */
import org.openide.filesystems.AbstractFileSystem;
import org.netbeans.modules.javacvs.commands.JavaCvsStatusManager;
import org.netbeans.modules.javacvs.caching.*;
import org.netbeans.modules.javacvs.JavaCvsFileSystem;
import org.netbeans.modules.cvsclient.JavaCvsSettings;
import org.netbeans.modules.vcscore.cache.*;
import org.netbeans.modules.vcscore.annotation.AnnotationProvider;
import org.netbeans.modules.vcscore.annotation.AnnotationSupport;
import org.netbeans.modules.cvsclient.NbJavaCvsStatusManager;
import org.netbeans.modules.cvsclient.NbJavaCvsFileSystem;
import org.openide.util.*;
import org.openide.filesystems.FileObject;
import java.util.*;
import java.io.*;
import java.lang.ref.*;
import java.text.MessageFormat;
import java.util.ResourceBundle;
import org.openide.util.SharedClassObject;
import org.netbeans.modules.cvsclient.commands.ErrorLogPanel;
import org.netbeans.modules.javacvs.commands.FileSystemCommand;
import org.netbeans.modules.javacvs.commands.CvsStatus;
import org.netbeans.modules.cvsclient.commands.JavaCvsRuntimeCommand;
import org.netbeans.modules.cvsclient.JavaCvsRuntimeCommandsProvider;
import org.netbeans.modules.vcscore.runtime.RuntimeCommandsProvider;



public class NbCvsFsCache extends CvsFsCache {


    private final String MEGABYTE_STRING;
    private final String KILOBYTE_STRING;
    private final String BYTE_STRING;
    
    /** Creates new CvsFsCache */
    public NbCvsFsCache(AbstractFileSystem fs, File homeDirectory) {
        super(fs, homeDirectory);
        AnnotationSupport.PatternType patternType = AnnotationSupport.getInstance().registerPatternType(JavaCvsSettings.ANNOTATION_TYPE);
        if (patternType.getPatternsAsArray().length == 0) {
            JavaCvsSettings settings = (JavaCvsSettings)SharedClassObject.findObject(JavaCvsSettings.class, true);
            patternType.setStringPattern(settings.getAnnotationPattern());
            patternType.addMultiSynchPattern(AnnotationSupport.ANNOTATION_PATTERN_FILE_NAME, JavaCvsStatusManager.NOT_IN_SYNCH);
            patternType.addMultiListPattern(AnnotationSupport.ANNOTATION_PATTERN_STATUS, ","); //NOI18N
            patternType.addMultiEmptyPattern(AnnotationSupport.ANNOTATION_PATTERN_REVISION);
            patternType.addMultiEmptyPattern(AnnotationSupport.ANNOTATION_PATTERN_LOCKER);
            patternType.addMultiEmptyPattern(AnnotationSupport.ANNOTATION_PATTERN_STICKY);
            patternType.addMultiEmptyPattern(AnnotationSupport.ANNOTATION_PATTERN_ATTR);
            patternType.addMultiEmptyPattern(AnnotationSupport.ANNOTATION_PATTERN_SIZE);
            patternType.addMultiEmptyPattern(AnnotationSupport.ANNOTATION_PATTERN_DATE);
            patternType.addMultiEmptyPattern(AnnotationSupport.ANNOTATION_PATTERN_TIME);
        }
        ResourceBundle bundle = NbBundle.getBundle(NbCvsFsCache.class);
        MEGABYTE_STRING = bundle.getString("LBL_Megabyte_Sign"); //NOI18N
        KILOBYTE_STRING = bundle.getString("LBL_Kilobyte_Sign"); //NOI18N
        BYTE_STRING = bundle.getString("LBL_Byte_Sign"); //NOI18N
    }
    
/*    public static JavaCvsCache getCacheObject() {
        if (cacheObject == null) {
            cacheObject = new NbJavaCvsCache();
        }
        return cacheObject;
    }
 */
    
    protected JavaCvsStatusManager getStatusManager() {
        return NbJavaCvsStatusManager.getInstance();
    }

    /** Performs status check on the specified "important" file(s)..
     * see JavaCvsFileSystem.annotateName()
     */
    public String getStatus(String nodeName, Vector importantFiles) {
        int currentStrategy;
/*        if (autoRefresh == JavaCvsFileSystem.AUTO_SIMPLE) {
            currentStrategy = CacheHandler.STRAT_DISK_OR_REFRESH;
        } else {
 **/
            currentStrategy = CacheHandler.STRAT_DISK;
//        }
        
        String status=""; // NOI18N
        int len = importantFiles.size();
        CacheFile file=null;
        String name;
        String fullName;
        String stat;

        //D.deb("len="+len); // NOI18N
        if( len < 1 ){
            return getStatusManager().getStatus(JavaCvsStatusManager.UNKNOWN);
        }
        else {
            if (autoRefresh == JavaCvsFileSystem.AUTO_SIMPLE) {
                name = (String) importantFiles.elementAt(0);
                File fl = new File(fsRootFile.getPath(), name);
                if (fl.getParentFile() != null) {
                    fl = fl.getParentFile();
                    checkDirectoryAutorefresh(fl, false);
                }
            }
            if( len==1 ){
                name = (String) importantFiles.elementAt(0);
                File fl = new File(fsRootFile.getPath(), name);
                if (fl != null) {
                    file = CacheHandler.getInstance().getCacheFile(fl, adjustStrategy(currentStrategy), this);
                }
                if (file != null) {
                    AnnotationSupport support = AnnotationSupport.getInstance();
                    JavaCvsAnnProvider annProvider = new JavaCvsAnnProvider(file, name);
                    stat = support.getStatusAnnotation(nodeName, name, annProvider, JavaCvsSettings.ANNOTATION_TYPE);
                }
                else stat = nodeName; // when we do not have status, return just the node name
                return stat;
            }
        }
        // for multidata objects do the following
        //D.deb("status="+status); // NOI18N
/*        String result = getStatusManager().getStatus(JavaCvsStatusManager.NOT_IN_SYNCH);
        name = (String) importantFiles.elementAt(0);
//        String rootDir = cvsfs.getRootDirectory().getAbsolutePath();
//        fullName = rootDir + File.separator + name;
        File fl = new File(fsRootFile.getAbsolutePath(), name);
        if (fl != null) {
            file = handler.getCacheFile(fl, adjustStrategy(currentStrategy), this);
        }
        if (file != null) stat = getStatusManager().getStatus(file.getStatus());
        else stat = "";
//        stat = file.getStatus();
  */      
        HashMap cacheFileMap = new HashMap(len);
        ArrayList fileList = new ArrayList(len);
        for(int i=0;i 1) {
            long megsLong = Math.round(megs * 100);
            double flMegs = (double)megsLong / 100;
            return Double.toString(flMegs) + MEGABYTE_STRING;
        }
        double kbytes = (double)size / 1024;
        if (kbytes > 1) {
            long kbytesLong = Math.round(kbytes * 100);
            double flKbytes = (double)kbytesLong / 100;
            return Double.toString(flKbytes) + KILOBYTE_STRING;
        }
        return Long.toString(size, 0)+ BYTE_STRING;
    }
    
}
... 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.