Permalink
Browse files

Merge branch 'develop' of github.com:daveray/seesaw into develop

Conflicts:
	src/seesaw/dnd.clj
  • Loading branch information...
2 parents bfa4df4 + 365f7b8 commit 52397677cce1f8a51e12a8e5533a6390a319a62b @daveray committed Sep 8, 2011
Showing with 17 additions and 16 deletions.
  1. +7 −6 src/seesaw/dnd.clj
  2. +5 −5 src/seesaw/examples/dnd.clj
  3. +5 −5 test/seesaw/test/dnd.clj
View
@@ -23,15 +23,15 @@
(defprotocol Flavorful
"Protocol for abstracting DataFlavor including automatic conversion from
external/native representations (e.g. uri-list) to friendlier internal
- representations (e.g. list of java.net.URL)."
+ representations (e.g. list of java.net.URI)."
(to-raw-flavor [this]
"Return an instance of java.awt.datatransfer.DataFlavor for this.")
(to-local [this value]
"Given an incoming value convert it to the expected local format. For example, a uri-list
- would return a vector of URL.")
+ would return a vector of URI.")
(to-remote [this value]
"Given an outgoing value, convert it to the appropriate remote format.
- For example, a vector of URLs would be serialized as a uri-list."))
+ For example, a vector of URIs would be serialized as a uri-list."))
; Default/do-nothin impl for DataFlavors
(extend-protocol Flavorful
@@ -77,15 +77,16 @@
(def ^{:doc "Flavor for a list of java.io.File objects" }
file-list-flavor DataFlavor/javaFileListFlavor)
-(def ^{:doc "Flavor for a list of java.net.URL objects." }
+(def ^{:doc "Flavor for a list of java.net.URI objects. Note it's URI, not URL.
+ With just java.net.URL it's possible to drop non-URL links, e.g. \"about:config\"." }
uri-list-flavor
(let [flavor (make-flavor "text/uri-list" String)]
(reify Flavorful
(to-raw-flavor [this] flavor)
(to-local [this value]
- (map #(java.net.URL. %) (clojure.string/split-lines value)))
+ (map #(java.net.URI. %) (clojure.string/split-lines value)))
(to-remote [this value]
- (clojure.string/join "\r\n" (map #(.toExternalForm ^java.net.URL %) value))))))
+ (clojure.string/join "\r\n" value)))))
(def ^{:doc "Flavor for HTML text"} html-flavor (make-flavor "text/html" String))
(def ^{:doc "Flavor for images as java.awt.Image" } image-flavor DataFlavor/imageFlavor)
@@ -50,23 +50,23 @@
; No :finish needed
})))
-; A list box that imports and exports URLs, like with a browser
+; A list box that imports and exports URIs, like with a browser
(defn url-target []
(listbox
- :model [(java.net.URL. "http://github.com/daveray/seesaw")]
+ :model [(java.net.URI. "http://github.com/daveray/seesaw")]
:drag-enabled? true
:drop-mode :insert
:transfer-handler
(dnd/default-transfer-handler
:import [dnd/uri-list-flavor (fn [{:keys [target data]}]
- ; data is seq of java.net.URL
+ ; data is seq of java.net.URI
(doseq [url data]
(.. target getModel (addElement url))))]
:export {
:actions (constantly :copy)
:start (fn [c]
(let [url (selection c)]
- [dnd/uri-list-flavor [url]]))
+ [dnd/uri-list-flavor [url] ]))
; No :finish needed
})))
@@ -96,7 +96,7 @@
:items [
(border-panel :border "Drag and Drop Text here" :center (scrollable (string-target)))
(border-panel :border "Drag and Drop Files here" :center (scrollable (file-target)))
- (border-panel :border "Drag and Drop URLs here" :center (scrollable (url-target)))
+ (border-panel :border "Drag and Drop URIs here" :center (scrollable (url-target)))
(border-panel :border "Drag and Drop Images here" :center (image-target))
])))
View
@@ -26,13 +26,13 @@
(= (local-object-flavor (class [])) (local-object-flavor []))))
(describe uri-list-flavor
- (it "implements to-remote to convert list of URLs to uri-list"
+ (it "implements to-remote to convert list of URIs to uri-list"
(= "http://google.com\r\nhttp://github.com"
(to-remote uri-list-flavor
- [(java.net.URL. "http://google.com")
- (java.net.URL. "http://github.com")])))
- (it "implements to-local to convert uri-list to list of URLs"
- (= [(java.net.URL. "http://google.com") (java.net.URL. "http://github.com")]
+ [(java.net.URI. "http://google.com")
+ (java.net.URI. "http://github.com")])))
+ (it "implements to-local to convert uri-list to list of URIs"
+ (= [(java.net.URI. "http://google.com") (java.net.URI. "http://github.com")]
(to-local uri-list-flavor "http://google.com\r\nhttp://github.com" ))))
(describe default-transferable

0 comments on commit 5239767

Please sign in to comment.