1.1 --- a/vcscore/src/org/netbeans/modules/vcscore/VcsActionSupporter.java Tue Jul 30 15:29:16 2002 +0000
1.2 +++ b/vcscore/src/org/netbeans/modules/vcscore/VcsActionSupporter.java Tue Jul 30 17:09:54 2002 +0000
1.3 @@ -101,6 +101,7 @@
1.4 VcsFileSystem fileSystem = (VcsFileSystem) this.fileSystem.get();
1.5 final VcsCommand cmd = fileSystem.getCommand(cmdName);
1.6 if (cmd == null) return false;
1.7 + fileObjects = VcsUtilities.convertFileObjects(fileObjects);
1.8 Set foSet = new HashSet();
1.9 for (int i = 0; i < fileObjects.length; i++) {
1.10 foSet.add(fileObjects[i]);
1.11 @@ -134,6 +135,7 @@
1.12 if (cmdSet == null) {
1.13 return;
1.14 }
1.15 + fileObjects = VcsUtilities.convertFileObjects(fileObjects);
1.16 for (Iterator it = cmdSet.iterator(); it.hasNext(); ) {
1.17 String cmdName = (String) it.next();
1.18 if (isEnabled(cmdName, fileObjects)) {
2.1 --- a/vcscore/src/org/netbeans/modules/vcscore/actions/VersioningExplorerAction.java Tue Jul 30 15:29:16 2002 +0000
2.2 +++ b/vcscore/src/org/netbeans/modules/vcscore/actions/VersioningExplorerAction.java Tue Jul 30 17:09:54 2002 +0000
2.3 @@ -29,7 +29,7 @@
2.4 import org.openide.loaders.DataObjectNotFoundException;
2.5 import org.openide.util.actions.NodeAction;
2.6
2.7 -import org.netbeans.modules.vcscore.VcsAttributes;
2.8 +import org.netbeans.modules.vcscore.util.VcsUtilities;
2.9 import org.netbeans.modules.vcscore.versioning.impl.VersioningExplorer;
2.10 import org.netbeans.modules.vcscore.versioning.VersioningRepository;
2.11 import org.netbeans.modules.vcscore.versioning.VersioningFileSystem;
2.12 @@ -87,40 +87,6 @@
2.13 explorer.requestFocus();
2.14 }
2.15
2.16 - /***
2.17 - * Performs the conversion from the Fileobjects retrieved from nodes to the real
2.18 - * underlying versioning filesystem's fileobjects. Should be used in the action's code whenever
2.19 - * the action needs to work with the fileobjects of the versioning fs.
2.20 - * That is nessesary when the nodes come from the MultiFilesystem layer,
2.21 - * otherwise we'll get the wrong set of fileobjects and commands will behave strangely.
2.22 - */
2.23 - private FileObject[] convertFileObjects(FileObject[] originals) {
2.24 - if (originals == null || originals.length == 0) {
2.25 - return originals;
2.26 - }
2.27 - FileObject[] toReturn = new FileObject[originals.length];
2.28 - for (int i = 0; i < originals.length; i++) {
2.29 - toReturn[i] = originals[i];
2.30 - FileObject fo = originals[i];
2.31 - FileSystem fs = (FileSystem)fo.getAttribute(VcsAttributes.VCS_NATIVE_FS);
2.32 - if (fs != null) {
2.33 - try {
2.34 - FileSystem fileSys = fo.getFileSystem();
2.35 - if (!fileSys.equals(fs)) {
2.36 - String nativePath = (String)fo.getAttribute(VcsAttributes.VCS_NATIVE_PACKAGE_NAME_EXT);
2.37 - toReturn[i] = fs.findResource(nativePath);
2.38 - }
2.39 - } catch (FileStateInvalidException exc) {
2.40 - continue;
2.41 - }
2.42 -
2.43 - } else {
2.44 - continue;
2.45 - }
2.46 - }
2.47 - return toReturn;
2.48 - }
2.49 -
2.50 private HashMap getFilesByFS(Node[] nodes) {
2.51 HashMap filesByFS = new HashMap();
2.52 HashMap map = getSupporterMap(nodes);
2.53 @@ -132,7 +98,7 @@
2.54 continue;
2.55 }
2.56 origFos = (FileObject[])foSet.toArray(origFos);
2.57 - FileObject[] correctFos = convertFileObjects(origFos);
2.58 + FileObject[] correctFos = VcsUtilities.convertFileObjects(origFos);
2.59 for (int i = 0; i < correctFos.length; i++) {
2.60 FileObject fo = correctFos[i];
2.61 try {
3.1 --- a/vcscore/src/org/netbeans/modules/vcscore/util/VcsUtilities.java Tue Jul 30 15:29:16 2002 +0000
3.2 +++ b/vcscore/src/org/netbeans/modules/vcscore/util/VcsUtilities.java Tue Jul 30 17:09:54 2002 +0000
3.3 @@ -19,11 +19,15 @@
3.4 import java.awt.*;
3.5
3.6 import org.openide.filesystems.FileObject;
3.7 +import org.openide.filesystems.FileSystem;
3.8 +import org.openide.filesystems.FileStateInvalidException;
3.9 import org.openide.loaders.DataObject;
3.10 import org.openide.loaders.DataObjectNotFoundException;
3.11 import org.openide.util.io.NbObjectInputStream;
3.12 import org.openide.util.io.NbObjectOutputStream;
3.13
3.14 +import org.netbeans.modules.vcscore.VcsAttributes;
3.15 +
3.16 /** Miscelaneous stuff.
3.17 *
3.18 * @author Michal Fadljevic, Martin Entlicher
3.19 @@ -688,6 +692,40 @@
3.20 }
3.21
3.22 /**
3.23 + * Performs the conversion from the Fileobjects retrieved from nodes to the real
3.24 + * underlying versioning filesystem's fileobjects. Should be used in the action's code whenever
3.25 + * the action needs to work with the fileobjects of the versioning fs.
3.26 + * That is nessesary when the nodes come from the MultiFilesystem layer,
3.27 + * otherwise we'll get the wrong set of fileobjects and commands will behave strangely.
3.28 + */
3.29 + public static FileObject[] convertFileObjects(FileObject[] originals) {
3.30 + if (originals == null || originals.length == 0) {
3.31 + return originals;
3.32 + }
3.33 + FileObject[] toReturn = new FileObject[originals.length];
3.34 + for (int i = 0; i < originals.length; i++) {
3.35 + toReturn[i] = originals[i];
3.36 + FileObject fo = originals[i];
3.37 + FileSystem fs = (FileSystem) fo.getAttribute(VcsAttributes.VCS_NATIVE_FS);
3.38 + if (fs != null) {
3.39 + try {
3.40 + FileSystem fileSys = fo.getFileSystem();
3.41 + if (!fileSys.equals(fs)) {
3.42 + String nativePath = (String) fo.getAttribute(VcsAttributes.VCS_NATIVE_PACKAGE_NAME_EXT);
3.43 + toReturn[i] = fs.findResource(nativePath);
3.44 + }
3.45 + } catch (FileStateInvalidException exc) {
3.46 + continue;
3.47 + }
3.48 +
3.49 + } else {
3.50 + continue;
3.51 + }
3.52 + }
3.53 + return toReturn;
3.54 + }
3.55 +
3.56 + /**
3.57 * Encodes Object into String encoded in HEX format
3.58 * @param value Object, which will be encoded
3.59 * @return serialized Object in String encoded in HEX format