Beispiel #1
0
        trFiles.addEventListener("beforerename", this.$beforerename = function(e){
            if (!ide.onLine && !ide.offlineFileSystemSupport) return false;

            if(trFiles.$model.data.firstChild == trFiles.selected)
                return false;

            // check for a path with the same name, which is not allowed to rename to:
            var path = e.args[0].getAttribute("path"),
                newpath = path.replace(/^(.*\/)[^\/]+$/, "$1" + e.args[1]).toLowerCase();

            var exists, nodes = trFiles.getModel().queryNodes(".//node()");
            for (var i = 0, len = nodes.length; i < len; i++) {
                var pathLwr = nodes[i].getAttribute("path").toLowerCase();
                if (nodes[i] != e.args[0] && pathLwr === newpath) {
                    exists = true;
                    break;
                }
            }

            if (exists) {
                util.alert("Error", "Unable to Rename",
                    "That name is already taken. Please choose a different name.");
                trFiles.getActionTracker().undo();
                return false;
            }

            fs.beforeRename(e.args[0], e.args[1]);
        });
Beispiel #2
0
 trFiles.addEventListener("beforerename", function(e){
     if (!ide.onLine && !ide.offlineFileSystemSupport) return false;
     
     if(trFiles.$model.data.firstChild == trFiles.selected)
         return false;
     
     // check for a path with the same name, which is not allowed to rename to:
     var path = e.args[0].getAttribute("path"),
         newpath = path.replace(/^(.*\/)[^\/]+$/, "$1" + e.args[1]);
     
     var exists, nodes = trFiles.getModel().queryNodes(".//node()[@path=\""+ newpath +"\"]");
     for (var i = 0; i < nodes.length; i++) {
         if (nodes[i] == e.args[0])
             continue;
         exists = true;
         break;
     }
     /*if (exists) {
         util.alert("Error", "Unable to move", "Couldn't move to this destination because there's already a node with the same name");
         trFiles.getActionTracker().undo();
         return false;
     }*/
     
     //setTimeout(function(){
         fs.beforeRename(e.args[0], e.args[1]);
     //});
 });
Beispiel #3
0
 moveSyncFile : function(oldPath, newPath) {
     var parentPath = ide.davPrefix + newPath.substring(0, newPath.lastIndexOf("/"));
     
     if (this.isFSNodeInModel(parentPath)) {
         if (!fs.getFileNode(parentPath))
             fs.createFolderTree(parentPath);
         
         var file = fs.model.queryNode("//node()[@path=" 
             + util.escapeXpathString(ide.davPrefix + oldPath) + "]");
         var parent = fs.model.queryNode("//node()[@path=" 
                 + util.escapeXpathString(parentPath) + "]");
 
         if (apf.getFilename(oldPath) != apf.getFilename(newPath))
             fs.beforeRename(file, null, newPath);
 
         if (file) {
             apf.xmldb.moveNode(parent, file);
             fs.beforeMove(parent, file);
             
             return file;
         }
         else
             return apf.xmldb.appendChild(parent, 
                 fs.createFileNodeFromPath(newPath));
     }
     else {
         this.createFolderInModelIfLoaded(parentPath);
     }
 },
        fs.saveFile(newPath, value, function(value, state, extra) {
            if (state !== apf.SUCCESS) {
                apf.xmldb.removeAttribute(file, "saving")
                return util.alert("Could not save document",
                    "An error occurred while saving this document",
                    "Please see if your internet connection is available and try again." +
                    "The server responded with status " + extra.status + ".");
            }

            var model = page.$model;
            var node = model.getXml();
            var doc = page.$doc;

            if (path !== newPath || parseInt(node.getAttribute("newfile") || 0, 10) === 1) {
                file = apf.getCleanCopy(node);
                fs.beforeRename(file, null, newPath, false, isReplace);
                doc.setNode(file);
                model.load(file);
                tabEditors.set(ide.getActivePage());
            }

            apf.xmldb.removeAttribute(oldFile, "saving");
            apf.xmldb.removeAttribute(file, "saving");

            if (_self.saveBuffer[path]) {
                delete _self.saveBuffer[path];
                _self._saveAsNoUI(page);
            }

            if (parseInt(file.getAttribute("newfile") || "0", 10) === 1) {
                apf.xmldb.removeAttribute(file, "newfile");
                apf.xmldb.removeAttribute(file, "changed");
                var xpath = newPath.replace(new RegExp("\/" + window.cloud9config.davPrefix.split("/")[1]), "")
                                    .replace(new RegExp("\/" + file.getAttribute("name")), "")
                                    .replace(/\/([^/]*)/g, "/node()[@name=\"$1\"]")
                                    .replace(/\/node\(\)\[@name="workspace"\]/, "")
                                    .replace(/\//, "") || "node()";
                if (self.trFiles && xpath) {
                    var oNode = trFiles.queryNode(xpath);
                    if (oNode && !trFiles.queryNode('//node()[@path=' + util.escapeXpathString(newPath) + ']'))
                        apf.xmldb.appendChild(oNode, file);
                }
            }

            ide.dispatchEvent("afterfilesave", {
                node: node,
                doc: doc,
                value: value,
                oldpath: oldPath,
                silentsave: false // It is a forced save, comes from UI
            });
        });
Beispiel #5
0
        fs.saveFile(newPath, value, function(value, state, extra) {
            if (state != apf.SUCCESS) {
                util.alert("Could not save document",
                  "An error occurred while saving this document",
                  "Please see if your internet connection is available and try again.");
            }
            panel.setAttribute("caption", "Saved file " + newPath);

            var model = page.$model;
            var node = model.getXml();
            var doc = page.$doc;

            if (path !== newPath || parseInt(node.getAttribute("newfile") || 0, 10) === 1) {
                model.load(node);
                file = model.data;
                fs.beforeRename(file, null, newPath, false);
                doc.setNode(file);
            }

            apf.xmldb.removeAttribute(file, "saving");

            if (self.saveBuffer[path]) {
                delete self.saveBuffer[path];
                self._saveAsNoUI(page);
            }

            if (parseInt(file.getAttribute("newfile") || "0", 10) === 1) {
                apf.xmldb.removeAttribute(file, "newfile");
                apf.xmldb.removeAttribute(file, "changed");
                var xpath = newPath.replace(new RegExp("\/" + cloud9config.davPrefix.split("/")[1]), "")
                                    .replace(new RegExp("\/" + file.getAttribute("name")), "")
                                    .replace(/\/([^/]*)/g, "/node()[@name=\"$1\"]")
                                    .replace(/\/node\(\)\[@name="workspace"\]/, "")
                                    .replace(/\//, "");
                if (xpath) {
                    var oNode  = trFiles.queryNode(xpath);
                    if (oNode && !trFiles.queryNode('//node()[@path="' + newPath + '"]'))
                        apf.xmldb.appendChild(oNode, file);
                }
            }

            ide.dispatchEvent("afterfilesave", {
                node: node,
                doc: doc,
                value: value,
                silentsave: false // It is a forced save, comes from UI
            });
        });
Beispiel #6
0
 setTimeout(function () {
     fs.beforeRename(args[1], null, args[0].getAttribute("path").replace(/[\/]+$/, "") + "/" + filename);
     args[1].removeAttribute("newname");
 });
Beispiel #7
0
 setTimeout(function () {
     fs.beforeRename(pNode, null,
         node.getAttribute("path").replace(/[\/]+$/, "") +
         "/" + filename, true, isReplaceAction);
     pNode.removeAttribute("newname");
 });