public class ArtifactContentEntry
implements Serializable
{
- private String name;
+ private String text;
private boolean file;
private int depth;
+ private boolean hasChildren;
+
public ArtifactContentEntry()
{
// no op
}
- public ArtifactContentEntry( String name, boolean file, int depth )
+ public ArtifactContentEntry( String text, boolean file, int depth, boolean hasChildren )
{
- this.name = name;
+ this.text = text;
this.file = file;
this.depth = depth;
+ this.hasChildren = hasChildren;
+ }
+
+ public String getText()
+ {
+ return text;
}
- public String getName()
+ public String getId()
{
- return name;
+ return text;
}
- public void setName( String name )
+ public void setText( String text )
{
- this.name = name;
+ this.text = text;
}
public boolean isFile()
this.depth = depth;
}
- @Override
- public String toString()
+ public boolean isHasChildren()
{
- final StringBuilder sb = new StringBuilder();
- sb.append( "ArtifactContentEntry" );
- sb.append( "{name='" ).append( name ).append( '\'' );
- sb.append( ", file=" ).append( file );
- sb.append( ", depth=" ).append( depth );
- sb.append( '}' );
- return sb.toString();
+ return hasChildren;
}
+ public void setHasChildren( boolean hasChildren )
+ {
+ this.hasChildren = hasChildren;
+ }
+
+
+
@Override
public boolean equals( Object o )
{
ArtifactContentEntry that = (ArtifactContentEntry) o;
+ if ( hasChildren != that.hasChildren )
+ {
+ return false;
+ }
if ( depth != that.depth )
{
return false;
{
return false;
}
- if ( !name.equals( that.name ) )
+ if ( text != null ? !text.equals( that.text ) : that.text != null )
{
return false;
}
@Override
public int hashCode()
{
- int result = name.hashCode();
+ int result = text != null ? text.hashCode() : 0;
result = 31 * result + ( file ? 1 : 0 );
result = 31 * result + depth;
+ result = 31 * result + ( hasChildren ? 1 : 0 );
return result;
}
+
+ @Override
+ public String toString()
+ {
+ final StringBuilder sb = new StringBuilder();
+ sb.append( "ArtifactContentEntry" );
+ sb.append( "{text='" ).append( text ).append( '\'' );
+ sb.append( ", file=" ).append( file );
+ sb.append( ", depth=" ).append( depth );
+ sb.append( ", children=" ).append( hasChildren );
+ sb.append( '}' );
+ return sb.toString();
+ }
}
{
Map<String, ArtifactContentEntry> artifactContentEntryMap = new HashMap<String, ArtifactContentEntry>();
int filterDepth = StringUtils.countMatches( filterPath, "/" );
- if ( filterDepth == 0 )
+ /*if ( filterDepth == 0 )
{
filterDepth = 1;
- }
+ }*/
JarFile jarFile = new JarFile( file );
try
{
currentEntry.getName(), "/" ) : currentEntry.getName();
String entryRootPath = getRootPath( cleanedEntryName );
int depth = StringUtils.countMatches( cleanedEntryName, "/" );
- if ( StringUtils.isEmpty( filterPath ) && !artifactContentEntryMap.containsKey( entryRootPath ) )
+ if ( StringUtils.isEmpty( filterPath ) && !artifactContentEntryMap.containsKey( entryRootPath )
+ && depth == filterDepth )
{
artifactContentEntryMap.put( entryRootPath,
}
else
{
- if ( StringUtils.startsWith( cleanedEntryName, filterPath ) && ( depth >= filterDepth || (
+ if ( StringUtils.startsWith( cleanedEntryName, filterPath ) && ( depth == filterDepth || (
!currentEntry.isDirectory() && depth == filterDepth ) ) )
{
artifactContentEntryMap.put( cleanedEntryName, new ArtifactContentEntry( cleanedEntryName,
--- /dev/null
+UL.jqueryFileTree {\r
+ font-family: Verdana, sans-serif;\r
+ font-size: 11px;\r
+ line-height: 18px;\r
+ padding: 0px;\r
+ margin: 0px;\r
+}\r
+\r
+UL.jqueryFileTree LI {\r
+ list-style: none;\r
+ padding: 0px;\r
+ padding-left: 20px;\r
+ margin: 0px;\r
+ white-space: nowrap;\r
+}\r
+\r
+UL.jqueryFileTree A {\r
+ color: #333;\r
+ text-decoration: none;\r
+ display: block;\r
+ padding: 0px 2px;\r
+}\r
+\r
+UL.jqueryFileTree A:hover {\r
+ background: #BDF;\r
+}\r
+\r
+/* Core Styles */\r
+.jqueryFileTree LI.directory { background: url(images/directory.png) left top no-repeat; }\r
+.jqueryFileTree LI.expanded { background: url(images/folder_open.png) left top no-repeat; }\r
+.jqueryFileTree LI.file { background: url(images/file.png) left top no-repeat; }\r
+.jqueryFileTree LI.wait { background: url(images/spinner.gif) left top no-repeat; }\r
+/* File Extensions*/\r
+.jqueryFileTree LI.ext_3gp { background: url(images/film.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_afp { background: url(images/code.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_afpa { background: url(images/code.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_asp { background: url(images/code.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_aspx { background: url(images/code.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_avi { background: url(images/film.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_bat { background: url(images/application.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_bmp { background: url(images/picture.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_c { background: url(images/code.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_cfm { background: url(images/code.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_cgi { background: url(images/code.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_com { background: url(images/application.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_cpp { background: url(images/code.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_css { background: url(images/css.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_doc { background: url(images/doc.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_exe { background: url(images/application.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_gif { background: url(images/picture.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_fla { background: url(images/flash.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_h { background: url(images/code.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_htm { background: url(images/html.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_html { background: url(images/html.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_jar { background: url(images/java.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_jpg { background: url(images/picture.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_jpeg { background: url(images/picture.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_js { background: url(images/script.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_lasso { background: url(images/code.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_log { background: url(images/txt.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_m4p { background: url(images/music.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_mov { background: url(images/film.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_mp3 { background: url(images/music.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_mp4 { background: url(images/film.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_mpg { background: url(images/film.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_mpeg { background: url(images/film.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_ogg { background: url(images/music.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_pcx { background: url(images/picture.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_pdf { background: url(images/pdf.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_php { background: url(images/php.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_png { background: url(images/picture.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_ppt { background: url(images/ppt.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_psd { background: url(images/psd.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_pl { background: url(images/script.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_py { background: url(images/script.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_rb { background: url(images/ruby.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_rbx { background: url(images/ruby.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_rhtml { background: url(images/ruby.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_rpm { background: url(images/linux.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_ruby { background: url(images/ruby.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_sql { background: url(images/db.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_swf { background: url(images/flash.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_tif { background: url(images/picture.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_tiff { background: url(images/picture.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_txt { background: url(images/txt.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_vb { background: url(images/code.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_wav { background: url(images/music.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_wmv { background: url(images/film.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_xls { background: url(images/xls.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_xml { background: url(images/code.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_zip { background: url(images/zip.png) left top no-repeat; }
\ No newline at end of file
<html>
<head>
<link rel="stylesheet" href="css/jquery.fileupload-ui.css"/>
+ <link rel="stylesheet" href="css/jqueryFileTree.css"/>
<link rel="stylesheet" href="css/chosen-0.9.7.css"/>
<link rel="stylesheet" href="css/jquery-ui-1.8.16.custom.css"/>
<link rel="stylesheet" href="css/bootstrap.2.0.3.css">
"jquery.fileupload.ip":"jquery.fileupload-ip-1.0.6",
"jquery.fileupload.ui":"jquery.fileupload-ui-6.6.3",
"tmpl": "tmpl.min",
+ "treeview": "jquery.treeview-1.5-pre",
+ "treeview.async":"jquery.treeview.async-0.1",
+ "jquery.treeview.edit": "jquery.treeview.edit",
+ "jqueryFileTree": "jqueryFileTree-1.0.1",
"redback": "redback/redback",
"redback.roles": "redback/roles",
"redback.user": "redback/user",
* specific language governing permissions and limitations
* under the License.
*/
-define("search",["jquery","i18n","jquery.tmpl","choosen","order!knockout","knockout.simpleGrid"], function() {
+define("search",["jquery","i18n","jquery.tmpl","choosen","order!knockout","knockout.simpleGrid","treeview"
+ ,"treeview.async","jquery.treeview.edit","jqueryFileTree"], function() {
if ($(e.target).attr("href")=="#artifact-details-file-content") {
$.log("file content:"+self.groupId+":"+self.artifactId+":"+self.version);
+
+ var entriesUrl = "restServices/archivaServices/browseService/artifactContentEntries/"+encodeURIComponent(self.groupId);
+ entriesUrl+="/"+encodeURIComponent(self.artifactId)+"/"+encodeURIComponent(self.version);
+ entriesUrl+="?repositoryId="+encodeURIComponent(getSelectedBrowsingRepository());
+ //entriesUrl+="&p="+encodeURIComponent(artifactContentEntry.name);
+
+ $("#main-content #artifact_content_tree").fileTree({
+ script: entriesUrl,
+ root: ""
+ },function(file) {
+ alert(file);
+ });
+ return;
+
var entriesUrl = "restServices/archivaServices/browseService/artifactContentEntries/"+encodeURIComponent(self.groupId);
entriesUrl+="/"+encodeURIComponent(self.artifactId)+"/"+encodeURIComponent(self.version);
entriesUrl+="?repositoryId="+encodeURIComponent(self.repositoryId);
type: "GET",
dataType: 'json',
success: function(data) {
+ //$("#artifact-details-file-content").html($("#artifact_content_tmpl").tmpl());//{artifactContentEntries:mapArtifactContentEntries(data)}));
+ //artifact_content_tmpl
var artifactContentEntryViewModel=
- new ArtifactContentEntryViewModel(self.groupId,self.artifactId,self.version,mapArtifactContentEntries(data));
- $("#artifact-details-file-content").html($("#artifact_content_main_tmpl").tmpl());
- ko.applyBindings(artifactContentEntryViewModel,mainContent.find("#artifact_file_content_div").get(0));
+ new ArtifactContentEntryViewModel(self.groupId,self.artifactId,self.version,[]);
+ artifactContentEntryViewModel.show();
+ //ko.applyBindings(artifactContentEntryViewModel,mainContent.find("#artifact_file_content_div").get(0));
}
});
}
}
- ArtifactContentEntry=function(name,file,depth){
- this.name=name;
+ ArtifactContentEntry=function(text,file,depth,id){
+ this.text=text;
this.file=file;
this.depth=depth;
+ this.id=id;
}
mapArtifactContentEntries=function(data){
}
if ( $.isArray(data)){
return $.map(data,function(e){
- return new ArtifactContentEntry(e.name,e.file,e.depth);
+ return new ArtifactContentEntry(e.text,e.file,e.depth,e.id);
})
}
- return new ArtifactContentEntry(data.name,data.file,data.depth);
+ return new ArtifactContentEntry(data.text,data.file,data.depth,e.id);
}
ArtifactContentEntryViewModel=function(groupId,artifactId,version,artifactContentEntries){
this.artifactId=artifactId;
this.version=version;
this.artifactContentEntries=ko.observableArray(artifactContentEntries);
- $.log("size:"+this.artifactContentEntries().length);
+ this.currentPath=ko.observable();
+
+ this.show=function(){
+ var entriesUrl = "restServices/archivaServices/browseService/artifactContentEntries/"+encodeURIComponent(self.groupId);
+ entriesUrl+="/"+encodeURIComponent(self.artifactId)+"/"+encodeURIComponent(self.version);
+ entriesUrl+="?repositoryId="+encodeURIComponent(getSelectedBrowsingRepository());
+ //entriesUrl+="&p="+encodeURIComponent(artifactContentEntry.name);
+
+ $("#main-content #artifact_content_tree").fileTree({
+ script: entriesUrl
+ },function(file) {
+ alert(file);
+ });
+ }
entries=function(){
return self.artifactContentEntries;
entriesUrl+="/"+encodeURIComponent(self.artifactId)+"/"+encodeURIComponent(self.version);
entriesUrl+="?repositoryId="+encodeURIComponent(getSelectedBrowsingRepository());
entriesUrl+="&p="+encodeURIComponent(artifactContentEntry.name);
+ self.currentPath(artifactContentEntry.name);
$.ajax(entriesUrl,{
type: "GET",
dataType: 'json',
--- /dev/null
+// jQuery File Tree Plugin
+//
+// Version 1.01
+//
+// Cory S.N. LaViska
+// A Beautiful Site (http://abeautifulsite.net/)
+// 24 March 2008
+//
+// Visit http://abeautifulsite.net/notebook.php?article=58 for more information
+//
+// Usage: $('.fileTreeDemo').fileTree( options, callback )
+//
+// Options: root - root folder to display; default = /
+// script - location of the serverside AJAX file to use; default = jqueryFileTree.php
+// folderEvent - event to trigger expand/collapse; default = click
+// expandSpeed - default = 500 (ms); use -1 for no animation
+// collapseSpeed - default = 500 (ms); use -1 for no animation
+// expandEasing - easing function to use on expand (optional)
+// collapseEasing - easing function to use on collapse (optional)
+// multiFolder - whether or not to limit the browser to one subfolder at a time
+// loadMessage - Message to display while initial tree loads (can be HTML)
+//
+// History:
+//
+// 1.01 - updated to work with foreign characters in directory/file names (12 April 2008)
+// 1.00 - released (24 March 2008)
+//
+// TERMS OF USE
+//
+// This plugin is dual-licensed under the GNU General Public License and the MIT License and
+// is copyright 2008 A Beautiful Site, LLC.
+//
+if(jQuery) (function($){
+
+ $.extend($.fn, {
+ fileTree: function(o, h) {
+ // Defaults
+ if( !o ) var o = {};
+ if( o.root == undefined ) o.root = '/';
+ if( o.script == undefined ) o.script = 'jqueryFileTree.php';
+ if( o.folderEvent == undefined ) o.folderEvent = 'click';
+ if( o.expandSpeed == undefined ) o.expandSpeed= 500;
+ if( o.collapseSpeed == undefined ) o.collapseSpeed= 500;
+ if( o.expandEasing == undefined ) o.expandEasing = null;
+ if( o.collapseEasing == undefined ) o.collapseEasing = null;
+ if( o.multiFolder == undefined ) o.multiFolder = true;
+ if( o.loadMessage == undefined ) o.loadMessage = 'Loading...';
+
+ $(this).each( function() {
+
+ function showTree(c, t) {
+ $(c).addClass('wait');
+ $(".jqueryFileTree.start").remove();
+ $.get(o.script, { p: t }, function(data) {
+ $(c).find('.start').html('');
+ var htmlContent = $("#artifact_content_tree_partial" ).tmpl({artifactContentEntries:mapArtifactContentEntries(data)});
+ $(c).removeClass('wait').append(htmlContent);
+ if( o.root == t ) $(c).find('UL:hidden').show(); else $(c).find('UL:hidden').slideDown({ duration: o.expandSpeed, easing: o.expandEasing });
+ bindTree(c);
+ });
+ }
+
+ function bindTree(t) {
+ $(t).find('LI A').bind(o.folderEvent, function() {
+ if( $(this).parent().hasClass('directory') ) {
+ if( $(this).parent().hasClass('collapsed') ) {
+ // Expand
+ if( !o.multiFolder ) {
+ $(this).parent().parent().find('UL').slideUp({ duration: o.collapseSpeed, easing: o.collapseEasing });
+ $(this).parent().parent().find('LI.directory').removeClass('expanded').addClass('collapsed');
+ }
+ $(this).parent().find('UL').remove(); // cleanup
+ showTree( $(this).parent(), escape($(this).attr('rel')) );//.match( /.*\// )
+ $(this).parent().removeClass('collapsed').addClass('expanded');
+ } else {
+ // Collapse
+ $(this).parent().find('UL').slideUp({ duration: o.collapseSpeed, easing: o.collapseEasing });
+ $(this).parent().removeClass('expanded').addClass('collapsed');
+ }
+ } else {
+ h($(this).attr('rel'));
+ }
+ return false;
+ });
+ // Prevent A from triggering the # on non-click events
+ if( o.folderEvent.toLowerCase != 'click' ) $(t).find('LI A').bind('click', function() { return false; });
+ }
+ // Loading message
+ $(this).html('<ul class="jqueryFileTree start"><li class="wait">' + o.loadMessage + '<li></ul>');
+ // Get the initial file list
+ showTree( $(this), escape(o.root) );
+ });
+ }
+ });
+
+})(jQuery);
\ No newline at end of file
</div>
<div id="artifact-details-file-content" class="tab-pane">
+ <div id="artifact_content_tree">
+ </div>
</div>
<div id="artifact-details-used-by-content" class="tab-pane"></div>
</script>
<script id="artifact_content_tmpl" type="text/html">
- <ul>
- {{each(i, artifactContentEntry) artifactContentEntries()}}
- <li data-bind="css: { 'browse-list': artifactContentEntry.file==false }">
- <a href="#" data-bind="click: function(){displayPath(artifactContentEntry)}">${artifactContentEntry.name}</a>
- </li>
- {{/each}}
- </ul>
+ <div id="artifact_content_tree">
+ </div>
+</script>
+
+<script id="artifact_content_tree_partial" type="text/html">
+ <ul class="jqueryFileTree" style="display: none;">
+ {{each artifactContentEntries}}
+ <li class="directory collapsed">
+ <a href="#" rel="${$value.text}/">${$value.text}</a>
+ </li>
+ {{/each}}
+ </ul>
</script>
\ No newline at end of file