You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by ja...@apache.org on 2013/12/17 14:52:00 UTC

[1/3] git commit: MARMOTTA-239: Added some more info (size) and download links to the context panel.

Updated Branches:
  refs/heads/develop e7b3ccad4 -> 593ea4fa1


MARMOTTA-239: Added some more info (size) and download links to the context panel.


Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/9a3913dc
Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/9a3913dc
Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/9a3913dc

Branch: refs/heads/develop
Commit: 9a3913dcae6da41958fb00012a98873a9f3f78e9
Parents: e7b3cca
Author: Jakob Frank <ja...@apache.org>
Authored: Tue Dec 17 12:02:41 2013 +0100
Committer: Jakob Frank <ja...@apache.org>
Committed: Tue Dec 17 12:02:41 2013 +0100

----------------------------------------------------------------------
 .../core/api/triplestore/ContextService.java    |  7 ++
 .../triplestore/ContextServiceImpl.java         | 21 +++++
 .../triplestore/ContextWebService.java          |  5 +-
 .../src/main/resources/web/admin/contexts.html  | 90 ++++++++++++++------
 4 files changed, 93 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/marmotta/blob/9a3913dc/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/api/triplestore/ContextService.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/api/triplestore/ContextService.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/api/triplestore/ContextService.java
index d224654..57d8d36 100644
--- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/api/triplestore/ContextService.java
+++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/api/triplestore/ContextService.java
@@ -158,6 +158,12 @@ public interface ContextService {
      * @return
      */
     String getContextLabel(URI context);
+
+    /**
+     * Return the number of triples for the context.
+     * @param context
+     */
+    long getContextSize(org.openrdf.model.URI context);
     
     /**
      * Import content into the context
@@ -186,4 +192,5 @@ public interface ContextService {
      */
     boolean removeContext(URI context);
 
+
 }

http://git-wip-us.apache.org/repos/asf/marmotta/blob/9a3913dc/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/triplestore/ContextServiceImpl.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/triplestore/ContextServiceImpl.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/triplestore/ContextServiceImpl.java
index ea1d698..63c958e 100644
--- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/triplestore/ContextServiceImpl.java
+++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/triplestore/ContextServiceImpl.java
@@ -314,6 +314,27 @@ public class ContextServiceImpl implements ContextService {
         }
         return null;
     }
+    
+    /**
+     * Return the number of triples for the context.
+     * @param context
+     */
+    @Override
+    public long getContextSize(URI context) {
+        try {
+            RepositoryConnection conn = sesameService.getConnection();
+            try {
+                conn.begin();
+                return conn.size(context);
+            } finally {
+                conn.commit();
+                conn.close();
+            }
+        } catch (RepositoryException e) {
+            handleRepositoryException(e, ContextServiceImpl.class);
+        }
+        return 0;
+    }
 
     /**
      * Import content into the context

http://git-wip-us.apache.org/repos/asf/marmotta/blob/9a3913dc/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/triplestore/ContextWebService.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/triplestore/ContextWebService.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/triplestore/ContextWebService.java
index 18605e9..14b2064 100644
--- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/triplestore/ContextWebService.java
+++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/triplestore/ContextWebService.java
@@ -76,11 +76,12 @@ public class ContextWebService {
                 }
                 return Response.ok().entity(res).build();
             } else {
-                ArrayList<Map<String,String>> result = new ArrayList<Map<String, String>>();
+                ArrayList<Map<String,Object>> result = new ArrayList<>();
                 for(org.openrdf.model.URI r : contextService.listContexts(filter != null)) {
-                    Map<String,String> ctxDesc = new HashMap<String, String>();
+                    Map<String,Object> ctxDesc = new HashMap<String, Object>();
                     ctxDesc.put("uri",r.stringValue());
                     ctxDesc.put("label", contextService.getContextLabel(r));
+                    ctxDesc.put("size", contextService.getContextSize(r));
                     result.add(ctxDesc);
                 }
                 return Response.ok().entity(result).build();

http://git-wip-us.apache.org/repos/asf/marmotta/blob/9a3913dc/platform/marmotta-core/src/main/resources/web/admin/contexts.html
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/resources/web/admin/contexts.html b/platform/marmotta-core/src/main/resources/web/admin/contexts.html
index 192309a..7a0127f 100644
--- a/platform/marmotta-core/src/main/resources/web/admin/contexts.html
+++ b/platform/marmotta-core/src/main/resources/web/admin/contexts.html
@@ -18,7 +18,7 @@
 
 -->
 <html>
-<head>
+    <head>
 <!--###BEGIN_HEAD###-->
     <title>Contexts</title>
     <link type="text/css" rel="stylesheet" href="../public/js/widgets/configurator/style.css" />
@@ -37,14 +37,19 @@
         in SPARQL.
     </p>
     <p>
-        Currently there are <span id="contexts-count">0</span> contexts in Marmotta:
+        Currently there are <strong><span id="contexts-count">0 contexts</span></strong> in Marmotta:
     </p>    
     <table id="contexts" class="simple_table">
-      <tr class="subtitle">
-        <th>Context</th>
-        <th>Label</th>
-        <th>&nbsp;</th>
-      </tr>    
+      <thead>
+        <tr class="subtitle">
+          <th>Label</th>
+          <th>Context</th>
+          <th>Size</th>
+          <th>Download</th>
+          <th>&nbsp;</th>
+        </tr>
+      </thead>
+      <tbody></tbody>    
     </table>  
     
     <script type="text/javascript" src="../../webjars/jquery/1.8.2/jquery.min.js"></script>
@@ -52,36 +57,65 @@
         jQuery(document).ready(function() {
 
             function appendContext(ctx, id) {
-                var uri = ctx["uri"];
-                var label = (ctx["label"] ? ctx["label"] : "");
-            	$("table#contexts > tbody:last").append("<tr id=\"context" + id + "\"><td><a href=\"" + uri + "\">" + uri + "</a></td><td>" + label + "</td><td><a href=\"#contexts\" class=\"deleteContext\">delete</a></td></tr>");
+                var uri = ctx["uri"],
+                    label = (ctx["label"] ? ctx["label"] : uri.replace(/.*[\/#](.*)/, "$1")),
+                    size = ctx["size"];
+        
+                $("<tr>", {"id": "context_"+id})
+                    .append($("<td>", {"text": label}))
+                    .append($("<td>").append($("<a>", {"text": uri, "href": uri})))
+                    .append($("<td>").append(size?$("<span>", {"text":size+" triple"+(size==1?"":"s")}):$("<em>", {"text":"unknown"})))
+                    .append(appendDownloadLinks($("<td>"), ctx))
+                    .append($("<td>").append($("<button>", {"text": "delete"}).click(deleteContext(uri, id, size))))
+                    .appendTo($("table#contexts > tbody:last"));        
+            }
+            function appendDownloadLinks(target, ctx) {
+                function dl(format) {
+                    return _SERVER_URL + "export/download?"
+                            + "context=" + encodeURIComponent(ctx["uri"])
+                            + "&format=" + encodeURIComponent(format);
+                }
+                return target
+                    .append($("<a>", {"text": "rdf+xml", "href": dl("application/rdf+xml")}))
+                    .append("&nbsp;")
+                    .append($("<a>", {"text": "turtle", "href": dl("text/turtle")}))
+                    .append("&nbsp;")
+                    .append($("<a>", {"text": "ld+json", "href": dl("application/ld+json")}));
             }
 
-            function deleteContext(uri, id) {
-            	$.ajax({
-            	    url: "../../context?graph=" + encodeURIComponent(uri),
-            	    type: "DELETE",
-            	    success: function(result) {
-            	    	alert("Context " + uri + " deleted!");
-            	        $("tr#" + id).remove();
-            	    }
-            	});
+            function deleteContext(uri, id, size) {
+                var question = "This will DELETE context <" + uri + ">";
+                if (size) {
+                    question += " and all " + size + " triple" + (size==1?"":"s") + " contained in it";
+                }
+                return function() {
+                    if (!confirm(question)) return;
+                    $.ajax({
+                        url: "../../context?graph=" + encodeURIComponent(uri),
+                        type: "DELETE",
+                        success: function(result) {
+                            alert("Context " + uri + " deleted!");
+                            $("tr#context_" + id).slideUp(function() {
+                                $(this).remove();
+                                var c = $("span#contexts-count"),
+                                    count = c.attr("data-count") -1;
+                                c.attr("data-count", count)
+                                    .text(count + " context" + (count==1?"":"s"));
+                            });
+                        }
+                    });
+                }
             }        
             
             $.getJSON("../../context/list", {labels:"true"}, function(data) {
                 var count = 0;
                 for (i in data) {                  
-                	appendContext(data[i], count);
-                	$("span#contexts-count").html(++count);
+                	appendContext(data[i], count++);
                 }
-                $("a.deleteContext").click(function() {
-                    var row = $(this).closest("td").closest("tr");
-                    var uri = row.find("td:first").text();
-                    var id = row.attr("id");
-                    deleteContext(uri, id);
-                });
+                $("span#contexts-count")
+                    .attr("data-count", count)
+                    .text(count + " context" + (count==1?"":"s"));
             });        
-            
         });
     </script>
 <!--###END_CONTENT###-->


[3/3] git commit: MARMOTTA-142: Added a little bit of doku, improved labels.

Posted by ja...@apache.org.
MARMOTTA-142: Added a little bit of doku, improved labels.


Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/593ea4fa
Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/593ea4fa
Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/593ea4fa

Branch: refs/heads/develop
Commit: 593ea4fa1e20883684786e1c254d65b01b58b58a
Parents: 559d2e6
Author: Jakob Frank <ja...@apache.org>
Authored: Tue Dec 17 14:50:43 2013 +0100
Committer: Jakob Frank <ja...@apache.org>
Committed: Tue Dec 17 14:50:43 2013 +0100

----------------------------------------------------------------------
 .../src/main/resources/web/admin/ldpath.html           | 13 +++++++------
 .../src/main/resources/web/admin/style.css             | 12 ++++++++++--
 2 files changed, 17 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/marmotta/blob/593ea4fa/platform/marmotta-ldpath/src/main/resources/web/admin/ldpath.html
----------------------------------------------------------------------
diff --git a/platform/marmotta-ldpath/src/main/resources/web/admin/ldpath.html b/platform/marmotta-ldpath/src/main/resources/web/admin/ldpath.html
index c7a7d37..9cb9270 100644
--- a/platform/marmotta-ldpath/src/main/resources/web/admin/ldpath.html
+++ b/platform/marmotta-ldpath/src/main/resources/web/admin/ldpath.html
@@ -42,14 +42,15 @@
 <body>
   <!--###BEGIN_CONTENT###-->
   <h1>LDPath Test Suite</h1>
-  <p>
-    This is the LDPath playground.
-  </p>
+  <p>This is the LDPath playground.</p>
+  <p>Add a number of prototypical Resources (URIs) from your dataset to test the result of your program.</p>
+  <p>Information about LDPath and Syntax of the language is available on the <a href="http://marmotta.apache.org/ldpath/">Website</a> and in the <a href="http://wiki.apache.org/marmotta/LDPath">Wiki</a>.</p>
   <div id="playground">
     <div id="context">
-      <h2>Context</h2>
+      <h2>Test Resources</h2>
+      <p>URIs where to start evaluating the LDPath program below.</p>
       <div id="test_context"></div>
-      <div><input id="addContextUri" type=text /><button id="addContext">Add Context</button></div>
+      <div><input id="addContextUri" type=text /><button id="addContext">Add URI</button></div>
     </div>
     <div id="editor">
       <div>
@@ -69,7 +70,7 @@
     <div id="result">
       <h2>Results</h2>
       <div>
-        <table id="testResults">
+        <table id="testResults" class="simple_table">
           <thead><tr><th>&nbsp;</th><th>Field</th><th>Result</th></tr></thead>
           <tbody></tbody>
         </table>

http://git-wip-us.apache.org/repos/asf/marmotta/blob/593ea4fa/platform/marmotta-ldpath/src/main/resources/web/admin/style.css
----------------------------------------------------------------------
diff --git a/platform/marmotta-ldpath/src/main/resources/web/admin/style.css b/platform/marmotta-ldpath/src/main/resources/web/admin/style.css
index 756f5bc..c6b1ee1 100644
--- a/platform/marmotta-ldpath/src/main/resources/web/admin/style.css
+++ b/platform/marmotta-ldpath/src/main/resources/web/admin/style.css
@@ -1,4 +1,4 @@
-/**
+/*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements. See the NOTICE file
  * distributed with this work for additional information
@@ -20,7 +20,7 @@ h2 {
 }
 
 .CodeMirror {
-    border: 1px solid #eee;
+    border: 1px solid #0B61A4;
     line-height: 1.25em !important;
 }
 
@@ -62,11 +62,19 @@ h2 {
     margin: 1px;
     display: inline-block;
 }
+
 #test_context span.context > .context {
     text-decoration: none;
     color: black;
 }
+
 #test_context span.context > .delete {
     text-decoration: none;
     color: red;
 }
+
+button#runTest {
+    font-size: 16px;
+    font-weight: bold;
+    margin: 10px;
+}


[2/3] git commit: MARMOTTA-346: Added syntax-highlighting to reasoner config page.

Posted by ja...@apache.org.
MARMOTTA-346: Added syntax-highlighting to reasoner config page.


Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/559d2e67
Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/559d2e67
Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/559d2e67

Branch: refs/heads/develop
Commit: 559d2e67b3656ad0c4ffe478de3daaf520f115d7
Parents: 9a3913d
Author: Jakob Frank <ja...@apache.org>
Authored: Tue Dec 17 14:14:58 2013 +0100
Committer: Jakob Frank <ja...@apache.org>
Committed: Tue Dec 17 14:14:58 2013 +0100

----------------------------------------------------------------------
 .../src/main/resources/web/admin/configure.html | 24 ++++++---
 .../resources/web/admin/widget/conf_reasoner.js | 56 +++++++++++++++++---
 2 files changed, 67 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/marmotta/blob/559d2e67/platform/marmotta-reasoner-kiwi/src/main/resources/web/admin/configure.html
----------------------------------------------------------------------
diff --git a/platform/marmotta-reasoner-kiwi/src/main/resources/web/admin/configure.html b/platform/marmotta-reasoner-kiwi/src/main/resources/web/admin/configure.html
index 63b0c64..5a97628 100644
--- a/platform/marmotta-reasoner-kiwi/src/main/resources/web/admin/configure.html
+++ b/platform/marmotta-reasoner-kiwi/src/main/resources/web/admin/configure.html
@@ -17,8 +17,7 @@
     limitations under the License.
 
 -->
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
-        "http://www.w3.org/TR/html4/loose.dtd">
+<!DOCTYPE HTML>
 <html>
 <head>
 <!--###BEGIN_HEAD###-->
@@ -45,15 +44,28 @@
         table{
             border: 1px dotted black !important;
         }
+        .CodeMirror {
+            border: 1px solid black;
+        }
+        #reasoner li .CodeMirror {
+            height: auto;
+        }
+        #reasoner li .CodeMirror-scroll {
+            overflow-y: hidden;
+            overflow-x: auto;
+        }
     </style>
 <!--###END_HEAD###-->
 </head>
 <body>
 <!--###BEGIN_CONTENT###-->
-<h1>Reasoning Configurator</h1>
-        <p>
-            Here you can configure the Reasoner.
-        </p>
+    <h1>Reasoning Configurator</h1>
+    <p>Here you can configure the Reasoner.</p>
+    <p>A detailed howto is available on the 
+        <a href="http://marmotta.apache.org/kiwi/reasoner.html">Marmotta Webpage (KiWi Reasoner)</a>
+        and collection of example reasoning programs is available 
+        <a href="http://wiki.apache.org/marmotta/Reasoner/ExamplePrograms">in the Wiki</a>.
+    </p> 
         <div id="reasoner">
             <h4>Loading reasoning configurator</h4>
         </div>

http://git-wip-us.apache.org/repos/asf/marmotta/blob/559d2e67/platform/marmotta-reasoner-kiwi/src/main/resources/web/admin/widget/conf_reasoner.js
----------------------------------------------------------------------
diff --git a/platform/marmotta-reasoner-kiwi/src/main/resources/web/admin/widget/conf_reasoner.js b/platform/marmotta-reasoner-kiwi/src/main/resources/web/admin/widget/conf_reasoner.js
index ad4c3f9..9d88207 100644
--- a/platform/marmotta-reasoner-kiwi/src/main/resources/web/admin/widget/conf_reasoner.js
+++ b/platform/marmotta-reasoner-kiwi/src/main/resources/web/admin/widget/conf_reasoner.js
@@ -29,13 +29,17 @@
     var title_input;
     var program_input;
     var list;
+    
+    CodeMirror.commands.autocomplete = function(cm) {
+        CodeMirror.showHint(cm, CodeMirror.hint.skwrl);
+    };
 
     $.fn.reasoning_config = function(options) {
         var settings = {
             host: 'http://localhost:8080/LMF/',
             samples :{
-                skos:"@prefix: skos: <http://www.w3.org/2004/02/skos/core#>\n($1 skos:broader $2) -> ($1 skos:broaderTransitive $2)\n($1 skos:narrower $2) -> ($1 skos:narrowerTransitive $2)\n($1 skos:broaderTransitive $2), ($2 skos:broaderTransitive $3) -> ($1 skos:broaderTransitive $3)\n($1 skos:narrowerTransitive $2), ($2 skos:narrowerTransitive $3) -> ($1 skos:narrowerTransitive $3)\n($1 skos:broader $2) -> ($2 skos:narrower $1)\n($1 skos:narrower $2) -> ($2 skos:broader $1)\n($1 skos:broader $2) -> ($1 skos:related $2)\n($1 skos:narrower $2) -> ($1 skos:related $2)\n($1 skos:related $2) -> ($2 skos:related $1)",
-                rdfs:"@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n($1 rdfs:subClassOf $2), ($2 rdfs:subClassOf $3) -> ($1 rdfs:subClassOf $3)\n($1 rdfs:subPropertyOf $2), ($2 rdfs:subPropertyOf $3) -> ($1 rdfs:subPropertyOf $3)\n($1 rdf:type $2), ($2 rdfs:subClassOf $3) -> ($1 rdf:type $3)\n($p rdfs:range $r), ($1 $p $2) -> ($2 rdf:type $r)\n($p rdfs:domain $d), ($1 $p $2) -> ($1 rdf:type $d)"
+                skos:"@prefix: skos: <http://www.w3.org/2004/02/skos/core#>\n\n($1 skos:broader $2) -> ($1 skos:broaderTransitive $2)\n($1 skos:narrower $2) -> ($1 skos:narrowerTransitive $2)\n($1 skos:broaderTransitive $2), ($2 skos:broaderTransitive $3) -> ($1 skos:broaderTransitive $3)\n($1 skos:narrowerTransitive $2), ($2 skos:narrowerTransitive $3) -> ($1 skos:narrowerTransitive $3)\n($1 skos:broader $2) -> ($2 skos:narrower $1)\n($1 skos:narrower $2) -> ($2 skos:broader $1)\n($1 skos:broader $2) -> ($1 skos:related $2)\n($1 skos:narrower $2) -> ($1 skos:related $2)\n($1 skos:related $2) -> ($2 skos:related $1)",
+                rdfs:"@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n\n($1 rdfs:subClassOf $2), ($2 rdfs:subClassOf $3) -> ($1 rdfs:subClassOf $3)\n($1 rdfs:subPropertyOf $2), ($2 rdfs:subPropertyOf $3) -> ($1 rdfs:subPropertyOf $3)\n($1 rdf:type $2), ($2 rdfs:subClassOf $3) -> ($1 rdf:type $3)\n($p rdfs:range $r), ($1 $p $2) -> ($2 rdf:type $r)\n($p rdfs:domain $d), ($1 $p $2) -> ($1 rdf:type $d)"
             },
             loader:"../../core/public/img/ajax-loader_small.gif"
         }
@@ -104,13 +108,14 @@
                     button.bind("click",function(){
                         do_remove($(this).attr('name'));
                     });
-                    var title = $("<h4></h4>").text(name);
-                    var pr = $("<pre style='width:863px;font-size:11px;margin:0;'></pre>").text(ps[i].rules);
+                    var title = $("<h4>").text(name);
+                    var pr = $("<div>");
                     li.append(title);
                     li.append(pr);
                     li.append(button);
                     li.append('<img class="loader" src="'+settings.loader+'" style="display:none;float:right;margin:5px"></div>');
                     list.append(li);
+                    createCodeMirror(pr, ps[i].rules, true);
                 }
             }
 
@@ -120,6 +125,41 @@
                 list.html("<li>no programs loaded</li>");
             }
         }
+        
+        function createCodeMirror(target, content, readOnly) {
+            target = $(target)[0];
+            if (target._cmEditor || false) {
+                removeCodeMirror(target);
+            }
+            if (readOnly) {
+                target._cmEditor = new CodeMirror(target, {
+                    readOnly: true,
+                    lineNumbers: true,
+                    matchBrackets: true,
+                    mode: "skwrl"
+                });
+                target._cmEditor.toTextArea = function() {}; // To avoid errors because of a missing function in removeCodeMirror()
+            } else {
+                target._cmEditor = CodeMirror.fromTextArea(target, {
+                    readOnly: false,
+                    lineNumbers : true,
+                    matchBrackets : true,
+                    extraKeys: {"Ctrl-Space": "autocomplete"},
+                    mode : "skwrl"
+                });
+            }
+            if (content !== undefined) {
+                target._cmEditor.setValue(content);
+                if (!readOnly)
+                    target._cmEditor.save();
+            }
+        }
+        function removeCodeMirror(target) {
+            if (target._cmEditor || false) {
+                target._cmEditor.toTextArea();
+                target._cmEditor = null;
+            }
+        }
 
         var write = function(programs) {
             div.html("");
@@ -144,7 +184,7 @@
             var button2 = $("<button style='position:relative;left:50%;margin-top:10px;margin-left:-50px;'></button>").text("clear");
             button2.bind("click",function(){
                 title_input.val("");
-                program_input.val("");
+                createCodeMirror(program_input, "");
             });
 
             table.append(tr1);
@@ -161,11 +201,11 @@
                 var x = $(this).val();
                 if(x=="---"){
                     title_input.val("");
-                    program_input.val("");
+                    createCodeMirror(program_input, "");
                     return;
                 }
                 title_input.val(x);
-                program_input.val(settings.samples[x]);
+                createCodeMirror(program_input, settings.samples[x]);
             });
             var sam_div = $('<div style="position: relative; float: right; margin-bottom: 5px; margin-top: -20px;"><span style="font-size:12px;margin-right:5px">Samples:</span>');
             sam_div.append(sam);
@@ -179,6 +219,8 @@
             div.append(button);
             div.append('<img class="loader" src="'+settings.loader+'" style="display:none;float:right;margin:5px"></div>');
 
+            createCodeMirror(program_input)
+            
             writePrograms(programs);
         }