|
What this is
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 java.beans.PropertyVetoException; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.io.NotActiveException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.ObjectStreamException; import java.util.HashMap; import java.util.HashSet; import java.util.Hashtable; import java.util.Iterator; import java.util.Map; import java.util.Set; import java.util.Vector; import org.openide.filesystems.AbstractFileSystem; import org.openide.filesystems.DefaultAttributes; import org.openide.filesystems.FileSystem; import org.openide.filesystems.FileStateInvalidException; import org.openide.filesystems.FileObject; import org.netbeans.modules.vcscore.VcsConfigVariable; import org.netbeans.modules.vcs.advanced.CommandLineVcsFileSystem; import org.netbeans.modules.vcs.advanced.Profile; import org.netbeans.modules.vcs.advanced.variables.Condition; import org.netbeans.modules.vcs.advanced.variables.ConditionedVariables; /** An almost empty copy of NetBeans JavaCVS file system. * This class acts as a transfer from NbJavaCvsFileSystem located in javacvs module to * CommandLineVcsFileSystem with the appropriate CVS profile located in * vcsgeneric module. * Since javacvs module was removed from the standard distribution, the * filesystems mounted via NbJavaCvsFileSystem are deserialized and converted * to CommandLineVcsFileSystem with CVS profile. * * @author Martin Entlicher */ public class NbJavaCvsFileSystem extends org.netbeans.modules.javacvs.JavaCvsFileSystem { // implements VcsSearchTypeFileSystem, VirtualsRefreshing { static final long serialVersionUID = 7883103611633487336L; public static final String PROP_USER_INTERFACE_MODE = "uiMode"; // NOI18N public static final String PROP_DISPLAY_TYPE = "displayType"; // NOI18N public static final String PROP_PROCESS_ALL_FILES = "processAllFiles"; //NOI18N public static final int MODE_NOVICE = 0; public static final int MODE_ADVANCED = 1; public static final int MODE_COMMAND_LINE = 2; public static final int DISP_TYPE_SIMPLE = 0; public static final int DISP_TYPE_FORMATTED = 1; public static final int DISP_TYPE_LIMITED = 2; // properties private int uiMode = 0; private int displayType = 1; /** Holds value of property processAllFiles. */ private boolean processAllFiles = false; // due to vcscore's cvs mount wizard. private boolean initialCheckout = false; //--- private String oldFsSystemName; private Integer numberOfFinishedCmdsToCollect; private Boolean versioningFileSystemShowMessage = null; private Integer versioningFileSystemMessageLength = null; private String versioningFileSystemIgnoreFiles = null; private static final String CONFIG_CVS = "cvs.xml"; // NOI18N public NbJavaCvsFileSystem() { // Create and use implementations of file system functionality: super(); // load defaults from the Settings object // cache = new CvsFsCache(this); // initCache(); /* JavaCvsSettings settings = (JavaCvsSettings)SharedClassObject.findObject( JavaCvsSettings.class, true); setOffLine(settings.isOffLine()); setUiMode(settings.getUiMode()); setAutoRefresh(settings.getAutoRefresh()); setDisplayType(settings.getDisplayType()); setHideShadowFiles(settings.isHideShadowFiles()); setProcessAllFiles(false); setHomeDirectory(settings.getHome()); */ } private CommandLineVcsFileSystem createCommandLineVcsFileSystem() { String configFileName; configFileName = CONFIG_CVS; CommandLineVcsFileSystem fs = new CommandLineVcsFileSystem(); fs.readConfiguration(configFileName); fs.setConfigFileName(configFileName); Vector vars = fs.getVariables(); HashMap varsByName = new HashMap(); for (int i = 0, n = vars.size (); i < n; i++) { VcsConfigVariable var = (VcsConfigVariable) vars.get (i); varsByName.put (var.getName (), var); } fs.setPreferredSystemName(getSystemName()); try { fs.setRootDirectory(getWorkingDir()); fs.setRelativeMountPoint(getRelMount()); } catch (PropertyVetoException pvex) { } catch (IOException ioex) { } setVar(vars, varsByName, "BUILT-IN", "true"); setVar(vars, varsByName, "SERVERTYPE", getCvsServerTypeName()); setVar(vars, varsByName, "CVS_SERVER", getCvsServerName()); setVar(vars, varsByName, "CVS_USERNAME", getCvsUserName()); setVar(vars, varsByName, "CVS_REPOSITORY", getCvsRepository()); setVar(vars, varsByName, CommandLineVcsFileSystem.VAR_ENVIRONMENT_PREFIX+"CVS_CLIENT_PORT", Integer.toString(getCvsPort())); fs.setVariables(vars); updateConditionalValues(fs); fs.setExpertMode(uiMode == MODE_ADVANCED || uiMode == MODE_COMMAND_LINE); //fs.setAnnotationPattern(getAnnotationPattern()); fs.setShortFileStatuses(true); // JavaCVS had shorted status names by default. fs.setAutoRefresh(getAutoRefresh()); fs.setCommandNotification(true); fs.setOffLine(isOffLine()); fs.setDebug(false); fs.setProcessUnimportantFiles(processAllFiles); fs.setHideShadowFiles(false); fs.setIgnoredGarbageFiles(getFsIgnoredFiles()); fs.setCreateBackupFiles(isCreateBackups()); fs.setRefreshTimeStored(getRefreshTime()); if (versioningFileSystemShowMessage != null) { fs.setVFSShowMessage(versioningFileSystemShowMessage.booleanValue()); } if (versioningFileSystemMessageLength != null) { fs.setVFSMessageLength(versioningFileSystemMessageLength.intValue()); } fs.setVFSShowGarbageFiles(versioningFileSystemIgnoreFiles); if (numberOfFinishedCmdsToCollect != null) { fs.setNumberOfFinishedCmdsToCollect(numberOfFinishedCmdsToCollect.intValue()); } fs.setHidden(isHidden()); fs.setReadOnly(isReadOnly()); return fs; } private void setVar(Vector vars, Map varsByName, String name, String value) { VcsConfigVariable var = (VcsConfigVariable) varsByName.get(name); if (var != null) { var.setValue(value); } else { var = new VcsConfigVariable(name, null, value, false, false, false, null); vars.add(var); varsByName.put(name, var); } } /** * Conditional variables should be updated when the variables change. * However we must pay attention not to alter variables, that were set * intentionally by the user in the customizer. Thus we should update * the variable values only when the condition result actually change. */ private static void updateConditionalValues(CommandLineVcsFileSystem fileSystem) { Profile profile = fileSystem.getProfile(); if (profile == null) return ; ConditionedVariables cVars = profile.getVariables(); Map conditionsByVariables = cVars.getConditionsByVariables(); Map varsByConditions = cVars.getVariablesByConditions(); if (conditionsByVariables.size() == 0) return ; Hashtable vars = fileSystem.getVariablesAsHashtable(); Map newVars = new HashMap(); Set removedVars = new HashSet(); for(Iterator it = conditionsByVariables.keySet().iterator(); it.hasNext(); ) { String name = (String) it.next(); Condition[] conditions = (Condition[]) conditionsByVariables.get(name); for (int i = 0; i < conditions.length; i++) { if (conditions[i].isSatisfied(vars)) { VcsConfigVariable var = (VcsConfigVariable) varsByConditions.get(conditions[i]); if (var != null) newVars.put(name, var); else removedVars.add(name); } } } Vector variables = fileSystem.getVariables(); for (int i = 0; i < variables.size(); i++) { VcsConfigVariable var = (VcsConfigVariable) variables.get(i); String name = var.getName(); VcsConfigVariable newVar = (VcsConfigVariable) newVars.get(name); if (newVar != null) { variables.set(i, newVar); } else if (removedVars.contains(name)) { variables.remove(i); } } fileSystem.setVariables(variables); } //------------------------------------------------------------------------------ // ---------------- serialization stuff //------------------------------------------- private void readObject(ObjectInputStream in) throws ClassNotFoundException, IOException, NotActiveException{ in.defaultReadObject(); } //------------------------------------------- private void writeObject(ObjectOutputStream out) throws IOException { out.defaultWriteObject(); } private Object readResolve() throws ObjectStreamException { return createCommandLineVcsFileSystem(); } // Dummy implementation of serialized classes so that the class can be // successfully deserialized. protected class NbInfoImpl extends InfoImpl { static final long serialVersionUID = -7503287378756255278L; public java.io.InputStream inputStream (String name) throws FileNotFoundException { return null; } public java.io.OutputStream outputStream(String name) throws IOException { return null; } } public class NbListImpl extends ListImpl { private static final long serialVersionUID = -6002001971220606463L; public String[] children (String name) { return null; } } public class JavaCvsAttributes extends DefaultAttributes { static final long serialVersionUID = 5320181565426569135L; public JavaCvsAttributes(AbstractFileSystem.Info info, AbstractFileSystem.Change change, AbstractFileSystem.List list) { super(info, change, list); } public Object readAttribute(String name, String attrName) { return null; } public void writeAttribute(final String name, final String attrName, final Object value) throws IOException, java.net.UnknownServiceException { } } } |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
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.