r1482 - in xwiki/trunk/core/src/main/java/com/xpn/xwiki: objects/classes plugin/zipexplorer

Jeremi Joslin jeremi at users.forge.objectweb.org
Tue Oct 31 13:54:37 CET 2006


Author: jeremi
Date: 2006-10-31 13:54:36 +0100 (Tue, 31 Oct 2006)
New Revision: 1482

Modified:
   xwiki/trunk/core/src/main/java/com/xpn/xwiki/objects/classes/ListItem.java
   xwiki/trunk/core/src/main/java/com/xpn/xwiki/plugin/zipexplorer/ZipExplorerPlugin.java
   xwiki/trunk/core/src/main/java/com/xpn/xwiki/plugin/zipexplorer/ZipExplorerPluginAPI.java
Log:
[GELC]
* add the treeview

Modified: xwiki/trunk/core/src/main/java/com/xpn/xwiki/objects/classes/ListItem.java
===================================================================
--- xwiki/trunk/core/src/main/java/com/xpn/xwiki/objects/classes/ListItem.java	2006-10-30 09:34:16 UTC (rev 1481)
+++ xwiki/trunk/core/src/main/java/com/xpn/xwiki/objects/classes/ListItem.java	2006-10-31 12:54:36 UTC (rev 1482)
@@ -1,12 +1,26 @@
+/*
+ * Copyright 2006, XpertNet SARL, and individual contributors as indicated
+ * by the contributors.txt.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ * @author ludovic
+ */
 package com.xpn.xwiki.objects.classes;
 
-/**
- * Created by IntelliJ IDEA.
- * User: ldubost
- * Date: 19 oct. 2006
- * Time: 15:23:56
- * To change this template use File | Settings | File Templates.
- */
 public class ListItem {
     private String id = "";
     private String value = "";

Modified: xwiki/trunk/core/src/main/java/com/xpn/xwiki/plugin/zipexplorer/ZipExplorerPlugin.java
===================================================================
--- xwiki/trunk/core/src/main/java/com/xpn/xwiki/plugin/zipexplorer/ZipExplorerPlugin.java	2006-10-30 09:34:16 UTC (rev 1481)
+++ xwiki/trunk/core/src/main/java/com/xpn/xwiki/plugin/zipexplorer/ZipExplorerPlugin.java	2006-10-31 12:54:36 UTC (rev 1482)
@@ -27,6 +27,7 @@
 import com.xpn.xwiki.cache.api.XWikiCache;
 import com.xpn.xwiki.XWikiContext;
 import com.xpn.xwiki.XWikiException;
+import com.xpn.xwiki.objects.classes.ListItem;
 import com.xpn.xwiki.api.Document;
 import com.xpn.xwiki.api.Api;
 import com.xpn.xwiki.api.Attachment;
@@ -40,10 +41,7 @@
 import java.io.ByteArrayOutputStream;
 import java.util.zip.ZipInputStream;
 import java.util.zip.ZipEntry;
-import java.util.Properties;
-import java.util.List;
-import java.util.Iterator;
-import java.util.ArrayList;
+import java.util.*;
 
 
 public class ZipExplorerPlugin extends XWikiDefaultPlugin {
@@ -143,7 +141,7 @@
     }
 
 
-    List getFileList(Document doc, String attachmentName, XWikiContext context) {
+    public List getFileList(Document doc, String attachmentName, XWikiContext context) {
         List zipList = null;
 
         if (attachmentName.endsWith(".zip")) {
@@ -181,6 +179,32 @@
         return zipList;
     }
 
+     public Vector getFileTreeList(Document doc, String attachmentName, XWikiContext context) {
+        List flatList = getFileList(doc, attachmentName, context);
+         Map fileTree = new HashMap();
+         Iterator it = flatList.iterator();
+         Vector res = new Vector();
+         while(it.hasNext()){
+             String url = (String) it.next();
+             StringBuffer buf = new StringBuffer(url.length());
+             String parentBuf = "";
+             String[] aUrl = url.split("/");
+             for (int i = 0; i < aUrl.length; i++){
+                 if (i == aUrl.length - 1 && !url.endsWith("/"))
+                    buf.append(aUrl[i]);
+                 else
+                    buf.append(aUrl[i] + "/");
+                 ListItem item = new ListItem(buf.toString(), aUrl[i], parentBuf);
+                 if (!fileTree.containsKey(buf.toString()))
+                    res.add(item);
+                 fileTree.put(buf.toString(), item);
+                 parentBuf = buf.toString();
+             }
+         }
+         return res;
+     }
+
+
     String getFileLink(Document doc, String attachmentName, String fileName, XWikiContext context) {
         String link = doc.getAttachmentURL(attachmentName);
         return link + "/" + fileName;

Modified: xwiki/trunk/core/src/main/java/com/xpn/xwiki/plugin/zipexplorer/ZipExplorerPluginAPI.java
===================================================================
--- xwiki/trunk/core/src/main/java/com/xpn/xwiki/plugin/zipexplorer/ZipExplorerPluginAPI.java	2006-10-30 09:34:16 UTC (rev 1481)
+++ xwiki/trunk/core/src/main/java/com/xpn/xwiki/plugin/zipexplorer/ZipExplorerPluginAPI.java	2006-10-31 12:54:36 UTC (rev 1482)
@@ -1,52 +1,57 @@
-/*
- * Copyright 2006, XpertNet SARL, and individual contributors as indicated
- * by the contributors.txt.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- *
- * @author ravenees
- */
-package com.xpn.xwiki.plugin.zipexplorer;
-
-import com.xpn.xwiki.XWikiContext;
-import com.xpn.xwiki.api.Api;
-import com.xpn.xwiki.api.Document;
-import com.xpn.xwiki.doc.XWikiAttachment;
-
-import java.util.List;
-
-
-public class ZipExplorerPluginAPI extends Api {
-
-    ZipExplorerPlugin plugin;
-
-    public ZipExplorerPluginAPI(ZipExplorerPlugin plugin, XWikiContext context) {
-        super(context);
-        this.plugin = plugin;
-    }
-
-    public XWikiAttachment downloadAttachment(XWikiAttachment attachment) {
-        return this.plugin.downloadAttachment(attachment, context);
-    }
-
-    public List getFileList(Document doc, String attachmentName) {
-        return this.plugin.getFileList(doc, attachmentName, context);
-    }
-
-    public String getFileLink(Document doc, String attachmentName, String fileName) {
-        return this.plugin.getFileLink(doc, attachmentName, fileName, context);
-    }
-}
+/*
+ * Copyright 2006, XpertNet SARL, and individual contributors as indicated
+ * by the contributors.txt.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ * @author ravenees
+ */
+package com.xpn.xwiki.plugin.zipexplorer;
+
+import com.xpn.xwiki.XWikiContext;
+import com.xpn.xwiki.api.Api;
+import com.xpn.xwiki.api.Document;
+import com.xpn.xwiki.doc.XWikiAttachment;
+
+import java.util.List;
+import java.util.Vector;
+
+
+public class ZipExplorerPluginAPI extends Api {
+
+    ZipExplorerPlugin plugin;
+
+    public ZipExplorerPluginAPI(ZipExplorerPlugin plugin, XWikiContext context) {
+        super(context);
+        this.plugin = plugin;
+    }
+
+    public XWikiAttachment downloadAttachment(XWikiAttachment attachment) {
+        return this.plugin.downloadAttachment(attachment, context);
+    }
+
+    public List getFileList(Document doc, String attachmentName) {
+        return this.plugin.getFileList(doc, attachmentName, context);
+    }
+
+    public Vector getFileTreeList(Document doc, String attachmentName) {
+        return this.plugin.getFileTreeList(doc, attachmentName, context);
+    }
+
+    public String getFileLink(Document doc, String attachmentName, String fileName) {
+        return this.plugin.getFileLink(doc, attachmentName, fileName, context);
+    }
+}





More information about the Xwiki-notifications mailing list