|
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.vcs.advanced.recognizer;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.File;
import java.util.Collection;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Map;
import java.util.Vector;
import org.openide.ErrorManager;
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileSystem;
import org.openide.filesystems.FileUtil;
import org.openide.filesystems.Repository;
import org.openide.util.Lookup;
import org.openide.util.WeakListener;
import org.netbeans.modules.vcscore.Variables;
import org.netbeans.modules.vcscore.VcsConfigVariable;
import org.netbeans.modules.vcscore.cmdline.VcsAdditionalCommand;
import org.netbeans.modules.vcscore.registry.FSInfo;
import org.netbeans.modules.vcscore.registry.FSRecognizer;
import org.netbeans.modules.vcscore.util.VcsUtilities;
import org.netbeans.modules.vcs.advanced.Profile;
import org.netbeans.modules.vcs.advanced.ProfilesFactory;
import org.netbeans.modules.vcs.advanced.variables.ConditionedVariables;
/**
*
* @author Martin Entlicher
*/
public class CommandLineFSRecognizer extends FSRecognizer implements PropertyChangeListener {
private static final String CONFIG_ROOT = "vcs/config"; // NOI18N
public static final String VAR_AUTORECOGNIZE_FROM_FILE = "AUTORECOGNIZE_FROM_FILE"; // NOI18N
public static final String VAR_AUTORECOGNIZE_FROM_COMMAND = "AUTORECOGNIZE_FROM_COMMAND"; // NOI18N
private Map variablesByProfileNames = new HashMap();
private Map displayTypesByProfileNames = new HashMap();
private Map commandsToFillByProfileNames = new HashMap();
/** Creates a new instance of Recognizer */
public CommandLineFSRecognizer() {
init();
}
private void init() {
ProfilesFactory profilesFactory = ProfilesFactory.getDefault();
profilesFactory.addPropertyChangeListener(WeakListener.propertyChange(this, profilesFactory));
String profileNames[] = profilesFactory.getProfilesNames();
for (int i = 0; i < profileNames.length; i++) {
if (profilesFactory.isOSCompatibleProfile(profileNames[i])) {
registerProfile(profilesFactory.getProfile(profileNames[i]));
}
}
}
private void registerProfile(Profile profile) {
String profileName = profile.getName();
ConditionedVariables cvars = profile.getVariables();
Collection profileVars = cvars.getSelfConditionedVariables(profile.getConditions(), Variables.getDefaultVariablesMap());
Hashtable profileVarsByName = new Hashtable();
variablesByProfileNames.put(profileName, profileVarsByName);
for (Iterator varIt = profileVars.iterator(); varIt.hasNext(); ) {
VcsConfigVariable var = (VcsConfigVariable) varIt.next();
if (VAR_AUTORECOGNIZE_FROM_FILE.equals(var.getName())) {
String autorecFromFileStr = var.getValue();
} else if (VAR_AUTORECOGNIZE_FROM_COMMAND.equals(var.getName())) {
String className = var.getValue();
Class execClass = null;
try {
execClass = Class.forName(className, true, VcsUtilities.getSFSClassLoader());
//org.openide.TopManager.getDefault().currentClassLoader());
} catch (ClassNotFoundException e) {}
if (execClass == null) {
try {
execClass = Class.forName(className, true,
(ClassLoader) Lookup.getDefault().lookup(ClassLoader.class));
} catch (ClassNotFoundException e) {
ErrorManager.getDefault().notify(e);
}
}
if (execClass != null) commandsToFillByProfileNames.put(profileName, execClass);
}
profileVarsByName.put(var.getName(), var.getValue());
}
}
/*
private Map getCmdFillVars(String autoFillVarsStr) {
String[] varsCmds = VcsUtilities.getQuotedStrings(autoFillVarsStr);
Map autoFillVars = new HashMap();
for (int i = 0; (i + 1) < varsCmds.length; i += 2) {
autoFillVars.put(varsCmds[i], varsCmds[i+1]);
}
return autoFillVars;
}
*/
/**
* Get a filesystem info for the given physical folder.
* @param folder The folder, that is to be recognized.
* @return Filesystem info for the given folder or
|
... 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.