text:
/**
 * webida - project configurator
 *
 * Src:
 *   plugins/project-configurator/plugin.js
 */
define([
    'webida-lib/app',
    'webida-lib/plugin-manager-0.1',
    'webida-lib/util/path',
    'dojo/topic',
    'text!./run-configuration.html',
    'text!./run-widget.html',
    'dijit/registry',
    'webida-lib/widgets/dialogs/buttoned-dialog/ButtonedDialog', // ButtonedDialog
    'dijit/layout/ContentPane',
    './projectConfigurator',
    './plugin',
    'plugins/workspace/plugin',
    'plugins/workbench/plugin',
    'webida-lib/widgets/dialogs/file-selection/FileSelDlg2States', // FileDialog
    'webida-lib/util/notify',
    'popup-dialog'
], function (ide, pm, pathUtil, topic, runConfHtml, runWidgetHtml, reg, ButtonedDialog,
              ContentPane, projectConfigurator, pc, workspace, workbench, FileDialog, notify,
              PopupDialog) {

    'use strict';

    //console.log('loading project configurator module...');

    var module = {};
    var fsMount = ide.getFSCache();

    var liveReloadHandleList = [];
    var EXTENSION_POINTS = {
        RUN_CONFIGURATION_TYPE: 'webida.ide.project-configurator:run-configuration-type',
        RUN_CONFIGURATION: 'webida.ide.project-configurator:run-configuration'
    };
    var extpoint = (function () {
        var confTypes = pm.getExtensions(EXTENSION_POINTS.RUN_CONFIGURATION_TYPE);
        var confs = pm.getExtensions(EXTENSION_POINTS.RUN_CONFIGURATION);

        return {
            getRunConfigurationTypeList: function () {
                return confTypes;
            },
            getRunConfigurationList: function () {
                return confs;
            },
            getRunDelegate: function (type) {
                var result = $.grep(confs, function (e) {
                    return e.type === type;
                });
                return result[0] ? result[0] : null;
            }
        };
    })();

    function saveProjectPropertyToFile(projectProperty) {
        projectConfigurator.saveProjectProperty(
            workspace.getRootPath() + projectProperty.name + '/',
            projectProperty);
    }

    function releaseLiveReloadHandle(handle) {
        handle.remove();
        handle = null;
    }

    function runProject(projectProperty, runObject, mode) {
        console.log('runProject', runObject, mode);
        if (runObject.type) {
            console.log('runProject with type', runObject.type);
            var delegate = extpoint.getRunDelegate(runObject.type);
            if (delegate) {
                require([delegate.module], function (mod) {
                    if (typeof mod[delegate.handler] === 'function') {
                        mod[delegate.handler](projectProperty, mode, runObject);
                    }
                });
            }
        } else {
            runWithAlias(projectProperty, runObject);
        }
    }

    function runWithAlias(projectProperty, runObject) {
        var projectPath = workspace.getRootPath() + projectProperty.name;
        var openname = projectPath + projectProperty.name;
        var runningWin = window.open('', openname, runObject.openArgument);
        if (!runningWin) {
            notify.error('Window can\'t be opened.<br />It might be interrupted by pop-up blocking, please check it.');
            return;
        }

        fsMount.addAlias(projectPath, 3600, function (err, data) {
            if (err) {
                notify.error(err);
                return;
            }

            var argStr = runObject.argument ? '?' + runObject.argument : '';
            var sharpStr = runObject.fragment ? '#' + runObject.fragment : '';
            var url = data.url + '/' + runObject.path + argStr + sharpStr;

            runningWin.location.href = './redirect.html#' + url;

            notify.success('\'' + projectProperty.name + '\' successfully launched');
            if (runningWin.focus) {
                runningWin.focus();
            }

            var reloadHandle = liveReloadHandleList[openname];
            if (reloadHandle) {
                releaseLiveReloadHandle(reloadHandle);
                liveReloadHandleList[openname] = null;
            }

            if (runObject.liveReload === true) {
                var handle = topic.subscribe('fs.cache.file.set', function (fsURL, target, reason, maybeModified) {
                    if (runningWin.closed) {
                        releaseLiveReloadHandle(handle);
                    } else {
                        if ((target.indexOf(projectPath) === 0) && (maybeModified)) {
                            runningWin.location.href = './redirect.html#' + url;
                        }
                    }
                });
                liveReloadHandleList[openname] = handle;
            }
        });
    }

    function checkUnsavedConf() {
        var saveButton = document.getElementsByClassName('rcw-action-save');
        if (!saveButton) {
            return;
        }
        var i;
        for (i = 0; i < saveButton.length; i++) {
            if ($(saveButton[i]).hasClass('rcw-display-none') === false) {
                return 'not been saved';
            }
        }

        saveButton = document.getElementsByClassName('rcw-action-newsave');
        if (!saveButton) {
            return;
        }
        for (i = 0; i < saveButton.length; i++) {
            if ($(saveButton[i]).hasClass('rcw-display-none') === false) {
                return 'not been created';
            }
        }
    }

    function isDuplicateRunName(projectProperty, name) {
        var runList = projectProperty.run;
        if (!runList || !runList.list) {
            return false;
        }

        for (var i = 0; i < runList.list.length; i++) {
            if (runList.list[i].name === name) {
                return true;
            }
        }
        return false;
    }

    function addButtonCssClass(button, size) {
        button.bind('mouseover', function () {
            button.addClass('rcw-button-hover-' + size);
        });

        button.bind('mouseout', function () {
            button.removeClass('rcw-button-hover-' + size);
            button.removeClass('rcw-button-push-' + size);
        });

        button.bind('mousedown', function () {
            button.addClass('rcw-button-push-' + size);
        });

        button.bind('mouseup', function () {
            button.removeClass('rcw-button-push-' + size);
        });
    }

    function foldButtonClicked(child, arrow, content) {
        var toggled = $(content).attr('toggled');
        if (toggled === 'unfold') {
            $(content).attr('toggled', 'fold');
            arrow.removeClass('rcw-title-arrow-unfold');
            if (arrow.hasClass('rcw-title-arrow-unfold-hover') === true) {
                arrow.removeClass('rcw-title-arrow-unfold-hover');
                arrow.addClass('rcw-title-arrow-hover');
            }

            content.removeClass('rcw-display-block');
        } else {
            $(content).attr('toggled', 'unfold');
            arrow.addClass('rcw-title-arrow-unfold');

            if (arrow.hasClass('rcw-title-arrow-hover') === true) {
                arrow.removeClass('rcw-title-arrow-hover');
                arrow.addClass('rcw-title-arrow-unfold-hover');
            }

            content.addClass('rcw-display-block');

            if (child) {
                $(child).css('height', '');
                $(child).css('width', '');
            }
        }
    }

    function addFoldButton(child, arrow, content) {
        var toggled;
        arrow.bind('mouseover', function () {
            toggled = $(content).attr('toggled');
            if (toggled === 'unfold') {
                arrow.addClass('rcw-title-arrow-unfold-hover');
            } else {
                arrow.addClass('rcw-title-arrow-hover');
            }
        });

        arrow.bind('mouseout', function () {
            arrow.removeClass('rcw-title-arrow-hover');
            arrow.removeClass('rcw-title-arrow-unfold-hover');
        });

        arrow.bind('mouseup', function () {
            foldButtonClicked(child, arrow, content);
        });
    }

    function makeConfigurationName(projectProperty, path) {
        var ret = path;

        if (isDuplicateRunName(projectProperty, ret) === true) {
            var temp;
            for (var i = 1; i < 100; i++) {
                temp = ret + '-' + i.toString();
                if (isDuplicateRunName(projectProperty, temp) !== true) {
                    return temp;
                }
            }
            var date = new Date();
            return ret + date.toGMTString();
        } else {
            return ret;
        }
    }

    function pathButtonClicked(projectProperty, pathInputBox, nameInputBox) {
        if (!projectProperty || !pathInputBox || !projectProperty.name) {
            notify.error('Cannot find root path');
            return;
        }

        var root = workspace.getRootPath() + projectProperty.name + '/';
        var initialPath;

        if (pathInputBox.value) {
            initialPath = root + pathInputBox.value;
        } else {
            initialPath = root;
        }

        var dlg = new FileDialog({
            mount: fsMount,
            root: root,
            initialSelection: [initialPath],
            title: 'Select the Main File to Run',
            singular: true,
            dirOnly: false,
            showRoot: false
        });
        dlg.open(function (selected) {
            if (selected) {
                if (selected.length <= 0) {
                    notify.warning('Select a file.');
                    return;
                }
                var pathSplit = selected[0].split(root);
                if (pathSplit.length > 0) {
                    pathInputBox.value = pathSplit[1];
                    if (!nameInputBox) {
                        return;
                    }
                    if (!nameInputBox.value) {
                        nameInputBox.value = makeConfigurationName(projectProperty, pathInputBox.value);
                    } else {
                        if ($(nameInputBox).attr('userinput') !== 'true') {
                            var splitName = nameInputBox.value.split(pathInputBox.value);
                            if (splitName.length > 0) {
                                nameInputBox.value = makeConfigurationName(projectProperty, pathInputBox.value);
                            }
                        }
                    }
                } else {
                    notify.warning('Select a file.');
                    return;
                }
            }
        });
    }

    function runButtonClicked(projectProperty, run, runListPane, child, content, arrow) {
        var runList = projectProperty.run;
        var runs = runListPane.domNode;
        var titles = $(runs).find('.rcw-title-name');
        for (var i = 0; i < runList.list.length; i++) {
            if ($(titles[i]).text() === runList.selectedId + ' [latest run]') {
                $(titles[i]).text(runList.list[i].name);
            }
            if ($(titles[i]).text() === run.name) {
                $(titles[i]).text(run.name + ' [latest run]');
            }
        }
        runList.selectedId = run.name;

        var toggled = $(content).attr('toggled');
        if (toggled !== 'unfold') {
            foldButtonClicked(child, arrow, content);
        }

        runProject(projectProperty, run);
    }

    function modifyButtonClicked(modifyButton, saveButton, cancelButton,
                                  runButton, deleteButton, pathButton, inputBoxs, readonlyInputBoxs, checkBox) {
        modifyButton.addClass('rcw-display-none');
        saveButton.removeClass('rcw-display-none');
        cancelButton.removeClass('rcw-display-none');
        runButton.addClass('rcw-display-none');
        deleteButton.addClass('rcw-display-none');
        pathButton.removeClass('rcw-display-none');

        for (var i = 0; i < inputBoxs.length; i++) {
            $(inputBoxs[i]).addClass('rcw-content-table-inputbox-edit');
            $(inputBoxs[i]).removeAttr('readonly');
            inputBoxs[i].oldValue = inputBoxs[i].value ? inputBoxs[i].value : '';
        }

        readonlyInputBoxs[0].oldValue = readonlyInputBoxs[0].value ? readonlyInputBoxs[0].value : '';

        checkBox.removeAttr('disabled');
        checkBox[0].oldValue = checkBox[0].checked;
    }

    function saveButtonClicked(projectProperty, child, runList, run, title,
                                inputBoxs, readonlyInputBoxs, saveButton, cancelButton, modifyButton,
                                runButton, deleteButton, pathButton, checkBoxNode) {
        if (!inputBoxs[0].value) {
            notify.error('Enter a name.');
            return;
        }

        if (isDuplicateRunName(projectProperty, inputBoxs[0].value) && inputBoxs[0].value !== run.name) {
            notify.error('Duplicate name');
            return;
        }

        if (!readonlyInputBoxs[0].value) {
            notify.error('Select a path.');
            return;
        }

        saveButton.addClass('rcw-display-none');
        cancelButton.addClass('rcw-display-none');
        modifyButton.removeClass('rcw-display-none');
        runButton.removeClass('rcw-display-none');
        deleteButton.removeClass('rcw-display-none');
        pathButton.addClass('rcw-display-none');

        for (var i = 0; i < inputBoxs.length; i++) {
            $(inputBoxs[i]).removeClass('rcw-content-table-inputbox-edit');
            $(inputBoxs[i]).attr('readonly', 'true');
        }
        checkBoxNode.attr('disabled', 'disabled');

        var titles = $(child).find('.rcw-title-name');

        if (runList) {
            if (runList.selectedId === run.name) {
                runList.selectedId = inputBoxs[0].value;
                $(titles[0]).text(inputBoxs[0].value + ' [latest run]');
            } else {
                $(titles[0]).text(inputBoxs[0].value);
            }
        } else {
            $(titles[0]).text(inputBoxs[0].value);
        }
        $(title[0]).attr('title', inputBoxs[0].value);

        run.name = inputBoxs[0].value;
        run.path = readonlyInputBoxs[0].value;
        run.argument = inputBoxs[1].value;
        run.fragment = inputBoxs[2].value;
        run.openArgument = inputBoxs[3].value;

        if (checkBoxNode[0].checked === true) {
            run.liveReload = true;
        } else {
            run.liveReload = false;
        }

        notify.success('Successfully modified');
    }

    function cancelButtonClicked(saveButton, cancelButton, modifyButton,
                                  runButton, deleteButton, pathButton, inputBoxs, readonlyInputBoxs, checkBox) {
        saveButton.addClass('rcw-display-none');
        cancelButton.addClass('rcw-display-none');
        modifyButton.removeClass('rcw-display-none');
        runButton.removeClass('rcw-display-none');
        deleteButton.removeClass('rcw-display-none');
        pathButton.addClass('rcw-display-none');

        for (var i = 0; i < inputBoxs.length; i++) {
            $(inputBoxs[i]).removeClass(
                'rcw-content-table-inputbox-edit');
            $(inputBoxs[i]).attr('readonly', 'true');
            inputBoxs[i].value = inputBoxs[i].oldValue ?
                inputBoxs[i].oldValue : '';
        }

        readonlyInputBoxs[0].value = readonlyInputBoxs[0].oldValue ?
            readonlyInputBoxs[0].oldValue : '';

        checkBox.attr('disabled', 'disabled');
        checkBox[0].checked = checkBox[0].oldValue;

        notify.info('Modification canceled');
    }

    function newSaveButtonClicked(projectProperty, child, runList, run, title,
                                   inputBoxs, readonlyInputBoxs, saveButton, newSaveButton, cancelButton,
                                   newCancelButton, modifyButton, runButton, deleteButton, pathButton, checkBox,
                                   createNewButton) {
        if (!inputBoxs[0].value) {
            notify.error('Enter a name.');
            return;
        }

        if (isDuplicateRunName(projectProperty, inputBoxs[0].value) && inputBoxs[0].value !== run.name) {
            notify.error('Duplicate name');
            return;
        }

        if (!readonlyInputBoxs[0].value) {
            notify.error('Select a path.');
            return;
        }

        saveButton.addClass('rcw-display-none');
        newSaveButton.addClass('rcw-display-none');
        cancelButton.addClass('rcw-display-none');
        newCancelButton.addClass('rcw-display-none');
        modifyButton.removeClass('rcw-display-none');
        runButton.removeClass('rcw-display-none');
        deleteButton.removeClass('rcw-display-none');
        pathButton.addClass('rcw-display-none');

        for (var i = 0; i < inputBoxs.length; i++) {
            $(inputBoxs[i]).removeClass('rcw-content-table-inputbox-edit');
            $(inputBoxs[i]).attr('readonly', 'true');
        }
        checkBox.attr('disabled', 'disabled');

        var titles = $(child).find('.rcw-title-name');

        if (runList) {
            if (runList.selectedId === run.name) {
                runList.selectedId = inputBoxs[0].value;
                $(titles[0]).text(inputBoxs[0].value + ' [latest run]');
            } else {
                $(titles[0]).text(inputBoxs[0].value);
            }
        } else {
            $(titles[0]).text(inputBoxs[0].value);
        }
        $(title[0]).attr('title', inputBoxs[0].value);

        run.name = inputBoxs[0].value;
        run.path = readonlyInputBoxs[0].value;
        run.argument = inputBoxs[1].value;
        run.fragment = inputBoxs[2].value;
        run.openArgument = inputBoxs[3].value;

        if (checkBox[0].checked === true) {
            run.liveReload = true;
        } else {
            run.liveReload = false;
        }

        if (!runList) {
            var runListItem = [run];
            runList = {
                selectedId: null,
                list: runListItem
            };
            projectProperty.run = runList;
        } else {
            runList.list.unshift(run);
        }

        //pathButton.set('disabled', true);
        createNewButton.set('disabled', false);

        notify.success('Successfully created');
    }

    function deleteButtonClicked(projectProperty, run, runListPane, markup) {
        var runList = projectProperty.run;
        if (!runList || !runList.list || runList.list.length < 1) {
            notify.error('Cannot read run configurations information');
            return;
        }

        PopupDialog.yesno({
            title: 'Delete Run Configuration',
            message: 'Are you sure you want to delete this run configuration?',
            type: 'info'
        }).then(function () {
            for (var i = 0; i < runList.list.length; i++) {
                if (runList.list[i] === run) {
                    if (runList.selectedId ===  run.name) {
                        runList.selectedId = null;
                    }
                    runList.list.splice(i, 1);
                    break;
                }
            }

            runListPane.removeChild(markup);

            notify.info('Successfully deleted');
        }, function () {
            notify.info('Deletion canceled');
            return;
        });
    }

    function addNewRunToListPane(projectProperty, runListPane) {
        var markup = new ContentPane({
            style: 'text-indent:20px; line-height:100%',
            content: runWidgetHtml
        });

        var child = markup.domNode;
        var title = $(child).find('.rcw-title-name');
        var contentBody = $(child).find('.rcw-content');
        var arrow = $(child).find('.rcw-title-arrow');
        var createNewButton = reg.byId('run-configuration-crete-button');

        var run = projectConfigurator.makeEmptyRunObject();

        $(contentBody).attr('toggled', 'unfold');
        arrow.addClass('rcw-title-arrow-unfold');
        contentBody.addClass('rcw-display-block');

        addFoldButton(child, arrow, contentBody);

        var runButtonNode = $(child).find('.rcw-title-run');
        addButtonCssClass(runButtonNode, '20');

        runButtonNode.addClass('rcw-display-none');

        runButtonNode.bind('mouseup', function () {
            runButtonClicked(projectProperty, run, runListPane, child, contentBody, arrow);
        });

        var deleteButtonNode = $(child).find('.rcw-title-delete');
        addButtonCssClass(deleteButtonNode, '20');

        deleteButtonNode.addClass('rcw-display-none');

        deleteButtonNode.bind('mouseup', function () {
            deleteButtonClicked(projectProperty, run, runListPane, markup);

            createNewButton.set('disabled', false);
        });

        var runList = projectProperty.run;

        var inputBoxNodes = $(child).find('.rcw-content-table-inputbox');

        for (var i = 0; i < inputBoxNodes.length; i++) {
            $(inputBoxNodes[i]).addClass('rcw-content-table-inputbox-edit');
            $(inputBoxNodes[i]).removeAttr('readonly');
        }

        var readonlyInputBoxNodes = $(child).find('.rcw-content-table-inputbox-readonly');

        var checkBoxNode = $(child).find('.rcw-content-table-checkbox');
        checkBoxNode.removeAttr('disabled');

        $(inputBoxNodes[0]).bind('input', function () {
            $(inputBoxNodes[0]).attr('userinput', 'true');
        });

        var modifyButtonNode = $(child).find('.rcw-action-modify');
        addButtonCssClass(modifyButtonNode, '20');
        modifyButtonNode.addClass('rcw-display-none');

        var saveButtonNode = $(child).find('.rcw-action-save');
        addButtonCssClass(saveButtonNode, '24');
        saveButtonNode.addClass('rcw-display-none');

        var newSaveButtonNode = $(child).find('.rcw-action-newsave');
        addButtonCssClass(newSaveButtonNode, '24');

        var cancelButtonNode = $(child).find('.rcw-action-cancel');
        addButtonCssClass(cancelButtonNode, '24');
        cancelButtonNode.addClass('rcw-display-none');

        var newCancelButtonNode = $(child).find('.rcw-action-newcancel');
        addButtonCssClass(newCancelButtonNode, '24');

        var pathButtonNode = $(child).find('.rcw-action-path');
        addButtonCssClass(pathButtonNode, '20');

        createNewButton.set('disabled', true);

        modifyButtonNode.bind('mouseup', function () {
            modifyButtonClicked(modifyButtonNode, saveButtonNode,
                                cancelButtonNode, runButtonNode, deleteButtonNode, pathButtonNode, inputBoxNodes,
                                readonlyInputBoxNodes, checkBoxNode);
        });

        saveButtonNode.bind('mouseup', function () {
            saveButtonClicked(projectProperty, child, runList, run, title,
                              inputBoxNodes, readonlyInputBoxNodes, saveButtonNode,
                              cancelButtonNode, modifyButtonNode, runButtonNode, deleteButtonNode,
                              pathButtonNode, checkBoxNode);
        });

        newSaveButtonNode.bind('mouseup', function () {
            newSaveButtonClicked(projectProperty, child, runList, run, title,
                                 inputBoxNodes, readonlyInputBoxNodes, saveButtonNode,
                                 newSaveButtonNode, cancelButtonNode, newCancelButtonNode,
                                 modifyButtonNode, runButtonNode, deleteButtonNode, pathButtonNode, checkBoxNode,
                                 createNewButton);
        });
        cancelButtonNode.bind('mouseup', function () {
            cancelButtonClicked(saveButtonNode, cancelButtonNode,
                                modifyButtonNode, runButtonNode, deleteButtonNode, pathButtonNode, inputBoxNodes,
                                readonlyInputBoxNodes, checkBoxNode);
        });

        newCancelButtonNode.bind('mouseup', function () {
            runListPane.removeChild(markup);

            createNewButton.set('disabled', false);

            notify.info('Creation canceled');
        });

        pathButtonNode.bind('mouseup', function () {
            pathButtonClicked(projectProperty, readonlyInputBoxNodes[0], inputBoxNodes[0]);
        });

        runListPane.addChild(markup, 0);

        $(document.getElementById('run-configuration-content')).animate({
            scrollTop: 0
        }, 500);

        pathButtonClicked(projectProperty, readonlyInputBoxNodes[0], inputBoxNodes[0]);
    }

    function addRunToListPane(projectProperty, runListPane, run) {
        var markup = new ContentPane({
            style: 'text-indent:20px; line-height:100%',
            content: runWidgetHtml
        });

        var child = markup.domNode;
        var title = $(child).find('.rcw-title-name');

        var contentBody = $(child).find('.rcw-content');
        var arrow = $(child).find('.rcw-title-arrow');

        var runList = projectProperty.run;
        var selected = false;

        if (runList.selectedId === run.name) {
            $(contentBody).attr('toggled', 'unfold');
            arrow.addClass('rcw-title-arrow-unfold');
            contentBody.addClass('rcw-display-block');
            $(title).text(run.name + ' [latest run]');
            selected = true;
        } else {
            $(title).text(run.name);
        }
        $(title).attr('title', run.name);

        addFoldButton(child, arrow, contentBody);

        var runButtonNode = $(child).find('.rcw-title-run');

        addButtonCssClass(runButtonNode, '20');

        runButtonNode.bind('mouseup', function () {
            runButtonClicked(projectProperty, run, runListPane, child, contentBody, arrow);
        });

        var deleteButtonNode = $(child).find('.rcw-title-delete');
        addButtonCssClass(deleteButtonNode, '20');

        deleteButtonNode.bind('mouseup', function () {
            deleteButtonClicked(projectProperty, run, runListPane, markup);
        });

        var inputBoxNodes = $(child).find('.rcw-content-table-inputbox');
        inputBoxNodes[0].value = run.name ? run.name : '';
        inputBoxNodes[1].value = run.argument ? run.argument : '';
        inputBoxNodes[2].value = run.fragment ? run.fragment : '';
        inputBoxNodes[3].value = run.openArgument ? run.openArgument : '';

        var readonlyInputBoxNodes = $(child).find('.rcw-content-table-inputbox-readonly');
        readonlyInputBoxNodes[0].value = run.path;

        var checkBoxNode = $(child).find('.rcw-content-table-checkbox'); //FIXME
        if (run.liveReload) {
            checkBoxNode[0].checked = true;
        } else {
            checkBoxNode[0].checked = false;
        }

        var modifyButtonNode = $(child).find('.rcw-action-modify');
        addButtonCssClass(modifyButtonNode, '20');

        var saveButtonNode = $(child).find('.rcw-action-save');
        addButtonCssClass(saveButtonNode, '24');
        saveButtonNode.addClass('rcw-display-none');

        var newSaveButtonNode = $(child).find('.rcw-action-newsave');
        addButtonCssClass(newSaveButtonNode, '24');
        newSaveButtonNode.addClass('rcw-display-none');

        var cancelButtonNode = $(child).find('.rcw-action-cancel');
        addButtonCssClass(cancelButtonNode, '24');
        cancelButtonNode.addClass('rcw-display-none');

        var newCancelButtonNode = $(child).find('.rcw-action-newcancel');
        addButtonCssClass(newCancelButtonNode, '24');
        newCancelButtonNode.addClass('rcw-display-none');

        var pathButtonNode = $(child).find('.rcw-action-path');
        addButtonCssClass(pathButtonNode, '20');
        pathButtonNode.addClass('rcw-display-none');

        modifyButtonNode.bind('mouseup', function () {
            modifyButtonClicked(modifyButtonNode, saveButtonNode,
                                cancelButtonNode, runButtonNode, deleteButtonNode, pathButtonNode, inputBoxNodes,
                                readonlyInputBoxNodes, checkBoxNode);
        });

        saveButtonNode.bind('mouseup', function () {
            saveButtonClicked(projectProperty, child, runList, run, title,
                              inputBoxNodes, readonlyInputBoxNodes, saveButtonNode,
                              cancelButtonNode, modifyButtonNode, runButtonNode, deleteButtonNode,
                              pathButtonNode, checkBoxNode);
        });

        cancelButtonNode.bind('mouseup', function () {
            cancelButtonClicked(saveButtonNode, cancelButtonNode,
                                modifyButtonNode, runButtonNode, deleteButtonNode, pathButtonNode, inputBoxNodes,
                                readonlyInputBoxNodes, checkBoxNode);
        });

        pathButtonNode.bind('mouseup', function () {
            pathButtonClicked(projectProperty, readonlyInputBoxNodes[0]);
        });

        runListPane.addChild(markup);
        if (selected === true) {
            return markup.id;
        }
    }

    function openRunConfigurationDialog(projectProperty) {
        var runConfigurationDialog = new ButtonedDialog({
            buttons: [
                {
                    caption: 'OK',
                    methodOnClick: 'okOnRunConf'
                }
            ],
            methodOnEnter: null,
            okOnRunConf: function () {
                var unSaveMsg = checkUnsavedConf();
                if (unSaveMsg) {
                    PopupDialog.yesno({
                        title: 'Run Configuration',
                        message: 'Run configuration has ' + unSaveMsg +
                        '. Are you sure you want to close this dialog?',
                        type: 'info'
                    }).then(function () {
                        runConfigurationDialog.hide();
                    }, function () {
                        return;
                    });
                } else {
                    runConfigurationDialog.hide();
                }
            },

            refocus: false,
            title: 'Run Configuration - ' + projectProperty.name,
            style: 'width: 600px',
            onHide: function () {
                saveProjectPropertyToFile(projectProperty); // ???
                runConfigurationDialog.destroyRecursive();
                workbench.focusLastWidget();
            },
            onLoad: function () {
                var runListPane = reg.byId('run-configuration-list-contentpane');
                var selectedID = null;
                if (projectProperty.run) {
                    var runList = projectProperty.run;
                    var temp;
                    if (runList && runList.list) {
                        for (var i = 0; i < runList.list.length; i++) {
                            temp = addRunToListPane(projectProperty, runListPane, runList.list[i]);
                            if (temp) {
                                selectedID = temp;
                            }
                        }
                    }
                }

                var createNewButton = reg.byId('run-configuration-crete-button');
                dojo.connect(createNewButton, 'onClick', function () {
                    createNewButton.set('disabled', true);
                    addNewRunToListPane(projectProperty, runListPane);
                });
            }
        });
        runConfigurationDialog.set('doLayout', false);
        runConfigurationDialog.setContentArea(runConfHtml);
        runConfigurationDialog.show();
    }

    function getRunConfigurationByName(projectProperty, name) {
        if (!projectProperty || !name) {
            return null;
        }

        var runObj = projectProperty.run;
        if (!runObj) {
            return null;
        }

        var runObjList = runObj.list;
        if (!runObjList) {
            return null;
        }

        for (var i = 0; i < runObjList.length; i++) {
            if (runObjList[i].name === name) {
                return runObjList[i];
            }
        }
        return null;
    }

    function _runBinded(projectProperty, mode) {
        var runConf;

        if (!projectProperty.run || !projectProperty.run.list || projectProperty.run.list.length === 0) {
            notify.info('Cannot find a run configuration. Add a new one.');
            openRunConfigurationDialog(projectProperty);
        } else if (projectProperty.run.list.length === 1) {
            runConf = getRunConfigurationByName(projectProperty,
                                                projectProperty.run.list[0].name);
            if (runConf) {
                projectProperty.run.selectedId = runConf.name;
                runProject(projectProperty, runConf);
            } else {
                notify.warning('Cannot find a run configuration. Add a new one.');
                openRunConfigurationDialog(projectProperty);
            }
            return;
        } else if (!projectProperty.run.selectedId) {
            notify.warning('Cannot find the latest run. Choose a run configuration and click run button');
            openRunConfigurationDialog(projectProperty);
        } else {
            runConf = getRunConfigurationByName(projectProperty,
                                                projectProperty.run.selectedId);
            if (runConf) {
                runProject(projectProperty, runConf, mode);
            } else {
                notify.warning('Cannot find the latest run. Choose a run configuration and click run button');
                openRunConfigurationDialog(projectProperty);
            }
        }
    }

    module.workspaceRunBinded = function () {
        var selectedPaths = workspace.getSelectedPaths();
        if (!selectedPaths || selectedPaths.length !== 1) {
            return null;
        }

        var selectedPath = selectedPaths[0];
        if (!selectedPath) {
            return;
        }
        var nodeSplit = selectedPath.split('/');
        var projectName = nodeSplit[2];
        var projectProperty = projectConfigurator.getConfigurationObjectByProjectName(projectName);
        if (!projectProperty) {
            projectConfigurator.createProjectProperty(
                workspace.getRootPath() + projectName + '/', function () {
                    projectProperty = projectConfigurator.getConfigurationObjectByProjectName(projectName);
                    _runBinded(projectProperty);
                });
        } else {
            _runBinded(projectProperty);
        }
    };

    module.workbenchDebugBinded = function () {
        this._workbenchRunBinded(projectConfigurator.DEBUG_MODE);
    };

    module.workbenchRunBinded = function () {
        this._workbenchRunBinded(projectConfigurator.RUN_MODE);
    };

    module._workbenchRunBinded = function (mode) {
        var context = workbench.getContext();
        var contextPaths;

        if (context && context.paths) {
            contextPaths = context.paths;
            if (contextPaths.length === 1) {
                var bRunnable = isRunnablePath(contextPaths[0]);
                if (bRunnable !== true) {
                    return;
                }
            } else {
                return;
            }
        }

        if (!contextPaths) {
            console.error('No valid context path');
            return;
        }
        var contextPath = contextPaths[0];
        if (contextPath === workspace.getRootPath()) {
            notify.warning('Cannot run workspace directory');
        }

        var projectName = parseProjectNameFromPath(contextPath);
        var projectProperty = projectConfigurator.getConfigurationObjectByProjectName(projectName);
        if (!projectProperty) {
            projectConfigurator.createProjectProperty(
                workspace.getRootPath() + projectName + '/', function () {
                    projectProperty = projectConfigurator.getConfigurationObjectByProjectName(projectName);
                    _runBinded(projectProperty);
                });
        } else {
            _runBinded(projectProperty, mode);
        }
    };

    function _runListBinded(projectProperty, runConfName) {
        if (runConfName === 'Run configurations') {
            openRunConfigurationDialog(projectProperty);
        } else {
            var runConfNameSplit = runConfName.split(' [');
            var name = runConfNameSplit[0];
            var runConf = getRunConfigurationByName(projectProperty, name);
            if (runConf) {
                projectProperty.run.selectedId = name;
            } else {
                runConf = projectConfigurator.makeEmptyRunObject();
                runConf.name = name;
                runConf.path = name;

                if (!projectProperty.run) {
                    var runListItem = [runConf];
                    var runList = {
                        selectedId: runConf.name,
                        list: runListItem
                    };
                    projectProperty.run = runList;
                } else {
                    projectProperty.run.selectedId = runConf.name;
                    projectProperty.run.list.unshift(runConf);
                }
            }
            saveProjectPropertyToFile(projectProperty);
            runProject(projectProperty, runConf, projectConfigurator.RUN_MODE);
        }
    }

    function isRunnableProjectPath(projectLevelPath) {
        if (!projectLevelPath || !pathUtil.isDirPath(projectLevelPath)) {
            return false;
        }

        var projectName = pathUtil.getName(projectLevelPath);
        if (!projectName || projectName[0] === '.') {
            return false;
        }

        return true;
    }

    function isRunnablePath(path) {
        var projectPath = projectConfigurator.getProjectRootPath(path);
        return isRunnableProjectPath(projectPath);
    }

    module.workspaceRunListBinded = function (arg) {
        var runString = pc.getContextItem(arg);
        if (!runString) {
            return null;
        }
        var runStirngSplit = runString.split(' : ');
        var projectName = runStirngSplit[0];
        var runConfName = runStirngSplit[1];

        var projectProperty = projectConfigurator.getConfigurationObjectByProjectName(
            projectName);

        if (!projectProperty) {
            projectConfigurator.createProjectProperty(
                workspace.getRootPath() + projectName + '/', function () {
                    projectProperty = projectConfigurator.getConfigurationObjectByProjectName(projectName);
                    _runListBinded(projectProperty, runConfName);
                });
        } else {
            _runListBinded(projectProperty, runConfName);
        }
    };

    module.workbenchRunListBinded = function (arg) {
        var runString = pc.getContextItem(arg);
        if (!runString) {
            return null;
        }

        var runStirngSplit = runString.split(' : ');
        var projectName = runStirngSplit[0];
        var runConfName = runStirngSplit[1];
        var projectProperty = projectConfigurator.getConfigurationObjectByProjectName(projectName);
        if (!projectProperty) {
            projectConfigurator.createProjectProperty(
                workspace.getRootPath() + projectName + '/', function () {
                    projectProperty = projectConfigurator.getConfigurationObjectByProjectName(projectName);
                    _runListBinded(projectProperty, runConfName);
                });
        } else {
            _runListBinded(projectProperty, runConfName);
        }
    };

    function parseProjectNameFromPath(path) {
        if (!path) {
            return '';
        }

        var splitPath = path.split('/');
        if (!splitPath || splitPath.length < 3) {
            return '';
        }

        return splitPath[2];
    }

    return module;
});


text:
INSERT INTO INGREDIENTES_PLATO VALUES (1, 'Papa');
INSERT INTO INGREDIENTES_PLATO VALUES (1, 'Papa');

SELECT * FROM INGREDIENTES_PLATO;

redpajama_set_name: RedPajamaGithub


text:
// Copyright (c) 2008, 2009 Andrew Cantino
// Copyright (c) 2008, 2009 Kyle Maxwell

/*
    Modified by Thamara Alves.
    Fevrier 2016, days working on: 1, 2
*/

function SelectorGadget() {
  this.border_width = 5;
  this.border_padding = 2;
  this.b_top = null;
  this.b_left = null;
  this.b_right = null;
  this.b_bottom = null;
  this.selected = [];
  this.rejected = [];
  this.special_mode = null;
  this.path_output_field = null;
  this.sg_div = null;
  this.unbound = false;
  this.prediction_helper = new DomPredictionHelper();
  this.restricted_elements = jQuery.map(['html', 'body', 'head', 'base'], function(selector) { return                     jQuery(selector).get(0) });
}

SelectorGadget.prototype = new Object();

SelectorGadget.prototype.makeBorders = function(orig_elem, makeRed) {

  this.removeBorders();
  this.setupBorders();

  if (orig_elem.parentNode)
    var path_to_show = orig_elem.parentNode.tagName.toLowerCase() + ' ' + orig_elem.tagName.toLowerCase();
  else
  var path_to_show = orig_elem.tagName.toLowerCase();

  var elem = jQuery(orig_elem);
  var p = elem.offset();

  var top = p.top;
  var left = p.left;
  var width = elem.outerWidth()
  var height = elem.outerHeight()

  this.b_top.css('width', this.px(width + this.border_padding * 2 + this.border_width * 2)).
             css('top', this.px(top - this.border_width - this.border_padding)).
             css('left', this.px(left - this.border_padding - this.border_width));
  this.b_bottom.css('width', this.px(width + this.border_padding * 2 + this.border_width * 2 - 5)).
                css('top', this.px(top + height + this.border_padding)).
                css('left', this.px(left - this.border_padding - this.border_width)).text(path_to_show);
  this.b_left.css('height', this.px(height + this.border_padding * 2)).
              css('top', this.px(top - this.border_padding)).
              css('left', this.px(left - this.border_padding - this.border_width));
  this.b_right.css('height', this.px(height + this.border_padding * 2)).
               css('top', this.px(top - this.border_padding)).
               css('left', this.px(left + width + this.border_padding));

  this.b_right.get(0).target_elem = this.b_left.get(0).target_elem = this.b_top.get(0).target_elem = this.b_bottom.get(0).target_elem = orig_elem;

  if (makeRed || elem.hasClass("sg_suggested") || elem.hasClass("sg_selected")) {
    this.b_top.addClass('sg_border_red');
    this.b_bottom.addClass('sg_border_red');
    this.b_left.addClass('sg_border_red');
    this.b_right.addClass('sg_border_red');
  } else {
    if (this.b_top.hasClass('sg_border_red')) {
      this.b_top.removeClass('sg_border_red');
      this.b_bottom.removeClass('sg_border_red');
      this.b_left.removeClass('sg_border_red');
      this.b_right.removeClass('sg_border_red');
    }
  }

  this.showBorders();
};

SelectorGadget.prototype.px = function(p) {
  return p + 'px';
};

SelectorGadget.prototype.showBorders = function() {
  this.b_top.show();
  this.b_bottom.show();
  this.b_left.show();
  this.b_right.show();
};

SelectorGadget.prototype.removeBorders = function() {
  if (this.b_top) {
    this.b_top.hide();
    this.b_bottom.hide();
    this.b_left.hide();
    this.b_right.hide();
  }
}

SelectorGadget.prototype.setupBorders = function() {
  if (!this.b_top) {
    var width = this.border_width + 'px';
    this.b_top = jQuery('
').addClass('sg_border').css('height', width).hide().bind("mousedown.sg", { 'self': this }, this.sgMousedown);
    this.b_bottom = jQuery('
').addClass('sg_border').addClass('sg_bottom_border').css('height', this.px(this.border_width + 6)).hide().bind("mousedown.sg", { 'self': this }, this.sgMousedown);
    this.b_left = jQuery('
').addClass('sg_border').css('width', width).hide().bind("mousedown.sg", { 'self': this }, this.sgMousedown);
    this.b_right = jQuery('
').addClass('sg_border').css('width', width).hide().bind("mousedown.sg", { 'self': this }, this.sgMousedown);

    this.addBorderToDom();
  }
};

SelectorGadget.prototype.addBorderToDom = function() {
  document.body.appendChild(this.b_top.get(0));
  document.body.appendChild(this.b_bottom.get(0));
  document.body.appendChild(this.b_left.get(0));
  document.body.appendChild(this.b_right.get(0));
};

SelectorGadget.prototype.removeBorderFromDom = function() {
  if (this.b_top) {
    this.b_top.remove();
    this.b_bottom.remove();
    this.b_left.remove();
    this.b_right.remove();
  }
};

SelectorGadget.prototype.sgMouseover = function(e) {
  var gadget = e.data.self;
  if (gadget.unbound) return true;
  if (this == document.body || this == document.body.parentNode) return false;
  var self = jQuery(this);
  if (gadget.special_mode != 'd') { // Jump to any the first selected parent of this node.
    var parent = gadget.firstSelectedOrSuggestedParent(this);
    if (parent != null && parent != this)
      gadget.makeBorders(parent, true);
    else
      gadget.makeBorders(this);
  } else {
    if (!jQuery('.sg_selected', this).get(0)) {
      gadget.makeBorders(this);
    }
  }
  return false;
};

SelectorGadget.prototype.firstSelectedOrSuggestedParent = function(elem) {
  var orig = elem;
  if (jQuery(elem).hasClass('sg_suggested') || jQuery(elem).hasClass('sg_selected')) return elem
  while (elem.parentNode && (elem = elem.parentNode)) {
    if (jQuery.inArray(elem, this.restricted_elements) == -1)
      if (jQuery(elem).hasClass('sg_suggested') || jQuery(elem).hasClass('sg_selected')) return elem
  }
  return null;
};

SelectorGadget.prototype.sgMouseout = function(e) {
  if (e.data.self.unbound) return true;
  if (this == document.body || this == document.body.parentNode) return false;
  e.data.self.removeBorders();
  return false;
};

SelectorGadget.prototype.sgMousedown = function(e) {
  var gadget = e.data.self;
  if (gadget.unbound) return true;
  var elem = this;
  var w_elem = jQuery(elem);

  if (w_elem.hasClass('sg_border')) {
    // They have clicked on one of our floating borders, target the element that we are bordering.
    elem = elem.target_elem || elem;
    w_elem = jQuery(elem);
  }

  if (elem == document.body || elem == document.body.parentNode) return;

  if (gadget.special_mode != 'd') {
    var potential_elem = gadget.firstSelectedOrSuggestedParent(elem);
    if (potential_elem != null && potential_elem != elem) {
      elem = potential_elem;
      w_elem = jQuery(elem);
    }
  } else {
    if (jQuery('.sg_selected', this).get(0)) gadget.blockClicksOn(elem); // Don't allow selection of elements that have a selected child.
  }

  if (w_elem.hasClass('sg_selected')) {
    w_elem.removeClass('sg_selected');
    gadget.selected.splice(jQuery.inArray(elem, gadget.selected), 1);
  } else if (w_elem.hasClass("sg_rejected")) {
    w_elem.removeClass('sg_rejected');
    gadget.rejected.splice(jQuery.inArray(elem, gadget.rejected), 1);
  } else if (w_elem.hasClass("sg_suggested")) {
    w_elem.addClass('sg_rejected');
    gadget.rejected.push(elem);
  } else {
    w_elem.addClass('sg_selected');
    gadget.selected.push(elem);
  }

  gadget.clearSuggested()
  var prediction = gadget.prediction_helper.predictCss(gadget.selected, gadget.rejected.concat(gadget.restricted_elements));
  gadget.suggestPredicted(prediction);
  gadget.setPath(prediction);
  gadget.removeBorders();

  gadget.blockClicksOn(elem);

  w_elem.trigger("mouseover.sg", { 'self': gadget }); // Refresh the borders by triggering a new mouseover event.

  return false;
};

SelectorGadget.prototype.setupEventHandlers = function() {
  jQuery("*:not(.sg_ignore)").bind("mouseover.sg", { 'self': this }, this.sgMouseover);
  jQuery("*:not(.sg_ignore)").bind("mouseout.sg", { 'self': this }, this.sgMouseout);
  jQuery("*:not(.sg_ignore)").bind("mousedown.sg", { 'self': this }, this.sgMousedown);
  jQuery("html").bind("keydown.sg", { 'self': this }, this.listenForActionKeys);
  jQuery("html").bind("keyup.sg", { 'self': this }, this.clearActionKeys);
};

// Why doesn't this work?
// SelectorGadget.prototype.removeEventHandlers = function() {
//   // For some reason the jQuery unbind isn't working for me.
//
//   // jQuery("*").unbind("mouseover.sg");//,  );
//   // jQuery("*").unbind("mouseout.sg");//, this.sgMouseout);
//   // jQuery("*").unbind("click.sg");//, this.sgMousedown);
//   // jQuery("html").unbind("keydown.sg");//, this.listenForActionKeys);
//   // jQuery("html").unbind("keyup.sg");//, this.clearActionKeys);
// };

// The only action key right now is shift, which snaps to any div that has been selected.
SelectorGadget.prototype.listenForActionKeys = function(e) {
  var gadget = e.data.self;
  if (gadget.unbound) return true;
  if (e.keyCode == 16 || e.keyCode == 68) { // shift or d
    gadget.special_mode = 'd';
    gadget.removeBorders();
  }
};

SelectorGadget.prototype.clearActionKeys = function(e) {
  var gadget = e.data.self;
  if (gadget.unbound) return true;
  gadget.removeBorders();
  gadget.special_mode = null;
};

// Block clicks for a moment by covering this element with a div.  Eww?
SelectorGadget.prototype.blockClicksOn = function(elem) {
  var elem = jQuery(elem);
  var p = elem.offset();
  var block = jQuery('
').css('position', 'absolute').css('z-index', '9999999').css('width', this.px(elem.outerWidth())).
                              css('height', this.px(elem.outerHeight())).css('top', this.px(p.top)).css('left', this.px(p.left)).
                              css('background-color', '');
  document.body.appendChild(block.get(0));
  setTimeout(function() { block.remove(); }, 400);
  return false;
};

SelectorGadget.prototype.setMode = function(mode) {
  if (mode == 'browse') {
    this.removeEventHandlers();
  } else if (mode == 'interactive') {
    this.setupEventHandlers();
  }
  this.clearSelected();
};

SelectorGadget.prototype.suggestPredicted = function(prediction) {
  if (prediction && prediction != '') {
    var count = 0;
    jQuery(prediction).each(function() {
      count += 1;
      if (!jQuery(this).hasClass('sg_selected') && !jQuery(this).hasClass('sg_ignore') && !jQuery(this).hasClass('sg_rejected')) jQuery(this).addClass('sg_suggested');
    });

   /* if (this.clear_button) {
      if (count > 0) {
        this.clear_button.attr('value', 'Clear (' + count + ')');
      } else {
        this.clear_button.attr('value', 'Clear');
      }
    }*/
  }
};

SelectorGadget.prototype.setPath = function(prediction) {
  if (prediction && prediction.length > 0)
    this.path_output_field.value = prediction;
  /*else
    this.path_output_field.value = 'No valid path found.';*/
};

SelectorGadget.prototype.refreshFromPath = function(e) {
  var self = (e && e.data && e.data.self) || this;
  var path = self.path_output_field.value;
  self.clearSelected();
  self.suggestPredicted(path);
  self.setPath(path);
};

SelectorGadget.prototype.showXPath = function(e) {
  var self = (e && e.data && e.data.self) || this;
  var path = self.path_output_field.value;
  if (path == 'No valid path found.') return;
  prompt("The CSS selector '" + path + "' as an XPath is shown below.  Please report any bugs that you find with this converter.",
         self.prediction_helper.cssToXPath(path));
};

SelectorGadget.prototype.clearSelected = function(e) {
  var self = (e && e.data && e.data.self) || this;
  self.selected = [];
  self.rejected = [];
  jQuery('.sg_selected').removeClass('sg_selected');
  jQuery('.sg_rejected').removeClass('sg_rejected');
  self.removeBorders();
  self.clearSuggested();
};

SelectorGadget.prototype.clearEverything = function(e) {
  var self = (e && e.data && e.data.self) || this;
  self.clearSelected()
  self.resetOutputs()
};

SelectorGadget.prototype.resetOutputs = function() {
  this.setPath();
};

SelectorGadget.prototype.clearSuggested = function() {
  jQuery('.sg_suggested').removeClass('sg_suggested');
 // if (this.clear_button) this.clear_button.attr('value', 'Clear');
};

SelectorGadget.prototype.showHelp = function() {
  alert("(Better help coming soon!  Please visit http://selectorgadget.com!  Please report bugs!)\n\nClick on a page element that you would like your selector to match (it will turn green). SelectorGadget will then generate a minimal CSS selector for that element, and will highlight (yellow) everything that is matched by the selector. Now click on a highlighted element to remove it from the selector (red), or click on an unhighlighted element to add it to the selector. Through this process of selection and rejection, SelectorGadget helps you to come up with the perfect CSS selector for your needs.\n\nHolding 'shift' while moving the mouse will let you select elements inside of other selected ones.");
};

SelectorGadget.prototype.makeInterface = function() {
  this.sg_div = jQuery('
').attr('id', '_sg_div').addClass('sg_bottom').addClass('sg_ignore');
  var self = this;
 /* var path = jQuery('<input>').attr('id', '_sg_path_field').addClass('sg_ignore').keydown(function(e) {
    if (e.keyCode == 13) {
      return self.refreshFromPath(e);
    }
  }).focus(function() { jQuery(this).select(); });
  this.sg_div.append(path);*/
 // this.clear_button = jQuery('<input type="button" value="Clear"/>').bind("click", {'self': this}, this.clearEverything).addClass('sg_ignore');
//  this.sg_div.append(this.clear_button);
 /* this.sg_div.append(jQuery('<input type="button" value="Toggle Position"/>').click(function() {
    if (self.sg_div.hasClass('sg_top')) {
      self.sg_div.removeClass('sg_top').addClass('sg_bottom');
    } else {
      self.sg_div.removeClass('sg_bottom').addClass('sg_top');
    }
  }).addClass('sg_ignore'));*/

/*  this.sg_div.append(jQuery('<input type="button" value="XPath"/>').bind("click", {'self': this}, this.showXPath).addClass('sg_ignore'));

  this.sg_div.append(jQuery('<input type="button" value="Help"/>').bind("click", {'self': this}, this.showHelp).addClass('sg_ignore'));

  this.sg_div.append(jQuery('<input type="button" value="X"/>').bind("click", {'self': this}, this.unbind).addClass('sg_ignore'));*/

  // this.sg_div.append(
  //   jQuery('Show XPath').bind("click", {'self': this}, this.showXPath)
  // );

  jQuery('body').append(this.sg_div);

 // this.path_output_field = path.get(0);
};

SelectorGadget.prototype.removeInterface = function(e) {

if (this.sg_div!=null)
{
  this.sg_div.remove();
  this.sg_div = null;
  this.removeBorderFromDom();
}
};

SelectorGadget.prototype.unbind = function(e) {
  var self = (e && e.data && e.data.self) || this;
  self.unbound = true;
  self.removeInterface();
  self.clearSelected();
};

SelectorGadget.prototype.setOutputMode = function(e, output_mode) {
  var self = (e && e.data && e.data.self) || this;
  self.output_mode = (e && e.data && e.data.mode) || output_mode;

};

SelectorGadget.prototype.rebind = function() {
  this.unbound = false;
  this.makeInterface();
  this.clearEverything();
  this.setupBorders();
  this.addBorderToDom();
};

SelectorGadget.prototype.randBetween = function(a, b) {
  return Math.floor(Math.random() * b) + a;
};

SelectorGadget.prototype.hideStatus = function(elements){
    for (i=0; i < elements.length; i++)
        if($(elements[i])!=null)
            $(elements[i]).hide()
};

SelectorGadget.prototype.showStatus = function(elements){
    for (i=0; i < elements.length; i++)
        if($(elements[i])!=null)
            $(elements[i]).show()
};

 SelectorGadget.prototype.createTheGrid = function(){

      var SG = window.selector_gadget

      //

      var gridDiv = jQuery('
', { id: 'sg-grid'})

      SG.sg_div.append(gridDiv)

      SG.path_output_field = TxtStatus.get(0)

      var data = [
            { id: 1, text: "text 1", position: 0 },
            { id: 2, text: "text 2", position: 1 },
            { id: 3, text: "text 3", position: 2 }
        ]

        var dataSource = new kendo.data.DataSource({
                data: data,
                schema: {
                    model: {
                        id: "id",
                        fields: {
                            id: { type: "number" },
                            text: { type: "string" },
                            position: { type: "number" }
                        }
                    }
                }
            });

        var grid = $("#sg-grid").kendoGrid({
            dataSource: dataSource,
            scrollable: false,
            columns: ["id", "text", "position"]
        }).data("kendoGrid");

        grid.table.kendoDraggable({
            filter: "tbody > tr",
            group: "gridGroup",
            hint: function(e) {
                return $('

' + e.html() + '

');
            }
        });

        grid.table/*.find("tbody > tr")*/.kendoDropTarget({
            group: "gridGroup",
            drop: function(e) {
                var target = dataSource.get($(e.draggable.currentTarget).data("id")),
                    dest = $(e.target);

                if (dest.is("th")) {
                    return;
                }
                dest = dataSource.get(dest.parent().data("id"));

                //not on same item
                if (target.get("id") !== dest.get("id")) {
                    //reorder the items
                    var tmp = target.get("position");
                    target.set("position", dest.get("position"));
                    dest.set("position", tmp);

                    dataSource.sort({ field: "position", dir: "asc" });
                }
            }
        });
 };

/*
SelectorGadget.prototype.analytics = function() {
  // http://www.vdgraaf.info/google-analytics-without-javascript.html
  var utmac = 'UA-148948-9';
  var utmhn = encodeURIComponent('www.selectorgadget.com');
  var utmn = this.randBetween(1000000000,9999999999); //random request number
  var cookie = this.randBetween(10000000,99999999); //random cookie number
  var random = this.randBetween(1000000000,2147483647); //number under 2147483647
  var today = Math.round(new Date().getTime()/1000.0);
  var referer = encodeURIComponent(window.location.href); //referer url
  var uservar='-'; //enter your own user defined variable
  var utmp='sg';

  var urchinUrl = 'http://www.google-analytics.com/__utm.gif?utmwv=1&utmn=' + utmn + '&utmsr=-&utmsc=-&utmul=-&utmje=0&utmfl=-&utmdt=-&utmhn=' + utmhn + '&utmr=' + referer + '&utmp=' + utmp + '&utmac=' + utmac + '&utmcc=__utma%3D' + cookie + '.' + random + '.' + today + '.' + today + '.' + today + '.2%3B%2B__utmb%3D' + cookie + '%3B%2B__utmc%3D' + cookie + '%3B%2B__utmz%3D' + cookie + '.' + today + '.2.2.utmccn%3D(direct)%7Cutmcsr%3D(direct)%7Cutmcmd%3D(none)%3B%2B__utmv%3D' + cookie + '.' + uservar + '%3B';
  document.body.appendChild(jQuery('').attr('src', urchinUrl).get(0));
};
*/

// And go!
if (typeof(selector_gadget) == 'undefined' || selector_gadget == null) {
  (function() {
    selector_gadget = new SelectorGadget();
    selector_gadget.makeInterface();
    selector_gadget.clearEverything();
    selector_gadget.setMode('interactive');
   // selector_gadget.analytics();
  })();
} else if (selector_gadget.unbound) {
  selector_gadget.rebind();
} else {
  selector_gadget.unbind();
}

jQuery('.selector_gadget_loading').remove();

// THE CODES BELOW CREATE THE STATUS
var SG = window.selector_gadget

// Add field to display current selection (note the use of jQuerySG,
// SelectorGadget's jQuery alias).
var TxtStatus = jQuery('<input>', { id: 'sg-status', class: 'selectorgadget_ignore' })

if (SG.sg_div!=null)
{
    TxtStatus.css('width', 300)

    SG.sg_div.append(TxtStatus)

    SG.path_output_field = TxtStatus.get(0)

    // Add button to dismiss SelectorGadget
    var btnOk = jQuery('<button>', { id: 'sg-ok', class: 'selectorgadget_ignore' }).text('OK')

    SG.sg_div.append(btnOk)

    jQuery(btnOk).bind('click', function(event) {
      jQuery(SG).unbind()
      jQuery(SG.sg_div).unbind()
      //SG.unbindAndRemoveInterface()
      SG.unbind()
      SG.removeInterface()
      SG = null
    })

    // Watch the input field for changes
    var val = saved = TxtStatus.val()
    var tid = setInterval(function() {
      val = TxtStatus.val()
      if(saved != val) {
        console.log('New path', val, 'matching', (jQuery(val).length), 'element(s)')
        saved = val
      }
    }, 50)

    var elements = []
    elements.push(btnOk, TxtStatus)

    //hide path
  SelectorGadget.prototype.hideStatus(elements)

  SelectorGadget.prototype.createTheGrid()

};

/*window.sg_options = {
   remote_interface: 'lib/sg_interface.js'
}

if (typeof window.selector_gadget!="undefined")
    window.selector_gadget = new SelectorGadget()*/


text:
<?php

defined('COT_CODE') or die('Wrong URL');

// ========================
// MySQL database parameters. Change to fit your host.
// ========================

$cfg['mysqlhost'] = 'localhost';	// Database host URL
$cfg['mysqlport'] = '';				// Database port, if non-default
$cfg['mysqluser'] = 'root';			// Database user
$cfg['mysqlpassword'] = '';			// Database password
$cfg['mysqldb'] = 'cotonti';		// Database name
// MySQL database charset and collate. Very useful when MySQL server uses different charset rather than site
// See the list of valid values here: http://dev.mysql.com/doc/refman/5.1/en/charset-charsets.html
$cfg['mysqlcharset'] = 'utf8';
$cfg['mysqlcollate'] = 'utf8_unicode_ci';

// ========================
// Main site URL without trailing slash.
// ========================

$cfg['mainurl'] = 'http://localhost';
$cfg['site_id'] = 'Some unique string specific to your site';
$cfg['secret_key'] = 'Secret key used for authentication, make it unique and keep in secret!';
$cfg['multihost'] = FALSE;			// Allow multiple host names for this site

// ========================
// Default theme, color scheme and default language
// ========================

$cfg['defaulttheme'] = 'nemesis';	// Default theme code. Be SURE it's pointing to a valid folder in ./themes/... !!
$cfg['defaultscheme'] = 'default';	// Default color scheme, only name, not like themename.css. Be SURE it's pointing to a valid folder in ./themes/defaulttheme/... !!
$cfg['defaulticons'] = 'default';	// Default icon pack
$cfg['defaultlang'] = 'en';			// Default language code
$cfg['enablecustomhf'] = FALSE;		// To enable header.$location.tpl and footer.$location.tpl
$cfg['admintheme'] = '';			// Put custom administration theme name here

// ========================
// Performance-related settings
// ========================

$cfg['cache'] = TRUE;			// Enable data caching
$cfg['cache_drv'] = '';			// Cache driver name to use on your server (if available)
								// Possible values: APC, Memcache, Xcache
$cfg['xtpl_cache'] = TRUE;		// Enable XTemplate structure disk cache. Should be TRUE on production sites
$cfg['html_cleanup'] = FALSE;	// Wipe extra spaces and breaks from HTML to get smaller footprint

$cfg['cache_index'] = FALSE;    // Static page cache for guests on index
$cfg['cache_page'] = FALSE;     // Static page cache for guests on pages and categories
$cfg['cache_forums'] = FALSE;   // Static page cache for guests on forums

// ========================
// More settings
// Should work fine in most of cases.
// If you don't know, don't change.
// TRUE = enabled / FALSE = disabled
// ========================

$cfg['check_updates'] = FALSE;		// Automatically check for updates, set it TRUE to enable

$cfg['display_errors'] = TRUE;		// Display error messages. Switch it FALSE on production sites

$cfg['redirmode'] = FALSE;			// 0 or 1, Set to '1' if you cannot sucessfully log in (IIS servers)
$cfg['xmlclient'] = FALSE;  		// For testing-purposes only, else keep it off.
$cfg['ipcheck'] = FALSE;  			// Will kill the logged-in session if the IP has changed
$cfg['authcache'] = TRUE;			// Auth cache in SQL tables. Set it FALSE if your huge database
									// goes down because of that
$cfg['customfuncs'] = FALSE;		// Includes file named functions.custom.php
$cfg['new_install'] = 1;			// This setting denotes a new install step and redirects you to the install page
									// If you already have Cotonti installed then set it to FALSE or remove it
$cfg['useremailduplicate'] = FALSE;     // Allow users to register new accounts with duplicate email. DO NOT ENABLE this setting unless you know for sure that you need it or it may make your database inconsistent.

// ========================
// Directory paths
// Set it to custom if you want to share
// folders among different hosts.
// ========================

$cfg['avatars_dir'] = 'datas/avatars';
$cfg['cache_dir'] = 'datas/cache';
$cfg['lang_dir'] = 'lang';
$cfg['modules_dir'] = 'modules';
$cfg['pfs_dir'] = 'datas/users';
$cfg['photos_dir'] = 'datas/photos';
$cfg['plugins_dir'] = 'plugins';
$cfg['system_dir'] = 'system';
$cfg['thumbs_dir'] = 'datas/thumbs';
$cfg['themes_dir'] = 'themes';
$cfg['extrafield_files_dir'] = 'datas/exflds';
$cfg['icons_dir'] = 'images/icons';

// ========================
// Directory and file permissions for uploaded files
// and files created with scripts.
// You can set it to values which deliver highest
// security and comfort on your host.
// ========================

$cfg['dir_perms'] = 0777;
$cfg['file_perms'] = 0664;

// ========================
// Important constant switches
// ========================

/**
 * Defines whether to display debugging information on critical errors.
 * Set it TRUE when you experiment with something new.
 * Set it FALSE on production sites.
 */
$cfg['debug_mode'] = FALSE;

/**
 * Path to debug log files used by functions which dump debug data into it.
 * This file MUST NOT be available to strangers (e.g. via HTTP) or it can
 * compromise your website security. Protect it with .htaccess or use some
 * path accessible to you only via FTP.
 */
$cfg['debug_logpath'] = 'datas/tmp';

/**
 * The shield is disabled for administrators by default. But if you are testing
 * it with your admin account, you can enable it by setting this TRUE.
 */
$cfg['shield_force'] = FALSE;

// ========================
// Names for MySQL tables
// Only change if you'd like to
// make 2 separated installs in the same database.
// or you'd like to share some tables between 2 sites.
// Else do not change.
// ========================

$db_x				= 'cot_'; // Default: cot_, prefix for extra fields' table(s)

// Examples:
// $db_auth			= 'my_custom_auth';
// $db_cache 		= 'my_custom_cache';


text:
<?php

namespace DTS\eBaySDK\Trading\Types;

/**
 *
 * @property string $Sender
 * @property string $RecipientUserID
 * @property string $SendToName
 * @property string $Subject
 * @property string $MessageID
 * @property string $ExternalMessageID
 * @property string $ContentType
 * @property string $Text
 * @property boolean $Flagged
 * @property boolean $Read
 * @property \DateTime $CreationDate
 * @property \DateTime $ReceiveDate
 * @property \DateTime $ExpirationDate
 * @property string $ItemID
 * @property \DTS\eBaySDK\Trading\Types\MyMessagesResponseDetailsType $ResponseDetails
 * @property \DTS\eBaySDK\Trading\Types\MyMessagesFolderType $Folder
 * @property string $Content
 * @property \DTS\eBaySDK\Trading\Enums\MessageTypeCodeType $MessageType
 * @property \DTS\eBaySDK\Trading\Enums\ListingStatusCodeType $ListingStatus
 * @property \DTS\eBaySDK\Trading\Enums\QuestionTypeCodeType $QuestionType
 * @property boolean $Replied
 * @property boolean $HighPriority
 * @property \DateTime $ItemEndTime
 * @property string $ItemTitle
 * @property \DTS\eBaySDK\Trading\Types\MessageMediaType[] $MessageMedia
 */
class MyMessagesMessageType extends \DTS\eBaySDK\Types\BaseType
{
    /**
     * @var array Properties belonging to objects of this class.
     */
    private static $propertyTypes = array(
        'Sender' => array(
            'type' => 'string',
            'unbound' => false,
            'attribute' => false,
            'elementName' => 'Sender'
        ),
        'RecipientUserID' => array(
            'type' => 'string',
            'unbound' => false,
            'attribute' => false,
            'elementName' => 'RecipientUserID'
        ),
        'SendToName' => array(
            'type' => 'string',
            'unbound' => false,
            'attribute' => false,
            'elementName' => 'SendToName'
        ),
        'Subject' => array(
            'type' => 'string',
            'unbound' => false,
            'attribute' => false,
            'elementName' => 'Subject'
        ),
        'MessageID' => array(
            'type' => 'string',
            'unbound' => false,
            'attribute' => false,
            'elementName' => 'MessageID'
        ),
        'ExternalMessageID' => array(
            'type' => 'string',
            'unbound' => false,
            'attribute' => false,
            'elementName' => 'ExternalMessageID'
        ),
        'ContentType' => array(
            'type' => 'string',
            'unbound' => false,
            'attribute' => false,
            'elementName' => 'ContentType'
        ),
        'Text' => array(
            'type' => 'string',
            'unbound' => false,
            'attribute' => false,
            'elementName' => 'Text'
        ),
        'Flagged' => array(
            'type' => 'boolean',
            'unbound' => false,
            'attribute' => false,
            'elementName' => 'Flagged'
        ),
        'Read' => array(
            'type' => 'boolean',
            'unbound' => false,
            'attribute' => false,
            'elementName' => 'Read'
        ),
        'CreationDate' => array(
            'type' => 'DateTime',
            'unbound' => false,
            'attribute' => false,
            'elementName' => 'CreationDate'
        ),
        'ReceiveDate' => array(
            'type' => 'DateTime',
            'unbound' => false,
            'attribute' => false,
            'elementName' => 'ReceiveDate'
        ),
        'ExpirationDate' => array(
            'type' => 'DateTime',
            'unbound' => false,
            'attribute' => false,
            'elementName' => 'ExpirationDate'
        ),
        'ItemID' => array(
            'type' => 'string',
            'unbound' => false,
            'attribute' => false,
            'elementName' => 'ItemID'
        ),
        'ResponseDetails' => array(
            'type' => 'DTS\eBaySDK\Trading\Types\MyMessagesResponseDetailsType',
            'unbound' => false,
            'attribute' => false,
            'elementName' => 'ResponseDetails'
        ),
        'Folder' => array(
            'type' => 'DTS\eBaySDK\Trading\Types\MyMessagesFolderType',
            'unbound' => false,
            'attribute' => false,
            'elementName' => 'Folder'
        ),
        'Content' => array(
            'type' => 'string',
            'unbound' => false,
            'attribute' => false,
            'elementName' => 'Content'
        ),
        'MessageType' => array(
            'type' => 'string',
            'unbound' => false,
            'attribute' => false,
            'elementName' => 'MessageType'
        ),
        'ListingStatus' => array(
            'type' => 'string',
            'unbound' => false,
            'attribute' => false,
            'elementName' => 'ListingStatus'
        ),
        'QuestionType' => array(
            'type' => 'string',
            'unbound' => false,
            'attribute' => false,
            'elementName' => 'QuestionType'
        ),
        'Replied' => array(
            'type' => 'boolean',
            'unbound' => false,
            'attribute' => false,
            'elementName' => 'Replied'
        ),
        'HighPriority' => array(
            'type' => 'boolean',
            'unbound' => false,
            'attribute' => false,
            'elementName' => 'HighPriority'
        ),
        'ItemEndTime' => array(
            'type' => 'DateTime',
            'unbound' => false,
            'attribute' => false,
            'elementName' => 'ItemEndTime'
        ),
        'ItemTitle' => array(
            'type' => 'string',
            'unbound' => false,
            'attribute' => false,
            'elementName' => 'ItemTitle'
        ),
        'MessageMedia' => array(
            'type' => 'DTS\eBaySDK\Trading\Types\MessageMediaType',
            'unbound' => true,
            'attribute' => false,
            'elementName' => 'MessageMedia'
        )
    );

    /**
     * @param array $values Optional properties and values to assign to the object.
     */
    public function __construct(array $values = array())
    {
        list($parentValues, $childValues) = self::getParentValues(self::$propertyTypes, $values);

        parent::__construct($parentValues);

        if (!array_key_exists(__CLASS__, self::$properties)) {
            self::$properties[__CLASS__] = array_merge(self::$properties[get_parent_class()], self::$propertyTypes);
        }

        if (!array_key_exists(__CLASS__, self::$xmlNamespaces)) {
            self::$xmlNamespaces[__CLASS__] = 'urn:ebay:apis:eBLBaseComponents';
        }

        $this->setValues(__CLASS__, $childValues);
    }
}


text:
require 'spec_helper'

describe 'ansible-logrotate::default' do

  describe package('logrotate') do
    it { should be_installed.by('apt') }
  end

end


text:
package org.kuali.kra.institutionalproposal.contacts;

import org.kuali.kra.award.home.ContactRole;
import org.kuali.kra.bo.Unit;
import org.kuali.kra.institutionalproposal.web.struts.form.InstitutionalProposalForm;
import org.kuali.kra.proposaldevelopment.bo.ProposalPersonRole;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * This class...
 */
public class InstitutionalProposalProjectPersonnelBean extends InstitutionalProposalContactsBean {

    /**
     * Comment for serialVersionUID
     */
    private static final long serialVersionUID = 6251507517307475952L;

    private InstitutionalProposalPersonUnit[] newInstitutionalProposalPersonUnits;

    private transient String selectedLeadUnit;

    public InstitutionalProposalProjectPersonnelBean(InstitutionalProposalForm institutionalProposalForm) {
        super(institutionalProposalForm);
    }

    public void addNewProjectPersonUnit(int projectPersonIndex) {
        InstitutionalProposalPerson person = getInstitutionalProposal().getProjectPersons().get(projectPersonIndex);
        InstitutionalProposalPersonUnitRuleAddEvent event = generateAddPersonUnitEvent(person, projectPersonIndex);
        boolean success = new InstitutionalProposalPersonUnitAddRuleImpl().processAddInstitutionalProposalPersonUnitBusinessRules(event);
        if(success) {
            person.add(newInstitutionalProposalPersonUnits[projectPersonIndex]);
            if(newInstitutionalProposalPersonUnits[projectPersonIndex].isLeadUnit()) {
                getInstitutionalProposal().setLeadUnit(newInstitutionalProposalPersonUnits[projectPersonIndex].getUnit());
                setSelectedLeadUnit(newInstitutionalProposalPersonUnits[projectPersonIndex].getUnitName());
            }
            initNewInstitutionalProposalPersonUnits();
        }
    }

    /**
     * This method is for adding a project person
     */
    public void addProjectPerson() {
        InstitutionalProposalProjectPersonRuleAddEvent event = generateAddProjectPersonEvent();
        boolean success = new InstitutionalProposalProjectPersonAddRuleImpl().processAddInstitutionalProposalProjectPersonBusinessRules(event);
        if(success){
        InstitutionalProposalPerson institutionalProposalPerson = getNewProjectPerson();
            getInstitutionalProposal().add(institutionalProposalPerson);
            init();
            if(institutionalProposalPerson.isPrincipalInvestigator()) {
                institutionalProposalPerson.getUnits().add(new InstitutionalProposalPersonUnit(institutionalProposalPerson, getInstitutionalProposal().getLeadUnit(), true));
            } else {
                if(institutionalProposalPerson.isEmployee() && !institutionalProposalPerson.isKeyPerson()) {
                    institutionalProposalPerson.getUnits().add(new InstitutionalProposalPersonUnit(institutionalProposalPerson, institutionalProposalPerson.getPerson().getUnit(), false));
                }
            }
        }
    }

    /**
     * This method deletes a Project Person from the list
     * @param lineToDelete
     */
    public void deleteProjectPerson(int lineToDelete) {
        List<InstitutionalProposalPerson> projectPersons = getProjectPersonnel();
        if(projectPersons.size() > lineToDelete) {
            projectPersons.remove(lineToDelete);
        }
    }

    /**
     * This method deletes a ProjectPersonUnit from the list
     * @param projectPersonIndex
     * @param unitIndex
     */
    public void deleteProjectPersonUnit(int projectPersonIndex, int unitIndex) {
        getInstitutionalProposal().getProjectPersons().get(projectPersonIndex).getUnits().remove(unitIndex);
    }

    /**
     * Gets the newInstitutionalProposalPersonUnit attribute.
     * @return Returns the newInstitutionalProposalPersonUnit.
     */
    public InstitutionalProposalPersonUnit getNewInstitutionalProposalPersonUnit(int projectPersonIndex) {
        if(newInstitutionalProposalPersonUnits == null | newInstitutionalProposalPersonUnits.length == 0) {
            initNewInstitutionalProposalPersonUnits();
        }
        return newInstitutionalProposalPersonUnits[projectPersonIndex];
    }

    /**
     * Gets the newInstitutionalProposalPersonUnits attribute.
     * @return Returns the newInstitutionalProposalPersonUnits.
     */
    public InstitutionalProposalPersonUnit[] getNewInstitutionalProposalPersonUnits() {
        for(InstitutionalProposalPersonUnit apu: newInstitutionalProposalPersonUnits) {
            lazyLoadUnit(apu);
        }
        return newInstitutionalProposalPersonUnits;
    }

    /**
     * @return
     */
    public InstitutionalProposalPerson getNewProjectPerson() {
        return (InstitutionalProposalPerson) newInstitutionalProposalContact;
    }

    /**
     * Gets the newUnitNumber attribute.
     * @return Returns the newUnitNumber.
     */
    public String getNewUnitNumber(int projectPersonIndex) {
        return newInstitutionalProposalPersonUnits[projectPersonIndex].getUnit() != null ? newInstitutionalProposalPersonUnits[projectPersonIndex].getUnit().getUnitNumber() : null;
    }

    /**
     * This method finds the InstitutionalProposalPersons
     * @return The list; may be empty
     */
    public List<InstitutionalProposalPerson> getProjectPersonnel() {
        return getInstitutionalProposal().getProjectPersons();
    }

    /**
     * This method finds the count of InstitutionalProposalContacts in the "Project Personnel" category
     * @return The count; may be 0
     */
    public int getProjectPersonnelCount() {
        return getProjectPersonnel().size();
    }

    /**
     * Gets the selectedLeadUnit attribute.
     * @return Returns the selectedLeadUnit.
     */
    public String getSelectedLeadUnit() {
        selectedLeadUnit = "";
        for(InstitutionalProposalPerson p: getProjectPersonnel()) {
            if(p.isPrincipalInvestigator()) {
                for(InstitutionalProposalPersonUnit apu: p.getUnits()) {
                    if(apu.isLeadUnit()) {
                        selectedLeadUnit = apu.getUnitName();
                    }
                }
            }
        }
        return selectedLeadUnit;
    }

    public String getUnitName(int projectPersonIndex) {
        return newInstitutionalProposalPersonUnits[projectPersonIndex].getUnit() != null ? newInstitutionalProposalPersonUnits[projectPersonIndex].getUnit().getUnitName() : null;
    }

    public String getUnitNumber(int projectPersonIndex) {
        return getNewUnitNumber(projectPersonIndex);
    }

    /**
     * Sets the selectedLeadUnit attribute value.
     * @param selectedLeadUnit The selectedLeadUnit to set.
     */
    public void setSelectedLeadUnit(String unitName) {
        this.selectedLeadUnit = unitName;
        setLeadUnitSelectionStates(unitName);
    }

    @Override
    protected InstitutionalProposalContact createNewContact() {
        return new InstitutionalProposalPerson();
    }

    /**
     * @see org.kuali.kra.InstitutionalProposal.contacts.InstitutionalProposalContactsBean#getContactRoleType()
     */
    @Override
    protected Class<? extends ContactRole> getContactRoleType() {
        return ProposalPersonRole.class;
    }

    /**
     * @see org.kuali.kra.InstitutionalProposal.contacts.InstitutionalProposalContactsBean#init()
     */
    @Override
    protected void init() {
        super.init();
        initNewInstitutionalProposalPersonUnits();
    }

    private InstitutionalProposalPerson findPrincipalInvestigator() {
        InstitutionalProposalPerson institutionalProposalPerson = null;
        for(InstitutionalProposalContact person: getInstitutionalProposal().getProjectPersons()) {
            if(ContactRole.PI_CODE.equals(person.getContactRole().getRoleCode())) {
                institutionalProposalPerson = (InstitutionalProposalPerson) person;
                break;
            }
        }
        return institutionalProposalPerson;
    }

    private InstitutionalProposalPersonUnitRuleAddEvent generateAddPersonUnitEvent(InstitutionalProposalPerson projectPerson, int addUnitPersonIndex) {
        return new InstitutionalProposalPersonUnitRuleAddEvent("InstitutionalProposalPersonUnitRuleAddEvent", "projectPersonnelBean.newInstitutionalProposalPersonUnit", getDocument(),
                                                                        projectPerson, newInstitutionalProposalPersonUnits[addUnitPersonIndex]);
    }

    private InstitutionalProposalProjectPersonRuleAddEvent generateAddProjectPersonEvent() {
        return new InstitutionalProposalProjectPersonRuleAddEvent("AddInstitutionalProposalProjectPersonRuleEvent", "projectPersonnelBean.newInstitutionalProposalContact", getDocument(),
                                                    (InstitutionalProposalPerson) newInstitutionalProposalContact);
    }

    private void initNewInstitutionalProposalPersonUnits() {
        newInstitutionalProposalPersonUnits = new InstitutionalProposalPersonUnit[getInstitutionalProposal().getProjectPersons().size()];
        int personIndex = 0;
        for(InstitutionalProposalPerson p: getInstitutionalProposal().getProjectPersons()) {
            newInstitutionalProposalPersonUnits[personIndex++] = new InstitutionalProposalPersonUnit(p);
        }
    }

    /**
     * @param awardPersonUnit
     */
    private void lazyLoadUnit(InstitutionalProposalPersonUnit institutionalProposalPersonUnit) {
        if(institutionalProposalPersonUnit.getUnitNumber() != null && institutionalProposalPersonUnit.getUnit() == null) {
            Map<String, Object> identifiers = new HashMap<String, Object>();
            identifiers.put("unitNumber", institutionalProposalPersonUnit.getUnitNumber());
            Unit newUnit = (Unit) getBusinessObjectService().findByPrimaryKey(Unit.class, identifiers);
            institutionalProposalPersonUnit.setUnit(newUnit);
        }
    }

    private void setLeadUnitSelectionStates(String unitName) {
        InstitutionalProposalPerson institutionalProposalPerson = findPrincipalInvestigator();
        for(InstitutionalProposalPersonUnit associatedUnit: institutionalProposalPerson.getUnits()) {
            associatedUnit.setLeadUnit(associatedUnit.getUnit().getUnitName().equals(unitName));
        }
    }
}


text:
// Jordan Davis
// 11.19.12
// COMP 4040
// HW9

#include <iostream>
#include <ctime>

using namespace std;

/*
	In the following example the difference in time when calling a dynamically bound
	method and a statically bound method is shown.  We have the superclass Rectangle
	with a method to find its perimeter, then we have a subclass Square with 2 methods
	to find its perimeter (more on that soon).  All perimeter calculations are done the
	same way so there is no bias on the timing.  The first method of Square is overriding
	Rectangles perimeter method and Square's second method is a static method to Square.
	In the main method we have a new Square object being made as well a Rectangle object
	which references the same Square.  The first loop calls the statically bound method of
	Square many times, this method is already pointed to by s in its vtable.  The second
	loops calls the perimeter method on a Rectangle object but that Rectangle holds a
	Square rather than a Rectangle so it has to look up the definition of Square's
	perimeter method and dynamically binds it at that point during runtime.  Both of the
	methods are called many, many times (1 000 000 000 in this example) and the difference
	in running times is caused by the vtable lookups in the second loop.
*/

// superclass
class Rectangle
{
	public:
		virtual int dynPerimeter()
		{
			return 2 * length + 2 * width;
		}

	protected:
		int length;
		int width;
};

// subclass, a Square is a Rectangle
class Square : public Rectangle
{
	public:
		// overrides Rectangle's version
		virtual int dynPerimeter()
		{
			return 2 * length + 2 * width;
		}

		int statPerimeter()
		{
			return 2 * length + 2 * width;
		}
};

int main()
{
	time_t start = 0;
	time_t end = 0;

	// instantiating a Square object
	Square s;

	// a Rectangle reference holding the address
	// of a Square (which is a type of Rectangle)
	Rectangle& r = s;

	// statically bound method calls
	start = time(NULL);

	for (int i = 0; i < 1000000000; ++i)
	{
		s.statPerimeter();
	}

	end = time(NULL);
	cout << "It took " << (end - start) << " seconds for a statically bound method!\n";

	// dynamically bound method calls
	start = time(NULL);

	for (int i = 0; i < 1000000000; ++i)
	{
		r.dynPerimeter();
	}

	end = time(NULL);
	cout << "It took " << (end - start) << " seconds for a dynamically bound method!\n";

	return 0;
}


text:
/*
 * Pathfinder
 * Core application for storage and analysis of IT landscape data
 *
 * OpenAPI spec version: 5.0.813
 *
 *
 * NOTE: This class is auto generated by the swagger code generator program.
 * https://github.com/swagger-api/swagger-codegen.git
 * Do not edit the class manually.
 */

package net.leanix.api.models;

import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.ArrayList;
import java.util.List;

/**
 * SubscriptionSettings
 */

public class SubscriptionSettings {
  /**
   * Gets or Sets subscriptionTypes
   */
  public enum SubscriptionTypesEnum {
    ACCOUNTABLE("ACCOUNTABLE"),

    RESPONSIBLE("RESPONSIBLE"),

    OBSERVER("OBSERVER");

    private String value;

    SubscriptionTypesEnum(String value) {
      this.value = value;
    }

    @Override
    public String toString() {
      return String.valueOf(value);
    }

    @JsonCreator
    public static SubscriptionTypesEnum fromValue(String text) {
      for (SubscriptionTypesEnum b : SubscriptionTypesEnum.values()) {
        if (String.valueOf(b.value).equals(text)) {
          return b;
        }
      }
      return null;
    }
  }

  @JsonProperty("subscriptionTypes")
  private List<SubscriptionTypesEnum> subscriptionTypes = new ArrayList<SubscriptionTypesEnum>();

  /**
   * Gets or Sets roleAssignment
   */
  public enum RoleAssignmentEnum {
    SINGLE("SINGLE"),

    MULTIPLE("MULTIPLE");

    private String value;

    RoleAssignmentEnum(String value) {
      this.value = value;
    }

    @Override
    public String toString() {
      return String.valueOf(value);
    }

    @JsonCreator
    public static RoleAssignmentEnum fromValue(String text) {
      for (RoleAssignmentEnum b : RoleAssignmentEnum.values()) {
        if (String.valueOf(b.value).equals(text)) {
          return b;
        }
      }
      return null;
    }
  }

  @JsonProperty("roleAssignment")
  private RoleAssignmentEnum roleAssignment = null;

  /**
   * Gets or Sets roleMode
   */
  public enum RoleModeEnum {
    ON_THE_FLY("ON_THE_FLY"),

    OPTIONAL("OPTIONAL"),

    REQUIRED("REQUIRED");

    private String value;

    RoleModeEnum(String value) {
      this.value = value;
    }

    @Override
    public String toString() {
      return String.valueOf(value);
    }

    @JsonCreator
    public static RoleModeEnum fromValue(String text) {
      for (RoleModeEnum b : RoleModeEnum.values()) {
        if (String.valueOf(b.value).equals(text)) {
          return b;
        }
      }
      return null;
    }
  }

  @JsonProperty("roleMode")
  private RoleModeEnum roleMode = null;

  public SubscriptionSettings subscriptionTypes(List<SubscriptionTypesEnum> subscriptionTypes) {
    this.subscriptionTypes = subscriptionTypes;
    return this;
  }

  public SubscriptionSettings addSubscriptionTypesItem(SubscriptionTypesEnum subscriptionTypesItem) {
    this.subscriptionTypes.add(subscriptionTypesItem);
    return this;
  }

   /**
   * Get subscriptionTypes
   * @return subscriptionTypes
  **/
  @ApiModelProperty(example = "null", required = true, value = "")
  public List<SubscriptionTypesEnum> getSubscriptionTypes() {
    return subscriptionTypes;
  }

  public void setSubscriptionTypes(List<SubscriptionTypesEnum> subscriptionTypes) {
    this.subscriptionTypes = subscriptionTypes;
  }

  public SubscriptionSettings roleAssignment(RoleAssignmentEnum roleAssignment) {
    this.roleAssignment = roleAssignment;
    return this;
  }

   /**
   * Get roleAssignment
   * @return roleAssignment
  **/
  @ApiModelProperty(example = "null", required = true, value = "")
  public RoleAssignmentEnum getRoleAssignment() {
    return roleAssignment;
  }

  public void setRoleAssignment(RoleAssignmentEnum roleAssignment) {
    this.roleAssignment = roleAssignment;
  }

  public SubscriptionSettings roleMode(RoleModeEnum roleMode) {
    this.roleMode = roleMode;
    return this;
  }

   /**
   * Get roleMode
   * @return roleMode
  **/
  @ApiModelProperty(example = "null", required = true, value = "")
  public RoleModeEnum getRoleMode() {
    return roleMode;
  }

  public void setRoleMode(RoleModeEnum roleMode) {
    this.roleMode = roleMode;
  }

  @Override
  public boolean equals(java.lang.Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    SubscriptionSettings subscriptionSettings = (SubscriptionSettings) o;
    return Objects.equals(this.subscriptionTypes, subscriptionSettings.subscriptionTypes) &&
        Objects.equals(this.roleAssignment, subscriptionSettings.roleAssignment) &&
        Objects.equals(this.roleMode, subscriptionSettings.roleMode);
  }

  @Override
  public int hashCode() {
    return Objects.hash(subscriptionTypes, roleAssignment, roleMode);
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("class SubscriptionSettings {\n");

    sb.append("    subscriptionTypes: ").append(toIndentedString(subscriptionTypes)).append("\n");
    sb.append("    roleAssignment: ").append(toIndentedString(roleAssignment)).append("\n");
    sb.append("    roleMode: ").append(toIndentedString(roleMode)).append("\n");
    sb.append("}");
    return sb.toString();
  }

  /**
   * Convert the given object to string with each line indented by 4 spaces
   * (except the first line).
   */
  private String toIndentedString(java.lang.Object o) {
    if (o == null) {
      return "null";
    }
    return o.toString().replace("\n", "\n    ");
  }

}


text:
package ua.com.fielden.platform.entity.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * This annotation has an opposite to {@link CritOnly} meaning. Specifically, it indicates that an entity property should only be used as part of the result set for dynamic entity
 * reviews (i.e. it cannot be used as one of selection criteria).
 *
 * @author TG Team
 *
 */
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.FIELD })
public @interface ResultOnly {
}


text:
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Runtime.InteropServices;

namespace Microsoft.VisualStudio.LanguageServices.CSharp.ProjectSystemShim.Interop
{
    [ComImport]
    [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
    [Guid("A1DEA584-FEB7-4ba5-ACC1-0C0EB3EAF016")]
    internal interface ICSNameTable
    {
        // members not ported
    }
}


text:
extern uint8_t gDFTIIR; //=6
#define DFTIIR gDFTIIR

extern uint8_t gFUZZ_IIR_BITS; //=1
#define FUZZ_IIR_BITS  gFUZZ_IIR_BITS

#define MAXNOTES  12 //MAXNOTES cannot be changed dynamically.

extern uint8_t gFILTER_BLUR_PASSES; //=2
#define FILTER_BLUR_PASSES gFILTER_BLUR_PASSES

extern uint8_t gSEMIBITSPERBIN; //=3
#define SEMIBITSPERBIN gSEMIBITSPERBIN

extern uint8_t gMAX_JUMP_DISTANCE; //=4
#define MAX_JUMP_DISTANCE gMAX_JUMP_DISTANCE

extern uint8_t gMAX_COMBINE_DISTANCE; //=7
#define MAX_COMBINE_DISTANCE gMAX_COMBINE_DISTANCE

extern uint8_t gAMP_1_IIR_BITS; //=4
#define AMP_1_IIR_BITS gAMP_1_IIR_BITS

extern uint8_t gAMP_2_IIR_BITS; //=2
#define AMP_2_IIR_BITS gAMP_2_IIR_BITS

extern uint8_t gMIN_AMP_FOR_NOTE; //=80
#define MIN_AMP_FOR_NOTE gMIN_AMP_FOR_NOTE

extern uint8_t gMINIMUM_AMP_FOR_NOTE_TO_DISAPPEAR; //=64
#define MINIMUM_AMP_FOR_NOTE_TO_DISAPPEAR gMINIMUM_AMP_FOR_NOTE_TO_DISAPPEAR

extern uint8_t gNOTE_FINAL_AMP; //=12
#define NOTE_FINAL_AMP gNOTE_FINAL_AMP

extern uint8_t gNERF_NOTE_PORP; //=15
#define NERF_NOTE_PORP gNERF_NOTE_PORP

extern uint8_t gUSE_NUM_LIN_LEDS; // = NUM_LIN_LEDS
#define USE_NUM_LIN_LEDS gUSE_NUM_LIN_LEDS

//We are not enabling these for the ESP8266 port.
#define LIN_WRAPAROUND 0
#define SORT_NOTES 0

#endif


text:
package com.srai.service;

import com.opencsv.CSVParser;
import com.opencsv.CSVReader;
import com.srai.model.ZipCode;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

@Component
@Slf4j
public class ZipCodes {

  private Map<Integer, ZipCode> zipCodes = Collections.synchronizedMap(new HashMap<Integer, ZipCode>());

  ZipCodes() {
    String csvFile = "us_postal_codes.csv";

    CSVReader reader = null;
    log.info("Establishing ZipCode dictionary");
    try {
      ClassLoader classloader = Thread.currentThread().getContextClassLoader();
      InputStream is = classloader.getResourceAsStream(csvFile);
      reader = new CSVReader(new InputStreamReader(is), CSVParser.DEFAULT_SEPARATOR, CSVParser.DEFAULT_QUOTE_CHARACTER, 1);
      String[] line;
      while ((line = reader.readNext()) != null) {
        if(StringUtils.isEmpty(line[0])) {
          continue;
        }
        zipCodes.put(new Integer(line[0]), new ZipCode(line));
      }
    } catch (IOException e) {
      e.printStackTrace();
    }
    log.info("Establishing ZipCode dictionary complete");
  }

  public boolean isValid(int zipCode) {
    return zipCodes.containsKey(new Integer(zipCode));
  }

  public boolean isWithinState(int zipCode, String stateAbr) {
    ZipCode zip = zipCodes.get(zipCode);
    return (zip == null ? false : zip.isWithinState(stateAbr));
  }

  public ZipCode get(int zipCode) {
    return zipCodes.get(zipCode);
  }
}


text:
// flow-typed signature: 370e579d80ffc3798085524d845602cf
// flow-typed version: <<STUB>>/lint-staged_v^4.0.2/flow_v0.52.0

/**
 * This is an autogenerated libdef stub for:
 *
 *   'lint-staged'
 *
 * Fill this stub out by replacing all the `any` types.
 *
 * Once filled out, we encourage you to share your work with the
 * community by sending a pull request to:
 * https://github.com/flowtype/flow-typed
 */

declare module 'lint-staged' {
  declare module.exports: any;
}

/**
 * We include stubs for each file inside this npm package in case you need to
 * require those files directly. Feel free to delete any files that aren't
 * needed.
 */
declare module 'lint-staged/src/calcChunkSize' {
  declare module.exports: any;
}

declare module 'lint-staged/src/findBin' {
  declare module.exports: any;
}

declare module 'lint-staged/src/generateTasks' {
  declare module.exports: any;
}

declare module 'lint-staged/src/index' {
  declare module.exports: any;
}

declare module 'lint-staged/src/readConfigOption' {
  declare module.exports: any;
}

declare module 'lint-staged/src/runScript' {
  declare module.exports: any;
}

// Filename aliases
declare module 'lint-staged/index' {
  declare module.exports: $Exports<'lint-staged'>;
}
declare module 'lint-staged/index.js' {
  declare module.exports: $Exports<'lint-staged'>;
}
declare module 'lint-staged/src/calcChunkSize.js' {
  declare module.exports: $Exports<'lint-staged/src/calcChunkSize'>;
}
declare module 'lint-staged/src/findBin.js' {
  declare module.exports: $Exports<'lint-staged/src/findBin'>;
}
declare module 'lint-staged/src/generateTasks.js' {
  declare module.exports: $Exports<'lint-staged/src/generateTasks'>;
}
declare module 'lint-staged/src/index.js' {
  declare module.exports: $Exports<'lint-staged/src/index'>;
}
declare module 'lint-staged/src/readConfigOption.js' {
  declare module.exports: $Exports<'lint-staged/src/readConfigOption'>;
}
declare module 'lint-staged/src/runScript.js' {
  declare module.exports: $Exports<'lint-staged/src/runScript'>;
}