-
Notifications
You must be signed in to change notification settings - Fork 0
/
editor.html
356 lines (315 loc) · 14.1 KB
/
editor.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
<!DOCTYPE html>
<html lang="en">
<head>
<title>Test Onto</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
<link rel="stylesheet" href="css/font-awesome-4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="css/docking.components.css">
<link rel="stylesheet" href="css/jOWL.css" type="text/css"/>
<style type="text/css">
/*
* Base structure
*/
/* Move down content because we have a fixed navbar that is 50px tall */
body {
padding-top: 50px;
}
/*
* Typography
*/
h1 {
margin-bottom: 20px;
padding-bottom: 9px;
border-bottom: 1px solid #eee;
}
/*
* Sidebar
*/
.sidebar {
position: fixed;
top: 51px;
bottom: 0;
left: 0;
z-index: 1000;
padding: 20px;
overflow-x: hidden;
overflow-y: auto;
/* Scrollable contents if viewport is shorter than content. */
border-right: 1px solid #eee;
}
/* Sidebar navigation */
.sidebar {
padding-left: 0;
padding-right: 0;
}
.sidebar .nav {
margin-bottom: 20px;
}
.sidebar .nav-item {
width: 100%;
}
.sidebar .nav-item+.nav-item {
margin-left: 0;
}
.sidebar .nav-link {
border-radius: 0;
}
/*
* Dashboard
*/
/* Placeholders */
.placeholders {
padding-bottom: 3rem;
}
.placeholder img {
padding-top: 1.5rem;
padding-bottom: 1.5rem;
}
.editor {
padding-bottom:15px;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>
<script type="text/javascript" src="scripts/inheritance.js"></script>
<script type="text/javascript" src="scripts/jquery.tooltip.js"></script>
<script type="text/javascript" src="scripts/jOWL.js"></script>
<script type="text/javascript" src="scripts/jOWL_UI.js"></script>
<script type="text/javascript" src="scripts/jOWLBrowser.js"></script>
<script type="text/javascript" src="scripts/jowl.element.js"></script>
<script type="text/javascript" src="scripts/jowl.document.js"></script>
<script type="text/javascript" src="scripts/jowl.datatype.js"></script>
<script type="text/javascript" src="scripts/jowl.thing.js"></script>
<script type="text/javascript" src="scripts/jowl.ontology.js"></script>
<script type="text/javascript" src="scripts/jowl.individual.js"></script>
<script type="text/javascript" src="scripts/jowl.property.js"></script>
<script type="text/javascript" src="scripts/jowl.class.js"></script>
<script type="text/javascript" src="scripts/jowl.intersection.js"></script>
<script type="text/javascript" src="scripts/jowl.restriction.js"></script>
<script type="text/javascript" src="scripts/jowl.sparql-dl.js"></script>
<script type="text/javascript" src="scripts/ui/docking.components.js"></script>
<script type="text/javascript" src="scripts/ui/jOWL_UI.js"></script>
<script type="text/javascript" src="scripts/ui/autocomplete.component.js"></script>
<script type="text/javascript" src="scripts/ui/treeview.component.js"></script>
<script type="text/javascript" src="scripts/ui/propertylens.component.js"></script>
<script type="text/javascript" src="scripts/ui/editor.js"></script>
<script type="text/javascript">
DockArea.options.bootstrap = 4;
var loadOptions = {reason : true, locale : 'en' };
/*
jOWL.load("data/wine.owl",
function(owlDocument){
OntologyProvider.setOntology(owlDocument);
}, loadOptions);*/
function download(filename, text) {
var pom = document.createElement('a');
pom.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
pom.setAttribute('download', filename);
if (document.createEvent) {
var event = document.createEvent('MouseEvents');
event.initEvent('click', true, true);
pom.dispatchEvent(event);
}
else {
pom.click();
}
}
$(document).ready(function() {
$('#NewFileButton').click(function(e){
var namespace = $('#namespace-field').val();
if(!namespace || !namespace.length){
e.preventDefault();
return false;
}
var doc = jOWL.create.document(namespace);
var owlDocument = jOWL.parse(doc);
var name = $('#name-field').val();
if(name && name.length){
console.log( owlDocument.getOntology());
//Add a label using the default locale...
owlDocument.getOntology().addLabel(name, loadOptions.locale);
}
OntologyProvider.setOntology(owlDocument);
});
$('#LoadFileButton').click(function(){
var file = $('#file-input').get(0).files[0];
if(!file) return false;
var reader = new FileReader();
reader.onload = function(e) {
var contents = e.target.result;
//console.log(contents, e);
var owlDocument = jOWL.parse(contents, loadOptions);
OntologyProvider.setOntology(owlDocument);
};
reader.readAsText(file);
});
$('#SaveFileButton').click(function(){
if(!OntologyProvider.ontology) return false;
var txt = OntologyProvider.ontology.toXML();
var name = $('#file-output').val();
if(!name || !name.length) name = "ontology";
download(name+".owl", txt);
});
var area = new DockArea($('#dockArea'));
var $column = $('.dock-col', area.$element);
var split1 = area.splitVertical($column);
split1.top.append(new OntologyEdit().$element);
var split = area.splitHorizontal(split1.bottom);
var tabs = new TabDockPanel();
tabs.appendTo(split.left);
var treeEdit = new ConceptTreeEdit();
var classEdit = new ClassDescriptionEdit();
treeEdit.addListener(classEdit);
tabs.addPanel(treeEdit)
tabs.addPanel(classEdit);
tabs.addPanel(new SparqlWidget());
treeEdit.initProvider();
tabs = new TabDockPanel();
tabs.appendTo(split.right);
treeEdit = new ConceptTreeEdit();
classEdit = new ClassDescriptionEdit();
treeEdit.addListener(classEdit);
tabs.addPanel(treeEdit)
tabs.addPanel(classEdit);
treeEdit.initProvider();
new DockPanelCreator($('#ClassTree'), {
create : function(){ return new ConceptTreeEdit(); }
});
new DockPanelCreator($('#ontoEdit'), {
create : function(){
return new OntologyEdit();
}
});
new DockPanelCreator($('#sparql-dl'), {
create : function(){
return new SparqlWidget();
}
});
});
</script>
</head>
<body>
<nav class="navbar navbar-toggleable-md navbar-inverse fixed-top bg-inverse">
<button class="navbar-toggler navbar-toggler-right hidden-lg-up" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault" aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<a class="navbar-brand" href="#">Ontology Editor</a>
<div class="collapse navbar-collapse" id="navbarsExampleDefault">
<ul class="navbar-nav mr-auto">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#">File <span class="sr-only">(current)</span></a>
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<a class="dropdown-item" href="#New" data-toggle="modal" data-target="#NewFile">New</a>
<a class="dropdown-item" href="#Load" data-toggle="modal" data-target="#LoadFile">Load</a>
<a class="dropdown-item" href="#Save" data-toggle="modal" data-target="#SaveFile">Save</a>
</div>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Settings</a>
</li>
</ul>
<form class="form-inline mt-2 mt-md-0">
<input class="form-control mr-sm-2" type="text" placeholder="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
</nav>
<div class="container-fluid">
<div class="row">
<nav class="col-sm-3 col-md-2 hidden-xs-down bg-faded sidebar">
<h1 class="navbar-brand">Drag and drop components</h1>
<ul class="nav nav-pills flex-column">
<li class="nav-item">
<a class="nav-link" id="ClassTree" href="#ClassTree"><i class="fa fa-puzzle-piece" aria-hidden="true"></i> owl:Class TreeView</a>
</li>
<li class="nav-item">
<a class="nav-link" id="ontoEdit" href="#ontoEdit"><i class="fa fa-puzzle-piece" aria-hidden="true"></i> owl:Ontology View</a>
</li>
<li class="nav-item">
<a class="nav-link" id="sparql-dl" href="#sparql-dl"><i class="fa fa-puzzle-piece" aria-hidden="true"></i> Sparql-DL widget</a>
</li>
</ul>
</nav>
<main class="col-sm-9 offset-sm-3 col-md-10 offset-md-2 pt-3">
<h1>Dashboard</h1>
<div id="dockArea">
</div>
</main>
</div>
</div>
<div id="Modals">
<!-- Modal -->
<div class="modal fade" id="LoadFile" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Load Owl File</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<input type="file" id="file-input" class="form-control"/>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" data-dismiss="modal" id="LoadFileButton" class="btn btn-primary">Load</button>
</div>
</div>
</div>
</div>
<!-- Modal -->
<div class="modal fade" id="SaveFile" tabindex="-1"
role="dialog" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Save to Owl File</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<input type="text" id="file-output" class="form-control" placeholder="file name"/>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" data-dismiss="modal" id="SaveFileButton" class="btn btn-primary">Save</button>
</div>
</div>
</div>
</div>
<!-- Modal -->
<div class="modal fade" id="NewFile" tabindex="-1"
role="dialog" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Create new Owl File</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="input-group">
<span class="input-group-addon">URI</span>
<input type="text" id="namespace-field" class="form-control" placeholder="Base URL of the ontology (required)"/>
</div>
<br/>
<div class="input-group">
<span class="input-group-addon">Name</span>
<input type="text" id="name-field" class="form-control" placeholder="Ontology name (optional)"/>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" data-dismiss="modal" id="NewFileButton" class="btn btn-primary">Create</button>
</div>
</div>
</div>
</div>
</div>
</body>
</html>