Commit 56cb1129 authored by Alain Takoudjou's avatar Alain Takoudjou Committed by Nicolas Wavrant

fix fileTreeView in slaprunner editor

parent b74603bc
...@@ -58,7 +58,7 @@ class FileBrowser(object): ...@@ -58,7 +58,7 @@ class FileBrowser(object):
html += 'gsdirs.push(new gsItem("2", "%s", "%s", "0", "%s", "dir", "%s"));' % (f, ff, md5sum, mdate) html += 'gsdirs.push(new gsItem("2", "%s", "%s", "0", "%s", "dir", "%s"));' % (f, ff, md5sum, mdate)
return html return html
def fancylistDirs(self, dir, key, all=False): def fancylistDirs(self, dir, key, listfiles, all=False):
dir = urllib.unquote(dir) dir = urllib.unquote(dir)
realdir = realpath(self.config, dir) realdir = realpath(self.config, dir)
if not realdir: if not realdir:
...@@ -73,18 +73,18 @@ class FileBrowser(object): ...@@ -73,18 +73,18 @@ class FileBrowser(object):
ff = os.path.join(dir, f) ff = os.path.join(dir, f)
realfile = os.path.join(realdir, f) realfile = os.path.join(realdir, f)
identity = "%s%s" % (key, i) identity = "%s%s" % (key, i)
if not os.path.isdir(realfile): if os.path.isdir(realfile):
dirList.append({"title": f, "key": identity,
"folder":True, "lazy":True, "path": ff})
elif listfiles:
regex = re.compile("(^.*)\.(.*)", re.VERBOSE) regex = re.compile("(^.*)\.(.*)", re.VERBOSE)
ext = regex.sub(r'\2', f) ext = regex.sub(r'\2', f)
if ext == f: if ext == f:
ext = "" ext = ""
dirList.append({"title": f, "key": identity,
"extraClasses": "ext_"+ext, "path": ff})
else:
fileList.append({"title": f, "key": identity, fileList.append({"title": f, "key": identity,
"folder":True, "lazy":True, "path": ff}) "extraClasses": "ext_"+ext, "path": ff})
i+=1 i+=1
return (fileList + dirList) return (dirList + fileList)
def makeDirectory(self, dir, filename): def makeDirectory(self, dir, filename):
"""Create a directory""" """Create a directory"""
......
...@@ -65,6 +65,13 @@ ul.fancytree-no-connector > li ...@@ -65,6 +65,13 @@ ul.fancytree-no-connector > li
background-color: silver; background-color: silver;
} }
span.fancytree-node
{
display: inline-block;
width: 100%;
border: 1px solid transparent;
}
/******************************************************************************* /*******************************************************************************
* Common icon definitions * Common icon definitions
...@@ -207,6 +214,7 @@ span.fancytree-checkbox:hover { background-position: -16px -32px; } ...@@ -207,6 +214,7 @@ span.fancytree-checkbox:hover { background-position: -16px -32px; }
span.fancytree-icon /* Default icon */ span.fancytree-icon /* Default icon */
{ {
margin-left: 3px; margin-left: 3px;
margin-top: 1px;
background-position: 0px 0px; background-position: 0px 0px;
} }
.fancytree-ico-cf span.fancytree-icon { background: url(images/directory.min.png) left top no-repeat; width: 22px;}/*background-position: 0px -16px; } /* Collapsed Folder */ .fancytree-ico-cf span.fancytree-icon { background: url(images/directory.min.png) left top no-repeat; width: 22px;}/*background-position: 0px -16px; } /* Collapsed Folder */
...@@ -294,21 +302,39 @@ span.ext_zip span.fancytree-icon { background: url(images/zip.png) left top no-r ...@@ -294,21 +302,39 @@ span.ext_zip span.fancytree-icon { background: url(images/zip.png) left top no-r
} }
span.fancytree-focused .fancytree-title { span.fancytree-focused .fancytree-title {
/*outline: 1px dotted black;*/ /*outline: 1px dotted black;*/
color: white; /*color: white;*/
} }
span.fancytree-selected .fancytree-title, span.fancytree-selected .fancytree-title,
span.fancytree-active .fancytree-title { span.fancytree-active .fancytree-title {
background-color: #D4D4D4; /*gray*/ /*background-color: #D4D4D4; /*gray*/
} }
span.fancytree-selected .fancytree-title { span.fancytree-selected .fancytree-title {
font-style: italic; font-style: italic;
} }
.fancytree-focused span.fancytree-selected .fancytree-title, .fancytree-focused span.fancytree-selected .fancytree-title,
.fancytree-focused span.fancytree-active .fancytree-title { .fancytree-focused span.fancytree-active .fancytree-title {
color: white; /*color: white;
background-color: #3875D7; /*blue*/ background-color: #3875D7; /*blue*/
} }
span.fancytree-node:hover
{
background-color: #BDF;
border-color: #70C0E7;
cursor: pointer;
}
.fancytree-container.fancytree-focused span.fancytree-node.fancytree-focused
{
border-color: #3399FF;
/* outline: 1px solid #3399FF; */
}
span.fancytree-node.fancytree-active,
span.fancytree-node.fancytree-selected
{ /* active/selcted nodes inside inactive tree */
background-color: #F7F7F7;
border-color: #DEDEDE;
}
/******************************************************************************* /*******************************************************************************
* 'table' extension * 'table' extension
*/ */
......
...@@ -11,7 +11,6 @@ $(document).ready(function () { ...@@ -11,7 +11,6 @@ $(document).ready(function () {
CurrentMode, CurrentMode,
script = "/readFolder", script = "/readFolder",
softwareDisplay = true, softwareDisplay = true,
fileTree,
Mode, Mode,
modes, modes,
projectDir = $("input#project").val(), projectDir = $("input#project").val(),
...@@ -86,7 +85,7 @@ $(document).ready(function () { ...@@ -86,7 +85,7 @@ $(document).ready(function () {
function selectFile(file) { function selectFile(file) {
$("#info").empty(); $("#info").empty();
$("#info").append("Selection: " + file); $("#info").append("Current work tree: " + file);
selection = file; selection = file;
return; return;
} }
...@@ -117,7 +116,7 @@ $(document).ready(function () { ...@@ -117,7 +116,7 @@ $(document).ready(function () {
$('#fileTreeFull').hide(); $('#fileTreeFull').hide();
} }
$("#info").empty(); $("#info").empty();
$("#info").append("Selection: " + base_path()); $("#info").append("Current work tree: " + base_path());
selection = ""; selection = "";
} }
...@@ -390,8 +389,11 @@ $(document).ready(function () { ...@@ -390,8 +389,11 @@ $(document).ready(function () {
}; };
// --- Init fancytree during startup ---------------------------------------- // --- Init fancytree during startup ----------------------------------------
$(function(){ function initTree(tree, path, key){
$("#fileTree").fancytree({ if (!key){
key = '0';
}
$(tree).fancytree({
activate: function(event, data) { activate: function(event, data) {
var node = data.node; var node = data.node;
}, },
...@@ -404,14 +406,14 @@ $(document).ready(function () { ...@@ -404,14 +406,14 @@ $(document).ready(function () {
}, },
source: { source: {
url: $SCRIPT_ROOT + "/fileBrowser", url: $SCRIPT_ROOT + "/fileBrowser",
data:{opt: 20, dir: currentProject, key: 0}, data:{opt: 20, dir: path, key: key, listfiles: 'yes'},
cache: false cache: false
}, },
lazyload: function(event, data) { lazyload: function(event, data) {
var node = data.node; var node = data.node;
data.result = { data.result = {
url: $SCRIPT_ROOT + "/fileBrowser", url: $SCRIPT_ROOT + "/fileBrowser",
data: {opt: 20, dir: node.data.path , key: node.key} data: {opt: 20, dir: node.data.path , key: node.key, listfiles: 'yes'}
} }
}, },
keydown: function(event, data) { keydown: function(event, data) {
...@@ -461,7 +463,7 @@ $(document).ready(function () { ...@@ -461,7 +463,7 @@ $(document).ready(function () {
bindContextMenu(data.node.span, !data.node.isFolder()); bindContextMenu(data.node.span, !data.node.isFolder());
} }
}); });
}); }
editor.setTheme("ace/theme/crimson_editor"); editor.setTheme("ace/theme/crimson_editor");
...@@ -494,7 +496,9 @@ $(document).ready(function () { ...@@ -494,7 +496,9 @@ $(document).ready(function () {
/*$('#fileTreeFull').fileTree({ root: currentProject, script: $SCRIPT_ROOT + script, folderEvent: 'click', expandSpeed: 750, collapseSpeed: 750, multiFolder: false, selectFolder: true }, function (file) { /*$('#fileTreeFull').fileTree({ root: currentProject, script: $SCRIPT_ROOT + script, folderEvent: 'click', expandSpeed: 750, collapseSpeed: 750, multiFolder: false, selectFolder: true }, function (file) {
selectFile(file); selectFile(file);
}, function (file) { openFile(file); });*/ }, function (file) { openFile(file); });*/
$("#info").append("Selection: " + base_path()); initTree('#fileTree', projectDir, 'pfolder');
initTree('#fileTreeFull', currentProject);
$("#info").append("Current work tree: " + base_path());
/*setDetailBox();*/ /*setDetailBox();*/
editor.on("change", function (e) { editor.on("change", function (e) {
...@@ -549,7 +553,7 @@ $(document).ready(function () { ...@@ -549,7 +553,7 @@ $(document).ready(function () {
$("#clearselect").click(function () { $("#clearselect").click(function () {
edit = false; edit = false;
$("#info").empty(); $("#info").empty();
$("#info").append("Selection: " + base_path()); $("#info").append("Current work tree: " + base_path());
$("input#subfolder").val(""); $("input#subfolder").val("");
$("#edit_info").empty(); $("#edit_info").empty();
$("#edit_info").append("No file in editor"); $("#edit_info").append("No file in editor");
......
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
</div> </div>
<div id="details_box"> <div id="details_box">
<div id="fileTree" class="file_tree_short"></div> <div id="fileTree" class="file_tree_short"></div>
<div id="fileTreeFull" style='display:none' class="file_tree_short" title="Double click to edit selected file..."></div> <div id="fileTreeFull" style='display:none' class="file_tree_short"></div>
</div> </div>
</div> </div>
<div id="code"> <div id="code">
......
...@@ -587,7 +587,7 @@ def fileBrowser(): ...@@ -587,7 +587,7 @@ def fileBrowser():
else: else:
opt = int(request.args.get('opt')) opt = int(request.args.get('opt'))
# try: try:
if opt == 1: if opt == 1:
#list files and directories #list files and directories
result = file_request.listDirs(dir) result = file_request.listDirs(dir)
...@@ -633,14 +633,15 @@ def fileBrowser(): ...@@ -633,14 +633,15 @@ def fileBrowser():
result = file_request.unzipFile(dir, filename, newfilename) result = file_request.unzipFile(dir, filename, newfilename)
elif opt == 20: elif opt == 20:
#Fancy Load folder #Fancy Load folder
key = int(request.args.get('key')) key = request.args.get('key')
dir = request.args.get('dir').encode('utf-8') dir = request.args.get('dir').encode('utf-8')
data = file_request.fancylistDirs(dir, key) listfiles = request.args.get('listfiles', '')
data = file_request.fancylistDirs(dir, key, listfiles)
result = json.dumps(data) result = json.dumps(data)
else: else:
result = "ARGS PARSE ERROR: Bad option..." result = "ARGS PARSE ERROR: Bad option..."
# except Exception as e: except Exception as e:
# return str(e) return str(e)
return result return result
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment