|
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.versioning; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.*; import java.io.*; //import java.util.StringTokenizer; import org.openide.filesystems.AbstractFileSystem; import org.openide.filesystems.FileObject; import org.openide.filesystems.FileSystem; import org.openide.filesystems.FileSystemCapability; import org.openide.filesystems.FileStatusEvent; import org.openide.filesystems.FileStatusListener; import org.openide.util.*; import org.openide.util.actions.SystemAction; import org.netbeans.modules.vcscore.cache.CacheHandlerEvent; import org.netbeans.modules.vcscore.cache.CacheHandlerListener; import org.netbeans.modules.vcscore.versioning.RevisionChildren; import org.netbeans.modules.vcscore.annotation.AnnotationProvider; import org.netbeans.modules.vcscore.versioning.RevisionEvent; import org.netbeans.modules.vcscore.versioning.RevisionItem; import org.netbeans.modules.vcscore.versioning.RevisionList; import org.netbeans.modules.vcscore.versioning.RevisionListener; import org.netbeans.modules.vcscore.versioning.VersioningFileSystem; //import org.netbeans.modules.vcscore.versioning.VcsFileObject; import org.netbeans.modules.vcscore.versioning.VcsFileStatusEvent; import org.netbeans.modules.vcscore.versioning.impl.*; import org.netbeans.modules.vcscore.util.Table; import org.netbeans.modules.vcscore.util.VcsUtilities; import org.netbeans.modules.vcscore.annotation.AnnotationSupport; import org.netbeans.modules.vcscore.annotation.AnnotationProvider; //import org.netbeans.modules.vcscore.versioning.impl.NumDotRevisionChildren; import org.netbeans.modules.cvsclient.*; import org.netbeans.modules.cvsclient.caching.NbCvsFsCache; import org.netbeans.modules.javacvs.commands.AbstractWaitForResultsDisplayer; import org.netbeans.modules.javacvs.commands.CvsLog; import org.netbeans.modules.cvsclient.commands.ErrorLogPanel; import org.netbeans.lib.cvsclient.command.log.LogInformation; import org.netbeans.lib.cvsclient.command.PipedFileInformation; import org.netbeans.modules.javacvs.commands.CvsUpdate; import org.netbeans.modules.javacvs.caching.CvsFsCache; import org.apache.regexp.RE; import org.apache.regexp.RESyntaxException; import org.openide.ErrorManager; /** * The VersioningSystem used by JavaCvsFileSystem * @author Milos */ public class JavaCvsVersioningSystem extends VersioningFileSystem implements CacheHandlerListener { private NbJavaCvsFileSystem fileSystem; private CvsFsCache fsCache; //private VersioningFileSystem.Status status; private VersioningFileSystem.Versions versions; private FileStatusListener fileStatus; private PropertyChangeListener propChange; private Hashtable revisionListsByName; /** Holds value of property showMessages. */ private boolean showMessages = true; /** Holds value of property messageLength. */ private int messageLength = 50; private String ignoreFiles = "~$|^\\.#"; //NOI18N public static final String PROP_SHOW_DEAD_FILES = "showDeadFiles"; //NOI18N public static final String PROP_SHOW_MESSAGES = "showMessages"; //NOI18N public static final String PROP_MESSAGE_LENGTH = "messageLength"; //NOI18N public static final String PROP_SHOW_UNIMPORTANT_FILES = "showUnimporantFiles"; //NOI18N public static final String PROP_IGNORE_FILES = "ignoredFiles"; //NOI18N private static final int BADGE_ICON_SHIFT_X = 16; private static final int BADGE_ICON_SHIFT_Y = 8; private VersStatus status; private File rootFile; /** regexp matcher for ignoredFiles, null if not needed */ private transient RE ignoredRE = null; private static final long serialVersionUID = 0; /** Creates new VcsVersioningSystem */ public JavaCvsVersioningSystem(NbJavaCvsFileSystem fileSystem, CvsFsCache fscache) { super(fileSystem); this.fileSystem = fileSystem; fsCache = fscache; try { setSystemName(fileSystem.getSystemName()); } catch (java.beans.PropertyVetoException vExc) {} //this.status = new VersioningFileStatus(); this.list = new VersioningList();//fileSystem.getVcsList(); this.info = fileSystem.getVcsInfo(); this.change = new VersioningFSChange(); this.attr = new JCvsVersAttributes(); this.versions = new VersioningVersions(); status = new VersStatus(); revisionListsByName = new Hashtable(); initListeners(); setCapability(null);//FileSystemCapability.DOC); rootFile = fileSystem.getRootDirectory(); try { ignoredRE = new RE(ignoreFiles); } catch (RESyntaxException rese) { ignoredRE = null; } } private void initListeners() { fileStatus = new FileStatusListener() { public void annotationChanged(FileStatusEvent ev) { fireMyFileStatusChanged(ev); } }; propChange = new FSPropertyChangeListener(); fileSystem.addFileStatusListener(WeakListener.fileStatus(fileStatus, fileSystem)); fileSystem.addPropertyChangeListener(WeakListener.propertyChange(propChange, fileSystem)); JavaCvsSettings settings = (JavaCvsSettings)SharedClassObject.findObject(JavaCvsSettings.class, true); settings.addPropertyChangeListener(WeakListener.propertyChange(propChange, settings)); addPropertyChangeListener(WeakListener.propertyChange(propChange, this)); } public void addNotify() { super.addNotify(); propagatePropertyChange(new String[] {PROP_MESSAGE_LENGTH, PROP_SHOW_MESSAGES, PROP_IGNORE_FILES}); } public void removeNotify() { super.removeNotify(); this.fileSystem = null; this.fsCache = null; } private void fireMyFileStatusChanged(FileStatusEvent ev) { synchronized (this) { Enumeration it = revisionListsByName.keys(); while (it.hasMoreElements()) { String pathName = (String)it.nextElement(); FileSystem fs = fileSystem; if (fs != null) { FileObject fo = fs.findResource(pathName); if (fo != null && ev.hasChanged(fo)) { RevisionList list = (RevisionList)revisionListsByName.get(pathName); AnnotationProvider prov = (AnnotationProvider)fo.getAttribute(AnnotationProvider.ANN_PROVIDER_FO_ATTRIBUTE); updateRevisionList(list, prov, fo); } } } // System.out.println("ev.source=" + ev.getSource().getClass()); } fireFileStatusChanged(ev); } // Utility method only: protected File getFile (String name) { if (name.length() > 0) { return new File (rootFile, name); } else { return new File(rootFile.getAbsolutePath()); } } private void updateRevisionList(RevisionList list, AnnotationProvider provider, FileObject fo) { Iterator it = list.iterator(); String actRev = provider.getAttributeValue(fo.getPackageNameExt('/','.'), AnnotationSupport.ANNOTATION_PATTERN_REVISION); boolean wasSet = false; while (it.hasNext()) { RevisionItem item = (RevisionItem)it.next(); if (item.isCurrent()) { if (!item.getRevision().equals(actRev)) { item.setCurrent(false); } else { wasSet = true; } continue; } if (item.getRevision().equals(actRev)) { item.setCurrent(true); wasSet = true; } } //TODO.. check status as well.. for needs-patch, needs-merge do refresh as well.. if (!wasSet) { // we couldn't set the new current revision.. it's a new one.. // reload revision list.. final RevisionList oldList = list; final String packNameExt = fo.getPackageNameExt('/','.'); org.netbeans.modules.vcscore.versioning.impl.VersioningDataNode.getVersioningRequestProcessor().post( new Runnable() { public void run() { VersioningVersions vers = (VersioningVersions)getVersions(); RevisionList newList = vers.createRevisionList(packNameExt); //System.out.println("old List = "+oldList); if (oldList != null) { ArrayList workNew = new ArrayList(newList); synchronized (oldList) { ArrayList workOld = new ArrayList(oldList); workNew.removeAll(oldList); //System.out.println("ADDING new revisions: "+workNew); oldList.addAll(workNew); // add all new revisions workOld.removeAll(newList); //System.out.println("ADDING new revisions: "+workNew); oldList.removeAll(workOld); // remove all old revisions (some VCS may perhaps allow removing revisions) } } } }); } } /* public AbstractFileSystem.List getList() { return fileSystem.getVcsList(); } public AbstractFileSystem.Info getInfo() { return fileSystem.getVcsInfo(); } */ public FileSystem.Status getStatus() { return status; } public VersioningFileSystem.Versions getVersions() { return versions; } public String[] getStates(org.openide.loaders.DataObject dObj) { return fileSystem.getStates(dObj); } public boolean isShowDeadFiles() { return false; //fileSystem.isShowDeadFiles(); } public void setShowDeadFiles(boolean showDeadFiles) { // fileSystem.setShowDeadFiles(showDeadFiles); firePropertyChange(PROP_SHOW_DEAD_FILES, !showDeadFiles ? Boolean.TRUE : Boolean.FALSE, showDeadFiles ? Boolean.TRUE : Boolean.FALSE); } public String getIgnoredFiles () { return ignoreFiles; } public synchronized void setIgnoredFiles (String nue) throws IllegalArgumentException { if (! nue.equals (ignoreFiles)) { if (nue.length () > 0) { try { ignoredRE = new RE (nue); } catch (RESyntaxException rese) { IllegalArgumentException iae = new IllegalArgumentException (); ErrorManager.getDefault().annotate (iae, rese); throw iae; } } else { ignoredRE = null; } ignoreFiles = nue; firePropertyChange (PROP_IGNORE_FILES, null, nue); // NOI18N refreshExistingFolders(); } } /* public RevisionChildren createRevisionChildren(RevisionList list) { return new NumDotRevisionChildren(list); } */ public boolean isReadOnly() { return false; } private static Object vsActionAccessLock = new Object(); /** Holds value of property showUnimportantFiles. */ private boolean showUnimportantFiles; public SystemAction[] getRevisionActions(FileObject fo, Set revisionItems) { JavaCvsVersioningAction action = (JavaCvsVersioningAction) SharedClassObject.findObject(JavaCvsVersioningAction.class, true); synchronized (vsActionAccessLock) { action.setFileSystem(fileSystem); action.setFileObject(fileSystem.findResource(fo.getPackageNameExt('/','.'))); action.setSelectedRevisionItems(revisionItems); } return new SystemAction[] {action }; } /* public void fireRevisionChange(String name) { fireRevisionChange(name, null); } */ private void vcsStatusChanged (String path, boolean recursively) { FileObject fo = findExistingResource(path); if (fo == null) return ; Enumeration enum = fo.getChildren(recursively); HashSet hs = new HashSet(); while(enum.hasMoreElements()) { fo = (FileObject) enum.nextElement(); hs.add(fo); //D.deb("Added "+fo.getName()+" fileObject to update status"+fo.getName()); // NOI18N } Set s = Collections.synchronizedSet(hs); fireVcsFileStatusChanged(new VcsFileStatusEvent(this, s)); } public void vcsStatusChanged (String name) { FileObject fo = findExistingResource(name); if (fo == null) return; fireVcsFileStatusChanged (new VcsFileStatusEvent(this, Collections.singleton(fo))); } /** * is called each time the status of a file changes in cache. * The filesystem has to decide wheater it affects him (only in case when * there's not the 1-to-1 relationship between cache and fs. */ public void statusChanged(CacheHandlerEvent event) { NbJavaCvsFileSystem fs = fileSystem; if (fs == null) { return; } String root = fs.getRootDirectory().getAbsolutePath(); String absPath = event.getCacheFile().getAbsolutePath(); if (absPath.startsWith(root)) { // it belongs to this FS -> do something //D.deb("-------- it is in this filesystem"); String path; if (root.length() == absPath.length()) { path = ""; } else { path = absPath.substring(root.length() + 1, absPath.length()); } path = path.replace(java.io.File.separatorChar, '/'); if (event.getCacheFile() instanceof org.netbeans.modules.vcscore.cache.CacheDir) { vcsStatusChanged(path, event.isRecursive()); } else { vcsStatusChanged(path); } } } /** * is Called when a file/dir is removed from cache. */ public void cacheRemoved(CacheHandlerEvent event) { } /** * is called when a file/dir is added to the cache. The filesystem should * generally perform findResource() on the dir the added files is in * and do refresh of that directory. * Note: */ public void cacheAdded(CacheHandlerEvent event) { } /** Getter for property showMessages. * @return Value of property showMessages. */ public boolean isShowMessages() { return this.showMessages; } /** Setter for property showMessages. * @param showMessages New value of property showMessages. */ public void setShowMessages(boolean showMessages) { if (this.showMessages != showMessages) { this.showMessages = showMessages; firePropertyChange(PROP_SHOW_MESSAGES, !showMessages ? Boolean.TRUE : Boolean.FALSE, showMessages ? Boolean.TRUE : Boolean.FALSE); redisplayRevisions(); } } private void redisplayRevisions() { Iterator it = this.revisionListsByName.values().iterator(); while (it.hasNext()) { RevisionList list = (RevisionList)it.next(); Iterator it2 = list.iterator(); while (it2.hasNext()) { RevisionItem item = (RevisionItem)it2.next(); if (isShowMessages()) { if (item.getMessage() != null) { item.setDisplayName(item.getRevision() + " " + cutMessageString(item.getMessage())); //NOI18N } } else { item.setDisplayName(item.getRevision()); } } } } /* private class VersioningFileStatus extends Object implements VersioningFileSystem.Status { public java.lang.String annotateName(java.lang.String displayName, java.util.Set files) { return fileSystem.annotateName(displayName, files); } public java.awt.Image annotateIcon(java.awt.Image icon, int iconType, java.util.Set files) { return fileSystem.annotateIcon(icon, iconType, files); } } */ private String cutMessageString(String message) { String toReturn = message; if (message != null && message.length() > (getMessageLength() + 3)) { toReturn = message.substring(0, getMessageLength()) + "..."; //NOI18N } if (toReturn != null) { toReturn = toReturn.replace('\n', ' '); } return toReturn; } /** Getter for property messageLength. * @return Value of property messageLength. */ public int getMessageLength() { return this.messageLength; } /** Setter for property messageLength. * @param messageLength New value of property messageLength. */ public void setMessageLength(int messageLength) { int oldLength = this.messageLength; this.messageLength = messageLength; if (messageLength < 0) { this.messageLength = 0; } firePropertyChange(PROP_MESSAGE_LENGTH, new Integer(oldLength), new Integer(messageLength)); redisplayRevisions(); } /** Getter for property showUnimportantFiles. * @return Value of property showUnimportantFiles. */ public boolean isShowUnimportantFiles() { return this.showUnimportantFiles; } /** Setter for property showUnimportantFiles. * @param showUnimportantFiles New value of property showUnimportantFiles. */ public void setShowUnimportantFiles(boolean showUnimportantFiles) { if (this.showUnimportantFiles != showUnimportantFiles) { this.showUnimportantFiles = showUnimportantFiles; firePropertyChange(PROP_SHOW_UNIMPORTANT_FILES, !showUnimportantFiles ? Boolean.TRUE : Boolean.FALSE, showUnimportantFiles ? Boolean.TRUE : Boolean.FALSE); refreshExistingFolders(); } } private class VersioningFolderListener extends org.openide.filesystems.FileChangeAdapter { public void fileRenamed(org.openide.filesystems.FileRenameEvent fileRenameEvent) { FileObject orig = (FileObject)fileRenameEvent.getSource(); orig.refresh(); } public void fileDataCreated(org.openide.filesystems.FileEvent fileEvent) { FileObject orig = (FileObject)fileEvent.getSource(); orig.refresh(); } public void fileFolderCreated(org.openide.filesystems.FileEvent fileEvent) { FileObject orig = (FileObject)fileEvent.getSource(); orig.refresh(); } public void fileChanged(org.openide.filesystems.FileEvent fileEvent) { FileObject orig = (FileObject)fileEvent.getSource(); orig.refresh(); } public void fileDeleted(org.openide.filesystems.FileEvent fileEvent) { FileObject orig = (FileObject)fileEvent.getSource(); orig.refresh(); } } private class VersioningList extends Object implements AbstractFileSystem.List { public String[] children(String name) { /* FileObject fo = fileSystem.findResource(str); if (fo == null) { return new String[0]; } if (fo.isFolder()) { fo.addFileChangeListener(fileChangeListener); } FileObject[] childs = fo.getChildren(); if (childs != null) { String[] toReturn = new String[childs.length]; for (int i = 0; i < childs.length; i++) { toReturn[i] = childs[i].getNameExt(); } return toReturn; } else { return new String[0]; } */ File f = getFile (name); String[] toReturn = null; // System.out.println("children for=" +name); if (f != null && f.isDirectory ()) { CvsFsCache cach = fsCache; if (cach != null) { toReturn = cach.getDirContent(f); } } if (toReturn == null) { toReturn = new String[0]; } for (int i = 0; i < toReturn.length; i++) { if ((ignoredRE != null && ignoredRE.match(toReturn[i])) || toReturn[i].equals(".nbattrs") || !isShowUnimportantFiles() && !fileSystem.isImportant((name.length() == 0) ? toReturn[i] : name + "/" + toReturn[i])) { //NOI18N // System.out.println("ignoring.." + toReturn[i]); toReturn[i] = null; } } return toReturn; } } private class VersioningVersions extends Object implements VersioningFileSystem.Versions { public VersioningVersions() { } public RevisionList getRevisions(String name, boolean refresh) { RevisionList list = null; synchronized (this) { list = (RevisionList) revisionListsByName.get(name);//new org.netbeans.modules.vcscore.versioning.impl.NumDotRevisionList(); if (list == null || refresh) { //org.openide.util.RequestProcessor.postRequest(new Runnable() { // public void run() { list = createRevisionList(name); if (list != null) revisionListsByName.put(name, list); //versioningSystem.fireRevisionChange(name); // } //}); //System.out.println("createRevisionList("+name+") = "+list); } } //list.add(new org.netbeans.modules.vcscore.versioning.impl.NumDotRevisionItem("1.1")); //list.add(new org.netbeans.modules.vcscore.versioning.impl.NumDotRevisionItem("1.2")); return list; } public RevisionList createRevisionList(final String name) { FsCommandFactory factory = FsCommandFactory.getFsInstance(); NbJavaCvsFileSystem fs = fileSystem; if (fs == null) { return null; } FileObject fo = fs.findResource(name); if (fo != null) { CvsLog comm = (CvsLog)factory.createCommand(CvsLog.class, false, new FileObject[] {fo}, fs.createClientProvider()); comm.setRecursive(false); org.netbeans.modules.cvsclient.commands.JavaCvsRuntimeCommand rCom = fs.prepareCommand(comm); // these command have meaning to be in waiting state.. rCom.setState(org.netbeans.modules.vcscore.runtime.RuntimeCommand.STATE_WAITING); comm.addDisplayerListener(new ErrorLogPanel(comm, true)); AbstractWaitForResultsDisplayer disp = new AbstractWaitForResultsDisplayer(comm.getImpl()); boolean error = disp.runAndWaitForFinish(); if (error) { return null; } Object obj = fo.getAttribute(AnnotationProvider.ANN_PROVIDER_FO_ATTRIBUTE); String currentRev = ""; if (obj != null) { AnnotationProvider provider = (AnnotationProvider)obj; currentRev = provider.getAttributeValue(name, AnnotationSupport.ANNOTATION_PATTERN_REVISION); } RevisionList list = new NumDotRevisionList(); Iterator it = disp.getResultList().iterator(); while (it.hasNext()) { // should be always just one item here.... LogInformation info = (LogInformation)it.next(); Iterator revIt = info.getRevisionList().iterator(); while (revIt.hasNext()) { LogInformation.Revision rev = (LogInformation.Revision)revIt.next(); NumDotRevisionItem item = new NumDotRevisionItem(rev.getNumber()); if (rev.getNumber().equals(currentRev)) { item.setCurrent(true); } item.setAuthor(rev.getAuthor()); item.setDate(rev.getDateString()); item.setMessage(rev.getMessage()); if (JavaCvsVersioningSystem.this.isShowMessages()) { item.setDisplayName(rev.getNumber() + " " + cutMessageString(rev.getMessage())); //NOI18N } else { item.setDisplayName(rev.getNumber()); } item.setTagNames(processTags(info.getAllSymbolicNames(), rev.getNumber())); list.add(item); createBranchItems(list, info, rev); } } return list; } return null;//(RevisionList) revisionListsByName.get(name); } private void createBranchItems(RevisionList addToList, LogInformation info, LogInformation.Revision revInfo) { String pattern = revInfo.getNumber() + ".0."; // NOI18N Iterator it = info.getAllSymbolicNames().iterator(); while (it.hasNext()) { LogInformation.SymName name = (LogInformation.SymName)it.next(); if (name.getRevision().startsWith(pattern)) { String idName = name.getRevision(); int lastInd = idName.lastIndexOf(".0."); // NOI18N idName = idName.substring(0, lastInd) + idName.substring(lastInd + 2, idName.length()); RevisionItem rev = new NumDotRevisionItem(idName); rev.setDisplayName(rev.getRevision() + " (" + name.getName() + ")"); // NOI18N String[] tagNames = new String[1]; tagNames[0] = name.getName(); rev.setTagNames(tagNames); addToList.add(rev); } else { String number = revInfo.getNumber(); String revString = name.getRevision(); if (revString.startsWith(number) && number.length() < revString.length()) { String remains = revString.substring(number.length()); if (remains.lastIndexOf('.') == 0) { RevisionItem rev = new NumDotRevisionItem(revString); rev.setDisplayName(rev.getRevision() + " (" + name.getName() + ")"); // NOI18N String[] tagNames = new String[1]; tagNames[0] = name.getName(); rev.setTagNames(tagNames); addToList.add(rev); } } } } } private String[] processTags(java.util.List lst, String revision) { java.util.List tags = new LinkedList(); Iterator it = lst.iterator(); while (it.hasNext()) { LogInformation.SymName tag = (LogInformation.SymName)it.next(); if (tag.getRevision().equals(revision)) { tags.add(tag.getName()); } } String[] toReturn = new String[tags.size()]; toReturn = (String[])tags.toArray(toReturn); return toReturn; } public java.io.InputStream inputStream(String name, String revision) throws java.io.FileNotFoundException { NbJavaCvsFileSystem fs = fileSystem; if (fs == null) { return null; } FsCommandFactory factory = FsCommandFactory.getFsInstance(); FileObject fo = fs.findResource(name); if (fo != null) { CvsUpdate comm = (CvsUpdate)factory.createCommand(CvsUpdate.class, false, new FileObject[] {fo}, fs.createClientProvider()); comm.setRecursive(false); comm.setPipeToOutput(true); comm.setUpdateByRevision(revision); fs.prepareCommand(comm); comm.addDisplayerListener(new ErrorLogPanel(comm, false)); AbstractWaitForResultsDisplayer disp = new AbstractWaitForResultsDisplayer(comm.getImpl()); boolean error = disp.runAndWaitForFinish(); if (error) { return null; } Iterator it = disp.getResultList().iterator(); while (it.hasNext()) { //should be just one :) PipedFileInformation info = (PipedFileInformation)it.next(); try { InputStream stream = new BufferedInputStream(new FileInputStream(info.getTempFile())); return stream; } catch (FileNotFoundException exc) { return null; } } } return null; //fileSystem.inputStream(name); } } private class FSPropertyChangeListener implements PropertyChangeListener { public void propertyChange(final PropertyChangeEvent event) { String propName = event.getPropertyName(); Object oldValue = event.getOldValue(); Object newValue = event.getNewValue(); if (JavaCvsSettings.PROP_ANNOTATION_PATTERN.equals(propName)) { FileObject root = findResource(""); Set foSet = new HashSet(); Enumeration enum = existingFileObjects(root); while (enum.hasMoreElements()) { foSet.add(enum.nextElement()); } fireFileStatusChanged(new FileStatusEvent(JavaCvsVersioningSystem.this, foSet, true, true)); return; } if (NbJavaCvsFileSystem.PROP_ROOT.equals(propName) && (!event.getSource().equals(JavaCvsVersioningSystem.this))) { rootFile = fileSystem.getRootDirectory(); try { String oldSystName = getSystemName(); setSystemName(fileSystem.getSystemName()); JavaCvsVersioningSystem.this.firePropertyChange(JavaCvsVersioningSystem.this.PROP_SYSTEM_NAME, oldSystName, getSystemName()); } catch (java.beans.PropertyVetoException vExc) { ErrorManager.getDefault().notify(org.openide.ErrorManager.WARNING, vExc); } FileObject fo = refreshRoot(); JavaCvsVersioningSystem.this.firePropertyChange(JavaCvsVersioningSystem.this.PROP_ROOT, null, fo); return; } if (NbJavaCvsFileSystem.PROP_SYSTEM_NAME.equals(propName) && (!event.getSource().equals(JavaCvsVersioningSystem.this))) { String oldSystName = getSystemName(); try { setSystemName(fileSystem.getSystemName()); } catch (java.beans.PropertyVetoException vExc) { ErrorManager.getDefault().notify(org.openide.ErrorManager.WARNING, vExc); } FileObject fo = refreshRoot(); JavaCvsVersioningSystem.this.firePropertyChange(JavaCvsVersioningSystem.this.PROP_SYSTEM_NAME, oldSystName, getSystemName()); return; } /* if (NbJavaCvsFileSystem.PROP_FS_INGORED_FILES.equals(propName)) { if (fileSystem.getFsIgnoredFiles() == null) { ignoredRE = null; } else if (fileSystem.getFsIgnoredFiles().length() > 0) { try { ignoredRE = new RE(fileSystem.getFsIgnoredFiles()); } catch (RESyntaxException rese) { } } } */ /* if (PROP_SHOW_DEAD_FILES.equals(propName)) { FileObject root = findResource(""); heyDoRefreshFolderRecursive(root); } */ } private void heyDoRefreshFolderRecursive(FileObject fo) { fo.refresh(); Enumeration enum = fo.getFolders(true); while(enum.hasMoreElements()) { ((FileObject) enum.nextElement()).refresh(); } } } /* private class FileStatusEventAdapter extends FileStatusEvent { private FileStatusEvent eventOrig; public FileStatusEventAdapter(FileStatusEvent event) { eventOrig = event; } public FileSystem getFileSystem() { return VcsVersioningSystem.this; } public boolean hasChanged(FileObject file) { FileObject fileOrig = fileSystem.findFileObject(file.getPackageNameExt('/', '.')); if (fileOrig == null) return false; return eventOrig.hasChanged(fileOrig); } public boolean isNameChange() { return eventOrig.isNameChange(); } public boolean isIconChange() { return eventOrig.isIconChange(); } } */ private class JCvsVersAttributes extends VersioningAttrs { public JCvsVersAttributes() { super(JavaCvsVersioningSystem.this.info); } public java.lang.Object readAttribute(String name, String attrName) { java.lang.Object retValue; if (AnnotationProvider.ANN_PROVIDER_FO_ATTRIBUTE.equals(attrName)) { CvsFsCache cache = fsCache; if (cache != null) { return ((NbCvsFsCache)cache).getAnnotationProvider(name); } return null; } retValue = super.readAttribute(name, attrName); if (retValue == null) { NbJavaCvsFileSystem fs = fileSystem; if (fs != null) { // You must not look for FileObject here. retValue = fs.getVcsAttributes().readAttribute(name, attrName); } } return retValue; } } private class VersStatus implements FileSystem.Status { public java.lang.String annotateName(java.lang.String str, java.util.Set set) { Iterator it = set.iterator(); // Set fsSet = new HashSet(set.size()); AnnotationProvider provider = null; FileObject fo = null; if (it.hasNext()) { // should be just one here ALWAYS.. fo = (FileObject)it.next(); if (fo == null || fo.isRoot()) { fo = null; } /* fsFo = fileSystem.findResource(fo.getPackageNameExt('/','.')); if (fsFo == null || fsFo.isRoot()) { fsFo = null; } else { provider = (AnnotationProvider)fsFo.getAttribute(AnnotationProvider.ANN_PROVIDER_FO_ATTRIBUTE); } // fsSet.add(fsFo); */ else { provider = (AnnotationProvider)fo.getAttribute(AnnotationProvider.ANN_PROVIDER_FO_ATTRIBUTE); } } String status = str; if (provider != null && fo != null) { status = AnnotationSupport.getInstance().getStatusAnnotation(fo.getNameExt(), fo.getPackageNameExt('/','.'), provider, JavaCvsSettings.ANNOTATION_TYPE); } return status; } public java.awt.Image annotateIcon(java.awt.Image icon, int param, java.util.Set set) { /* Iterator it = set.iterator(); Set fsSet = new HashSet(set.size()); while (it.hasNext()) { FileObject fo = (FileObject)it.next(); FileObject fsFo = fileSystem.findResource(fo.getPackageNameExt('/','.')); if (fsFo != null) { fsSet.add(fsFo); } } return fileSystem.getStatus().annotateIcon(image, param, fsSet); */ int len = set.size(); Vector important = new Vector(); Iterator it = set.iterator(); if (it.hasNext()) { FileObject fo = (FileObject)it.next(); if (fo != null) { important.add(fo.getPackageNameExt('/','.')); } } if (important.size() == 0) { return icon; } CvsFsCache cache = fsCache; if (cache != null) { String status = cache.getFileStatusOnly(important); if (status != null) { java.awt.Image img = NbJavaCvsStatusManager.getInstance().getIcon(status); if (img != null) { icon = org.openide.util.Utilities.mergeImages(icon, img, BADGE_ICON_SHIFT_X, BADGE_ICON_SHIFT_Y); } } } return icon; } } } |
... 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.