Toggle navigation
Toggle navigation
This project
Loading...
Sign in
data.posccaesar.org
/
npd
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Issues
1
Merge Requests
0
Wiki
Network
Create a new issue
Commits
Issue Boards
Authored by
Holger Knublauch
2012-01-07 17:47:01 +1000
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d7ed7ffb012a67f71f13cda022594235c0800dcd
d7ed7ffb
1 parent
ec32fb8e
Tree selection working
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
73 additions
and
8 deletions
appschema.org/app.ui.ttl
appschema.org/app.www/app.js
appschema.org/imports/tree.uispin.html
appschema.org/app.ui.ttl
View file @
d7ed7ff
This diff is collapsed. Click to expand it.
appschema.org/app.www/app.js
View file @
d7ed7ff
...
...
@@ -339,6 +339,73 @@ function appReloadForm(resourceURI, queryGraphURI, linkElementId) {
/**
* Selects a given node in a given tree.
* Will expand if necessary, using a server-side shortest path algorithm.
* @param treeId the id of the tree
* @param nodeURI the URI of the resource to select
*/
function
appSelectTreeNode
(
treeId
,
nodeURI
)
{
// TODO: Currently this only works on the Tree that was created last
// but not if multiple trees are on a page
var
tree
=
$
(
'#'
+
treeId
);
var
dataProviderURI
=
tree
.
attr
(
'treedataprovider'
);
if
(
!
dataProviderURI
)
{
alert
(
'Error: Element with id '
+
treeId
+
' does not have treedataprovider attribute'
);
return
;
}
var
rootURI
=
tree
.
attr
(
'treeroot'
);
// Do nothing if it's already selected
var
sel
=
tree
.
jstree
(
'get_selected'
);
if
(
sel
)
{
if
(
sel
.
attr
(
'resource'
)
==
nodeURI
)
{
return
;
}
}
// Load path to root from the server and then call helper function
var
data
=
{
_format
:
'json'
,
_viewClass
:
'app:TreeShortestPathCallback'
,
dataProvider
:
'<'
+
dataProviderURI
+
'>'
,
node
:
'<'
+
nodeURI
+
'>'
};
if
(
rootURI
)
{
data
.
root
=
'<'
+
rootURI
+
'>'
;
}
$
.
get
(
uispinServlet
,
data
,
function
(
path
)
{
appSelectTreeNodeHelper
(
tree
,
tree
,
path
,
0
);
});
}
// Private helper function - walks an array, expanding nodes along the way
function
appSelectTreeNodeHelper
(
tree
,
node
,
path
,
index
)
{
var
next
=
path
[
index
];
node
.
children
(
"ul"
).
children
(
"li"
).
each
(
function
(
i
,
o
)
{
var
child
=
$
(
o
);
if
(
child
.
attr
(
'resource'
)
==
next
)
{
if
(
index
==
path
.
length
-
1
)
{
// End reached: select this node
tree
.
jstree
(
'select_node'
,
child
,
true
);
child
[
0
].
scrollIntoView
();
}
else
{
tree
.
jstree
(
'open_node'
,
child
,
function
()
{
appSelectTreeNodeHelper
(
tree
,
child
,
path
,
index
+
1
);
});
}
}
});
}
/**
* Submits a form and switches it to viewing mode when done.
* @param form the id of the form
* @param servlet the optional name of the servlet
...
...
appschema.org/imports/tree.uispin.html
View file @
d7ed7ff
...
...
@@ -5,8 +5,7 @@
ui:view=
"{= ?dataProvider }"
arg:root=
"{= ?root }"
>
<!-- The div that will be turned into a jsTree below -->
<div
id=
"{= ?id }"
/>
<div
id=
"{= ?id }"
treedataprovider=
"{= ?dataProvider }"
treeroot=
"{= ?root }"
/>
<script
type=
"text/javascript"
>
$
(
function
()
{
...
...
@@ -15,12 +14,7 @@
"plugins"
:
[
"themes"
,
"json_data"
,
"ui"
,
"crrm"
,
"cookies"
,
"search"
,
"types"
,
"hotkeys"
],
"ui"
],
"json_data"
:
{
"ajax"
:
{
...
...
@@ -40,6 +34,10 @@
"themes"
:
{
"theme"
:
"classic"
},
"ui"
:
{
"select_limit"
:
1
}
});
});
...
...
Please
register
or
login
to post a comment