Example #1
0
                            _self.webdav.exec("readdir", [path], function(data) {
                                if (!data || data instanceof Error) {
                                    // @todo: should we display the error message in the Error object too?
                                    return util.alert("Error", "File '" + filename + "' could not be created",
                                        "An error occurred while creating a new file, please try again.");
                                }

                                // parse xml
                                var filesInDirXml = apf.getXml(data);

                                // we expect the new created file in the directory listing
                                var fullFilePath = path + "/" + filename;
                                var nodes = filesInDirXml
                                    .selectNodes("//file[@path=" + util.escapeXpathString(fullFilePath) + "]");

                                // not found? display an error
                                if (nodes.length === 0) {
                                    return util.alert("Error", "File '" + filename + "' could not be created",
                                        "An error occurred while creating a new file, please try again.");
                                }

                                file = nodes[0];

                                both++;
                                ide.dispatchEvent("newfile", {
                                    fileName: filename,
                                    parentPath: path,
                                    path: fullFilePath
                                });
                                done();
                            });
Example #2
0
            fs.webdav.exec("readdir", [path], function(data) {
                if (!data || data instanceof Error) {
                    // @todo: should we display the error message in the Error object too?
                    util.alert("Error", "File '" + filename + "' could not be created",
                        "An error occurred while creating a new file, please try again.");
                    return next();
                }
                
                // parse xml
                var filesInDirXml = apf.getXml(data);
                
                // we expect the new created file in the directory listing
                var fullFilePath = path + "/" + filename;
                file = filesInDirXml.selectSingleNode("//file[@path='" + fullFilePath + "']");
                
                // not found? display an error
                if (!file) {
                    util.alert("Error", "File '" + filename + "' could not be created",
                        "An error occurred while creating a new file, please try again.");
                    return next();
                }
                
                var oXml = apf.xmldb.appendChild(node, file);

                trFiles.select(oXml);
                if (file.size < MAX_OPENFILE_SIZE)
                    ide.dispatchEvent("openfile", {doc: ide.createDocument(oXml)});
                
                next();
            });
Example #3
0
    checkUploadSize: function(files) {
        var file;
        var files_too_big = [];
        for (var filesize, totalsize = 0, i = 0, l = files.length; i < l; ++i) {
            file = files[i];
            filesize = file.size;
            totalsize += filesize;

            if (filesize > MAX_UPLOAD_SIZE_FILE) {
                files_too_big.push(file.name)
            }
        }
        
        if (files_too_big.length) {
            if (files_too_big.length == 1) {
                util.alert(
                    "Maximum file-size exceeded", "A file exceeds our upload limit of 50MB per file.",
                    "Please remove the file '" + files_too_big[0] + "' from the list to continue."
                );
            }
            else {
                util.alert(
                    "Maximum file-size exceeded", "Some files exceed our upload limit of 50MB per file.",
                    "Please remove any files larger than 50MB from the list to continue."
                );
            }
            
            return false;
        }
        
        return true;
    },
Example #4
0
    onMessage: function(e) {
        var message = e.message;

        if (!message.extra || message.extra.type != "gitblame")
            return false;
        if (!this.blamejs[message.extra.path])
            return;

        var type = message.type.substr(-5);
        if (type == "-exit") {
            message.code && util.alert(
                "Error", "There was an error returned from the server:",
                message.data
            );
            delete this.blamejs[path];
            return;
        }
        // Is the body coming in piecemeal? Process after this message
        if (type != "-data" || !message.data) {
            return;
        }
        var path = message.extra.path;
        var blamejs = this.blamejs[path];

        if (!blamejs.parseBlame(message.data)) {
            util.alert(
                "Problem Parsing", "Problem Parsing",
                "There was a problem parsing the blame output. Blame us, blame the file, but don't blame blame.\nBlame."
            );
            return false;
        }

        // Now formulate the output
        this.formulateOutput(blamejs, path);
    },
Example #5
0
    onMessage: function(e) {
        var message = e.message;

        if (message.type != "result" && message.subtype != "blame")
            return;

        // Is the body coming in piecemeal? Process after this message
        if (!message.body.out && !message.body.err)
            return;

        ide.removeEventListener("socketMessage", this.$onMessage = this.onMessage.bind(this));

        //console.log(message);
        if (message.body.err) {
            util.alert(
                "Error",
                "There was an error returned from the server:",
                message.body.err
            );

            return;
        }

        if (!this.blamejs.parseBlame(message.body.out)) {
            util.alert(
                "Problem Parsing",
                "Problem Parsing",
                "There was a problem parsing the blame output. Blame us, blame the file, but don't blame blame. Blame."
            );
            return false;
        }

        // Now formulate the output
        this.formulateOutput(this.blamejs.getCommitData(), this.blamejs.getLineData());
    },
Example #6
0
    onBeforeDrop: function(e) {
        if (!(window.File && window.FileReader)) {
            util.alert(
                "Could not upload file(s)", "An error occurred while dropping this file(s)",
                "Your browser does not offer support for drag and drop for file uploads. " +
                "Please try with a recent version of Chrome or Firefox."
            );
            return false;
        }

        var files = e.dataTransfer.files;
        // Dropped item is a folder, second condition is for FireFox
        if (!files.length || !files[0].size ||
                // because this isnt a super check it also triggers on a file that the
                // browser doesn't recognize (no mime-type), so... let's check on file name
                // containing a . as well, it will only change behavior in Chrome a.t.m.
                // and as of Chrome 21 folder upload is available there
                (files.length == 1 && files[0].type == "" &&
                    files[0].name.indexOf(".") === -1)) {

            ext.initExtension(this);

            winNoFolderSupport.show();

            // only in Chrome display button to upload dialog with select folder
            if (!apf.isWebkit)
                btnNoFolderSupportOpenDialog.hide();

            return false;
        }

        var filesLength = files.length;
        if (filesLength < 1)
            return false;

        // if dropped on editor open file
        if (e.currentTarget.id == "tabEditorsDropArea") {
            if (filesLength <= MAX_OPEN_FILES_EDITOR)
                this.openOnUpload = true;
            else {
                return util.alert(
                    "Maximum files exceeded", "The number of files dropped in the editor exceeds the limit.",
                    "Please update your selection to " + MAX_OPEN_FILES_EDITOR + " files to continue."
                );
            }
        }

        this.onDrop(e);

        return true;
    },
Example #7
0
        connection.on("message", function(message) {
            if (typeof message == "string") {
                try {
                    message = JSON.parse(message);
                }
                catch(e) {
                    window.console && console.error("Error parsing socket message", e, "message:", message);
                    return;
                }
            }

            if (message.type == "attached") {
                ide.connecting = false;
                ide.connected = true;
                ide.dispatchEvent("socketConnect");
            }

            if (message.type === "error") {
                // TODO: Don't display all errors?
                if (ide.dispatchEvent("showerrormessage", message) !== false) {
                    util.alert(
                        "Error on server",
                        "Received following error from server:",
                        JSON.stringify(message.message)
                    );
                }
            }

            /* Jabberwocky*/
            /* This is how you display a message to the user */
            if(message.type === "level"){
                if(ide.dispatchEvent("showerrormessage",message) !== false){
                    util.alert(
                        "You may have leveled",
                        "You may have been deemed worthy:",
                        JSON.stringify(message.message)
                        );
                }
                ide.level.level = message.ld.level;
                ide.level.score = message.ld.score;

            }



            ide.dispatchEvent("socketMessage", {
                message: message
            });

             
        });
Example #8
0
 showFilesTooBigDialog: function(files) {
     if (files.length == 1) {
         util.alert(
             "Maximum file-size exceeded", "A file exceeds our upload limit of 50MB per file.",
             "Please remove the file '" + files[0] + "' from the list to continue."
         );
     }
     else {
         util.alert(
             "Maximum file-size exceeded", "Some files exceed our upload limit of 50MB per file.",
             "Please remove all files larger than 50MB from the list to continue."
         );
     }
 },
Example #9
0
    gitShow : function(hash) {
        var data = {
            command : this.command,
            subcommand : "show",
            file : this.getFilePath(),
            hash : hash
        };

        ide.dispatchEvent("track_action", {type: "gittools", cmd: this.command, subcommand: data.subcommand});
        if (ext.execCommand(this.command, data) !== false) {
            if (ide.dispatchEvent("consolecommand." + this.command, {
              data: data
            }) !== false) {
                if (!ide.onLine) {
                    util.alert(
                        "Currently Offline",
                        "Currently Offline",
                        "This operation could not be completed because you are offline."
                    );
                } else {
                    ide.send(JSON.stringify(data));
                }
            }
        }
    },
Example #10
0
        fs.saveFile(path, value, function(data, 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. "
                        + (state == apf.TIMEOUT
                            ? "The connection timed out."
                            : "The error reported was " + extra.message));
            }

            ide.dispatchEvent("afterfilesave", {
                node: node,
                doc: doc,
                value: value,
                silentsave: silentsave
            });

            ide.dispatchEvent("track_action", {
                type: "save as filetype",
                fileType: node.getAttribute("name").split(".").pop().toLowerCase(),
                success: state != apf.SUCCESS ? "false" : "true"
            });

            apf.xmldb.removeAttribute(node, "saving");
            apf.xmldb.removeAttribute(node, "new");
            apf.xmldb.setAttribute(node, "modifieddate", apf.queryValue(extra.data, "//d:getlastmodified"));

            if (_self.saveBuffer[path]) {
                delete _self.saveBuffer[path];
                _self.quicksave(page);
            }
        });
Example #11
0
 showGroupChat: function () {
     var otCollab = require("core/ext").extLut["ext/ot/ot"];
     if (otCollab && otCollab.inited)
         require("ext/ot/" + "chat").show();
     else
         util.alert("Collab and Group chat isn't possible in this workspaces");
 },
Example #12
0
 onBeforeDrop: function(e) {
     if (!(window.File && window.FileReader/* && window.FormData*/)) {
         util.alert(
             "Could not upload file(s)", "An error occurred while dropping this file(s)",
             "Your browser does not offer support for drag and drop for file uploads. " +
             "Please try with a recent version of Chrome or Firefox."
         );
         return false;
     }
     
     /** Dropped item is a folder */
     if (e.dataTransfer.files.length == 0) {
         ext.initExtension(this);
         
         winNoFolderSupport.show();
         
         if (!apf.isWebkit)
             btnNoFolderSupportOpenDialog.hide();
         
         return false;
     }
     var files = e.dataTransfer.files;
     if (!(this.checkUploadSize(files) && this.checkNumberOfFiles(files)))
         return false;
     
     if (e.dataTransfer.files.length < 1)
         return false;
     
     this.onDrop(e);
     
     return true;
 },
Example #13
0
    onMessage : function(e) {
        var message = e.message;
//        console.log("MSG", message)

        switch(message.type) {
            case "node-debug-ready":
                ide.dispatchEvent("debugready");
                break;

            case "chrome-debug-ready":
                winTab.show();
                dbgChrome.loadTabs();
                ide.dispatchEvent("debugready");
                break;

            case "node-exit":
                stProcessRunning.deactivate();
                stDebugProcessRunning.deactivate();
                break;

            case "state":
                stDebugProcessRunning.setProperty("active", message.debugClient);
                dbgNode.setProperty("strip", message.workspaceDir + "/");
                ide.dispatchEvent("noderunnerready");
                break;

            case "error":
                if (message.code !== 6)
                    util.alert("Server Error", "Server Error", message.message);
                ide.socket.send('{"command": "state"}');
                break;
                
        }
    },
Example #14
0
        fs.saveFile(path, value, function(data, state, extra){
            apf.xmldb.removeAttribute(node, "saving");

            if (state != apf.SUCCESS) {
                // Undo removal of changed status
                apf.xmldb.setAttribute(node, "changed", "1");

                if (extra.status == 409 /* Conflict */) {
                    ide.dispatchEvent("saveconflict", {
                        node             : node, 
                        latestRevisionId : extra.http.getResponseHeader("X-Revision-Id")
                    });
                } else {
                    util.alert(
                        "Could not save document",
                        "An error occurred while saving this document",
                        "Please see if your internet connection is available and try again. "
                            + (state == apf.TIMEOUT
                                ? "The connection timed out."
                                : "The error reported was " + extra.message));
                }
            } else {
                panel.setAttribute("caption", "Saved file " + path);
                ide.dispatchEvent("afterfilesave", {node: node, doc: doc, value: value});

                apf.xmldb.removeAttribute(node, "changed");
                apf.xmldb.removeAttribute(node, "new");
                apf.xmldb.setAttribute(node, "modifieddate", apf.queryValue(extra.data, "//d:getlastmodified"));

                if (_self.saveBuffer[path]) {
                    delete _self.saveBuffer[path];
                    _self.quicksave(page);
                }
            }
        });
Example #15
0
        function complete(data, state, extra) {
            if (state != apf.SUCCESS) {
                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. "
                        + (state == apf.TIMEOUT
                            ? "The connection timed out."
                            : "The error reported was " + extra.message),
                    next);
            }
            
            /** Request successful */
            fs.webdav.exec("readdir", [path], function(data) {
                if (data instanceof Error) {
                    // @todo: in case of error, show nice alert dialog.
                    return next();
                }
                
                var strXml = data.match(new RegExp(("(<file path='" + path +
                    "/" + filename + "'.*?>)").replace(/\//g, "\\/")))[1];

                var oXml = apf.xmldb.appendChild(node, apf.getXml(strXml));

                trFiles.select(oXml);
                if (file.size < MAX_OPENFILE_SIZE)
                    ide.dispatchEvent("openfile", {doc: ide.createDocument(oXml)});
                
                next();
            });
        }
Example #16
0
                    _self.webdav.exec("mkdir", [path, name], function(data) {
                        // @todo: in case of error, show nice alert dialog
                        if (!data || data instanceof Error)
                            throw Error;
                        
                        // parse xml
                        var nodesInDirXml = apf.getXml(data);
                        // we expect the new created file in the directory listing
                        var fullFolderPath = path + "/" + name;
                        var folder = nodesInDirXml.selectSingleNode("//folder[@path='" + fullFolderPath + "']");
                        // not found? display an error

                        if (!folder) {
                             return util.alert("Error", "Folder '" + name + "' could not be created",
                                 "An error occurred while creating a new folder, please try again.");
                        }
                        tree.slideOpen(null, node, true, function(data, flag, extra){
                            // empty data means it didn't trigger <insert> binding,
                            // therefore the node was expanded already
                            if (!data)
                                tree.add(folder, node);

                            folder = apf.queryNode(node, "folder[@path='"+ fullFolderPath +"']");

                            tree.select(folder);
                            tree.startRename();
                        });
                    });
Example #17
0
    onMessage: function(e) {
        var message = e.message;
        //console.log(message);

        if (message.type != "result" && message.subtype != "gittools")
            return;

        if (message.body.err) {
            util.alert(
                "Error", 
                "There was an error returned from the server:",
                message.body.err
            );

            return;
        }

        switch(message.body.gitcommand) {
            case "blame":
                this.onGitBlameMessage(message);
                break;
            case "log":
                this.onGitLogMessage(message);
                break;
            case "show":
                this.onGitShowMessage(message);
                break;
            default:
                return;
        }
    },
Example #18
0
    requestBlame : function() {
        var cmd = "gittools";

        var data = {
            command : cmd,
            subcommand : "blame",
            file    : tabEditors.getPage().$model.data.getAttribute("path")
        };

        ide.addEventListener("socketMessage", this.$onMessage = this.onMessage.bind(this));
        ide.dispatchEvent("track_action", {type: "blame", cmd: cmd});
        if (ext.execCommand(cmd, data) !== false) {
            if (ide.dispatchEvent("consolecommand." + cmd, {
              data: data
            }) !== false) {
                if (!ide.onLine) {
                    util.alert(
                        "Currently Offline",
                        "Currently Offline",
                        "This operation could not be completed because you are offline."
                    );
                }
                else {
                    ide.send(data);
                }
            }
        }
    },
Example #19
0
    afterswitch : function(e) {
        var page = e.nextPage;
        var fromHandler, toHandler = ext.extLut[page.type];

        if (e.previousPage && e.previousPage != e.nextPage)
            fromHandler = ext.extLut[e.previousPage.type];

        if (fromHandler != toHandler) {
            if (fromHandler)
                fromHandler.disable();
            toHandler.enable();
        }

        var path = page.$model.data.getAttribute("path").replace(/^\/workspace/, "");
        /*if (window.history.pushState) {
            var p = location.pathname.split("/");
            window.history.pushState(path, path, "/" + (p[1] || "name") + "/" + (p[2] || "project") + path);
        }
        else {
            apf.history.setHash("!" + path);
        }*/
        apf.history.setHash("!" + path);

        settings.save();

        if (!e.keepEditor) {
            var fileExtension = (path || "").split(".").pop().toLowerCase();
            var editor = this.fileExtensions[fileExtension]
              && this.fileExtensions[fileExtension][0]
              || this.fileExtensions["default"];

            if (!editor) {
                util.alert(
                    "No editor is registered",
                    "Could not find an editor to display content",
                    "There is something wrong with the configuration of your IDE. No editor plugin is found.");
                return;
            }

            if (!editor.inited)
                this.initEditor(editor);

            this.currentEditor = editor;
        }
        else {
            var editor = page.$editor;
        }

        if (editor.focus)
            editor.focus();

        //toHandler.$rbEditor.select();

        /*if (self.TESTING) {}
            //do nothing
        else if (page.appid)
            app.navigateTo(page.appid + "/" + page.id);
        else if (!page.id)
            app.navigateTo(app.loc || (app.loc = "myhome"));*/
    },
Example #20
0
    requestBlame : function() {
        var cmd = "gittools";

        var data = {
            command : cmd,
            subcommand : "blame",
            file    : tabEditors.getPage().$model.data.getAttribute("path")
        };

        ide.dispatchEvent("track_action", {type: "blame", cmd: cmd});
        if (ext.execCommand(cmd, data) !== false) {
            if (ide.dispatchEvent("consolecommand." + cmd, {
              data: data
            }) !== false) {
                if (!ide.onLine) {
                    util.alert(
                        "Currently Offline",
                        "Currently Offline",
                        "This operation could not be completed because you are offline."
                    );
                }
                else {
                    ide.send(data);
                    // Set gutter width
                    editors.currentEditor.ceEditor.$editor.renderer.setGutterWidth("300px");
                }
            }
        }
    },
Example #21
0
    gitLog : function() {
        var data = {
            command : this.command,
            subcommand : "log",
            file : this.getFilePath()
        };

        ide.dispatchEvent("track_action", {type: "gittools", cmd: this.command, subcommand: data.subcommand});
        if (ext.execCommand(this.command, data) !== false) {
            if (ide.dispatchEvent("consolecommand." + this.command, {
              data: data
            }) !== false) {
                if (!ide.onLine) {
                    util.alert(
                        "Currently Offline",
                        "Currently Offline",
                        "This operation could not be completed because you are offline."
                    );
                }
                else {
                    if (!this.gitLogs[data.file]) {
                        this.gitLogs[data.file] = {
                            logData : [],
                            lastLoadedGitLog : 0,
                            lastSliderValue : 0,
                            currentRevision : editors.currentEditor ? editors.currentEditor.ceEditor.getSession().getValue() : "",
                            revisions : {}
                        };
                    }
                    ide.send(JSON.stringify(data));
                }
            }
        }
    },
Example #22
0
        connection.on("message", function(message) {
            if (typeof message == "string") {
                try {
                    message = JSON.parse(message);
                }
                catch(e) {
                    window.console && console.error("Error parsing socket message", e, "message:", message);
                    return;
                }
            }

            if (message.type == "attached") {
                ide.connecting = false;
                ide.connected = true;
                ide.dispatchEvent("socketConnect");
            }

            if (message.type === "error") {
                // TODO: Don't display all errors?
                if (ide.dispatchEvent("showerrormessage", message) !== false) {
                    util.alert(
                        "Error on server",
                        "Received following error from server:",
                        JSON.stringify(message.message)
                    );
                }
            }

            ide.dispatchEvent("socketMessage", {
                message: message
            });
        });
Example #23
0
        ide.socketMessage = function(message) {
            if (typeof message == "string") {
                try {
                    message = JSON.parse(message);
                }
                catch(e) {
                    window.console && console.error("Error parsing socket message", e, "message:", message);
                    return;
                }
            }

            if (message.type == "attached") {
                ide.dispatchEvent("socketConnect"); //This is called too often!!
            }

            if (message.type === "error") {
                // TODO: Don't display all errors?
                util.alert(
                    "Error on server",
                    "Received following error from server:",
                    JSON.stringify(message.message)
                );
            }
            
            ide.dispatchEvent("socketMessage", {
                message: message
            });
        };
Example #24
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]);
        });
Example #25
0
    switchEditor : function(path){
        var page = tabEditors.getPage();
        if (!page || page.type == path)
            return;

        var lastType = page.type;

        var info;
        if ((info = page.$doc.dispatchEvent("validate", info)) === true) {
            util.alert(
                "Could not switch editor",
                "Could not switch editor because this document is invalid.",
                "Please fix the error and try again:" + info
            );
            return;
        }

        var editor = ext.extLut[path];
        if (!editor.inited)
            this.initEditor(editor);

        //editor.$rbEditor.select();

        page.setAttribute("type", path);

        page.$editor = editor;
        this.currentEditor = editor;

        this.beforeswitch({nextPage: page});
        this.afterswitch({nextPage: page, previousPage: {type: lastType}, keepEditor : true});
    },
Example #26
0
        beautify: function() {
            var editor = editors.currentEditor;

            var sel = editor.getSelection();
            var doc = editor.getDocument();
            var range = sel.getRange();
            var value = doc.getTextRange(range);

            // Load up current settings data
            var preserveEmpty = extSettings.model.queryValue("beautify/jsbeautify/@preserveempty") == "true" ? true : false;
            var keepIndentation = extSettings.model.queryValue("beautify/jsbeautify/@keeparrayindentation") == "true" ? true : false;
            var braces = extSettings.model.queryValue("beautify/jsbeautify/@braces") || "end-expand";
            var indentSize = extSettings.model.queryValue("editors/code/@tabsize") || "4";
            var indentTab = extSettings.model.queryValue("editors/code/@softtabs") == "true" ? " " : "\t";

            if (indentTab == "\t") indentSize = 1;

            try {
                value = jsbeautify.js_beautify(value, {
                    indent_size: indentSize,
                    indent_char: indentTab,
                    preserve_newlines: preserveEmpty,
                    keep_array_indentation: keepIndentation,
                    brace_style: braces
                });
            }
            catch (e) {
                util.alert("Error", "This code could not be beautified", "Please correct any JavaScript errors and try again");
                return;
            }

            var end = doc.replace(range, value);
            sel.setSelectionRange(Range.fromPoints(range.start, end));
        },
Example #27
0
                            _self.webdav.exec("readdir", [path], function(data) {
                                if (data instanceof Error) {
                                    // @todo: should we display the error message in the Error object too?
                                    return util.alert("Error", "File '" + filename + "' could not be created",
                                        "An error occurred while creating a new file, please try again.");
                                }

                                var m = data.match(new RegExp(("(<file path='" + path +
                                    "/" + filename + "'.*?>)").replace(/\//g, "\\/")))
                                if (!m) {
                                    return util.alert("Error", "File '" + filename + "' could not be created",
                                        "An error occurred while creating a new file, please try again.");
                                }
                                file = apf.getXml(m[1]);

                                both++;
                                done();
                            });
Example #28
0
    $reportBadInput: function(path, extraMessage) {
        var message = "Could not load extension '" + path + "'.";

        if (!path.match("://") && !path.match("/"))
            message += "\nFor local extensions, specify a path like ext/extension/extensionmain.";
        if (extraMessage)
            message += "\n" + extraMessage;
        util.alert("Error", "Validation Error", message);
    },
Example #29
0
    unregister : function(oExtension, silent){
        //Check exts that depend on oExtension
        var using = oExtension.using;
        if (using) {
            var inUseBy = [];
            for (var use, i = 0, l = using.length; i < l; i++) {
                if ((use = using[i]).registered)
                    inUseBy.push(use.path);
            }

            if (inUseBy.length) {
                //@todo move this to outside this function
                if (!silent)
                    util.alert(
                        "Could not disable extension",
                        "Extension is still in use",
                        "This extension cannot be disabled, because it is still in use by the following extensions:<br /><br />"
                        + " - " + inUseBy.join("<br /> - ")
                        + "<br /><br /> Please disable those extensions first.");
                return false;
            }
        }

        delete oExtension.registered;
        this.extensions.remove(oExtension);
        delete this.extLut[oExtension.path];

        //Check commands to clean up
        var commands = oExtension.commands;
        if (commands) {
            for (var cmd in commands) {
                if (this.commandsLut[cmd])
                    delete this.commandsLut[cmd];
            }
        }

        //Check deps to clean up
        var deps = oExtension.deps;
        if (deps) {
            for (var dep, ii = 0, ll = deps.length; ii < ll; ii++) {
                dep = deps[ii];
                if (dep.registered && dep.type == this.GENERAL && !oExtension.alone)
                    this.unregister(dep, true);
            }
        }

        this.extHandlers[oExtension.type].unregister(oExtension);

        this.model.setQueryValue("plugin[@path='" + oExtension.path + "']/@enabled", 0);

        if (oExtension.inited) {
            oExtension.destroy();
            delete oExtension.inited;
        }

        return true;
    },
Example #30
0
    onBeforeDrop: function(e) {
        if (!(window.File && window.FileReader)) {
            util.alert(
                "Could not upload file(s)", "An error occurred while dropping this file(s)",
                "Your browser does not offer support for drag and drop for file uploads. " +
                "Please try with a recent version of Chrome or Firefox."
            );
            return false;
        }
        
        var files = e.dataTransfer.files;
        // Dropped item is a folder, second condition is for FireFox
        if (!files.length || !files[0].size || (files.length == 1 && files[0].type == "")) {
            ext.initExtension(this);

            winNoFolderSupport.show();

            // only in Chrome display button to upload dialog with select folder
            if (!apf.isWebkit)
                btnNoFolderSupportOpenDialog.hide();

            return false;
        }

        var filesLength = files.length;
        if (filesLength < 1)
            return false;

        // if dropped on editor open file
        if (e.currentTarget.id == "tabEditorsDropArea") {
            if (filesLength <= MAX_OPEN_FILES_EDITOR)
                this.openOnUpload = true;
            else {
                return util.alert(
                    "Maximum files exceeded", "The number of files dropped in the editor exceeds the limit.",
                    "Please update your selection to " + MAX_OPEN_FILES_EDITOR + " files to continue."
                );
            }
        }

        this.onDrop(e);

        return true;
    },