roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ghu...@apache.org
Subject svn commit: r1602936 - in /roller/trunk/app/src/main: java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileImageChooser.java webapp/WEB-INF/jsps/editor/MediaFileImageChooser.jsp
Date Mon, 16 Jun 2014 17:35:59 GMT
Author: ghuber
Date: Mon Jun 16 17:35:58 2014
New Revision: 1602936

URL: http://svn.apache.org/r1602936
Log:
ROL-2011, empty file chooser.

Modified:
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileImageChooser.java
    roller/trunk/app/src/main/webapp/WEB-INF/jsps/editor/MediaFileImageChooser.jsp

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileImageChooser.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileImageChooser.java?rev=1602936&r1=1602935&r2=1602936&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileImageChooser.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileImageChooser.java
Mon Jun 16 17:35:58 2014
@@ -17,7 +17,6 @@
  */
 package org.apache.roller.weblogger.ui.struts2.editor;
 
-
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
@@ -45,9 +44,8 @@ public class MediaFileImageChooser exten
     private String directoryId;
     private String directoryName;
 
-    private List<MediaFile>          childFiles;
-    private MediaFileDirectory       currentDirectory;
-
+    private List<MediaFile> childFiles;
+    private MediaFileDirectory currentDirectory;
 
     public MediaFileImageChooser() {
         this.actionName = "mediaFileImageChooser";
@@ -59,27 +57,29 @@ public class MediaFileImageChooser exten
      * Prepares view action
      */
     public void myPrepare() {
-        refreshAllDirectories();
     }
 
     /**
-     * Fetches and displays list of media file for the given directory.
-     * The directory could be chosen by ID or path.
-     *
+     * Fetches and displays list of media file for the given directory. The
+     * directory could be chosen by ID or path.
+     * 
      * @return String The result of the action.
      */
     @SkipValidation
     public String execute() {
-        MediaFileManager manager = WebloggerFactory.getWeblogger().getMediaFileManager();
+        MediaFileManager manager = WebloggerFactory.getWeblogger()
+                .getMediaFileManager();
         try {
             MediaFileDirectory directory;
             if (this.directoryId != null) {
                 directory = manager.getMediaFileDirectory(this.directoryId);
             } else if (this.directoryName != null) {
-                directory = manager.getMediaFileDirectoryByName(getActionWeblog(), this.directoryName);
+                directory = manager.getMediaFileDirectoryByName(
+                        getActionWeblog(), this.directoryName);
                 this.directoryId = directory.getId();
             } else {
-                directory = manager.getDefaultMediaFileDirectory(getActionWeblog());
+                directory = manager
+                        .getDefaultMediaFileDirectory(getActionWeblog());
                 this.directoryId = directory.getId();
             }
 
@@ -92,17 +92,33 @@ public class MediaFileImageChooser exten
                 }
             }
 
-            Collections.sort(this.childFiles,
-                    new MediaFileComparator(MediaFileComparatorType.NAME));
+            Collections.sort(this.childFiles, new MediaFileComparator(
+                    MediaFileComparatorType.NAME));
 
             this.currentDirectory = directory;
 
+            // List of available directories
+            List<MediaFileDirectory> sortedDirList = new ArrayList<MediaFileDirectory>();
+            List<MediaFileDirectory> directories = manager
+                    .getMediaFileDirectories(getActionWeblog());
+            for (MediaFileDirectory mediaFileDirectory : directories) {
+                if (!"default".equals(mediaFileDirectory.getName())
+                        && "default".equals(directory.getName())
+                        || !"default".equals(directory.getName())) {
+                    sortedDirList.add(mediaFileDirectory);
+                }
+            }
+
+            Collections.sort(sortedDirList, new MediaFileDirectoryComparator(
+                    DirectoryComparatorType.NAME));
+            setAllDirectories(sortedDirList);
+
             return SUCCESS;
 
         } catch (FileIOException ex) {
             log.error("Error viewing media file directory ", ex);
             addError("MediaFile.error.view");
-            
+
         } catch (Exception e) {
             log.error("Error viewing media file directory ", e);
             addError("MediaFile.error.view");
@@ -123,7 +139,8 @@ public class MediaFileImageChooser exten
             String dirPath = "";
             for (String directoryName : directoryNames) {
                 dirPath = dirPath + "/" + directoryName;
-                directoryHierarchy.add(new KeyValueObject(dirPath, directoryName));
+                directoryHierarchy.add(new KeyValueObject(dirPath,
+                        directoryName));
             }
         }
         return directoryHierarchy;
@@ -137,7 +154,8 @@ public class MediaFileImageChooser exten
     }
 
     /**
-     * @param directoryId the directoryId to set
+     * @param directoryId
+     *            the directoryId to set
      */
     public void setDirectoryId(String directoryId) {
         this.directoryId = directoryId;
@@ -151,7 +169,8 @@ public class MediaFileImageChooser exten
     }
 
     /**
-     * @param directoryName the directoryName to set
+     * @param directoryName
+     *            the directoryName to set
      */
     public void setDirectoryName(String directoryName) {
         this.directoryName = directoryName;
@@ -165,7 +184,8 @@ public class MediaFileImageChooser exten
     }
 
     /**
-     * @param childFiles the childFiles to set
+     * @param childFiles
+     *            the childFiles to set
      */
     public void setChildFiles(List<MediaFile> childFiles) {
         this.childFiles = childFiles;
@@ -179,7 +199,8 @@ public class MediaFileImageChooser exten
     }
 
     /**
-     * @param currentDirectory the currentDirectory to set
+     * @param currentDirectory
+     *            the currentDirectory to set
      */
     public void setCurrentDirectory(MediaFileDirectory currentDirectory) {
         this.currentDirectory = currentDirectory;

Modified: roller/trunk/app/src/main/webapp/WEB-INF/jsps/editor/MediaFileImageChooser.jsp
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/webapp/WEB-INF/jsps/editor/MediaFileImageChooser.jsp?rev=1602936&r1=1602935&r2=1602936&view=diff
==============================================================================
--- roller/trunk/app/src/main/webapp/WEB-INF/jsps/editor/MediaFileImageChooser.jsp (original)
+++ roller/trunk/app/src/main/webapp/WEB-INF/jsps/editor/MediaFileImageChooser.jsp Mon Jun
16 17:35:58 2014
@@ -94,7 +94,8 @@
 </s:else>
 
 
-<s:if test="childFiles || childDirectories || (pager && pager.items.size() >
0)">
+<%-- || (pager && pager.items.size() > 0) --%>
+<s:if test="childFiles || allDirectories">
 
 <s:form id="mediaFileChooserForm" name="mediaFileChooserForm" action="mediaFileView">
 	<s:hidden name="salt" />
@@ -121,7 +122,7 @@
     <div  width="720px" height="500px">
         <ul id = "myMenu">
 
-            <s:if test="childDirectories.size() == 0 && childFiles.size() ==0">
+            <s:if test="childFiles.size() == 0">
                 <p style="text-align: center"><s:text name="mediaFileView.noFiles"/></p>
             </s:if>
 
@@ -129,7 +130,7 @@
 
             <%-- List media directories first --%>
 
-            <s:iterator id="directory" value="childDirectories">
+            <s:iterator id="directory" value="allDirectories">
                 <li class="align-images"
                         onmouseover="highlight(this, true)" onmouseout="highlight(this, false)">
                     <div class="mediaObject">
@@ -146,10 +147,11 @@
             <%-- --------------------------------------------------------- --%>
 
             <%-- List media files next --%>
+            <s:if test="childFiles.size() > 0">
 
-            <s:iterator id="mediaFile" value="childFiles">
+                <s:iterator id="mediaFile" value="childFiles">
 
-                <li class="align-images"
+                    <li class="align-images"
                         onmouseover="highlight(this, true)" onmouseout="highlight(this, false)">
 
                         <s:url id="mediaFileURL" includeContext="false"
@@ -158,29 +160,30 @@
                         <s:url id="mediaFileThumbnailURL"
                             value="%{#mediaFile.thumbnailURL}"></s:url>
 
-                    <div class="mediaObject"
-                         onclick="onSelectImage('<s:property value="#mediaFile.name"/>','<s:property
value="%{mediaFileURL}" />')" >
+                        <div class="mediaObject"
+                             onclick="onSelectImage('<s:property value="#mediaFile.name"/>','<s:property
value="%{mediaFileURL}" />')" >
 
-                        <s:if test="#mediaFile.imageFile">
+                            <s:if test="#mediaFile.imageFile">
 
-                            <img border="0" src='<s:property value="%{mediaFileThumbnailURL}"
/>'
-                                 width='<s:property value="#mediaFile.thumbnailWidth"/>'
-                                 height='<s:property value="#mediaFile.thumbnailHeight"/>'
/>
-                        </s:if>
+                                <img border="0" src='<s:property value="%{mediaFileThumbnailURL}"
/>'
+                                     width='<s:property value="#mediaFile.thumbnailWidth"/>'
+                                     height='<s:property value="#mediaFile.thumbnailHeight"/>'
/>
+                            </s:if>
 
-                    </div>
+                        </div>
 
-                    <div class="mediaObjectInfo">
-                        <label>
-                            <str:truncateNicely upper="50">
-                                <s:property value="#mediaFile.name" />
-                            </str:truncateNicely>
-                        </label>
-                    </div>
+                        <div class="mediaObjectInfo">
+                            <label>
+                                <str:truncateNicely upper="50">
+                                    <s:property value="#mediaFile.name" />
+                                </str:truncateNicely>
+                            </label>
+                        </div>
 
-                </li>
+                    </li>
 
-            </s:iterator>
+                </s:iterator>
+            </s:if>
 
         </ul>
     </div>



Mime
View raw message