You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by rw...@apache.org on 2019/06/12 22:55:03 UTC

svn commit: r1861202 - in /pivot/trunk: demos/src/org/apache/pivot/demos/dnd/FileDropTargetDemo.java demos/src/org/apache/pivot/demos/xml/XMLViewer.java wtk/src/org/apache/pivot/wtk/media/BufferedImageSerializer.java

Author: rwhitcomb
Date: Wed Jun 12 22:55:03 2019
New Revision: 1861202

URL: http://svn.apache.org/viewvc?rev=1861202&view=rev
Log:
PIVOT-1032: Misc. small style changes.

Modified:
    pivot/trunk/demos/src/org/apache/pivot/demos/dnd/FileDropTargetDemo.java
    pivot/trunk/demos/src/org/apache/pivot/demos/xml/XMLViewer.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/media/BufferedImageSerializer.java

Modified: pivot/trunk/demos/src/org/apache/pivot/demos/dnd/FileDropTargetDemo.java
URL: http://svn.apache.org/viewvc/pivot/trunk/demos/src/org/apache/pivot/demos/dnd/FileDropTargetDemo.java?rev=1861202&r1=1861201&r2=1861202&view=diff
==============================================================================
--- pivot/trunk/demos/src/org/apache/pivot/demos/dnd/FileDropTargetDemo.java (original)
+++ pivot/trunk/demos/src/org/apache/pivot/demos/dnd/FileDropTargetDemo.java Wed Jun 12 22:55:03 2019
@@ -44,10 +44,11 @@ import org.apache.pivot.wtk.TableView;
 import org.apache.pivot.wtk.Window;
 
 public class FileDropTargetDemo extends Window implements Bindable {
-    @BXML
-    private TableView fileTableView;
-    @BXML
-    private PushButton uploadButton;
+    @BXML private TableView fileTableView;
+    @BXML private PushButton uploadButton;
+
+    /** Flag whether to expand directories recursively when dropped. TODO: implement in GUI. */
+    private static boolean expandDirectories = false;
 
     private FileList fileList = null;
 
@@ -122,6 +123,19 @@ public class FileDropTargetDemo extends
                 return (dragContent.containsFileList() ? DropAction.COPY : null);
             }
 
+            private void addFile(File file, FileList tableData) {
+                if (file.isDirectory()) {
+                    tableData.add(file);
+                    if (expandDirectories) {
+                        for (File subdirFile : file.listFiles()) {
+                            addFile(subdirFile, tableData);
+                        }
+                    }
+                } else {
+                    tableData.add(file);
+                }
+            }
+
             @Override
             public DropAction drop(Component component, Manifest dragContent,
                 int supportedDropActions, int x, int y, DropAction userDropAction) {
@@ -130,13 +144,8 @@ public class FileDropTargetDemo extends
                 if (dragContent.containsFileList()) {
                     try {
                         FileList tableData = (FileList) fileTableView.getTableData();
-                        FileList fileListLocal = dragContent.getFileList();
-                        for (File file : fileListLocal) {
-                            if (file.isDirectory()) {
-                                // TODO Expand recursively
-                            }
-
-                            tableData.add(file);
+                        for (File file : dragContent.getFileList()) {
+                            addFile(file, tableData);
                         }
 
                         dropAction = DropAction.COPY;

Modified: pivot/trunk/demos/src/org/apache/pivot/demos/xml/XMLViewer.java
URL: http://svn.apache.org/viewvc/pivot/trunk/demos/src/org/apache/pivot/demos/xml/XMLViewer.java?rev=1861202&r1=1861201&r2=1861202&view=diff
==============================================================================
--- pivot/trunk/demos/src/org/apache/pivot/demos/xml/XMLViewer.java (original)
+++ pivot/trunk/demos/src/org/apache/pivot/demos/xml/XMLViewer.java Wed Jun 12 22:55:03 2019
@@ -54,7 +54,7 @@ import org.apache.pivot.xml.XMLSerialize
  * Utility application that allows the user to browse an XML DOM using a tree
  * view component.
  */
-public class XMLViewer implements Application {
+public final class XMLViewer implements Application {
     private Window window = null;
 
     @BXML private TreeView treeView = null;
@@ -69,7 +69,7 @@ public class XMLViewer implements Applic
     public static final String WINDOW_TITLE = "XML Viewer";
 
     @Override
-    public void startup(Display display, Map<String, String> properties) throws Exception {
+    public void startup(final Display display, final Map<String, String> properties) throws Exception {
         BXMLSerializer bxmlSerializer = new BXMLSerializer();
         bxmlSerializer.getNamespace().put(APPLICATION_KEY, this);
 
@@ -97,7 +97,7 @@ public class XMLViewer implements Applic
     }
 
     @Override
-    public boolean shutdown(boolean optional) {
+    public boolean shutdown(final boolean optional) {
         if (window != null) {
             window.close();
         }
@@ -122,7 +122,7 @@ public class XMLViewer implements Applic
         }
     }
 
-    public DropAction drop(Manifest dragContent) {
+    public DropAction drop(final Manifest dragContent) {
         DropAction dropAction = null;
 
         try {
@@ -164,6 +164,7 @@ public class XMLViewer implements Applic
 
         if (node == null) {
             // no selection, but it's ok
+            return;
         } else if (node instanceof TextNode) {
             TextNode textNode = (TextNode) node;
             textArea.setText(textNode.getText());
@@ -212,7 +213,7 @@ public class XMLViewer implements Applic
         }
     }
 
-    private void setDocument(Element document) {
+    private void setDocument(final Element document) {
         // Remove prompt decorator now that we have real data to show
         if (promptDecorator != null) {
             treeView.getDecorators().remove(promptDecorator);
@@ -228,7 +229,11 @@ public class XMLViewer implements Applic
         treeView.setSelectedPath(path);
     }
 
-    public static void main(String[] args) {
+    /**
+     * Run the program on the desktop.
+     * @param args The command line arguments (if any, not used).
+     */
+    public static void main(final String[] args) {
         DesktopApplicationContext.main(XMLViewer.class, args);
     }
 

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/media/BufferedImageSerializer.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/media/BufferedImageSerializer.java?rev=1861202&r1=1861201&r2=1861202&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/media/BufferedImageSerializer.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/media/BufferedImageSerializer.java Wed Jun 12 22:55:03 2019
@@ -36,11 +36,11 @@ public class BufferedImageSerializer imp
      * Supported image formats.
      */
     public enum Format {
-        PNG ("png",  "image/png"),
+        PNG("png", "image/png"),
+        BMP("bmp", "image/bmp"),
+        GIF("gif", "image/gif"),
         JPEG("jpeg", "image/jpeg"),
-        BMP ("bmp",  "image/bmp"),
-        WBMP("wbmp", "image/vnd.wap.wbmp"),
-        GIF ("gif",  "image/gif");
+        WBMP("wbmp", "image/vnd.wap.wbmp");
 
         private String name;
         private String mimeType;
@@ -126,7 +126,7 @@ public class BufferedImageSerializer imp
     }
 
     @Override
-    public String getMIMEType(final BufferedImage bufferedImage) {
+    public final String getMIMEType(final BufferedImage bufferedImage) {
         return outputFormat.getMIMEType();
     }
 }